From 8213e37a421c4a926687463a3c10344889250a81 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 14 Aug 2023 19:00:19 +0200 Subject: [PATCH] make atomic tests in prog var testing optional This is helpful for testing progvars on implementations not implementing all the optional atomic features. --- test_conformance/basic/test_progvar.cpp | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/test_conformance/basic/test_progvar.cpp b/test_conformance/basic/test_progvar.cpp index 41cc019907..b4ff1ec0a7 100644 --- a/test_conformance/basic/test_progvar.cpp +++ b/test_conformance/basic/test_progvar.cpp @@ -48,6 +48,7 @@ #include #include "harness/typeWrappers.h" #include "harness/errorHelpers.h" +#include "harness/featureHelpers.h" #include "harness/mt19937.h" #include "procs.h" @@ -57,6 +58,7 @@ static int l_has_double = 0; static int l_has_half = 0; static int l_64bit_device = 0; +static int l_has_atomics = 1; static int l_has_int64_atomics = 0; static int l_has_intptr_atomics = 0; static int l_has_cles_int64 = 0; @@ -398,7 +400,7 @@ class StringTable { //////////////////// // File scope function declarations -static void l_load_abilities(cl_device_id device); +static int l_load_abilities(cl_device_id device); static const char* l_get_fp64_pragma(void); static const char* l_get_cles_int64_pragma(void); static int l_build_type_table(cl_device_id device); @@ -547,12 +549,26 @@ static cl_int print_build_log(cl_program program, cl_uint num_devices, return error; } -static void l_load_abilities(cl_device_id device) +static int l_load_abilities(cl_device_id device) { l_has_half = is_extension_available(device, "cl_khr_fp16"); l_has_double = is_extension_available(device, "cl_khr_fp64"); l_has_cles_int64 = is_extension_available(device, "cles_khr_int64"); + if (get_device_cl_version(device) >= Version(3, 0)) + { + OpenCLCFeatures features; + int ret = get_device_cl_c_features(device, features); + if (ret) + { + log_error("Couldn't query OpenCL C features for the device!\n"); + return ret; + } + + l_has_atomics = features.supports__opencl_c_atomic_order_seq_cst + && features.supports__opencl_c_atomic_scope_device; + } + l_has_int64_atomics = is_extension_available(device, "cl_khr_int64_base_atomics") && is_extension_available(device, "cl_khr_int64_extended_atomics"); @@ -566,7 +582,8 @@ static void l_load_abilities(cl_device_id device) } // 32-bit devices always have intptr atomics. - l_has_intptr_atomics = !l_64bit_device || l_has_int64_atomics; + l_has_intptr_atomics = + l_has_atomics && (!l_64bit_device || l_has_int64_atomics); union { char c[4]; @@ -608,6 +625,8 @@ static void l_load_abilities(cl_device_id device) "CL_DEVICE_LINKER_AVAILABLE failed.")) return; } + + return TEST_PASS; } @@ -649,7 +668,9 @@ static int l_build_type_table(cl_device_id device) const char* intptr_atomics[] = { "atomic_intptr_t", "atomic_uintptr_t", "atomic_size_t", "atomic_ptrdiff_t" }; - l_load_abilities(device); + int ret = l_load_abilities(device); + if (ret) return CL_INVALID_DEVICE; + num_type_info = 0; // Boolean. @@ -688,6 +709,7 @@ static int l_build_type_table(cl_device_id device) // Atomic types. for (iscalar = 0; iscalar < sizeof(atomics) / sizeof(atomics[0]); ++iscalar) { + if (!l_has_atomics) continue; if (!l_has_int64_atomics && strstr(atomics[iscalar], "long")) continue; if (!(l_has_int64_atomics && l_has_double) && strstr(atomics[iscalar], "double"))