c - Linking a PGI OpenACC-enabled library with gcc

前端 未结 1 935
离开以前
离开以前 2020-12-21 17:31

Briefly speaking, my question relies in between compiling/building files (using libraries) with two different compilers while exploiting OpenACC co

1条回答
  •  臣服心动
    2020-12-21 18:13

    Add "-ta=tesla:nordc" to your pgcc compilation. By default PGI uses runtime dynamic compilation (RDC) for the GPU code. However RDC requires an extra link step (with nvlink) that gcc does not support. The "nordc" sub-option disables RDC so you'll be able to use OpenACC code in a library. However by disabling RDC you can no longer call external device routines from a compute region.

    % pgcc -acc -ta=tesla:nordc -c libmyacc.c
    % ar -cvq libmyacc.a libmyacc.o
    a - libmyacc.o
    % gcc f1.c -L/proj/pgi/linux86-64/16.5/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L. -laccapi -laccg -laccn -laccg2 -ldl -lcudadevice -lpgmp -lnuma -lpthread -lnspgc -lpgc -lm -lgcc -lc -lgcc -lmyacc
    % a.out
    Hello --- Start of the main.
    Sum: 500500.000
    Num devices: 8
    Sum2: 500500.000
    

    Hope this helps, Mat

    0 讨论(0)
提交回复
热议问题