Added cl_half support for test_printf (#1622)

* Added support to test half floats with printf calls (issue #142, printf)

* Added corrections related to rounding and casting halfs (issue #142, printf)

* Reusing similar function (issue #142, printf)

* Corrected path without cl_khr_fp16 support (issue #142, printf)

* Cosmetic fix for order of vector tests (issue #142, printf)

* Added correction related to vendor test review (issue #142, printf)
This commit is contained in:
Marcin Hajder
2023-03-28 17:57:03 +02:00
committed by GitHub
parent f537c40abc
commit 20ab003053
5 changed files with 396 additions and 60 deletions

View File

@@ -1511,22 +1511,33 @@ size_t get_min_alignment(cl_context context)
return align_size;
}
cl_device_fp_config get_default_rounding_mode(cl_device_id device)
cl_device_fp_config get_default_rounding_mode(cl_device_id device,
const cl_uint &param)
{
if (param == CL_DEVICE_DOUBLE_FP_CONFIG)
test_error_ret(
-1,
"FAILURE: CL_DEVICE_DOUBLE_FP_CONFIG not supported by this routine",
0);
char profileStr[128] = "";
cl_device_fp_config single = 0;
int error = clGetDeviceInfo(device, CL_DEVICE_SINGLE_FP_CONFIG,
sizeof(single), &single, NULL);
int error = clGetDeviceInfo(device, param, sizeof(single), &single, NULL);
if (error)
test_error_ret(error, "Unable to get device CL_DEVICE_SINGLE_FP_CONFIG",
0);
{
std::string message = std::string("Unable to get device ")
+ std::string(param == CL_DEVICE_HALF_FP_CONFIG
? "CL_DEVICE_HALF_FP_CONFIG"
: "CL_DEVICE_SINGLE_FP_CONFIG");
test_error_ret(error, message.c_str(), 0);
}
if (single & CL_FP_ROUND_TO_NEAREST) return CL_FP_ROUND_TO_NEAREST;
if (0 == (single & CL_FP_ROUND_TO_ZERO))
test_error_ret(-1,
"FAILURE: device must support either "
"CL_DEVICE_SINGLE_FP_CONFIG or CL_FP_ROUND_TO_NEAREST",
"CL_FP_ROUND_TO_ZERO or CL_FP_ROUND_TO_NEAREST",
0);
// Make sure we are an embedded device before allowing a pass

View File

@@ -159,7 +159,9 @@ size_t get_min_alignment(cl_context context);
/* Helper to obtain the default rounding mode for single precision computation.
* (Double is always CL_FP_ROUND_TO_NEAREST.) Returns 0 on error. */
cl_device_fp_config get_default_rounding_mode(cl_device_id device);
cl_device_fp_config
get_default_rounding_mode(cl_device_id device,
const cl_uint &param = CL_DEVICE_SINGLE_FP_CONFIG);
#define PASSIVE_REQUIRE_IMAGE_SUPPORT(device) \
if (checkForImageSupport(device)) \