[clang] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU (PR #115241)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 16:39:34 PST 2024


https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/115241

>From 451f37016c5bd4cbd0bb08cc172995e8af4e7482 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 6 Nov 2024 18:27:07 -0600
Subject: [PATCH] [AMDGPU] Make `__GCC_DESTRUCTIVE_SIZE` 128 on AMDGPU

Summary:
The cache line size on AMDGPU varies between 64 and 128 (The lowest L2
cache also goes to 256 on some architectures.) This macro is intended to
present a size that will not cause destructive interference, so we
choose the larger of those values.
---
 clang/lib/Basic/Targets/AMDGPU.h   | 4 ++++
 clang/test/Driver/amdgpu-macros.cl | 1 +
 2 files changed, 5 insertions(+)

diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 6edd3474d4edae..81e96ed65c47bf 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -462,6 +462,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
   }
 
   bool hasHIPImageSupport() const override { return HasImage; }
+
+  std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
+    return std::make_pair(128, 128);
+  }
 };
 
 } // namespace targets
diff --git a/clang/test/Driver/amdgpu-macros.cl b/clang/test/Driver/amdgpu-macros.cl
index dd5a4483e4d607..5ce9d339d4c050 100644
--- a/clang/test/Driver/amdgpu-macros.cl
+++ b/clang/test/Driver/amdgpu-macros.cl
@@ -153,6 +153,7 @@
 // ARCH-GCN-DAG: #define __[[FAMILY]]__ 1
 // ARCH-GCN-DAG: #define __amdgcn_processor__ "[[CPU]]"
 // ARCH-GCN-DAG: #define __AMDGCN_WAVEFRONT_SIZE [[WAVEFRONT_SIZE]]
+// ARCH-GCN-DAG: #define __GCC_DESTRUCTIVE_SIZE 128
 // UNSAFEFPATOMIC-DAG: #define __AMDGCN_UNSAFE_FP_ATOMICS__ 1
 
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx906 -mwavefrontsize64 \



More information about the cfe-commits mailing list