Skip to content

Commit

Permalink
add missing wait to get correct timer information (#2432)
Browse files Browse the repository at this point in the history
The wait was missing which results into wrong timings in cases where the
example was changed to use a asynchron queue.
The time for the memcopies before the operations was part of the kernel
execution time.
  • Loading branch information
psychocoderHPC authored Dec 2, 2024
1 parent 85721cd commit b78fd8b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion example/vectorAdd/src/vectorAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ auto example(TAccTag const&) -> int

// Enqueue the kernel execution task
{
// wait in case we are using an asynchronous queue to time actual kernel runtime
alpaka::wait(queue);
auto const beginT = std::chrono::high_resolution_clock::now();
alpaka::enqueue(queue, taskKernel);
alpaka::wait(queue); // wait in case we are using an asynchronous queue to time actual kernel runtime
// wait in case we are using an asynchronous queue to time actual kernel runtime
alpaka::wait(queue);
auto const endT = std::chrono::high_resolution_clock::now();
std::cout << "Time for kernel execution: " << std::chrono::duration<double>(endT - beginT).count() << 's'
<< std::endl;
Expand Down

0 comments on commit b78fd8b

Please sign in to comment.