Skip to content

Instantly share code, notes, and snippets.

@mratsim
Created September 16, 2017 10:50
Show Gist options
  • Save mratsim/b382fd761c8f70f95e6e64723c688797 to your computer and use it in GitHub Desktop.
Save mratsim/b382fd761c8f70f95e6e64723c688797 to your computer and use it in GitHub Desktop.
CUDA - Grid-stride loop
__global__
void saxpy(int n, float a, float *x, float *y)
{
for (int i = blockIdx.x * blockDim.x + threadIdx.x;
i < n;
i += blockDim.x * gridDim.x)
{
y[i] = a * x[i] + y[i];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment