CUDA Fortran and CUDA C (with nvcc) error

OpenACC and CUDA Fortran
victor_ramalho
Posts: 3
Joined: Jun 11 2019

CUDA Fortran and CUDA C (with nvcc) error

Post by victor_ramalho » Tue Jun 11, 2019 2:43 pm

Hello, I am trying to run CUDA C CUFFT wrappers ("fortran_cufft1d.cu"), compiled with nvcc, in a main CUDA Fortran program ("fortran-test.f90") compiled with pgfortran. The program runs and prints out results, but shows the error

free(): invalid pointer: 0x0000000000fbc510 ***
======= Backtrace: =========
...

If I compile the main program as f90 (i.e., without "-Mcuda" flag) with pgfortran, it links the CUDA C object without problems. The error shows when compiling the main program as CUDA Fortran. As I plan to use pinned memory on the main program to call the CUDA C wrappers, I will need a CUDA Fortran main. Any ideas? And if this is not possible, what alternatives could be used.

mkcolg
Posts: 8107
Joined: Jun 30 2004

Re: CUDA Fortran and CUDA C (with nvcc) error

Post by mkcolg » Wed Jun 12, 2019 7:46 am

If I compile the main program as f90 (i.e., without "-Mcuda" flag) with pgfortran, it links the CUDA C object without problems.
Does this run successfully as well? My answer below is assuming that the code can be successfully run.

Just to clarify, your not actually using any CUDA Fortran features right now but see this runtime error when adding the "-Mcuda" flag? In this case, is the nvcc version and the CUDA version pgfortran is using the same? Which nvcc version are you using? Which PGI version?

PGI 19.4 will default to using CUDA 10.0, so you may need to use "-Mcuda=cuda10.1" or "-Mcuda=cuda9.2", or set the "CUDA_HOME" environment variable to the same CUDA SDK install directory as your nvcc, to get the CUDA versions to match.

-Mat

victor_ramalho
Posts: 3
Joined: Jun 11 2019

Re: CUDA Fortran and CUDA C (with nvcc) error

Post by victor_ramalho » Wed Jun 12, 2019 12:13 pm

Hello Mat, thanks for the reply.
Does this run successfully as well? My answer below is assuming that the code can be successfully run.
Yes
Just to clarify, your not actually using any CUDA Fortran features right now but see this runtime error when adding the "-Mcuda" flag?
Yes, exactly
In this case, is the nvcc version and the CUDA version pgfortran is using the same? Which nvcc version are you using? Which PGI version?
I am using PGI via module load. After "module load pgi/19.4", the command "pgfortran --version" gives
pgfortran 19.4-0 LLVM 64-bit target on x86-64 Linux -tp skylake
PGI Compilers and Tools
Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.

The command "nvcc --version" gives
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:07:04_CDT_2018
Cuda compilation tools, release 9.2, V9.2.148

So I'd assume PGI 19.4 uses cuda 10.0 by default (as you mentioned) while nvcc is stuck with version 9.2 . Tried running everything with "-Mcuda=9.2" but got the same errors.

I also tried running with "-Mcuda=cc70" and set nvcc arch flags to sm_70, code70, but got the same error as well.

About the CUDA_HOME variable, I believe it is not set ("echo $CUDA_HOME" prints nothing).

mkcolg
Posts: 8107
Joined: Jun 30 2004

Re: CUDA Fortran and CUDA C (with nvcc) error

Post by mkcolg » Wed Jun 12, 2019 1:42 pm

Ok, so it's not sounding like version mismatch issue.

Another possibility is that CUDA Fortran will use RDC by default, while with CUDA C, RDC is disabled by default.

Try using "-Mcuda=cuda9.2,nordc", or add "-rdc=true" to your CUDA options.

If that doesn't work, I'm not sure then. Can you send a reproducing example to PGI Customer Service (trs@pgroup.com) and ask Alex to forward it to me so I can take a look?

-Mat

victor_ramalho
Posts: 3
Joined: Jun 11 2019

Re: CUDA Fortran and CUDA C (with nvcc) error

Post by victor_ramalho » Wed Jun 12, 2019 2:23 pm

Tried "-Mcuda=cuda9.2,nordc", same error; and all with "-Mcuda=9.2" and "nvcc ... -rdc=true", still same error.

Just sent an email with a small code (CUFFT of an array of 5 samples), with the requested instructions. Thanks again.

Post Reply