hipEventElapsedTime should respect device (#1992)

Fixes SWDEV-228636.
Also added a unit test to verify this.
Этот коммит содержится в:
Sarbojit2019
2020-04-06 15:38:25 +05:30
коммит произвёл GitHub
родитель 67830996a9
Коммит 3523219b43
3 изменённых файлов: 113 добавлений и 2 удалений
+9 -2
Просмотреть файл
@@ -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();