Skip to content

Commit 4412fa0

Browse files
authored
Adding warmup steps to coarsening.cu (gpu-mode#46)
1 parent f604fbe commit 4412fa0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lecture_008/coarsening.cu

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ int main()
5353
cudaMemcpy(d_a, a, size, cudaMemcpyHostToDevice);
5454
cudaMemcpy(d_b, b, size, cudaMemcpyHostToDevice);
5555

56+
// warmup
57+
VecAdd<<<(N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(d_a, d_b, d_c);
58+
cudaDeviceSynchronize();
59+
60+
VecAddCoarsened<<<(N + 2*THREADS_PER_BLOCK - 1) / (2*THREADS_PER_BLOCK), THREADS_PER_BLOCK>>>(d_a, d_b, d_c);
61+
cudaDeviceSynchronize();
62+
5663
// Start timer for VecAdd kernel
5764
cudaEventRecord(start);
5865
VecAdd<<<(N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(d_a, d_b, d_c);

0 commit comments

Comments
 (0)