Measure execution time of C++ mixed code (CPU+GPU)

Hi. I’m trying to measure time requested by some code written in C++ to get executed. Some part is executed on CPU and some has multiple kernel calls on GPU using OpenACC (10’000+). Trying to use std::chrono doesn’t return a reasonable time, since it requires about 2 mins of execution but the std::chrono function returns as result more than 15 minutes. My code looks something like this:

auto start = high_resolution_clock::now();
//has multiple functions inside that are executed on CPU
//inside has some other functions executed on CPU and multiple calls to functions that run on the GPU using OpenACC (10’000+)
auto stop = high_resolution_clock::now();
auto duration = duration_cast(stop-start);

“duration” variable should return a time that converted to minutes should be about 2 mins but instead returns more than 15 minutes. What am I doing wrong?
Thanks in advance

Is the actual wall clock time 2 minutes but your internal timer returning 15, or is the wall clock time 15 mins as well but your are expecting it to be 2?

In other words is the problem with the timers or are the timers causing your program to run longer?

In either case, I’m not really sure what’s wrong. Do you have a minimal reproducing example you can share so I can take a look?