Nvfortran "Ambiguous interfaces for generic" inconsistency

Hi All,

I’m working on a piece of software that has a module for integer valued-code and a separate module for real-valued code. Both of these make use of interface blocks with the same name and rely on having a different type (bound to different names) to differentiate between them.

If I call the function from the same scope that this disambiguating variable is defined in, I get no issues, however if it’s in a nested subroutine I get the following:

NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure foo (nvfortan-bug-broken.f90: 65)

I’ve uploaded a small code to demonstrate this (though I had to change the extension to upload them). There are 2 files, nvfortran-example-working.f90 and nvfortran-example-broken.f90 where the only difference is the nested subroutine. Both of these compile under gfortran.

nvfortan-example-working.txt (943 Bytes)
nvfortan-example-broken.txt (1.0 KB)

$ nvfortran --version

nvfortran 24.3-0 64-bit target on x86-64 Linux -tp sandybridge
NVIDIA Compilers and Tools
Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.

$ gfortran --version
GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ nvfortran nvfortan-example-broken.f90
NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure foo (nvfortan-example-broken.f90: 65)
NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure foo (nvfortan-example-broken.f90: 66)
  0 inform,   0 warnings,   2 severes, 0 fatal for update

$ nvfortran nvfortan-example-working.f90

$ ./a.out
 d1%x =             1
 d2%x =     2.000000

Thanks for the report and nice reproducing examples.

I’ve filed a problem report, TPR #35642, and sent it to engineering for investigation.

Hi, I am encountering a similar problem. I have a f90 program that I want to offload to gpu with openacc, and I want to employ nvlamath to call dgetrf. When I do the following it works without problems:
!$acc kernels
call dgetrf(arguments)
!$acc end kernels

However, it fails if I do something like:
!$acc kernels
call subroutine a
!$acc end kernels
where “subroutine a” calls dgetrf of nvlamath. I get the following error when compiling:
NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure dgetrf (bn_solve.F90: 135)
I am using the NVHPC version 23.7.

Hi gnavo,

This issue is unrelated to the original post, but just happens to give the same error message. The message applies to any case when the compiler can’t match a specific subroutine when called through a generic interface.

The GPU Lapack routines which NVLAMATH wraps around, do not have device callable versions and must be called from the host. The computation is done on the device, but initiated from the host.

Hence I’m a bit surprised the first case worked and suspect something else is going on such as the compiler detecting that this is a host call so not actually offloading this region to the device. Though when used in a device routine, the compiler can’t do this and you get the generic interface error as there’s not device routine to map to.

-Mat

1 Like