Skip to content

Instantly share code, notes, and snippets.

@aterrel
Created March 14, 2012 15:18
Show Gist options
  • Save aterrel/2037192 to your computer and use it in GitHub Desktop.
Save aterrel/2037192 to your computer and use it in GitHub Desktop.
Advection Riemann problem using the ispc
#define NUM_GHOST 2
#define NUM_STATES 1
#define NUM_WAVES 1
void advection_rp(uniform double* q_left, uniform double* q_right,
uniform double* amdq, uniform double* apdq, uniform double* wave, uniform double* s)
{
// Wave and speed
wave[0] = q_right[0] - q_left[0];
s[0] = 1.0;
amdq[0] = 0.0 ? (s[0] * wave[0]) > 0.0 : (s[0] * wave[0]);
apdq[0] = 0.0 ? (s[0] * wave[0]) < 0.0 : (s[0] * wave[0]);
}
export void advection_rp_step_ispc(uniform double* q, uniform int nx, uniform int ny,
uniform double* amdq, uniform double* apdq,
uniform double* wave, uniform double* wave_speeds)
{
for(int row = NUM_GHOST; row <= ny + NUM_GHOST; ++row) {
foreach (col = NUM_GHOST ... nx + NUM_GHOST + 1) {
int idx_left = col + row*(nx + 2*NUM_GHOST) - 1;
int idx_up = col + (row - 1)*(nx + 2*NUM_GHOST);
int idx_center = idx_left + 1;
int idx_out_x = (col - NUM_GHOST) + (row - NUM_GHOST) * (nx + 1);
int idx_out_y = idx_out_x + ((nx + 1)*(ny + 1));
advection_rp(q + idx_left*NUM_STATES, q + idx_center*NUM_STATES,
amdq + idx_out_x*NUM_STATES, apdq + idx_out_x*NUM_STATES,
wave + NUM_WAVES*NUM_STATES*idx_out_x, wave_speeds + NUM_WAVES*idx_out_x);
advection_rp(q + idx_up*NUM_STATES, q + idx_center*NUM_STATES,
amdq + idx_out_y*NUM_STATES, apdq + idx_out_y*NUM_STATES,
wave + NUM_WAVES*NUM_STATES*idx_out_y, wave_speeds + NUM_WAVES*idx_out_y);
}
}
}
$ ispc --arch=x86-64 --target=sse2,sse4-x2,avx-x2 advection_rp_step_ispc.ispc -o objs/advection_rp_step_ispc.o -h objs/advection_rp_step_ispc.h
advection_rp_step_ispc.ispc:9:15: Performance Warning: Gather required to compute
value in expression.
wave[0] = q_right[0] - q_left[0];
^^^^^^^^^^
advection_rp_step_ispc.ispc:9:28: Performance Warning: Gather required to compute
value in expression.
wave[0] = q_right[0] - q_left[0];
^^^^^^^^^
advection_rp_step_ispc.ispc:9:5: Performance Warning: Scatter required for storing
value.
wave[0] = q_right[0] - q_left[0];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
advection_rp_step_ispc.ispc:10:5: Performance Warning: Scatter required for storing
value.
s[0] = 1.0;
^^^^^^^^^^
advection_rp_step_ispc.ispc:12:47: Performance Warning: Gather required to compute
value in expression.
amdq[0] = 0.0 ? (s[0] * wave[0]) > 0.0 : (s[0] * wave[0]);
^^^^
advection_rp_step_ispc.ispc:12:54: Performance Warning: Gather required to compute
value in expression.
amdq[0] = 0.0 ? (s[0] * wave[0]) > 0.0 : (s[0] * wave[0]);
^^^^^^^
advection_rp_step_ispc.ispc:12:5: Performance Warning: Scatter required for storing
value.
amdq[0] = 0.0 ? (s[0] * wave[0]) > 0.0 : (s[0] * wave[0]);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
advection_rp_step_ispc.ispc:13:47: Performance Warning: Gather required to compute
value in expression.
apdq[0] = 0.0 ? (s[0] * wave[0]) < 0.0 : (s[0] * wave[0]);
^^^^
advection_rp_step_ispc.ispc:13:54: Performance Warning: Gather required to compute
value in expression.
apdq[0] = 0.0 ? (s[0] * wave[0]) < 0.0 : (s[0] * wave[0]);
^^^^^^^
advection_rp_step_ispc.ispc:13:5: Performance Warning: Scatter required for storing
value.
apdq[0] = 0.0 ? (s[0] * wave[0]) < 0.0 : (s[0] * wave[0]);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
type.cpp:1081: Assertion failed: "m->errorCount > 0"
***
*** Please file a bug report at https://github.com/ispc/ispc/issues
*** (Including as much information as you can about how to reproduce this error).
*** You have apparently encountered a bug in the compiler that we'd like to fix!
***
Illegal instruction: 4
$ ispc --version
Intel(r) SPMD Program Compiler (ispc), build 20120313 (commit 9ec8e5a275457fb1, LLVM 3.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment