Skip to content

Commit 66763bf

Browse files
committed
[HIP] Fix host/device synchronization
1 parent 7c8617b commit 66763bf

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

source/adapters/hip/device.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -940,12 +940,6 @@ ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(ur_device_handle_t hDevice,
940940
UR_CHECK_ERROR(hipEventCreateWithFlags(&Event, hipEventDefault));
941941
UR_CHECK_ERROR(hipEventRecord(Event));
942942
}
943-
if (pHostTimestamp) {
944-
using namespace std::chrono;
945-
*pHostTimestamp =
946-
duration_cast<nanoseconds>(steady_clock::now().time_since_epoch())
947-
.count();
948-
}
949943

950944
if (pDeviceTimestamp) {
951945
UR_CHECK_ERROR(hipEventSynchronize(Event));
@@ -955,5 +949,11 @@ ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(ur_device_handle_t hDevice,
955949
*pDeviceTimestamp = (uint64_t)(ElapsedTime * (double)1e6);
956950
}
957951

952+
if (pHostTimestamp) {
953+
using namespace std::chrono;
954+
*pHostTimestamp =
955+
duration_cast<nanoseconds>(steady_clock::now().time_since_epoch())
956+
.count();
957+
}
958958
return UR_RESULT_SUCCESS;
959959
}

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{{OPT}}urDeviceCreateWithNativeHandleTest.Success
22
{{OPT}}urDeviceGetTest.InvalidValueNumEntries
3-
{{OPT}}urDeviceGetGlobalTimestampTest.Success
4-
{{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime
53
{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_SINGLE_FP_CONFIG
64
{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_DOUBLE_FP_CONFIG
75
{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_QUEUE_PROPERTIES

0 commit comments

Comments
 (0)