Is there a function like cpu_time for GPUs, please

Hello!

I was trying to time a GPU subroutine. I actually did try gpu_time, but it didn’t work.

Thanks in advance,
Sincerely,
Erin

Hi Erin,

I’m not aware of any timers that can be used on the device, but I’m not sure it would make sense to use them if they do exist.

What are you trying to do?

Typically folks use profilers (Nsight-Systems/Nsight-Compute), NVTX instrumentation, or put CPU timers around CUDA kernel calls or compute regions for directives (OpenACC/OpenMP). Putting timers within a kernel would mean each thread would be doing it’s own timing. Given thread lifetime doesn’t not necessarily match the lifetime of the kernel, plus there can be millions of threads, the timings would be somewhat meaningless and unmanageable.

-Mat

Great! I have been using the cpu_time function, but wanted to make sure that I wasn’t missing something.

Thanks so much!
Erin