[llvm] c54f22f - [AMDGPU] Add eventMask function in WaitcntGenerator class (NFC) (#85210)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 21:53:01 PDT 2024
Author: Christudasan Devadasan
Date: 2024-03-15T10:22:58+05:30
New Revision: c54f22f5fe3eef055df4be7239b890eaab15f5ff
URL: https://github.com/llvm/llvm-project/commit/c54f22f5fe3eef055df4be7239b890eaab15f5ff
DIFF: https://github.com/llvm/llvm-project/commit/c54f22f5fe3eef055df4be7239b890eaab15f5ff.diff
LOG: [AMDGPU] Add eventMask function in WaitcntGenerator class (NFC) (#85210)
This would bring a cleaner interface while obtaining wait event masks by
combining various wait event types in the derived classes.
Added:
Modified:
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index a6184c5e1e0487..27621906e4c5fd 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -485,6 +485,16 @@ 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.
+ static constexpr unsigned
+ eventMask(std::initializer_list<WaitEventType> Events) {
+ unsigned Mask = 0;
+ for (auto &E : Events)
+ Mask |= 1 << E;
+
+ return Mask;
+ }
};
class WaitcntGeneratorPreGFX12 : public WaitcntGenerator {
@@ -506,14 +516,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 +551,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;
}
More information about the llvm-commits
mailing list