How to get CUDA event starting and ending time without using nvprof

539 views Asked by At

I wrote some Java code that uses JCuda to execute some CUDA kernels. I would like to profile the application in order to understand how streams are overlapped and whatnot. I am able to use cuda event calls such as cudaEventElpasedTime to get the execution time of a kernel, but I do not know how to get the starting and ending timestamps for the same kernel.

I know nvprof can generate such results and display the timelines, but I do not find a way to run nvprof with a Java application.

Edit: Now I understand how to use nvprof to profile a Java application thanks to the answers. I still prefer getting the starting and ending times using cudaEvent calls so I would have more control. It seems nvprof can get that information but there is no APIs for an end user to do so?

1

There are 1 answers

1
ApoorvaJ On BEST ANSWER

There are two ways to do this:

  1. If you can run your JCuda application via the command-line, you can profile it using the command nvprof --profile-child-processes <command to run your JCuda application>

  2. If you cannot run your application via the command-line, open a terminal and run nvprof using the command nvprof --profile-all-processes. Nvprof will go into daemon mode and keep waiting for CUDA activity to happen. Now launch your application as usual from your IDE, and once CUDA activity happens and the application exits, nvprof will print results in its terminal session.