oneapi-src / oneapi-src/oneAPI-samples

The Execution Time Difference Between Event_Profiling and Steady Clock

Open
#1,352 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C++
Stars
1.2k
Forks
745
PR merge metrics
No merged PRs in 30d

Description

I am trying to profile my code and I am getting different results each time I run the code.

auto start = std::chrono::steady_clock::now();
foo()      
auto end = std::chrono::steady_clock::now();
time = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();

why is this giving me different results than using

start_kernel_time = event.get_profiling_info<info::event_profiling::command_start>();
end_kernel_time = event.get_profiling_info<info::event_profiling::command_end>();
time_kernel = (end_kernel_time - start_kernel_time) / kNs; // kNs = 1e9

I run the code several times and interesting thing is steady_clock version first printed out 6.7 seconds and then in the second run printed out 0.07 seconds ( unrealistic) then the event profiling was printed the ~0.64 seconds which made more sense. Why it is different ?

I am using oneapi 2023 with icpx compiler

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or sample entry point is named. Start by reproducing the two timing snippets with the stated oneAPI 2023 and icpx setup, then compare the host steady-clock interval with event_profiling command_start and command_end; done means documenting the cause of the discrepancy and a reliable way to measure the execution time.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.