Skip to content

Commit c6b890e

Browse files
committed
Update REQUIRE_EXTENSION macro to use the new overload
Change `REQUIRE_EXTENSION` to use the new overload of `is_extension_available`. The macro will now use its argument, `ext`, to construct `ext##_EXTENSION_NAME` and `ext##_EXTENSION_VERSION`, which, for example, correspond to `CL_KHR_SEMAPHORE_EXTENSION_NAME` and `CL_KHR_SEMAPHORE_EXTENSION_VERSION`, respectively. The extension name and version are both defined in the OpenCL headers. This guarantees that the macro is checking for the latest extension version before running the test, and eliminates a class of errors, where the user has a spelling mistake in the extension name to check. This is enforced at compile time, as a variable with a typo in its name will not be defined in the headers. Update all instances of `REQUIRE_EXTENSION` to match. Add a new macro, `HAS_EXTENSION`, that also calls the new overload, but does not check the result or return a test status if the call failed. This is useful for instances where tests require acting upon the result of the call, and not necessarily skip the test. Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
1 parent e01e8c8 commit c6b890e

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

test_common/harness/testHarness.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,22 @@ template <typename T> T *register_test(const char *name, Version version)
150150

151151
#define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2))
152152

153-
#define REQUIRE_EXTENSION(name) \
153+
#define REQUIRE_EXTENSION(ext) \
154154
do \
155155
{ \
156-
if (!is_extension_available(device, name)) \
156+
if (!is_extension_available(device, ext##_EXTENSION_NAME, \
157+
ext##_EXTENSION_VERSION)) \
157158
{ \
158-
log_info(name \
159+
log_info(ext##_EXTENSION_NAME \
159160
" is not supported on this device. Skipping test.\n"); \
160161
return TEST_SKIPPED_ITSELF; \
161162
} \
162163
} while (0)
163164

165+
#define HAS_EXTENSION(ext) \
166+
is_extension_available(device, ext##_EXTENSION_NAME, \
167+
ext##_EXTENSION_VERSION)
168+
164169
extern int gFailCount;
165170
extern int gTestCount;
166171
extern cl_uint gReSeed;

test_conformance/api/negative_enqueue_map_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ REGISTER_TEST(negative_enqueue_map_image)
2929
{
3030
constexpr size_t image_dim = 32;
3131

32-
REQUIRE_EXTENSION("cl_ext_immutable_memory_objects");
32+
REQUIRE_EXTENSION(CL_EXT_IMMUTABLE_MEMORY_OBJECTS);
3333

3434
static constexpr cl_mem_flags mem_flags[]{
3535
CL_MEM_IMMUTABLE_EXT | CL_MEM_USE_HOST_PTR,

test_conformance/api/test_kernels.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Copyright (c) 2017 The Khronos Group Inc.
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
@@ -667,7 +667,7 @@ REGISTER_TEST(kernel_global_constant)
667667

668668
REGISTER_TEST(negative_set_immutable_memory_to_writeable_kernel_arg)
669669
{
670-
REQUIRE_EXTENSION("cl_ext_immutable_memory_objects");
670+
REQUIRE_EXTENSION(CL_EXT_IMMUTABLE_MEMORY_OBJECTS);
671671

672672
cl_int error = CL_SUCCESS;
673673
clProgramWrapper program;

test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ static cl_int get_device_semaphore_handle_types(
121121
// Confirm the semaphores can be successfully queried
122122
REGISTER_TEST_VERSION(external_semaphores_queries, Version(1, 2))
123123
{
124-
REQUIRE_EXTENSION("cl_khr_semaphore");
125-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
124+
REQUIRE_EXTENSION(CL_KHR_SEMAPHORE);
125+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
126126

127127
if (init_vulkan_device(1, &device))
128128
{
@@ -199,7 +199,7 @@ REGISTER_TEST_VERSION(external_semaphores_queries, Version(1, 2))
199199

200200
REGISTER_TEST_VERSION(external_semaphores_cross_context, Version(1, 2))
201201
{
202-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
202+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
203203

204204
GET_PFN(device, clEnqueueSignalSemaphoresKHR);
205205
GET_PFN(device, clEnqueueWaitSemaphoresKHR);
@@ -322,7 +322,7 @@ REGISTER_TEST_VERSION(external_semaphores_cross_context, Version(1, 2))
322322
// Confirm that a signal followed by a wait will complete successfully
323323
REGISTER_TEST_VERSION(external_semaphores_simple_1, Version(1, 2))
324324
{
325-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
325+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
326326

327327
if (init_vulkan_device(1, &device))
328328
{
@@ -391,7 +391,7 @@ REGISTER_TEST_VERSION(external_semaphores_simple_1, Version(1, 2))
391391
// Confirm that a semaphore can be reused multiple times
392392
REGISTER_TEST_VERSION(external_semaphores_reuse, Version(1, 2))
393393
{
394-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
394+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
395395

396396
if (init_vulkan_device(1, &device))
397397
{
@@ -509,7 +509,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id device,
509509
cl_command_queue queue_1,
510510
cl_command_queue queue_2)
511511
{
512-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
512+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
513513

514514
if (init_vulkan_device(1, &device))
515515
{
@@ -612,7 +612,7 @@ REGISTER_TEST_VERSION(external_semaphores_cross_queues_io, Version(1, 2))
612612

613613
REGISTER_TEST_VERSION(external_semaphores_cross_queues_io2, Version(1, 2))
614614
{
615-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
615+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
616616

617617
if (init_vulkan_device(1, &device))
618618
{
@@ -714,7 +714,7 @@ REGISTER_TEST_VERSION(external_semaphores_cross_queues_io2, Version(1, 2))
714714
// Confirm that we can signal multiple semaphores with one command
715715
REGISTER_TEST_VERSION(external_semaphores_multi_signal, Version(1, 2))
716716
{
717-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
717+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
718718

719719
if (init_vulkan_device(1, &device))
720720
{
@@ -796,7 +796,7 @@ REGISTER_TEST_VERSION(external_semaphores_multi_signal, Version(1, 2))
796796
// Confirm that we can wait for multiple semaphores with one command
797797
REGISTER_TEST_VERSION(external_semaphores_multi_wait, Version(1, 2))
798798
{
799-
REQUIRE_EXTENSION("cl_khr_external_semaphore");
799+
REQUIRE_EXTENSION(CL_KHR_EXTERNAL_SEMAPHORE);
800800

801801
if (init_vulkan_device(1, &device))
802802
{

test_conformance/spir/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Copyright (c) 2017 The Khronos Group Inc.
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
@@ -6911,7 +6911,7 @@ int main (int argc, const char* argv[])
69116911
cl_device_id device = get_platform_device(device_type, choosen_device_index, choosen_platform_index);
69126912
printDeviceHeader(device);
69136913

6914-
REQUIRE_EXTENSION("cl_khr_spir");
6914+
REQUIRE_EXTENSION(CL_KHR_SPIR);
69156915

69166916
std::vector<Version> versions;
69176917
get_spir_version(device, versions);
@@ -6986,4 +6986,3 @@ int main (int argc, const char* argv[])
69866986
return 3;
69876987
}
69886988
}
6989-

0 commit comments

Comments
 (0)