Skip to content

Commit

Permalink
Adding warmup steps to coarsening.cu (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
zinccat authored Jan 6, 2025
1 parent 32d3664 commit 7314692
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lecture_008/coarsening.cu
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ int main()
cudaMemcpy(d_a, a, size, cudaMemcpyHostToDevice);
cudaMemcpy(d_b, b, size, cudaMemcpyHostToDevice);

// warmup
VecAdd<<<(N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(d_a, d_b, d_c);
cudaDeviceSynchronize();

VecAddCoarsened<<<(N + 2*THREADS_PER_BLOCK - 1) / (2*THREADS_PER_BLOCK), THREADS_PER_BLOCK>>>(d_a, d_b, d_c);
cudaDeviceSynchronize();

// Start timer for VecAdd kernel
cudaEventRecord(start);
VecAdd<<<(N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK, THREADS_PER_BLOCK>>>(d_a, d_b, d_c);
Expand Down

0 comments on commit 7314692

Please sign in to comment.