SWDEV-270599 - Refactored the way we get time from start/stop events in all cases

Change-Id: Id3f9bcad45d643e493daf9d5f47b3a032a427177


[ROCm/clr commit: f665936fe1]
This commit is contained in:
Christophe Paquot
2021-05-03 12:55:37 -07:00
والد f6f8fa7787
کامیت 18af8b7754
3فایلهای تغییر یافته به همراه14 افزوده شده و 15 حذف شده
@@ -97,32 +97,30 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) {
return hipErrorNotReady;
}
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_)) {
if (event_ == eStop.event_ && recorded_ && eStop.recorded_) {
// 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
// marker.
amd::Command* command = new amd::Marker(*event_->command().queue(), kMarkerDisableFlush);
command->enqueue();
command->awaitCompletion();
ms = static_cast<float>(static_cast<int64_t>(command->event().profilingInfo().end_ -
event_->profilingInfo().end_))/1000000.f;
ms = static_cast<float>(static_cast<int64_t>(command->event().profilingInfo().end_) - time())/1000000.f;
command->release();
} else {
// For certain HIP API's that take both start and stop event
// 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;
ms = static_cast<float>(eStop.time() - time())/1000000.f;
}
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) {
if ((event_ == nullptr) || (event_->command().queue() == hostQueue)) {
return hipSuccess;
@@ -112,6 +112,7 @@ private:
bool recorded_;
bool ready();
int64_t time() const;
};
};
@@ -390,7 +390,7 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX,
command->retain();
}
if (stopEvent != nullptr) {
eStop->addMarker(queue, command, false);
eStop->addMarker(queue, command, true);
command->retain();
}
command->release();