From 242c767f73c5f76fcc2c50a8cda86097d2891b0d Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Thu, 6 Jul 2023 12:58:27 +0200 Subject: [PATCH] Corrected condition to verify if additional pragma is necessary (issue #142, basic) --- test_conformance/basic/test_explicit_s2v.cpp | 8 ++++++-- test_conformance/basic/test_fpmath.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test_conformance/basic/test_explicit_s2v.cpp b/test_conformance/basic/test_explicit_s2v.cpp index 2f0fc86d95..238b6e06e8 100644 --- a/test_conformance/basic/test_explicit_s2v.cpp +++ b/test_conformance/basic/test_explicit_s2v.cpp @@ -26,6 +26,8 @@ #include "harness/conversions.h" #include "harness/typeWrappers.h" +namespace { + // clang-format off #define DECLARE_S2V_IDENT_KERNEL(srctype,dsttype,size) \ @@ -286,10 +288,10 @@ struct TypesIterator }; std::stringstream sstr; - if (srcType == kDouble || dstType == kDouble) + if (srcT == kDouble || dstT == kDouble) sstr << "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; - if (srcType == kHalf || dstType == kHalf) + if (srcT == kHalf || dstT == kHalf) sstr << "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n"; snprintf(pragma, sizeof(pragma), "%s", sstr.str().c_str()); @@ -333,6 +335,8 @@ struct TypesIterator 128; // hardcoded in original test }; +} // anonymous namespace + int test_explicit_s2v(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { diff --git a/test_conformance/basic/test_fpmath.cpp b/test_conformance/basic/test_fpmath.cpp index 6719e72816..8a2210fbcf 100644 --- a/test_conformance/basic/test_fpmath.cpp +++ b/test_conformance/basic/test_fpmath.cpp @@ -33,7 +33,11 @@ #include "procs.h" -static const char *fp_kernel_code = R"( +extern cl_half_rounding_mode halfRoundingMode; + +namespace { + +const char *fp_kernel_code = R"( %s __kernel void test_fp(__global TYPE *srcA, __global TYPE *srcB, __global TYPE *dst) { @@ -42,8 +46,6 @@ __kernel void test_fp(__global TYPE *srcA, __global TYPE *srcB, __global TYPE *d dst[tid] = srcA[tid] OP srcB[tid]; })"; -extern cl_half_rounding_mode halfRoundingMode; - #define HFF(num) cl_half_from_float(num, halfRoundingMode) #define HTF(num) cl_half_to_float(num) @@ -370,6 +372,8 @@ struct TypesIterator std::map type2name; }; +} // anonymous namespace + int test_fpmath(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) {