This is an archive of the discontinued LLVM Phabricator instance.

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

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



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.

37 ↗(On Diff #372358)

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
37 ↗(On Diff #372369)

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


@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.

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.