Compiling and linking OpenACC in different files

All,

In a previous thread, I figured out how to use !$acc routine with my kernel to the point where it compiles, huzzah! Now, however, I have a new question: does OpenACC code have to be inline or infile?

That is, my kernel calls three subroutines–deledd, getvistau, getnirtau–which are in two files. The first one, deledd, is in the main file, sorad.acc.F90, that the calling kernels loop is in. But the other two are USE associated from a separate module, gettau, in a separate file. When I try to compile like this I get:

$ pgfortran -fast -r4 -Mextend -Mpreprocess -Ktrap=fp -Kieee -Minfo=all -tp=sandybridge-64 -acc -ta=nvidia:5.5,cc35 -DNITERS=6 -DGPU_PRECISION=8 -c src/sorad.acc.F90
sorad:
    327, Generating copyin(cosz_dev(:m))
...
         Generating NVIDIA code
    384, Loop is parallelizable
         Accelerator kernel generated
        384, !$acc loop gang, vector(128) ! blockidx%x threadidx%x
    405, Loop carried dependence of 'swh' prevents parallelization
         Loop carried backward dependence of 'swh' prevents vectorization
...
deledd:
   1686, Generating acc routine gang
         Generating NVIDIA code
ptxas fatal   : Unresolved extern function 'gettau_getvistau_'
PGF90-S-0155-Compiler failed to translate accelerator region (see -Minfo messages): Device compiler exited with error status code (src/sorad.acc.F90: 1)
pgfortran-Fatal-/usr/local/sles11/pgi/linux86-64/14.1/bin/pgf902 TERMINATED by signal 11
Arguments to /usr/local/sles11/pgi/linux86-64/14.1/bin/pgf902
/usr/local/sles11/pgi/linux86-64/14.1/bin/pgf902 /gpfsm/dnb31/tdirs/pbs/slurm.974475.mathomp4/pgfortranVX0gnKuNF1g5.ilm -fn src/sorad.acc.F90 -opt 2 -terse 1 -inform warn -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -x 117 0x1000 -quad -vect 56 -y 34 16 -x 34 0x8 -y 19 8 -y 35 0 -x 42 0x30 -x 39 0x40 -x 199 10 -x 39 0x80 -x 34 0x400000 -x 149 1 -x 150 1 -x 59 4 -x 6 0x100 -y 129 2 -tp sandybridge -x 120 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -x 120 0x200 -astype 0 -x 121 1 -ieee 1 -x 70 0x40000000 -x 124 1 -accel tesla -x 186 0x80000 -x 180 0x400 -x 180 0x4000000 -x 163 0x100 -x 121 0x800 -y 70 0x40000000 -x 176 0x140000 -x 177 0x0202007f -x 163 0x1 -x 186 0x80000 -x 180 0x400 -x 180 0x4000000 -x 189 0x80000 -x 163 0x100 -x 121 0x800 -x 176 0x100 -x 176 0x100 -x 189 2 -x 189 0x800 -y 70 0x40000000 -y 189 0x4000000 -x 9 1 -x 42 0x14200000 -x 72 0x1 -x 136 0x11 -quad -x 119 0x10000000 -x 129 0x40000000 -x 129 2 -x 164 0x1000 -y 124 0x8 -x 24 1 -x 42 0x400000 -y 129 4 -x 129 0x400 -x 0 0x1000000 -x 2 0x100000 -x 0 0x2000000 -x 161 53239 -x 162 53239 -cmdline '+pgfortran src/sorad.acc.F90 -tp=sandybridge-64 -fast -Mvect=sse -Mcache_align -Mflushz -Mpre -r4 -Mextend -Mpreprocess -Ktrap=fp -Kieee -Minfo=all -acc -ta=nvidia:5.5,cc35 -DNITERS=6 -DGPU_PRECISION=8 -c' -asm /gpfsm/dnb31/tdirs/pbs/slurm.974475.mathomp4/pgfortranxX0gfyW7jDQ0.sm
make[1]: *** [sorad.acc.o] Error 127
make[1]: Leaving directory `/gpfsm/dnb31/mathomp4/G21p3-Benchmark-Sorad'
make: *** [run_acc] Error 2

One thought I had was maybe I just had to put the .o those files are in the compile line, but, nope:

$ pgfortran -fast -r4 -Mextend -Mpreprocess -Ktrap=fp -Kieee -Minfo=all -tp=sandybridge-64 -acc -ta=nvidia:5.0,cc35,time -DNITERS=6 -DGPU_PRECISION=8 gettau.acc.o -c src/sorad.acc.F90
...
deledd:
   1686, Generating acc routine gang
         Generating NVIDIA code
ptxas fatal   : Unresolved extern function 'gettau_getvistau_'
PGF90-S-0155-Compiler failed to translate accelerator region (see -Minfo messages): Device compiler exited with error status code (src/sorad.acc.F90: 1)
pgfortran-Fatal-/usr/local/sles11/pgi/linux86-64/14.1/bin/pgf902 TERMINATED by signal 11
...

Any help?

Thanks,
Matt

Hi Matt,

You may need to move to 14.2. In 14.1, “routine” only supported subroutines, 14.2 added functions.

  • Mat