Skip to content

Instantly share code, notes, and snippets.

@BrentFarris
Created October 15, 2023 02:32
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 BrentFarris/f79abf00b4e707d7c7da6dcd6d6c5dfa to your computer and use it in GitHub Desktop.
Save BrentFarris/f79abf00b4e707d7c7da6dcd6d6c5dfa to your computer and use it in GitHub Desktop.
int threadsPerBlock = blockDim.x * blockDim.y * blockDim.z;
int blocksPerGrid = gridDim.x * gridDim.y * gridDim.z;
int threadPositionInBlock = threadIdx.x +
blockDim.x * threadIdx.y +
blockDim.x * blockDim.y * threadIdx.z;
int blockPosInGrid = blockIdx.x +
gridDim.x * blockIdx.y +
gridDim.x * gridDim.y * blockIdx.z;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment