-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for urEnqueueUSMPrefetch (#312)
- Loading branch information
1 parent
d3c656d
commit 2d3a576
Showing
3 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,135 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include <uur/fixtures.h> | ||
|
||
using urEnqueueUSMPrefetchWithParamTest = | ||
uur::urUSMDeviceAllocTestWithParam<ur_usm_migration_flag_t>; | ||
|
||
UUR_TEST_SUITE_P(urEnqueueUSMPrefetchWithParamTest, | ||
::testing::Values(UR_USM_MIGRATION_FLAG_DEFAULT), | ||
uur::deviceTestWithParamPrinter<ur_usm_migration_flag_t>); | ||
|
||
TEST_P(urEnqueueUSMPrefetchWithParamTest, Success) { | ||
ur_event_handle_t prefetch_event = nullptr; | ||
ASSERT_SUCCESS(urEnqueueUSMPrefetch(queue, ptr, allocation_size, | ||
getParam(), 0, nullptr, | ||
&prefetch_event)); | ||
|
||
ASSERT_SUCCESS(urQueueFlush(queue)); | ||
ASSERT_SUCCESS(urEventWait(1, &prefetch_event)); | ||
|
||
const auto event_status = | ||
uur::GetEventInfo<ur_event_status_t>(prefetch_event, | ||
UR_EVENT_INFO_COMMAND_EXECUTION_STATUS); | ||
ASSERT_TRUE(event_status.has_value()); | ||
ASSERT_EQ(event_status.value(), UR_EVENT_STATUS_COMPLETE); | ||
ASSERT_SUCCESS(urEventRelease(prefetch_event)); | ||
} | ||
|
||
/** | ||
* Tests that urEnqueueUSMPrefetch() waits for its dependencies to finish before | ||
* executing. | ||
*/ | ||
TEST_P(urEnqueueUSMPrefetchWithParamTest, CheckWaitEvent) { | ||
|
||
ur_queue_handle_t memset_queue; | ||
ASSERT_SUCCESS(urQueueCreate(context, device, nullptr, &memset_queue)); | ||
|
||
size_t big_allocation = 65536; | ||
void *memset_ptr = nullptr; | ||
ASSERT_SUCCESS( | ||
urUSMDeviceAlloc(context, device, nullptr, nullptr, | ||
big_allocation, 0, &memset_ptr)); | ||
|
||
ur_event_handle_t memset_event; | ||
ASSERT_SUCCESS( | ||
urEnqueueUSMMemset(memset_queue, memset_ptr, 0, big_allocation, 0, | ||
nullptr, &memset_event)); | ||
|
||
ur_event_handle_t prefetch_event = nullptr; | ||
ASSERT_SUCCESS(urEnqueueUSMPrefetch(queue, ptr, allocation_size, | ||
getParam(), 1, &memset_event, | ||
&prefetch_event)); | ||
|
||
ASSERT_SUCCESS(urQueueFlush(queue)); | ||
ASSERT_SUCCESS(urQueueFlush(memset_queue)); | ||
ASSERT_SUCCESS(urEventWait(1, &prefetch_event)); | ||
|
||
const auto memset_status = | ||
uur::GetEventInfo<ur_event_status_t>(memset_event, | ||
UR_EVENT_INFO_COMMAND_EXECUTION_STATUS); | ||
ASSERT_TRUE(memset_status.has_value()); | ||
ASSERT_EQ(memset_status.value(), UR_EVENT_STATUS_COMPLETE); | ||
|
||
const auto event_status = | ||
uur::GetEventInfo<ur_event_status_t>(prefetch_event, | ||
UR_EVENT_INFO_COMMAND_EXECUTION_STATUS); | ||
ASSERT_TRUE(event_status.has_value()); | ||
ASSERT_EQ(event_status.value(), UR_EVENT_STATUS_COMPLETE); | ||
|
||
ASSERT_SUCCESS(urEventRelease(prefetch_event)); | ||
ASSERT_SUCCESS(urEventRelease(memset_event)); | ||
|
||
ASSERT_SUCCESS(urUSMFree(context, memset_ptr)); | ||
} | ||
|
||
using urEnqueueUSMPrefetchTest = uur::urUSMDeviceAllocTest; | ||
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueUSMPrefetchTest); | ||
|
||
TEST_P(urEnqueueUSMPrefetchTest, InvalidNullHandleQueue) { | ||
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, | ||
urEnqueueUSMPrefetch(nullptr, ptr, allocation_size, | ||
UR_USM_MIGRATION_FLAG_DEFAULT, 0, | ||
nullptr, | ||
nullptr)); | ||
} | ||
|
||
TEST_P(urEnqueueUSMPrefetchTest, InvalidNullPointerMem) { | ||
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, | ||
urEnqueueUSMPrefetch(queue, nullptr, allocation_size, | ||
UR_USM_MIGRATION_FLAG_DEFAULT, 0, | ||
nullptr, | ||
nullptr)); | ||
} | ||
|
||
TEST_P(urEnqueueUSMPrefetchTest, InvalidEnumeration) { | ||
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, | ||
urEnqueueUSMPrefetch(queue, ptr, allocation_size, | ||
UR_USM_MIGRATION_FLAG_FORCE_UINT32, 0, | ||
nullptr, | ||
nullptr)); | ||
} | ||
|
||
TEST_P(urEnqueueUSMPrefetchTest, InvalidSizeZero) { | ||
ASSERT_EQ_RESULT( | ||
UR_RESULT_ERROR_INVALID_SIZE, | ||
urEnqueueUSMPrefetch(queue, ptr, 0, UR_USM_MIGRATION_FLAG_DEFAULT, 0, | ||
nullptr, | ||
nullptr)); | ||
} | ||
|
||
TEST_P(urEnqueueUSMPrefetchTest, InvalidSizeTooLarge) { | ||
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, | ||
urEnqueueUSMPrefetch(queue, ptr, allocation_size * 2, | ||
UR_USM_MIGRATION_FLAG_DEFAULT, 0, | ||
nullptr, | ||
nullptr)); | ||
} | ||
|
||
TEST_P(urEnqueueUSMPrefetchTest, InvalidEventWaitList) { | ||
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST, | ||
urEnqueueUSMPrefetch(queue, ptr, allocation_size, | ||
UR_USM_MIGRATION_FLAG_DEFAULT, 1, | ||
nullptr, | ||
nullptr)); | ||
|
||
ur_event_handle_t validEvent; | ||
ASSERT_SUCCESS(urEnqueueEventsWait(queue, 0, nullptr, &validEvent)); | ||
|
||
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST, | ||
urEnqueueUSMPrefetch(queue, ptr, allocation_size, | ||
UR_USM_MIGRATION_FLAG_DEFAULT, 0, | ||
&validEvent, | ||
nullptr)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters