SWDEV-270599 - Refactored the way we get time from start/stop events in all cases
Change-Id: Id3f9bcad45d643e493daf9d5f47b3a032a427177
[ROCm/clr commit: f665936fe1]
Tá an tiomantas seo le fáil i:
@@ -97,32 +97,30 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) {
|
|||||||
return hipErrorNotReady;
|
return hipErrorNotReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event_ != eStop.event_ && recorded_ && eStop.recorded_) {
|
if (event_ == eStop.event_ && recorded_ && eStop.recorded_) {
|
||||||
ms = static_cast<float>(static_cast<int64_t>(eStop.event_->profilingInfo().end_ -
|
|
||||||
event_->profilingInfo().end_))/1000000.f;
|
|
||||||
} else if (event_ != eStop.event_ && !recorded_ && !eStop.recorded_) {
|
|
||||||
//It is invalid to use unrecorded events across multiple commands to get time
|
|
||||||
//For example start and stop events from different hipExtLaunchKernelGGL calls
|
|
||||||
return hipErrorInvalidHandle;
|
|
||||||
} else if (event_ == eStop.event_ && (recorded_ || eStop.recorded_)) {
|
|
||||||
// Events are the same, which indicates the stream is empty and likely
|
// Events are the same, which indicates the stream is empty and likely
|
||||||
// eventRecord is called on another stream. For such cases insert and measure a
|
// eventRecord is called on another stream. For such cases insert and measure a
|
||||||
// marker.
|
// marker.
|
||||||
amd::Command* command = new amd::Marker(*event_->command().queue(), kMarkerDisableFlush);
|
amd::Command* command = new amd::Marker(*event_->command().queue(), kMarkerDisableFlush);
|
||||||
command->enqueue();
|
command->enqueue();
|
||||||
command->awaitCompletion();
|
command->awaitCompletion();
|
||||||
ms = static_cast<float>(static_cast<int64_t>(command->event().profilingInfo().end_ -
|
ms = static_cast<float>(static_cast<int64_t>(command->event().profilingInfo().end_) - time())/1000000.f;
|
||||||
event_->profilingInfo().end_))/1000000.f;
|
|
||||||
command->release();
|
command->release();
|
||||||
} else {
|
} else {
|
||||||
// For certain HIP API's that take both start and stop event
|
ms = static_cast<float>(eStop.time() - time())/1000000.f;
|
||||||
// or scenarios where HIP API takes one of the events and the other event is recorded with hipEventRecord
|
|
||||||
ms = static_cast<float>(static_cast<int64_t>(eStop.event_->profilingInfo().end_ -
|
|
||||||
event_->profilingInfo().start_))/1000000.f;
|
|
||||||
}
|
}
|
||||||
return hipSuccess;
|
return hipSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t Event::time() const {
|
||||||
|
assert(event_ != nullptr);
|
||||||
|
if (recorded_) {
|
||||||
|
return static_cast<int64_t>(event_->profilingInfo().end_);
|
||||||
|
} else {
|
||||||
|
return static_cast<int64_t>(event_->profilingInfo().start_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) {
|
hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) {
|
||||||
if ((event_ == nullptr) || (event_->command().queue() == hostQueue)) {
|
if ((event_ == nullptr) || (event_->command().queue() == hostQueue)) {
|
||||||
return hipSuccess;
|
return hipSuccess;
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ private:
|
|||||||
bool recorded_;
|
bool recorded_;
|
||||||
|
|
||||||
bool ready();
|
bool ready();
|
||||||
|
int64_t time() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX,
|
|||||||
command->retain();
|
command->retain();
|
||||||
}
|
}
|
||||||
if (stopEvent != nullptr) {
|
if (stopEvent != nullptr) {
|
||||||
eStop->addMarker(queue, command, false);
|
eStop->addMarker(queue, command, true);
|
||||||
command->retain();
|
command->retain();
|
||||||
}
|
}
|
||||||
command->release();
|
command->release();
|
||||||
|
|||||||
Tagairt in Eagrán Nua
Cuir bac ar úsáideoir