Counting Threads in a Launch
__global__ void scale(float* x, int n, float a) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) x[i] = a * x[i];
}
int n = 1000000;
int threads = 256;
int blocks = (n + threads - 1) / threads; // 3907
scale<<<blocks, threads>>>(d_x, n, 2.0f);
How many threads does this launch start, how many warps is that, and what do the leftover threads do?
Sign in to answer questions and track your progress
Sign In