Skip to content

Commit 5763d9e

Browse files
committed
SWDEV-439581 - hip event flags clean up
Change-Id: I2197762d912da41a8b53b32b3446f0a958c988a6
1 parent 26b3b1d commit 5763d9e

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

hipamd/src/hip_event.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ hipError_t Event::synchronize() {
7474
auto hip_device = g_devices[deviceId()];
7575
// Check HW status of the ROCcrl event. Note: not all ROCclr modes support HW status
7676
static constexpr bool kWaitCompletion = true;
77-
if (!hip_device->devices()[0]->IsHwEventReady(*event_, kWaitCompletion, flags)) {
77+
if (!hip_device->devices()[0]->IsHwEventReady(*event_, kWaitCompletion, flags_)) {
7878
if (event_->HwEvent() != nullptr) {
7979
amd::Command* command = nullptr;
80-
hipError_t status = recordCommand(command, event_->command().queue(), flags);
80+
hipError_t status = recordCommand(command, event_->command().queue(), flags_);
8181
command->enqueue();
82-
hip_device->devices()[0]->IsHwEventReady(command->event(), kWaitCompletion, flags);
82+
hip_device->devices()[0]->IsHwEventReady(command->event(), kWaitCompletion, flags_);
8383
command->release();
8484
} else {
8585
event_->awaitCompletion();
@@ -93,7 +93,7 @@ bool Event::awaitEventCompletion() {
9393
}
9494

9595
bool EventDD::awaitEventCompletion() {
96-
return g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_, true, flags);
96+
return g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_, true, flags_);
9797
}
9898

9999
hipError_t Event::elapsedTime(Event& eStop, float& ms) {
@@ -104,7 +104,7 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) {
104104
return hipErrorInvalidHandle;
105105
}
106106

107-
if (flags & hipEventDisableTiming) {
107+
if (flags_ & hipEventDisableTiming) {
108108
return hipErrorInvalidHandle;
109109
}
110110

@@ -120,7 +120,7 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) {
120120
return hipErrorInvalidHandle;
121121
}
122122

123-
if ((flags | eStop.flags) & hipEventDisableTiming) {
123+
if ((flags_ | eStop.flags_) & hipEventDisableTiming) {
124124
return hipErrorInvalidHandle;
125125
}
126126

@@ -224,7 +224,7 @@ hipError_t Event::streamWait(hipStream_t stream, uint flags) {
224224
hipError_t Event::recordCommand(amd::Command*& command, amd::HostQueue* stream,
225225
uint32_t ext_flags ) {
226226
if (command == nullptr) {
227-
int32_t releaseFlags = ((ext_flags == 0) ? flags : ext_flags) &
227+
int32_t releaseFlags = ((ext_flags == 0) ? flags_ : ext_flags) &
228228
(hipEventReleaseToDevice | hipEventReleaseToSystem |
229229
hipEventDisableSystemFence);
230230
if (releaseFlags & hipEventDisableSystemFence) {

hipamd/src/hip_event.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ class Event {
102102
if (type == Query) {
103103
ready = g_devices[deviceId()]->devices()[0]->IsHwEventReadyForcedWait(*event_);
104104
} else {
105-
ready = g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_, flags);
105+
ready = g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_, false, flags_);
106106
}
107107
return ready;
108108
}
109109

110110
public:
111-
Event(unsigned int flags) : flags(flags), lock_("hipEvent_t", true),
111+
Event(uint32_t flags) : flags_(flags), lock_("hipEvent_t", true),
112112
event_(nullptr), unrecorded_(false), stream_(nullptr) {
113113
// No need to init event_ here as addMarker does that
114114
device_id_ = hip::getCurrentDevice()->deviceId(); // Created in current device ctx
@@ -119,7 +119,7 @@ class Event {
119119
event_->release();
120120
}
121121
}
122-
unsigned int flags;
122+
uint32_t flags_; //!< flags associated with the event
123123

124124
virtual hipError_t query();
125125
virtual hipError_t synchronize();

hipamd/src/hip_module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX,
405405

406406
if (stopEvent != nullptr) {
407407
hip::Event* eStop = reinterpret_cast<hip::Event*>(stopEvent);
408-
if (eStop->flags & hipEventDisableSystemFence) {
408+
if (eStop->flags_ & hipEventDisableSystemFence) {
409409
command->setEventScope(amd::Device::kCacheStateIgnore);
410410
} else {
411411
command->setEventScope(amd::Device::kCacheStateSystem);

rocclr/device/device.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,8 @@ class Device : public RuntimeObject {
19301930
virtual bool IsHwEventReady(
19311931
const amd::Event& event, //!< AMD event for HW status validation
19321932
bool wait = false, //!< If true then forces the event completion
1933-
int hip_event_flags = 0) const {
1933+
uint32_t hip_event_flags = 0 //!< flags associated with the event. 0 = hipEventDefault
1934+
) const {
19341935
return false;
19351936
};
19361937

rocclr/device/rocm/rocdevice.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2924,13 +2924,16 @@ bool Device::IsHwEventReadyForcedWait(const amd::Event& event) const {
29242924
}
29252925

29262926
// ================================================================================================
2927-
bool Device::IsHwEventReady(const amd::Event& event, bool wait, int hip_event_flags) const {
2927+
bool Device::IsHwEventReady(const amd::Event& event, bool wait, uint32_t hip_event_flags) const {
29282928
void* hw_event =
29292929
(event.NotifyEvent() != nullptr) ? event.NotifyEvent()->HwEvent() : event.HwEvent();
29302930
if (hw_event == nullptr) {
29312931
ClPrint(amd::LOG_INFO, amd::LOG_SIG, "No HW event");
29322932
return false;
29332933
} else if (wait) {
2934+
// hipEventBlockingSync
2935+
// when set the CPU gives up host thread for other work
2936+
// when not set the CPU enters a busy-wait on the event to occur
29342937
constexpr int kHipEventBlockingSync = 0x1;
29352938
bool active_wait = !(hip_event_flags & kHipEventBlockingSync) && ActiveWait();
29362939
return WaitForSignal(reinterpret_cast<ProfilingSignal*>(hw_event)->signal_, active_wait);

rocclr/device/rocm/rocdevice.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class NullDevice : public amd::Device {
288288
}
289289

290290
bool IsHwEventReady(const amd::Event& event, bool wait = false,
291-
int hip_event_flags = 0) const override {
291+
uint32_t hip_event_flags = 0) const override {
292292
return false;
293293
}
294294

@@ -488,7 +488,7 @@ class Device : public NullDevice {
488488
cl_set_device_clock_mode_output_amd* pSetClockModeOutput);
489489

490490
virtual bool IsHwEventReady(const amd::Event& event, bool wait = false,
491-
int hip_event_flags = 0) const;
491+
uint32_t hip_event_flags = 0) const;
492492
virtual bool IsHwEventReadyForcedWait(const amd::Event& event) const;
493493
virtual void getHwEventTime(const amd::Event& event, uint64_t* start, uint64_t* end) const;
494494
virtual void ReleaseGlobalSignal(void* signal) const;

0 commit comments

Comments
 (0)