-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AMDGPU] Add eventMask function in WaitcntGenerator class (NFC) #85210
Conversation
This would bring a cleaner interface while obtaining wait event masks by combining various wait event types in the derived classes.
@llvm/pr-subscribers-backend-amdgpu Author: Christudasan Devadasan (cdevadas) ChangesThis would bring a cleaner interface while obtaining wait event masks by combining various wait event types in the derived classes. Full diff: https://github.com/llvm/llvm-project/pull/85210.diff 1 Files Affected:
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;
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
✅ With the latest revision this PR passed the C/C++ code formatter. |
e9f4ba5
to
8b7957a
Compare
This would bring a cleaner interface while obtaining wait event masks by combining various wait event types in the derived classes.