diff --git a/test_conformance/subgroups/main.cpp b/test_conformance/subgroups/main.cpp index 44416dd7..ebe94558 100644 --- a/test_conformance/subgroups/main.cpp +++ b/test_conformance/subgroups/main.cpp @@ -19,8 +19,10 @@ #include #include "procs.h" #include "harness/testHarness.h" +#include "CL/cl_half.h" MTdata gMTdata; +cl_half_rounding_mode g_rounding_mode; test_definition test_list[] = { ADD_TEST_VERSION(sub_group_info_ext, Version(2, 0)), @@ -66,6 +68,22 @@ static test_status InitCL(cl_device_id device) ret = TEST_SKIP; } } + // Determine the rounding mode to be used in float to half conversions in + // init and reference code + const cl_device_fp_config fpConfig = get_default_rounding_mode(device); + + if (fpConfig == CL_FP_ROUND_TO_NEAREST) + { + g_rounding_mode = CL_HALF_RTE; + } + else if (fpConfig == CL_FP_ROUND_TO_ZERO && gIsEmbedded) + { + g_rounding_mode = CL_HALF_RTZ; + } + else + { + assert(false && "Unreachable"); + } return ret; } diff --git a/test_conformance/subgroups/subgroup_common_templates.h b/test_conformance/subgroups/subgroup_common_templates.h index b30c416b..4333e95b 100644 --- a/test_conformance/subgroups/subgroup_common_templates.h +++ b/test_conformance/subgroups/subgroup_common_templates.h @@ -301,7 +301,7 @@ static float to_float(subgroups::cl_half x) { return cl_half_to_float(x.data); } static subgroups::cl_half to_half(float x) { subgroups::cl_half value; - value.data = cl_half_from_float(x, CL_HALF_RTE); + value.data = cl_half_from_float(x, g_rounding_mode); return value; } diff --git a/test_conformance/subgroups/subhelpers.h b/test_conformance/subgroups/subhelpers.h index 93673b35..9232cded 100644 --- a/test_conformance/subgroups/subhelpers.h +++ b/test_conformance/subgroups/subhelpers.h @@ -28,6 +28,7 @@ #define NR_OF_ACTIVE_WORK_ITEMS 4 extern MTdata gMTdata; +extern cl_half_rounding_mode g_rounding_mode; struct WorkGroupParams { @@ -1080,7 +1081,7 @@ template typename std::enable_if::is_sb_scalar_type::value>::type set_value(Ty &lhs, const cl_ulong &rhs) { - lhs.data = rhs; + lhs.data = cl_half_from_float(static_cast(rhs), g_rounding_mode); } // compare for common vectors diff --git a/test_conformance/subgroups/test_ifp.cpp b/test_conformance/subgroups/test_ifp.cpp index 428f2cdc..fccaa8c7 100644 --- a/test_conformance/subgroups/test_ifp.cpp +++ b/test_conformance/subgroups/test_ifp.cpp @@ -360,17 +360,21 @@ int test_ifp_ext(cl_device_id device, cl_context context, } // ifp only in subgroup functions tests: test_status error; - error = checkIFPSupport(device, ifpSupport); - if (error != TEST_PASS) + auto device_cl_version = get_device_cl_version(device); + if (device_cl_version >= Version(2, 1)) { - return error; - } - if (ifpSupport == false) - { - log_info( - "Error reason: the extension cl_khr_subgroups requires that " - "Independed forward progress has to be supported by device.\n"); - return TEST_FAIL; + error = checkIFPSupport(device, ifpSupport); + if (error != TEST_PASS) + { + return error; + } + if (ifpSupport == false) + { + log_info( + "Error reason: the extension cl_khr_subgroups requires that " + "Independed forward progress has to be supported by device.\n"); + return TEST_FAIL; + } } return test_ifp(device, context, queue, num_elements, false); -} \ No newline at end of file +}