I have a shared library libraberto.so
compiled with PGCC
. It contains OpenACC pragma directives and is compiled with the -acc
flag to ensure these directives are enabled. The corresponding makefile rules are:
libraberto.so: file1.o file2.o ...
pgcc -shared -o./libraberto.so file1.o file2.o ...
%.o: %.c
pgcc -acc -Minfo=accel -c -fpic -I./inc/ -o./$@ $<
Where file1.c
, file2.c
, etc. are the source files which make up the library.
I then have a mex_gateway.c
file which simply calls a routine within the shared library from MATLAB, passes it variables (arrays and scalars) and then receives output arrays. It is compiled as follows:
mex -lraberto mex_gateway.c
The compilation works fine, however when I try to run the gateway in MATLAB, I get the following error:
Invalid MEX-file '[...]/mex_gateway.mexa64':
[...]/libraberto.so: undefined symbol: __pgi_uacc_dataenterstart
I wasn't able to find any information on this particular error (symbol) on Google, and am not sure where to look in my code. The program works fine when compiling the shared library without OpenACC directives (i.e. without -acc
). I thought the error might be due to the particular nature of the arrays used by MEX (mxArray
), which might not play nice with OpenACC when transferring data to the accelerator, but memcpy
'ing the inputs to true malloc
'd C arrays before passing them to the shared library routine makes no difference.