Created
September 16, 2017 10:50
-
-
Save mratsim/b382fd761c8f70f95e6e64723c688797 to your computer and use it in GitHub Desktop.
CUDA - Grid-stride loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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