[libc-commits] [libc] [libc][gpu] Disable loop unrolling in the throughput benchmark loop by default (PR #153971)

via libc-commits libc-commits at lists.llvm.org
Sat Aug 16 11:49:01 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h -- libc/benchmarks/gpu/timing/amdgpu/timing.h libc/benchmarks/gpu/timing/nvptx/timing.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/benchmarks/gpu/timing/amdgpu/timing.h b/libc/benchmarks/gpu/timing/amdgpu/timing.h
index 5c1d3a058..ece40778d 100644
--- a/libc/benchmarks/gpu/timing/amdgpu/timing.h
+++ b/libc/benchmarks/gpu/timing/amdgpu/timing.h
@@ -118,9 +118,9 @@ throughput_baseline(const cpp::array<T, N> &inputs) {
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (auto input : inputs) {
     asm("" ::"v"(input));
     result = input;
@@ -151,9 +151,9 @@ static LIBC_INLINE uint64_t throughput(F f, const cpp::array<T, N> &inputs) {
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (auto input : inputs) {
     asm("" ::"v"(input));
     result = f(input);
@@ -183,9 +183,9 @@ static LIBC_INLINE uint64_t throughput_baseline(
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (size_t i = 0; i < N; i++) {
     T x = inputs1[i];
     T y = inputs2[i];
@@ -219,9 +219,9 @@ static LIBC_INLINE uint64_t throughput(F f, const cpp::array<T, N> &inputs1,
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (size_t i = 0; i < N; i++) {
     T x = inputs1[i];
     T y = inputs2[i];
diff --git a/libc/benchmarks/gpu/timing/nvptx/timing.h b/libc/benchmarks/gpu/timing/nvptx/timing.h
index e671e378c..fa0875c92 100644
--- a/libc/benchmarks/gpu/timing/nvptx/timing.h
+++ b/libc/benchmarks/gpu/timing/nvptx/timing.h
@@ -107,9 +107,9 @@ throughput_baseline(const cpp::array<T, N> &inputs) {
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (auto input : inputs) {
     asm("" ::"r"(input));
     result = input;
@@ -140,9 +140,9 @@ static LIBC_INLINE uint64_t throughput(F f, const cpp::array<T, N> &inputs) {
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (auto input : inputs) {
     asm("" ::"r"(input));
     result = f(input);
@@ -172,9 +172,9 @@ static LIBC_INLINE uint64_t throughput_baseline(
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (size_t i = 0; i < N; i++) {
     T x = inputs1[i];
     T y = inputs2[i];
@@ -208,9 +208,9 @@ static LIBC_INLINE uint64_t throughput(F f, const cpp::array<T, N> &inputs1,
 
   T result{};
 
-  #if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
-  #pragma clang loop unroll(disable)
-  #endif
+#if defined(LIBC_GPU_BENCHMARKS_DISABLE_UNROLL)
+#pragma clang loop unroll(disable)
+#endif
   for (size_t i = 0; i < N; i++) {
     T x = inputs1[i];
     T y = inputs2[i];

``````````

</details>


https://github.com/llvm/llvm-project/pull/153971


More information about the libc-commits mailing list