Skip to content

Commit d4e45e1

Browse files
committed
Merge branch 'petr/fix-hip-sync' into benie/hip-cts-fixes-combined
2 parents 858938d + c7f34f3 commit d4e45e1

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

source/adapters/hip/device.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -939,21 +939,18 @@ ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(ur_device_handle_t hDevice,
939939
if (pDeviceTimestamp) {
940940
UR_CHECK_ERROR(hipEventCreateWithFlags(&Event, hipEventDefault));
941941
UR_CHECK_ERROR(hipEventRecord(Event));
942-
}
943-
if (pHostTimestamp) {
944-
using namespace std::chrono;
945-
*pHostTimestamp =
946-
duration_cast<nanoseconds>(steady_clock::now().time_since_epoch())
947-
.count();
948-
}
949-
950-
if (pDeviceTimestamp) {
951942
UR_CHECK_ERROR(hipEventSynchronize(Event));
952943
float ElapsedTime = 0.0f;
953944
UR_CHECK_ERROR(hipEventElapsedTime(&ElapsedTime,
954945
ur_platform_handle_t_::EvBase, Event));
955946
*pDeviceTimestamp = (uint64_t)(ElapsedTime * (double)1e6);
956947
}
957948

949+
if (pHostTimestamp) {
950+
using namespace std::chrono;
951+
*pHostTimestamp =
952+
duration_cast<nanoseconds>(steady_clock::now().time_since_epoch())
953+
.count();
954+
}
958955
return UR_RESULT_SUCCESS;
959956
}

source/adapters/hip/platform.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//===----------------------------------------------------------------------===//
1010

1111
#include "platform.hpp"
12+
#include "context.hpp"
1213

1314
hipEvent_t ur_platform_handle_t_::EvBase{nullptr};
1415

@@ -90,6 +91,16 @@ urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
9091
PlatformIds[i].Devices.emplace_back(
9192
new ur_device_handle_t_{Device, Context, &PlatformIds[i]});
9293
}
94+
95+
// Setup EvBase
96+
{
97+
ScopedContext Active(PlatformIds.front().Devices.front().get());
98+
hipEvent_t EvBase;
99+
UR_CHECK_ERROR(hipEventCreate(&EvBase));
100+
UR_CHECK_ERROR(hipEventRecord(EvBase, 0));
101+
102+
ur_platform_handle_t_::EvBase = EvBase;
103+
}
93104
} catch (const std::bad_alloc &) {
94105
// Signal out-of-memory situation
95106
for (int i = 0; i < NumDevices; ++i) {

test/conformance/device/device_adapter_hip.match

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{{OPT}}urDeviceCreateWithNativeHandleTest.Success
22
{{OPT}}urDeviceGetTest.InvalidValueNumEntries
3-
{{OPT}}urDeviceGetGlobalTimestampTest.Success
43
{{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime
54
{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_SINGLE_FP_CONFIG
65
{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_DOUBLE_FP_CONFIG

0 commit comments

Comments
 (0)