[libc-commits] [libc] [libc][NFC] Simplify AMDGPU constant frequency checks (PR #79653)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Jan 26 13:41:01 PST 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/79653

Summary:
The AMDGPU fixed frequency clock is fixed to a chip dependent frequency.
More modern chips have started to fix this at known values of 25 MHz or
100 MHz, so this function forwards those values. This was done using the
individual architectures. This patch simply uses the more concise
`__GFXn__` macro which indicates the major revision


>From ff190f6bc7fb54cabcf9e55b4418d317569a1f4d Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 26 Jan 2024 15:35:56 -0600
Subject: [PATCH] [libc][NFC] Simplify AMDGPU constant frequency checks

Summary:
The AMDGPU fixed frequency clock is fixed to a chip dependent frequency.
More modern chips have started to fix this at known values of 25 MHz or
100 MHz, so this function forwards those values. This was done using the
individual architectures. This patch simply uses the more concise
`__GFXn__` macro which indicates the major revision
---
 libc/src/time/gpu/time_utils.h | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/libc/src/time/gpu/time_utils.h b/libc/src/time/gpu/time_utils.h
index ffab6438c711830..531a748665b07b4 100644
--- a/libc/src/time/gpu/time_utils.h
+++ b/libc/src/time/gpu/time_utils.h
@@ -17,18 +17,11 @@ namespace LIBC_NAMESPACE {
 // AMDGPU does not have a single set frequency. Different architectures and
 // cards can have vary values. Here we default to a few known values, but for
 // complete support the frequency needs to be read from the kernel driver.
-#if defined(__gfx940__) || defined(__gfx941__) || defined(__gfx942__) ||       \
-    defined(__gfx1010__) || defined(__gfx1011__) || defined(__gfx1012__) ||    \
-    defined(__gfx1013__) || defined(__gfx1030__) || defined(__gfx1031__) ||    \
-    defined(__gfx1032__) || defined(__gfx1033__) || defined(__gfx1034__) ||    \
-    defined(__gfx1035__) || defined(__gfx1036__) || defined(__gfx1100__) ||    \
-    defined(__gfx1101__) || defined(__gfx1102__) || defined(__gfx1103__) ||    \
-    defined(__gfx1150__) || defined(__gfx1151__)
+#if defined(__GFX10__) || defined(__GFX11__) || defined(__GFX12__) ||          \
+    defined(__gfx940__) || defined(__gfx941__) || defined(__gfx942__)
 // These architectures use a 100 MHz fixed frequency clock.
 constexpr uint64_t clock_freq = 100000000;
-#elif defined(__gfx900__) || defined(__gfx902__) || defined(__gfx904__) ||     \
-    defined(__gfx906__) || defined(__gfx908__) || defined(__gfx909__) ||       \
-    defined(__gfx90a__) || defined(__gfx90c__)
+#elif defined(__GFX9__)
 // These architectures use a 25 MHz fixed frequency clock expect for Vega 10
 // which is actually 27 Mhz. We default to 25 MHz in all cases anyway.
 constexpr uint64_t clock_freq = 25000000;



More information about the libc-commits mailing list