This is an archive of the discontinued LLVM Phabricator instance.

[libc] Implement the 'nanosleep' function on the GPU
ClosedPublic

Authored by jhuber6 on Aug 30 2023, 2:00 PM.

Details

Summary

The GPU has the ability to sleep for very short periods of time. We can
map this to the existing nanosleep utility. This patch maps the
nanosleep utility to the existing hardware instructions as best as
possible.

Depends on D159118

Diff Detail

Event Timeline

jhuber6 created this revision.Aug 30 2023, 2:00 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 30 2023, 2:00 PM
jhuber6 requested review of this revision.Aug 30 2023, 2:00 PM
sivachandra accepted this revision.Aug 30 2023, 2:24 PM

OK for structuring changes.

This revision is now accepted and ready to land.Aug 30 2023, 2:24 PM
JonChesterfield accepted this revision.Aug 30 2023, 2:46 PM

We should probably create llvm intrinsics for the ad hoc ptx assembly remaining. I don't think there's any inline asm for intrinsics in amdgpu, though there may still be some as control flow hacks

We should probably create llvm intrinsics for the ad hoc ptx assembly remaining. I don't think there's any inline asm for intrinsics in amdgpu, though there may still be some as control flow hacks

Definitely, probably a good job to round them all up and implement them since they're pretty simple. Which actually reminds me that I forgot to check for sm_70 in this so thanks for that.

jhuber6 updated this revision to Diff 554841.Aug 30 2023, 3:04 PM

Add default and change the unit test. The test requires C++20 but doesn't seem to actually use it so I removed it such that we can run it here.

sivachandra accepted this revision.Aug 30 2023, 3:10 PM
This revision was automatically updated to reflect the committed changes.