Originally published at: https://developer.nvidia.com/blog/customize-cuda-fortran-profiling-nvtx/
The NVIDIA Tools Extension (NVTX) library lets developers annotate custom events and ranges within the profiling timelines generated using tools such as the NVIDIA Visual Profiler (NVVP) and NSight. In my own optimization work, I rely heavily on NVTX to better understand internal as well as customer codes and to spot opportunities for better interaction…
Great post, it is great to have access to these features in Fortran.
I modified your module to comply with the Fortran standard requirements that arguments to c_loc have attribute TARGET or POINTER. This allows the module to work for the XLF compiler as well as PGI.
Here is a gist to the modified module: https://gist.github.com/dap...
Thanks for sharing your modifications, David!
Sorry to revive an old thread.
It seems that David’s modification caused PGI/NVHPC to generate labels that are repeated characters of the first character in the string. For instance, when I pass “Total integral”, the NVTX marker becomes “TTTTTTTTT …”, that is the letter “T” repeated 256 times.
To fix this, I have changed that line from
character, private, target :: tempName(256)
to
character(len=256), private, target :: tempName
I guess this is because in Fortran an array of 256 characters isn’t the same as a string of length 256, unlike in C.
Try to use this version:
It will work with PGI,XLF and gfortran