[libc-commits] [libc] bae46d1 - [libc][Obvious] Correctly initialize the default clock frequency (#76582)

via libc-commits libc-commits at lists.llvm.org
Fri Dec 29 12:17:37 PST 2023


Author: Joseph Huber
Date: 2023-12-29T14:17:33-06:00
New Revision: bae46d14eb664493f7da445bab131241b7421a8c

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

LOG: [libc][Obvious] Correctly initialize the default clock frequency (#76582)

Summary:
The AMDGPU architecture does not use a fixed frequency for all of its
architectures. However, the newer GPUs tend to have one that's
consistent between them (Except for Vega10). This was set up but not
actually used, so the implementation was just defaulting to whatever
value the global was being set to. Fix.

Added: 
    

Modified: 
    libc/src/time/gpu/time_utils.h

Removed: 
    


################################################################################
diff  --git a/libc/src/time/gpu/time_utils.h b/libc/src/time/gpu/time_utils.h
index 53548181e17e25..f56179f29a5673 100644
--- a/libc/src/time/gpu/time_utils.h
+++ b/libc/src/time/gpu/time_utils.h
@@ -36,10 +36,11 @@ constexpr uint64_t clock_freq = 25000000;
 constexpr uint64_t clock_freq = 0;
 #endif
 
-// We provide an externally visible symbol such that the runtime can set this to
-// the correct value. If it is not set we try to default to the known values.
+// We provide an externally visible symbol such that the runtime can set
+// this to the correct value. If it is not set we try to default to the
+// known values.
 extern "C" [[gnu::visibility("protected")]] uint64_t
-    [[clang::address_space(4)]] __llvm_libc_clock_freq;
+    [[clang::address_space(4)]] __llvm_libc_clock_freq = clock_freq;
 #define GPU_CLOCKS_PER_SEC static_cast<clock_t>(__llvm_libc_clock_freq)
 
 #elif defined(LIBC_TARGET_ARCH_IS_NVPTX)


        


More information about the libc-commits mailing list