This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][DeviceRTL] Add the support for printf in a freestanding way
ClosedPublic

Authored by tianshilei1992 on Sep 13 2021, 3:55 PM.

Details

Summary

For NVPTX, printf can be used just with a function declaration. For AMDGCN, an
function definition is added, but it simply returns.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Sep 13 2021, 3:55 PM
tianshilei1992 requested review of this revision.Sep 13 2021, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2021, 3:55 PM

I think clang will lower printf for nvptx targets to vprintf. Can you check that. Also check what it emits for amdgcn targets.

openmp/libomptarget/DeviceRTL/src/Debug.cpp
37

no need for these annotations.

JonChesterfield added a comment.EditedSep 13 2021, 4:19 PM

I'm surprised that compiles for amdgpu, should be an error about variadic functions being unimplemented. Perhaps the cmake for the new runtime only builds on nvptx?

fixed wrong implementation

tianshilei1992 marked an inline comment as done.Sep 13 2021, 5:23 PM

So this compiles with nvptx and amdgcn properly?

So this compiles with nvptx and amdgcn properly?

I checked nvptx, it works. Will Ask @JonChesterfield to help see if clang lowers it to vprintf as well.

This revision is now accepted and ready to land.Sep 22 2021, 12:34 PM
openmp/libomptarget/DeviceRTL/src/Debug.cpp
37

Since AMD FE doesn't lower it to vprintf, what should we do here? If we enable the feature, there will be link error.

Stub it out with a macro until printf exists for amdgpu. Hopefully that won't be too much longer

gaurd the code with macro for now

openmp/libomptarget/DeviceRTL/include/Debug.h
33

@JonChesterfield This should be sufficient, right?

If we use PRINT everywhere, sure. Else we need PRINTF too.

I had #define printf(...) in mind instead of the MACROs, but strictly speaking one probably shouldn't override a libc function like that.

add PRINTF for AMDGCN as well

jdoerfert accepted this revision.Oct 7 2021, 7:10 PM

LG, 2 nits.

openmp/libomptarget/DeviceRTL/include/Debug.h
27
This revision was landed with ongoing or failed builds.Oct 7 2021, 7:15 PM
This revision was automatically updated to reflect the committed changes.