This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add linking of OpenMP math library
Needs ReviewPublic

Authored by jhuber6 on Mar 11 2022, 7:57 AM.

Details

Summary

This patch adds support for linking in the OpenMP math wrappers library.
The math library first replaces all math calls with an OpenMP wrapper
call. This wrapper call is linked early with a library that associates
the wrapper call to the original math function. This is necessary to
have access to the math function symbols without including the math
header which includes incompatible code with the GPU. These wrapper
functions have another library which maps them to the device library
version late when doing LTO. Linking libdevice must be done after this
library and done late when doing LTO. Unfortunately doing LTO with
libdevice is very slow right now.

Depends on D121467

Diff Detail

Event Timeline

jhuber6 created this revision.Mar 11 2022, 7:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2022, 7:57 AM
jhuber6 requested review of this revision.Mar 11 2022, 7:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2022, 7:57 AM
jdoerfert added inline comments.Mar 11 2022, 10:20 AM
clang/include/clang/Driver/Options.td
1056

FWIW, I don't believe this amdgpu/nvpxt separation is actually improving things, on the contrary.

clang/include/clang/Driver/Options.td
1056

libomptarget_gpu? Definitely simplifies clang which is a win. I think it's an artefact of the previous device runtime layout.

jhuber6 added inline comments.Mar 11 2022, 10:36 AM
clang/include/clang/Driver/Options.td
1056

The device library has different triples so we don't get errors when linking, not sure if it's possible to compile to generic IR that doesn't care about the triple. And I thought the same but wasn't too concerned with addressing it in the off chance someone wants to compile for amdgpu and nvptx64 at the same time and also specify the libraries.