forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurQueueCreateWithNativeHandle.cpp
74 lines (63 loc) · 3.1 KB
/
urQueueCreateWithNativeHandle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (C) 2023 Intel Corporation
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See LICENSE.TXT
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <uur/fixtures.h>
using urQueueCreateWithNativeHandleTest = uur::urQueueTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE(urQueueCreateWithNativeHandleTest);
TEST_P(urQueueCreateWithNativeHandleTest, Success) {
ur_native_handle_t native_handle = 0;
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urQueueGetNativeHandle(queue, nullptr, &native_handle));
// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
// We can however convert the native_handle back into a unified-runtime handle
// and perform some query on it to verify that it works.
ur_queue_handle_t q = nullptr;
ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device,
nullptr, &q));
ASSERT_NE(q, nullptr);
ur_context_handle_t q_context = nullptr;
ASSERT_SUCCESS(urQueueGetInfo(q, UR_QUEUE_INFO_CONTEXT, sizeof(q_context),
&q_context, nullptr));
ASSERT_EQ(q_context, context);
ASSERT_SUCCESS(urQueueRelease(q));
}
TEST_P(urQueueCreateWithNativeHandleTest, SuccessWithProperties) {
ur_native_handle_t native_handle = 0;
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urQueueGetNativeHandle(queue, nullptr, &native_handle));
// We cannot assume anything about a native_handle, not even if it's
// `nullptr` since this could be a valid representation within a backend.
// We can however convert the native_handle back into a unified-runtime handle
// and perform some query on it to verify that it works.
ur_queue_handle_t q = nullptr;
ur_queue_native_properties_t properties = {
nullptr, UR_STRUCTURE_TYPE_QUEUE_NATIVE_PROPERTIES, false};
ASSERT_SUCCESS(urQueueCreateWithNativeHandle(native_handle, context, device,
&properties, &q));
ASSERT_NE(q, nullptr);
ur_context_handle_t q_context = nullptr;
ASSERT_SUCCESS(urQueueGetInfo(q, UR_QUEUE_INFO_CONTEXT, sizeof(q_context),
&q_context, nullptr));
ASSERT_EQ(q_context, context);
ASSERT_SUCCESS(urQueueRelease(q));
}
TEST_P(urQueueCreateWithNativeHandleTest, InvalidNullHandle) {
ur_native_handle_t native_handle = 0;
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urQueueGetNativeHandle(queue, nullptr, &native_handle));
ur_queue_handle_t q = nullptr;
ASSERT_EQ(urQueueCreateWithNativeHandle(native_handle, nullptr, device,
nullptr, &q),
UR_RESULT_ERROR_INVALID_NULL_HANDLE);
}
TEST_P(urQueueCreateWithNativeHandleTest, InvalidNullPointer) {
ur_native_handle_t native_handle = 0;
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urQueueGetNativeHandle(queue, nullptr, &native_handle));
ASSERT_EQ(urQueueCreateWithNativeHandle(native_handle, context, device,
nullptr, nullptr),
UR_RESULT_ERROR_INVALID_NULL_POINTER);
}