Skip to content

Commit

Permalink
Attempt to fix test.
Browse files Browse the repository at this point in the history
Signed-off-by: JackAKirk <jack.kirk@codeplay.com>
  • Loading branch information
JackAKirk committed Sep 12, 2024
1 parent 88292cb commit 80226e6
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions test/conformance/device/urDeviceGetGlobalTimestamps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ T absolute_difference(T a, T b) {
return std::max(a, b) - std::min(a, b);
}

/*
void create_context_if_cuda(uur::raii::Context context,
const ur_device_handle_t *devs) {
void *vendorValue = nullptr;
Expand All @@ -38,13 +39,22 @@ void create_context_if_cuda(uur::raii::Context context,
ASSERT_SUCCESS(urContextCreate(1, devs, nullptr, context.ptr()));
}
}
create_context_if_cuda(context, devices.data());
*/

using urDeviceGetGlobalTimestampTest = uur::urAllDevicesTest;

TEST_F(urDeviceGetGlobalTimestampTest, Success) {

uur::raii::Context context = nullptr;
create_context_if_cuda(context, devices.data());
void *vendorValue = nullptr;
size_t *pPropSizeRet = nullptr;
urDeviceGetInfo(devices[0], UR_DEVICE_INFO_VENDOR_ID, sizeof(uint32_t),
vendorValue, pPropSizeRet);
// cuda backend defines global timestamp only over a context.
if (*reinterpret_cast<uint32_t *>(vendorValue) == 4318u) {
ASSERT_SUCCESS(urContextCreate(1, devices.data(), nullptr, context.ptr()));
}

for (auto device : devices) {
uint64_t device_time = 0;
Expand All @@ -60,7 +70,14 @@ TEST_F(urDeviceGetGlobalTimestampTest, Success) {
TEST_F(urDeviceGetGlobalTimestampTest, SuccessHostTimer) {

uur::raii::Context context = nullptr;
create_context_if_cuda(context, devices.data());
void *vendorValue = nullptr;
size_t *pPropSizeRet = nullptr;
urDeviceGetInfo(devices[0], UR_DEVICE_INFO_VENDOR_ID, sizeof(uint32_t),
vendorValue, pPropSizeRet);
// cuda backend defines global timestamp only over a context.
if (*reinterpret_cast<uint32_t *>(vendorValue) == 4318u) {
ASSERT_SUCCESS(urContextCreate(1, devices.data(), nullptr, context.ptr()));
}

for (auto device : devices) {
uint64_t host_time = 0;
Expand All @@ -73,7 +90,14 @@ TEST_F(urDeviceGetGlobalTimestampTest, SuccessHostTimer) {
TEST_F(urDeviceGetGlobalTimestampTest, SuccessNoTimers) {

uur::raii::Context context = nullptr;
create_context_if_cuda(context, devices.data());
void *vendorValue = nullptr;
size_t *pPropSizeRet = nullptr;
urDeviceGetInfo(devices[0], UR_DEVICE_INFO_VENDOR_ID, sizeof(uint32_t),
vendorValue, pPropSizeRet);
// cuda backend defines global timestamp only over a context.
if (*reinterpret_cast<uint32_t *>(vendorValue) == 4318u) {
ASSERT_SUCCESS(urContextCreate(1, devices.data(), nullptr, context.ptr()));
}

for (auto device : devices) {
ASSERT_SUCCESS(urDeviceGetGlobalTimestamps(device, nullptr, nullptr));
Expand All @@ -83,7 +107,14 @@ TEST_F(urDeviceGetGlobalTimestampTest, SuccessNoTimers) {
TEST_F(urDeviceGetGlobalTimestampTest, SuccessSynchronizedTime) {

uur::raii::Context context = nullptr;
create_context_if_cuda(context, devices.data());
void *vendorValue = nullptr;
size_t *pPropSizeRet = nullptr;
urDeviceGetInfo(devices[0], UR_DEVICE_INFO_VENDOR_ID, sizeof(uint32_t),
vendorValue, pPropSizeRet);
// cuda backend defines global timestamp only over a context.
if (*reinterpret_cast<uint32_t *>(vendorValue) == 4318u) {
ASSERT_SUCCESS(urContextCreate(1, devices.data(), nullptr, context.ptr()));
}

for (auto device : devices) {
// get the timer resolution of the device
Expand Down Expand Up @@ -139,7 +170,14 @@ TEST_F(urDeviceGetGlobalTimestampTest, SuccessSynchronizedTime) {
TEST_F(urDeviceGetGlobalTimestampTest, InvalidNullHandleDevice) {

uur::raii::Context context = nullptr;
create_context_if_cuda(context, devices.data());
void *vendorValue = nullptr;
size_t *pPropSizeRet = nullptr;
urDeviceGetInfo(devices[0], UR_DEVICE_INFO_VENDOR_ID, sizeof(uint32_t),
vendorValue, pPropSizeRet);
// cuda backend defines global timestamp only over a context.
if (*reinterpret_cast<uint32_t *>(vendorValue) == 4318u) {
ASSERT_SUCCESS(urContextCreate(1, devices.data(), nullptr, context.ptr()));
}

uint64_t device_time = 0;
uint64_t host_time = 0;
Expand Down

0 comments on commit 80226e6

Please sign in to comment.