gcc/libgomp
Tom de Vries 02150de863 [libgomp, nvptx] Handle CUDA_ONE_CALL_MAYBE_NULL
This patch adds handling of functions that may not be present in the cuda
driver.

Such a function can be declared using CUDA_ONE_CALL_MAYBE_NULL in cuda-lib.def,
it can be called with the usual convenience macros, but before calling its
presence needs to be tested using new macro CUDA_CALL_EXISTS.

When using the dlopen interface (PLUGIN_NVPTX_DYNAMIC == 1), we allow
non-present functions by allowing dlsym to return NULL.  Otherwise
(PLUGIN_NVPTX_DYNAMIC == 0) we declare the non-present function to be weak.

Build and reg-tested libgomp on x86_64 with nvidia accelerator, with and without
--disable-cuda-driver, in combination with a trigger patch that adds a
non-existing function foo to cuda-lib.def:
...
CUDA_ONE_CALL_MAYBE_NULL (foo)
...
and declares it in plugin-nvptx.c:
...
CUresult foo (void);
...
and then uses it in nvptx_init after the init_cuda_lib call:
...
  if (CUDA_CALL_EXISTS (foo))
    CUDA_CALL (foo);
...

Also build and reg-tested on x86_64 with nvidia accelerator, with and without
--disable-cuda-driver, in combination with a trigger patch that replaces all
CUDA_ONE_CALLs in cuda-lib.def with CUDA_ONE_CALL_MAYBE_NULL, and guards two
CUDA_CALLs with CUDA_CALL_EXISTS, one for a regular fn, and one for a fn that is
a define in cuda/cuda.h.

2018-08-07  Tom de Vries  <tdevries@suse.de>

	* plugin/plugin-nvptx.c (DO_PRAGMA): Define.
	(struct cuda_lib_s): Add def/undef of CUDA_ONE_CALL_MAYBE_NULL.
	(init_cuda_lib): Add new param to CUDA_ONE_CALL_1.  Add arg to
	corresponding call in CUDA_ONE_CALL.  Add def/undef of
	CUDA_ONE_CALL_MAYBE_NULL.
	(CUDA_CALL_EXISTS): Define.

From-SVN: r263346
2018-08-06 22:13:56 +00:00
..
config
plugin
testsuite
acinclude.m4
aclocal.m4
affinity.c
alloc.c
atomic.c
barrier.c
ChangeLog
ChangeLog.graphite
config.h.in
configure
configure.ac
configure.tgt
critical.c
env.c
error.c
fortran.c
hashtab.h
icv-device.c
icv.c
iter_ull.c
iter.c
libgomp_f.h.in
libgomp_g.h
libgomp-plugin.c
libgomp-plugin.h
libgomp.h
libgomp.map
libgomp.spec.in
libgomp.texi
lock.c
loop_ull.c
loop.c
Makefile.am
Makefile.in
oacc-async.c
oacc-cuda.c
oacc-host.c
oacc-init.c
oacc-int.h
oacc-mem.c
oacc-parallel.c
oacc-plugin.c
oacc-plugin.h
omp_lib.f90.in
omp_lib.h.in
omp.h.in
openacc_lib.h
openacc.f90
openacc.h
ordered.c
parallel.c
priority_queue.c
priority_queue.h
sections.c
secure_getenv.h
single.c
splay-tree.c
splay-tree.h
target.c
task.c
taskloop.c
team.c
work.c