[llvm] [AMDGPU] Add eventMask function in WaitcntGenerator class (NFC) (PR #85210)
Christudasan Devadasan via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 07:22:56 PDT 2024
https://github.com/cdevadas updated https://github.com/llvm/llvm-project/pull/85210
>From b626059b2930b1175e4f06df89a865900cf70903 Mon Sep 17 00:00:00 2001
From: Christudasan Devadasan <Christudasan.Devadasan at amd.com>
Date: Thu, 14 Mar 2024 12:02:51 +0530
Subject: [PATCH 1/2] [AMDGPU] Add eventMask function in WaitcntGenerator class
(NFC)
This would bring a cleaner interface while obtaining wait event masks
by combining various wait event types in the derived classes.
---
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 40 ++++++++++++---------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index a6184c5e1e0487..03db4e0147457e 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -485,6 +485,15 @@ class WaitcntGenerator {
virtual AMDGPU::Waitcnt getAllZeroWaitcnt(bool IncludeVSCnt) const = 0;
virtual ~WaitcntGenerator() = default;
+
+ // Create a mask value from the initializer list of wait event types.
+ unsigned eventMask(std::initializer_list<WaitEventType> Events) const {
+ unsigned Mask = 0;
+ for (auto &E : Events)
+ Mask |= 1 << E;
+
+ return Mask;
+ }
};
class WaitcntGeneratorPreGFX12 : public WaitcntGenerator {
@@ -506,14 +515,12 @@ class WaitcntGeneratorPreGFX12 : public WaitcntGenerator {
assert(ST);
static const unsigned WaitEventMaskForInstPreGFX12[NUM_INST_CNTS] = {
- (1 << VMEM_ACCESS) | (1 << VMEM_READ_ACCESS) |
- (1 << VMEM_SAMPLER_READ_ACCESS) | (1 << VMEM_BVH_READ_ACCESS),
- (1 << SMEM_ACCESS) | (1 << LDS_ACCESS) | (1 << GDS_ACCESS) |
- (1 << SQ_MESSAGE),
- (1 << EXP_GPR_LOCK) | (1 << GDS_GPR_LOCK) | (1 << VMW_GPR_LOCK) |
- (1 << EXP_PARAM_ACCESS) | (1 << EXP_POS_ACCESS) |
- (1 << EXP_LDS_ACCESS),
- (1 << VMEM_WRITE_ACCESS) | (1 << SCRATCH_WRITE_ACCESS),
+ eventMask({VMEM_ACCESS, VMEM_READ_ACCESS, VMEM_SAMPLER_READ_ACCESS,
+ VMEM_BVH_READ_ACCESS}),
+ eventMask({SMEM_ACCESS, LDS_ACCESS, GDS_ACCESS, SQ_MESSAGE}),
+ eventMask({EXP_GPR_LOCK, GDS_GPR_LOCK, VMW_GPR_LOCK, EXP_PARAM_ACCESS,
+ EXP_POS_ACCESS, EXP_LDS_ACCESS}),
+ eventMask({VMEM_WRITE_ACCESS, SCRATCH_WRITE_ACCESS}),
0,
0,
0};
@@ -543,15 +550,14 @@ class WaitcntGeneratorGFX12Plus : public WaitcntGenerator {
assert(ST);
static const unsigned WaitEventMaskForInstGFX12Plus[NUM_INST_CNTS] = {
- (1 << VMEM_ACCESS) | (1 << VMEM_READ_ACCESS),
- (1 << LDS_ACCESS) | (1 << GDS_ACCESS),
- (1 << EXP_GPR_LOCK) | (1 << GDS_GPR_LOCK) | (1 << VMW_GPR_LOCK) |
- (1 << EXP_PARAM_ACCESS) | (1 << EXP_POS_ACCESS) |
- (1 << EXP_LDS_ACCESS),
- (1 << VMEM_WRITE_ACCESS) | (1 << SCRATCH_WRITE_ACCESS),
- (1 << VMEM_SAMPLER_READ_ACCESS),
- (1 << VMEM_BVH_READ_ACCESS),
- (1 << SMEM_ACCESS) | (1 << SQ_MESSAGE)};
+ eventMask({VMEM_ACCESS, VMEM_READ_ACCESS}),
+ eventMask({LDS_ACCESS, GDS_ACCESS}),
+ eventMask({EXP_GPR_LOCK, GDS_GPR_LOCK, VMW_GPR_LOCK, EXP_PARAM_ACCESS,
+ EXP_POS_ACCESS, EXP_LDS_ACCESS}),
+ eventMask({VMEM_WRITE_ACCESS, SCRATCH_WRITE_ACCESS}),
+ eventMask({VMEM_SAMPLER_READ_ACCESS}),
+ eventMask({VMEM_BVH_READ_ACCESS}),
+ eventMask({SMEM_ACCESS, SQ_MESSAGE})};
return WaitEventMaskForInstGFX12Plus;
}
>From e9f4ba5b9b34a189432e563172fd3702e24d56da Mon Sep 17 00:00:00 2001
From: Christudasan Devadasan <Christudasan.Devadasan at amd.com>
Date: Thu, 14 Mar 2024 19:52:01 +0530
Subject: [PATCH 2/2] made eventMask a constexpr
---
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 03db4e0147457e..5a0ff86a7f248f 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -487,7 +487,7 @@ class WaitcntGenerator {
virtual ~WaitcntGenerator() = default;
// Create a mask value from the initializer list of wait event types.
- unsigned eventMask(std::initializer_list<WaitEventType> Events) const {
+ static constexpr unsigned eventMask(std::initializer_list<WaitEventType> Events) {
unsigned Mask = 0;
for (auto &E : Events)
Mask |= 1 << E;
More information about the llvm-commits
mailing list