At runtime: “Fatal error: Registered function ‘nvkernel_xyz_foo_2_’ not found in the CUBIN, error 1”

Hi, below I have two similar simple codes. I would say that both should have the same behavior but maybe I’m missing something. The thing is that the former code builds and runs and the latter builds but gives an error. I wonder what the difference is.

program works
  use iso_fortran_env, only : REAL64
  implicit none

  integer, parameter :: dp = REAL64
  integer, parameter :: nx = 100
  real(dp) :: accum = 0.0

  character(len=nx) :: temp = 'F'
  integer :: j

  !$omp target map(tofrom:accum) map(to:temp)
  do j = 1, nx
    if(temp(j:j) == 'F') then
        accum = accum + 1
    end if
  end do
  !$omp end target

end program
program fails
  use iso_fortran_env, only : REAL64
  implicit none

  integer, parameter :: dp = REAL64
  integer, parameter :: nx = 100
  real(dp) :: accum = 0.0

  character(len=nx) :: temp = 'F'
  integer :: j

  !$omp target enter data map(to:temp)
  !$omp target map(tofrom:accum)
  do j = 1, nx
    if(temp(j:j) == 'F') then
        accum = accum + 1
    end if
  end do
  !$omp end target
  !$omp target exit data map(delete:temp)

end program

My compiler is nvfortran 22.7, and the error output is:

Fatal error: Registered function 'nvkernel_MAIN__F1L13_2_' not found in the CUBIN, error 1
Aborted

Add “temp” to the map clause:

  !$omp target enter data map(to:temp)
  !$omp target map(tofrom:accum,temp)

It wont get recopied to the device since it’s in the outer data region, but helps the runtime know which object to use.

Thanks Mat!, this change actually fixes the problem.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.