SWDEV-486602 - Optimize HSA callback performance
- Don't generate callbacks for HIP events - Don't process profiling info in the callback for HIP events - Wait for CPU status update of the submitted commands every 50 calls. That will allow to drain the commands and destroy HSA signals. Change-Id: Ib601a350e7e7c2b6c6209a172385389baccf73a9
This commit is contained in:
+12
-14
@@ -64,6 +64,7 @@ hipError_t Event::query() {
|
||||
return ready() ? hipSuccess : hipErrorNotReady;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t Event::synchronize() {
|
||||
amd::ScopedLock lock(lock_);
|
||||
|
||||
@@ -76,19 +77,12 @@ 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 (!hip_device->devices()[0]->IsHwEventReady(*event_, kWaitCompletion, flags_)) {
|
||||
if (event_->HwEvent() != nullptr) {
|
||||
amd::Command* command = nullptr;
|
||||
hipError_t status = recordCommand(command, event_->command().queue(), flags_);
|
||||
command->enqueue();
|
||||
hip_device->devices()[0]->IsHwEventReady(command->event(), kWaitCompletion, flags_);
|
||||
command->release();
|
||||
} else {
|
||||
event_->awaitCompletion();
|
||||
}
|
||||
event_->awaitCompletion();
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
bool Event::awaitEventCompletion() {
|
||||
return event_->awaitCompletion();
|
||||
}
|
||||
@@ -222,8 +216,9 @@ hipError_t Event::streamWait(hipStream_t stream, uint flags) {
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t Event::recordCommand(amd::Command*& command, amd::HostQueue* stream,
|
||||
uint32_t ext_flags ) {
|
||||
uint32_t ext_flags, bool batch_flush) {
|
||||
if (command == nullptr) {
|
||||
int32_t releaseFlags = ((ext_flags == 0) ? flags_ : ext_flags) &
|
||||
(hipEventReleaseToDevice | hipEventReleaseToSystem |
|
||||
@@ -234,11 +229,12 @@ hipError_t Event::recordCommand(amd::Command*& command, amd::HostQueue* stream,
|
||||
releaseFlags = amd::Device::kCacheStateInvalid;
|
||||
}
|
||||
// Always submit a EventMarker.
|
||||
command = new hip::EventMarker(*stream, !kMarkerDisableFlush, true, releaseFlags);
|
||||
command = new hip::EventMarker(*stream, !kMarkerDisableFlush, true, releaseFlags, batch_flush);
|
||||
}
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t Event::enqueueRecordCommand(hipStream_t stream, amd::Command* command, bool record) {
|
||||
command->enqueue();
|
||||
if (event_ == &command->event()) return hipSuccess;
|
||||
@@ -251,11 +247,13 @@ hipError_t Event::enqueueRecordCommand(hipStream_t stream, amd::Command* command
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
hipError_t Event::addMarker(hipStream_t stream, amd::Command* command, bool record) {
|
||||
// ================================================================================================
|
||||
hipError_t Event::addMarker(hipStream_t stream, amd::Command* command,
|
||||
bool record, bool batch_flush) {
|
||||
hip::Stream* hip_stream = hip::getStream(stream);
|
||||
// Keep the lock always at the beginning of this to avoid a race. SWDEV-277847
|
||||
amd::ScopedLock lock(lock_);
|
||||
hipError_t status = recordCommand(command, hip_stream);
|
||||
hipError_t status = recordCommand(command, hip_stream, 0, batch_flush);
|
||||
if (status != hipSuccess) {
|
||||
return hipSuccess;
|
||||
}
|
||||
@@ -415,7 +413,7 @@ hipError_t hipEventRecord_common(hipEvent_t event, hipStream_t stream) {
|
||||
if (g_devices[e->deviceId()]->devices()[0] != &hip_stream->device()) {
|
||||
return hipErrorInvalidHandle;
|
||||
}
|
||||
status = e->addMarker(stream, nullptr, true);
|
||||
status = e->addMarker(stream, nullptr, true, !hip::Event::kBatchFlush);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user