Skip to content

Commit 4fb953a

Browse files
authored
[AMDGPU] Make __GCC_DESTRUCTIVE_SIZE 128 on AMDGPU (#115241)
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.
1 parent f5e4ffa commit 4fb953a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/lib/Basic/Targets/AMDGPU.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,14 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
462462
}
463463

464464
bool hasHIPImageSupport() const override { return HasImage; }
465+
466+
std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
467+
// This is imprecise as the value can vary between 64, 128 (even 256!) bytes
468+
// depending on the level of cache and the target architecture. We select
469+
// the size that corresponds to the largest L1 cache line for all
470+
// architectures.
471+
return std::make_pair(128, 128);
472+
}
465473
};
466474

467475
} // namespace targets

clang/test/Driver/amdgpu-macros.cl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
// ARCH-GCN-DAG: #define __[[FAMILY]]__ 1
154154
// ARCH-GCN-DAG: #define __amdgcn_processor__ "[[CPU]]"
155155
// ARCH-GCN-DAG: #define __AMDGCN_WAVEFRONT_SIZE [[WAVEFRONT_SIZE]]
156+
// ARCH-GCN-DAG: #define __GCC_DESTRUCTIVE_SIZE 128
157+
// ARCH-GCN-DAG: #define __GCC_CONSTRUCTIVE_SIZE 128
156158
// UNSAFEFPATOMIC-DAG: #define __AMDGCN_UNSAFE_FP_ATOMICS__ 1
157159

158160
// RUN: %clang -E -dM -target amdgcn -mcpu=gfx906 -mwavefrontsize64 \

0 commit comments

Comments
 (0)