1

As suggested in the answer from the following post, I am trying to build my Fortran program using mpif90 with -acc=gpu flag.

Getting started with OpenACC + MPI Fortran program

I was shown the following error:

gfortran: error: unrecognized command line option ‘-acc=gpu’

I don't understand how I can use mpif90 to compile OpenACC parts of the code. Don't I need a compiler like nvfortran to tell the computer about my OpenACC directives in the code? It's so confusing for me to know how I can tell to the computer about both of my mpi and OpenACC parts of the code simultaneously.

I am posting my make file here for reference:

OBJECTS = Main.o Module.o Pre_processing.o boundary_conditions.o \
              interpolation.o viscous_fluxes.o
MODULES = Module.mod
CASE = Riemann.f90

# FC= pgfortran
# FFLAG = -acc -fast -mcmodel=medium -ta=tesla:managed -Minfo=accel
# FFLAG = -fast -mcmodel=medium

FC= mpif90
FFLAG = -acc=gpu

output: a.out

a.out: $(MODULES) $(OBJECTS) cases/$(CASE)
    $(FC) $(FFLAG) $(OBJECTS) cases/$(CASE) -o a.out

%.o: %.f90
    $(FC) $(FFLAG) -c $<

%.mod: %.f90
    $(FC) $(FFLAG) -c $<

.PHONY: clean
clean :
    rm -f *.o *.mod *.out *.qdrep

I have following compilers installed on my PC which has two Nvidia A6000 GPU cards:

GNU Fortran (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 & nvfortran 21.9-0 64-bit target on x86-64 Linux -tp zen

  • 2
    since Fortran compiler generally do not inter-operate, your best bet is to rebuild your MPI library with the Fortran compiler you plan using (`pgfortran` if I read correctly your `Makefile`) – Gilles Gouaillardet Dec 03 '21 at 02:04
  • 4
    The NVHPC SDK ships with several pre-build MPI configured for use with nvfortran. You just need to set your PATH to include the "/Linux_x86_64/21.9/comm_libs/mpi/bin/" and possibly LD_LIBRARY_PATH to include "/Linux_x86_64/21.9/comm_libs/mpi/lib" – Mat Colgrove Dec 03 '21 at 02:36
  • 2
    Note that `mpif90` is a wrapper that could refer to any compiler. In your present MPI configuration it refers to gfortran. You must switch to the MPI library supplied with your NVIDIA compilers. – Vladimir F Героям слава Dec 03 '21 at 10:38

0 Answers0