[libc-commits] [libc] [libc] Remove remaining GPU architecture dependent instructions (PR #81612)
Shilei Tian via libc-commits
libc-commits at lists.llvm.org
Tue Feb 13 07:46:14 PST 2024
================
@@ -22,14 +22,15 @@ LLVM_LIBC_FUNCTION(int, nanosleep,
uint64_t nsecs = req->tv_nsec + req->tv_sec * TICKS_PER_NS;
uint64_t start = gpu::fixed_frequency_clock();
-#if defined(LIBC_TARGET_ARCH_IS_NVPTX) && __CUDA_ARCH__ >= 700
+#if defined(LIBC_TARGET_ARCH_IS_NVPTX)
uint64_t end = start + nsecs / (TICKS_PER_NS / GPU_CLOCKS_PER_SEC);
uint64_t cur = gpu::fixed_frequency_clock();
// The NVPTX architecture supports sleeping and guaruntees the actual time
// slept will be somewhere between zero and twice the requested amount. Here
// we will sleep again if we undershot the time.
while (cur < end) {
- __nvvm_nanosleep(static_cast<uint32_t>(nsecs));
+ if (__nvvm_reflect("__CUDA_ARCH") >= 700)
+ LIBC_INLINE_ASM("nanosleep.u32 %0;" ::"r"(nsecs));
----------------
shiltian wrote:
So `__nvvm_nanosleep` is not always available but the asm is always supported?
https://github.com/llvm/llvm-project/pull/81612
More information about the libc-commits
mailing list