@@ -26,30 +26,47 @@ TEST(DeviceAsan, Initialization) {
26
26
status = urLoaderInit (0 , loaderConfig);
27
27
ASSERT_EQ (status, UR_RESULT_SUCCESS);
28
28
29
- ur_adapter_handle_t adapter ;
30
- status = urAdapterGet (1 , &adapter, nullptr );
29
+ uint32_t num_adapters ;
30
+ status = urAdapterGet (0 , nullptr , &num_adapters );
31
31
ASSERT_EQ (status, UR_RESULT_SUCCESS);
32
32
33
- ur_platform_handle_t platform;
34
- status = urPlatformGet (&adapter, 1 , 1 , &platform, nullptr );
33
+ std::vector<ur_adapter_handle_t > adapters;
34
+ adapters.resize (num_adapters);
35
+ status = urAdapterGet (num_adapters, adapters.data (), nullptr );
35
36
ASSERT_EQ (status, UR_RESULT_SUCCESS);
36
37
37
- ur_device_handle_t device;
38
- status = urDeviceGet (platform, UR_DEVICE_TYPE_DEFAULT, 1 , &device, nullptr );
39
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
38
+ for (auto adapter : adapters) {
39
+ ur_adapter_backend_t backend;
40
+ status = urAdapterGetInfo (adapter, UR_ADAPTER_INFO_BACKEND, sizeof (backend),
41
+ &backend, nullptr );
42
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
43
+ if (backend == UR_ADAPTER_BACKEND_OPENCL ||
44
+ backend == UR_ADAPTER_BACKEND_HIP) {
45
+ // Helper methods are unsupported
46
+ continue ;
47
+ }
40
48
41
- ur_context_handle_t context ;
42
- status = urContextCreate ( 1 , &device, nullptr , &context );
43
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
49
+ ur_platform_handle_t platform ;
50
+ status = urPlatformGet (&adapter, 1 , 1 , &platform, nullptr );
51
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
44
52
45
- status = urContextRelease (context);
46
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
53
+ ur_device_handle_t device;
54
+ status = urDeviceGet (platform, UR_DEVICE_TYPE_DEFAULT, 1 , &device, nullptr );
55
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
47
56
48
- status = urDeviceRelease (device);
49
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
57
+ ur_context_handle_t context;
58
+ status = urContextCreate (1 , &device, nullptr , &context);
59
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
50
60
51
- status = urAdapterRelease (adapter);
52
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
61
+ status = urContextRelease (context);
62
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
63
+
64
+ status = urDeviceRelease (device);
65
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
66
+
67
+ status = urAdapterRelease (adapter);
68
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
69
+ }
53
70
54
71
status = urLoaderTearDown ();
55
72
ASSERT_EQ (status, UR_RESULT_SUCCESS);
@@ -70,49 +87,67 @@ TEST(DeviceAsan, UnsupportedFeature) {
70
87
status = urLoaderInit (0 , loaderConfig);
71
88
ASSERT_EQ (status, UR_RESULT_SUCCESS);
72
89
73
- ur_adapter_handle_t adapter ;
74
- status = urAdapterGet (1 , &adapter, nullptr );
90
+ uint32_t num_adapters ;
91
+ status = urAdapterGet (0 , nullptr , &num_adapters );
75
92
ASSERT_EQ (status, UR_RESULT_SUCCESS);
76
93
77
- ur_platform_handle_t platform;
78
- status = urPlatformGet (&adapter, 1 , 1 , &platform, nullptr );
94
+ std::vector<ur_adapter_handle_t > adapters;
95
+ adapters.resize (num_adapters);
96
+ status = urAdapterGet (num_adapters, adapters.data (), nullptr );
79
97
ASSERT_EQ (status, UR_RESULT_SUCCESS);
80
98
81
- ur_device_handle_t device;
82
- status = urDeviceGet (platform, UR_DEVICE_TYPE_DEFAULT, 1 , &device, nullptr );
83
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
99
+ for (auto adapter : adapters) {
100
+ ur_adapter_backend_t backend;
101
+ status = urAdapterGetInfo (adapter, UR_ADAPTER_INFO_BACKEND, sizeof (backend),
102
+ &backend, nullptr );
103
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
104
+ SCOPED_TRACE (backend);
105
+ if (backend == UR_ADAPTER_BACKEND_OPENCL ||
106
+ backend == UR_ADAPTER_BACKEND_HIP) {
107
+ // Helper methods are unsupported
108
+ continue ;
109
+ }
84
110
85
- ur_context_handle_t context ;
86
- status = urContextCreate ( 1 , &device, nullptr , &context );
87
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
111
+ ur_platform_handle_t platform ;
112
+ status = urPlatformGet (&adapter, 1 , 1 , &platform, nullptr );
113
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
88
114
89
- // Check for explict unsupported features
90
- ur_bool_t isSupported;
91
- status = urDeviceGetInfo (device, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT,
92
- sizeof (isSupported), &isSupported, nullptr );
93
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
94
- ASSERT_EQ (isSupported, 0 );
115
+ ur_device_handle_t device;
116
+ status = urDeviceGet (platform, UR_DEVICE_TYPE_DEFAULT, 1 , &device, nullptr );
117
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
95
118
96
- status = urDeviceGetInfo (device, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP,
97
- sizeof (isSupported), &isSupported, nullptr );
98
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
99
- ASSERT_EQ (isSupported, 0 );
119
+ ur_context_handle_t context;
120
+ status = urContextCreate (1 , &device, nullptr , &context);
121
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
100
122
101
- ur_device_command_buffer_update_capability_flags_t update_flag;
102
- status = urDeviceGetInfo (
103
- device, UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_CAPABILITIES_EXP ,
104
- sizeof (update_flag ), &update_flag , nullptr );
105
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
106
- ASSERT_EQ (update_flag , 0 );
123
+ // Check for explict unsupported features
124
+ ur_bool_t isSupported;
125
+ status = urDeviceGetInfo ( device, UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT ,
126
+ sizeof (isSupported ), &isSupported , nullptr );
127
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
128
+ ASSERT_EQ (isSupported , 0 );
107
129
108
- status = urContextRelease (context);
109
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
130
+ status = urDeviceGetInfo (device, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP,
131
+ sizeof (isSupported), &isSupported, nullptr );
132
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
133
+ ASSERT_EQ (isSupported, 0 );
110
134
111
- status = urDeviceRelease (device);
112
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
135
+ ur_device_command_buffer_update_capability_flags_t update_flag;
136
+ status = urDeviceGetInfo (
137
+ device, UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_CAPABILITIES_EXP,
138
+ sizeof (update_flag), &update_flag, nullptr );
139
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
140
+ ASSERT_EQ (update_flag, 0 );
113
141
114
- status = urAdapterRelease (adapter);
115
- ASSERT_EQ (status, UR_RESULT_SUCCESS);
142
+ status = urContextRelease (context);
143
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
144
+
145
+ status = urDeviceRelease (device);
146
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
147
+
148
+ status = urAdapterRelease (adapter);
149
+ ASSERT_EQ (status, UR_RESULT_SUCCESS);
150
+ }
116
151
117
152
status = urLoaderTearDown ();
118
153
ASSERT_EQ (status, UR_RESULT_SUCCESS);
0 commit comments