hipEventElapsedTime should respect device (#1992)

Fixes SWDEV-228636.
Also added a unit test to verify this.

[ROCm/clr commit: 3523219b43]
This commit is contained in:
Sarbojit2019
2020-04-06 15:38:25 +05:30
committed by GitHub
parent 318fbce04d
commit 77fd519260
3 changed files with 113 additions and 2 deletions
+9 -2
View File
@@ -30,7 +30,12 @@ THE SOFTWARE.
//---
ihipEvent_t::ihipEvent_t(unsigned flags) : _criticalData(this) { _flags = flags; };
ihipEvent_t::ihipEvent_t(unsigned flags) : _criticalData(this) {
_flags = flags;
GET_TLS();
auto ctx = ihipGetTlsDefaultCtx();
_deviceId = ctx == nullptr ? -1 : ctx->getDevice()->_deviceId;
};
// Attach to an existing completion future:
@@ -175,7 +180,9 @@ hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) {
HIP_INIT_API(hipEventElapsedTime, ms, start, stop);
if (ms == nullptr) return ihipLogStatus(hipErrorInvalidValue);
if ((start == nullptr) || (stop == nullptr)) return ihipLogStatus(hipErrorInvalidHandle);
if ((start == nullptr) || (stop == nullptr) ||
(start->_deviceId != stop->_deviceId))
return ihipLogStatus(hipErrorInvalidHandle);
*ms = 0.0f;
auto startEcd = start->locked_copyCrit();