SWDEV-276210 - Honor scopes for hipEventRecord

Honor hipEventReleaseToDevice and hipEventReleaseToSystem flags.
hipEventRecord would flush caches if no release flags are provided. To
change this behavior set ROC_EVENT_NO_FLUSH=1

Change-Id: I03e41b515b1d0cf963b0c2d5b9901b09e71a0e59
This commit is contained in:
Saleel Kudchadker
2022-04-01 15:16:13 -07:00
förälder c1503da69b
incheckning f320acb797
4 ändrade filer med 23 tillägg och 9 borttagningar
+17 -4
Visa fil
@@ -71,7 +71,11 @@ hipError_t Event::synchronize() {
// Check HW status of the ROCcrl event. Note: not all ROCclr modes support HW status
static constexpr bool kWaitCompletion = true;
if (!g_devices[deviceId()]->devices()[0]->IsHwEventReady(*event_, kWaitCompletion)) {
event_->awaitCompletion();
amd::Command* command = nullptr;
hipError_t status = recordCommand(command, event_->command().queue(), flags);
command->enqueue();
g_devices[deviceId()]->devices()[0]->IsHwEventReady(command->event(), kWaitCompletion);
command->release();
}
return hipSuccess;
@@ -202,11 +206,20 @@ hipError_t Event::streamWait(hipStream_t stream, uint flags) {
return hipSuccess;
}
hipError_t Event::recordCommand(amd::Command*& command, amd::HostQueue* queue) {
hipError_t Event::recordCommand(amd::Command*& command, amd::HostQueue* queue,
uint32_t ext_flags ) {
if (command == nullptr) {
static constexpr bool kRecordExplicitGpuTs = true;
uint32_t releaseFlags = ((ext_flags == 0) ? flags : ext_flags) &
(hipEventReleaseToSystem | hipEventReleaseToDevice);
if (releaseFlags & hipEventReleaseToDevice) {
releaseFlags = amd::Device::kCacheStateAgent;
} else if (releaseFlags & hipEventReleaseToSystem) {
releaseFlags = amd::Device::kCacheStateSystem;
} else {
releaseFlags = amd::Device::kCacheStateIgnore;
}
// Always submit a EventMarker.
command = new hip::EventMarker(*queue, !kMarkerDisableFlush, kRecordExplicitGpuTs);
command = new hip::EventMarker(*queue, !kMarkerDisableFlush, releaseFlags);
}
return hipSuccess;
}
+4 -3
Visa fil
@@ -53,7 +53,7 @@ typedef struct ihipIpcEventShmem_s {
class EventMarker : public amd::Marker {
public:
EventMarker(amd::HostQueue& queue, bool disableFlush, bool markerTs = false)
EventMarker(amd::HostQueue& queue, bool disableFlush, uint32_t markerTs = 0)
: amd::Marker(queue, disableFlush) {
profilingInfo_.enabled_ = true;
profilingInfo_.callback_ = nullptr;
@@ -93,7 +93,8 @@ class Event {
virtual hipError_t enqueueStreamWaitCommand(hipStream_t stream, amd::Command* command);
virtual hipError_t streamWait(hipStream_t stream, uint flags);
virtual hipError_t recordCommand(amd::Command*& command, amd::HostQueue* queue);
virtual hipError_t recordCommand(amd::Command*& command, amd::HostQueue* queue,
uint32_t flags = 0);
virtual hipError_t enqueueRecordCommand(hipStream_t stream, amd::Command* command, bool record);
hipError_t addMarker(hipStream_t stream, amd::Command* command, bool record);
@@ -199,7 +200,7 @@ class IPCEvent : public Event {
hipError_t enqueueStreamWaitCommand(hipStream_t stream, amd::Command* command);
hipError_t streamWait(hipStream_t stream, uint flags);
hipError_t recordCommand(amd::Command*& command, amd::HostQueue* queue);
hipError_t recordCommand(amd::Command*& command, amd::HostQueue* queue, uint32_t flags = 0);
hipError_t enqueueRecordCommand(hipStream_t stream, amd::Command* command, bool record);
};
+1 -1
Visa fil
@@ -130,7 +130,7 @@ hipError_t IPCEvent::streamWait(hipStream_t stream, uint flags) {
return hipSuccess;
}
hipError_t IPCEvent::recordCommand(amd::Command*& command, amd::HostQueue* queue) {
hipError_t IPCEvent::recordCommand(amd::Command*& command, amd::HostQueue* queue, uint32_t flags) {
bool recorded = isRecorded();
if (!recorded) {
command = new amd::Marker(*queue, kMarkerDisableFlush);
+1 -1
Visa fil
@@ -208,7 +208,7 @@ void Stream::destroyAllStreams(int deviceId) {
// ================================================================================================
void iHipWaitActiveStreams(amd::HostQueue* blocking_queue, bool wait_null_stream) {
amd::Command::EventWaitList eventWaitList;
amd::Command::EventWaitList eventWaitList(0);
{
amd::ScopedLock lock(streamSetLock);