Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,21 +939,18 @@ ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(ur_device_handle_t hDevice,
if (pDeviceTimestamp) {
UR_CHECK_ERROR(hipEventCreateWithFlags(&Event, hipEventDefault));
UR_CHECK_ERROR(hipEventRecord(Event));
}
if (pHostTimestamp) {
using namespace std::chrono;
*pHostTimestamp =
duration_cast<nanoseconds>(steady_clock::now().time_since_epoch())
.count();
}

if (pDeviceTimestamp) {
UR_CHECK_ERROR(hipEventSynchronize(Event));
float ElapsedTime = 0.0f;
UR_CHECK_ERROR(hipEventElapsedTime(&ElapsedTime,
ur_platform_handle_t_::EvBase, Event));
*pDeviceTimestamp = (uint64_t)(ElapsedTime * (double)1e6);
}

if (pHostTimestamp) {
using namespace std::chrono;
*pHostTimestamp =
duration_cast<nanoseconds>(steady_clock::now().time_since_epoch())
.count();
}
return UR_RESULT_SUCCESS;
}
11 changes: 11 additions & 0 deletions source/adapters/hip/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//===----------------------------------------------------------------------===//

#include "platform.hpp"
#include "context.hpp"

hipEvent_t ur_platform_handle_t_::EvBase{nullptr};

Expand Down Expand Up @@ -90,6 +91,16 @@ urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
PlatformIds[i].Devices.emplace_back(
new ur_device_handle_t_{Device, Context, &PlatformIds[i]});
}

// Setup EvBase
{
ScopedContext Active(PlatformIds.front().Devices.front().get());
hipEvent_t EvBase;
UR_CHECK_ERROR(hipEventCreate(&EvBase));
UR_CHECK_ERROR(hipEventRecord(EvBase, 0));

ur_platform_handle_t_::EvBase = EvBase;
}
} catch (const std::bad_alloc &) {
// Signal out-of-memory situation
for (int i = 0; i < NumDevices; ++i) {
Expand Down
1 change: 0 additions & 1 deletion test/conformance/device/device_adapter_hip.match
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{OPT}}urDeviceCreateWithNativeHandleTest.Success
{{OPT}}urDeviceGetTest.InvalidValueNumEntries
{{OPT}}urDeviceGetGlobalTimestampTest.Success
{{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime
{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_SINGLE_FP_CONFIG
{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_DOUBLE_FP_CONFIG
Expand Down