Enable queue profile only if we attach a profiler

Submit explicit profile marker for hipEventRecord to record
timestamps. Enable explicit signal profiling if the API specifies
start and stop events.

Toggle this with env var HIP_FORCE_QUEUE_PROFILING=0

Change-Id: Iae449a63ec3ebf6c2880e65d7b1dd1031a29018f


[ROCm/clr commit: dec95e58e3]
Dieser Commit ist enthalten in:
Saleel Kudchadker
2020-07-22 11:35:15 -07:00
Ursprung 1cdf2afd5e
Commit fd7ea936fe
4 geänderte Dateien mit 38 neuen und 19 gelöschten Zeilen
+14 -8
Datei anzeigen
@@ -140,6 +140,19 @@ hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) {
void Event::addMarker(amd::HostQueue* queue, amd::Command* command, bool record) {
amd::ScopedLock lock(lock_);
if (queue->properties().test(CL_QUEUE_PROFILING_ENABLE)) {
if (command == nullptr) {
command = queue->getLastQueuedCommand(true);
if (command == nullptr) {
command = new amd::Marker(*queue, kMarkerDisableFlush);
command->enqueue();
}
}
} else if (command == nullptr) {
command = new hip::ProfileMarker(*queue, false);
command->enqueue();
}
if (event_ == &command->event()) return;
if (event_ != nullptr) {
@@ -239,16 +252,9 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {
}
hip::Event* e = reinterpret_cast<hip::Event*>(event);
amd::ScopedLock lock(e->lock());
amd::HostQueue* queue = hip::getQueue(stream);
amd::Command* command = queue->getLastQueuedCommand(true);
if (command == nullptr) {
command = new amd::Marker(*queue, kMarkerDisableFlush);
command->enqueue();
}
e->addMarker(queue, command, true);
e->addMarker(queue, nullptr, true);
HIP_RETURN(hipSuccess);
}