This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] added cmath wrappers to unbreak CUDA compilation after D79555
ClosedPublic

Authored by tra on Jan 11 2023, 5:13 PM.

Details

Summary

libc++ introduced a handful of internal functions that may or may not be
constexpr, depending on C++ version. For pre-constexpr variants we must declare
device counterparts. Otherwise the code fails to compile on the GPU side.
See https://reviews.llvm.org/D79555

Diff Detail

Event Timeline

tra created this revision.Jan 11 2023, 5:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2023, 5:13 PM
tra updated this revision to Diff 488733.Jan 12 2023, 12:14 PM

Simplified the wrapper.

tra updated this revision to Diff 488734.Jan 12 2023, 12:16 PM

nit fix.

tra published this revision for review.Jan 12 2023, 12:18 PM
tra added reviewers: jlebar, philnik.
tra added inline comments.
clang/lib/Headers/cuda_wrappers/cmath
109

__builtin_logb() results in a libcall to logb() which we do not have on the GPU side, so we have to use CUDA-provided function.

154

Ditto for __builtin_scalbn()

Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 12:18 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tra updated this revision to Diff 488736.Jan 12 2023, 12:22 PM

Reformatted the code

jlebar accepted this revision.Jan 12 2023, 3:05 PM

LGTM. Do we need changes to the test-suite to cover this too? (test-suite being in a separate repo, so it would be a separate patch.)

This revision is now accepted and ready to land.Jan 12 2023, 3:05 PM
tra added a comment.Jan 12 2023, 3:17 PM

LGTM. Do we need changes to the test-suite to cover this too? (test-suite being in a separate repo, so it would be a separate patch.)

test-suite on CUDA bots already covering this and the bots are currently broken. This change should fix them (they appear to work when I run them locally with this patch).

This revision was landed with ongoing or failed builds.Jan 12 2023, 3:38 PM
This revision was automatically updated to reflect the committed changes.