This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Allow CUDA to be linked with OpenMP using the new driver
ClosedPublic

Authored by jhuber6 on Feb 21 2022, 11:47 AM.

Details

Summary

After basic support for embedding and handling CUDA files was added to
the new driver, we should be able to call CUDA functions from OpenMP
code. This patch makes the necessary changes to successfuly link in CUDA
programs that were compiled using the new driver. With this patch it
should be possible to compile device-only CUDA code (no kernels) and
call it from OpenMP as follows:

$ clang++ cuda.cu -fopenmp-new-driver -offload-arch=sm_70 -c
$ clang++ openmp.cpp cuda.o -fopenmp-new-driver -fopenmp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_70

Currently this requires using a host variant to suppress the generation
of a CPU-side fallback call.

Depends on D120272

Diff Detail

Event Timeline

jhuber6 created this revision.Feb 21 2022, 11:47 AM
jhuber6 requested review of this revision.Feb 21 2022, 11:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2022, 11:47 AM
jhuber6 updated this revision to Diff 410370.Feb 21 2022, 12:48 PM

Make sure we don't pass PTX to nvlink.

jhuber6 updated this revision to Diff 410414.Feb 21 2022, 3:58 PM

Changing after rebasing previous commits.

jhuber6 updated this revision to Diff 412810.Mar 3 2022, 12:27 PM

Updating to use fatbinaries and fatbinary magic.

Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 12:27 PM
jhuber6 updated this revision to Diff 421555.Apr 8 2022, 9:35 AM

Update handling for fatbinaries.

jhuber6 updated this revision to Diff 425807.Apr 28 2022, 8:55 AM

Ping and rebase

jhuber6 updated this revision to Diff 426050.Apr 29 2022, 7:17 AM

Adding test

This revision is now accepted and ready to land.Apr 29 2022, 7:27 AM