Skip to content

Commit c54f22f

Browse files
authored
[AMDGPU] Add eventMask function in WaitcntGenerator class (NFC) (llvm#85210)
This would bring a cleaner interface while obtaining wait event masks by combining various wait event types in the derived classes.
1 parent 32a067c commit c54f22f

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,16 @@ class WaitcntGenerator {
485485
virtual AMDGPU::Waitcnt getAllZeroWaitcnt(bool IncludeVSCnt) const = 0;
486486

487487
virtual ~WaitcntGenerator() = default;
488+
489+
// Create a mask value from the initializer list of wait event types.
490+
static constexpr unsigned
491+
eventMask(std::initializer_list<WaitEventType> Events) {
492+
unsigned Mask = 0;
493+
for (auto &E : Events)
494+
Mask |= 1 << E;
495+
496+
return Mask;
497+
}
488498
};
489499

490500
class WaitcntGeneratorPreGFX12 : public WaitcntGenerator {
@@ -506,14 +516,12 @@ class WaitcntGeneratorPreGFX12 : public WaitcntGenerator {
506516
assert(ST);
507517

508518
static const unsigned WaitEventMaskForInstPreGFX12[NUM_INST_CNTS] = {
509-
(1 << VMEM_ACCESS) | (1 << VMEM_READ_ACCESS) |
510-
(1 << VMEM_SAMPLER_READ_ACCESS) | (1 << VMEM_BVH_READ_ACCESS),
511-
(1 << SMEM_ACCESS) | (1 << LDS_ACCESS) | (1 << GDS_ACCESS) |
512-
(1 << SQ_MESSAGE),
513-
(1 << EXP_GPR_LOCK) | (1 << GDS_GPR_LOCK) | (1 << VMW_GPR_LOCK) |
514-
(1 << EXP_PARAM_ACCESS) | (1 << EXP_POS_ACCESS) |
515-
(1 << EXP_LDS_ACCESS),
516-
(1 << VMEM_WRITE_ACCESS) | (1 << SCRATCH_WRITE_ACCESS),
519+
eventMask({VMEM_ACCESS, VMEM_READ_ACCESS, VMEM_SAMPLER_READ_ACCESS,
520+
VMEM_BVH_READ_ACCESS}),
521+
eventMask({SMEM_ACCESS, LDS_ACCESS, GDS_ACCESS, SQ_MESSAGE}),
522+
eventMask({EXP_GPR_LOCK, GDS_GPR_LOCK, VMW_GPR_LOCK, EXP_PARAM_ACCESS,
523+
EXP_POS_ACCESS, EXP_LDS_ACCESS}),
524+
eventMask({VMEM_WRITE_ACCESS, SCRATCH_WRITE_ACCESS}),
517525
0,
518526
0,
519527
0};
@@ -543,15 +551,14 @@ class WaitcntGeneratorGFX12Plus : public WaitcntGenerator {
543551
assert(ST);
544552

545553
static const unsigned WaitEventMaskForInstGFX12Plus[NUM_INST_CNTS] = {
546-
(1 << VMEM_ACCESS) | (1 << VMEM_READ_ACCESS),
547-
(1 << LDS_ACCESS) | (1 << GDS_ACCESS),
548-
(1 << EXP_GPR_LOCK) | (1 << GDS_GPR_LOCK) | (1 << VMW_GPR_LOCK) |
549-
(1 << EXP_PARAM_ACCESS) | (1 << EXP_POS_ACCESS) |
550-
(1 << EXP_LDS_ACCESS),
551-
(1 << VMEM_WRITE_ACCESS) | (1 << SCRATCH_WRITE_ACCESS),
552-
(1 << VMEM_SAMPLER_READ_ACCESS),
553-
(1 << VMEM_BVH_READ_ACCESS),
554-
(1 << SMEM_ACCESS) | (1 << SQ_MESSAGE)};
554+
eventMask({VMEM_ACCESS, VMEM_READ_ACCESS}),
555+
eventMask({LDS_ACCESS, GDS_ACCESS}),
556+
eventMask({EXP_GPR_LOCK, GDS_GPR_LOCK, VMW_GPR_LOCK, EXP_PARAM_ACCESS,
557+
EXP_POS_ACCESS, EXP_LDS_ACCESS}),
558+
eventMask({VMEM_WRITE_ACCESS, SCRATCH_WRITE_ACCESS}),
559+
eventMask({VMEM_SAMPLER_READ_ACCESS}),
560+
eventMask({VMEM_BVH_READ_ACCESS}),
561+
eventMask({SMEM_ACCESS, SQ_MESSAGE})};
555562

556563
return WaitEventMaskForInstGFX12Plus;
557564
}

0 commit comments

Comments
 (0)