This is an archive of the discontinued LLVM Phabricator instance.

[Libomptarget] Allow the device runtime to be compiled for the host
ClosedPublic

Authored by jhuber6 on May 9 2022, 12:22 PM.

Details

Summary

Currently the OpenMP offloading device runtime is only expected to be
compiled for the specific architecture it's targeting. This is
problematic if we want to make compiling the device runtime more general
via the standar clang driver rather than invoking the clang front-end
directly. This patch addresses this by primarily changing the declare
type to nohost so the host will not contain any of this code.
Additionally we forward declare the functions that are defined via
variants, otherwise these would cause problems on the host.

Diff Detail

Event Timeline

jhuber6 created this revision.May 9 2022, 12:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2022, 12:22 PM
jhuber6 requested review of this revision.May 9 2022, 12:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2022, 12:22 PM
tianshilei1992 accepted this revision.May 10 2022, 7:28 AM

LGTM. Just would be better to add comments for those forward declaration.

openmp/libomptarget/DeviceRTL/src/Mapping.cpp
26–43

Could you add some comments here saying that's just a declaration and every target has to implement them.

openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
66

similar here

This revision is now accepted and ready to land.May 10 2022, 7:28 AM
jhuber6 added inline comments.May 10 2022, 7:43 AM
openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
66

Will do.

I'm not super happy about the forward decls. Should we augment begin declare tatrget with begin declare variant match(device={kind(nohost)}) instead?

I'm not super happy about the forward decls. Should we augment begin declare tatrget with begin declare variant match(device={kind(nohost)}) instead?

Do you mean by changing the declare? Or by nesting variants. I wasn't sure if that worked.

jdoerfert accepted this revision.May 10 2022, 9:15 AM

I think we are lacking a good way to do what I want, let's go ahead with forward declares for now.