Skip to content

Instantly share code, notes, and snippets.

@tallendev
Created July 25, 2018 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tallendev/8623f697ac3e86a7b45c6c7f61505914 to your computer and use it in GitHub Desktop.
Save tallendev/8623f697ac3e86a7b45c6c7f61505914 to your computer and use it in GitHub Desktop.
extern "C"
__global__ void uvmer(const double* a)
{
size_t id = blockIdx.x * blockDim.x + threadIdx.x;
// 1-4
double rc[TASKS_PER_THREAD];
#pragma unroll
for (; id < (blockDim.x * gridDim.x * TASKS_PER_THREAD); id += blockDim.x * gridDim.x)
{
rc[id / (blockDim.x * gridDim.x)] = a[id * PSIZE];
}
// this loop does nothing but ensure compiler does not remove rc
for (int i = 0; i < TASKS_PER_THREAD; i++)
if (rc[i] != 0)
continue;
else
printf("ok %lf\n", rc[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment