[libc-commits] [libc] 515bd1c - [libc][Obvious] Fix timing on AMDGPU not being initialized

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Jul 5 14:08:44 PDT 2023


Author: Joseph Huber
Date: 2023-07-05T16:08:37-05:00
New Revision: 515bd1c9b88189f4f48406e81448ccf4d263b268

URL: https://github.com/llvm/llvm-project/commit/515bd1c9b88189f4f48406e81448ccf4d263b268
DIFF: https://github.com/llvm/llvm-project/commit/515bd1c9b88189f4f48406e81448ccf4d263b268.diff

LOG: [libc][Obvious] Fix timing on AMDGPU not being initialized

Summary:
Reviewer requested that this routine not be a macro, however that means
that it was not being intitialized as the static initializer was done
before the memcpy from the device. Fix this so we can get timing
information.

Added: 
    

Modified: 
    libc/test/UnitTest/LibcTest.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/UnitTest/LibcTest.cpp b/libc/test/UnitTest/LibcTest.cpp
index d5e6fdfd8e0da5..3ffd0c3d18abd4 100644
--- a/libc/test/UnitTest/LibcTest.cpp
+++ b/libc/test/UnitTest/LibcTest.cpp
@@ -19,11 +19,12 @@
 #include "src/__support/GPU/utils.h"
 static long clock() { return __llvm_libc::gpu::fixed_frequency_clock(); }
 #if defined(LIBC_TARGET_ARCH_IS_NVPTX)
-uint64_t CLOCKS_PER_SEC = 1000000000UL;
+#define CLOCKS_PER_SEC 1000000000UL
 #else
 // The AMDGPU loader needs to initialize this at runtime by querying the driver.
-extern "C" [[gnu::visibility("protected")]] uint64_t __llvm_libc_clock_freq;
-uint64_t CLOCKS_PER_SEC = __llvm_libc_clock_freq;
+extern "C" [[gnu::visibility("protected")]] uint64_t
+    [[clang::address_space(4)]] __llvm_libc_clock_freq;
+#define CLOCKS_PER_SEC __llvm_libc_clock_freq
 #endif
 #else
 static long clock() { return 0; }


        


More information about the libc-commits mailing list