Got an error while compiling [NVFORTRAN-S-0084-Illegal]

The following simple source code can not be compiled and the latest NVIDIA compiler put the following error message. Could you tell me why the compiler put the following error ?
I think the subroutines “nvtxRangePushA” and “nvtxRangePop” are available for me.

NVFORTRAN-S-0084-Illegal use of symbol nvtxrangepop - attempt to CALL a FUNCTION (main.f90: 14)
0 inform, 0 warnings, 1 severes, 0 fatal for main

program main
  use nvtx
  implicit none
  integer,parameter :: n = 1024
  integer :: i
  real(kind=8),dimension(n) :: a

  call nvtxRangePushA("test")
!$acc kernels
  do i = 1,n
     a(i) = 1.0d0
  end do
!$acc end kernels
  call nvtxRangePop()
end program main

% nvfortran --version
nvfortran 23.11-0 64-bit target on x86-64 Linux -tp skylake-avx512
NVIDIA Compilers and Tools
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

Regarding the compiler error, indeed, nvtxRangePushA is a C function.

If you use the nvtx wrappers that come with the compiler, the following code should build smoothly:

program main
  use nvtx
  implicit none
  integer,parameter :: n = 1024
  integer :: i
  real(kind=8),dimension(n) :: a

  call nvtxStartRange("test")
!$acc kernels
  do i = 1,n
     a(i) = 1.0d0
  end do
!$acc end kernels
  call nvtxEndRange()
end program main

The compilation command is:

nvfortran test.f90 -lnvhpcwrapnvtx

Yes, using NVTX Fortran wrappers is the best way to go, but if you really do want to use the RangePush/Pop functions, you need to capture the return code instead of trying to call them as if they were subroutines.

% cat test.F90
program main
  use nvtx
  implicit none
  integer,parameter :: n = 1024
  integer :: i, rc
  real(kind=8),dimension(n) :: a

  rc = nvtxRangePush("test")
!$acc kernels
  do i = 1,n
     a(i) = 1.0d0
  end do
!$acc end kernels
  rc = nvtxRangePop()
end program main
% nvfortran -acc test.F90 -cudalib=nvtx
%
1 Like

Dear Mat-san,

Thank you for the replying to me. Following your advise, I did, the compilation was done successfully.
BTW, if my remory is correct, “call nvtxRangePushA” and “call nvtxRangePop()” had been avaiable for us. From when the specifications for NVTX fortran wrappers have been changed ?

Dear Rommel-san,

Thank you for your reply. I will try.
I’m sorry to bother you but, could you tell me what is a difference between “nvtxStartRange()” and “nvtxRangePop” ?

No, nothing has changed. The Fortran wrappers which I pointed you to the documentation has been the preferred method for sometime. I personally use both so might have used the C version in examples before.

The primary difference between these and calling the C routines directly is that they include the optional argument to set the color making them easier to use in Fortran. For the C routines, you’d need create an attribute to do this and call the “Ex” versions of the routines.

Dear Mat-san,

Understood. Thank you for your reply.