This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Replace `cuda.h` with (forward) declarations in the offload plugin
Needs ReviewPublic

Authored by jdoerfert on Jan 20 2021, 4:06 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary
Note: This has not been tested yet.

To enable us to build the plugin without CUDA available on the build
machine we (forward) declare all the `cuda.h` symbols we use and load
the runtime functions from libcuda.so when the plugin is loaded.

Diff Detail

Event Timeline

jdoerfert created this revision.Jan 20 2021, 4:06 PM
jdoerfert requested review of this revision.Jan 20 2021, 4:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2021, 4:06 PM
Herald added a subscriber: sstefan1. · View Herald Transcript
tra added a subscriber: tra.Jan 20 2021, 4:30 PM
tra added inline comments.
openmp/libomptarget/plugins/cuda/src/rtl.cpp
77–78

Nit: I'd suggest declaring the functions with their real names and only use the macro to affect the callers.
Hiding the declaration behind the macro appears to just hide things unnecessarily.

#define cuMemAlloc cuMemAlloc_v2
CUresult cuMemAlloc_v2(CUdeviceptr *, size_t);
jdoerfert updated this revision to Diff 318063.Jan 20 2021, 4:47 PM

Load the cuda functions at runtime

jdoerfert edited the summary of this revision. (Show Details)Jan 20 2021, 4:49 PM
jdoerfert updated this revision to Diff 318069.Jan 20 2021, 5:09 PM
jdoerfert edited the summary of this revision. (Show Details)

Look for CUDA functions on demand and once only, inform libomptarget if CUDA was not found.