mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Add fp16 testing to conversions and bruteforce (#1975)
Merge the `fp16-staging` branch into `main`, adding fp16 (`half`) testing to the conversions and math bruteforce tests. --------- Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com> Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com> Signed-off-by: Guo, Yilong <yilong.guo@intel.com> Signed-off-by: John Kesapides <john.kesapides@arm.com> Co-authored-by: Marcin Hajder <marcin.hajder@gmail.com> Co-authored-by: Ewan Crawford <ewan@codeplay.com> Co-authored-by: Wawiorko, Grzegorz <grzegorz.wawiorko@intel.com> Co-authored-by: Sreelakshmi Haridas Maruthur <sharidas@quicinc.com> Co-authored-by: Harald van Dijk <harald@gigawatt.nl> Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com> Co-authored-by: Haonan Yang <haonan.yang@intel.com> Co-authored-by: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Co-authored-by: niranjanjoshi121 <43807392+niranjanjoshi121@users.noreply.github.com> Co-authored-by: Wenwan Xing <wenwan.xing@intel.com> Co-authored-by: Yilong Guo <yilong.guo@intel.com> Co-authored-by: Romaric Jodin <89833130+rjodinchr@users.noreply.github.com> Co-authored-by: joshqti <127994991+joshqti@users.noreply.github.com> Co-authored-by: Pekka Jääskeläinen <pekka.jaaskelainen@tuni.fi> Co-authored-by: imilenkovic00 <155085410+imilenkovic00@users.noreply.github.com> Co-authored-by: John Kesapides <46718829+JohnKesapidesARM@users.noreply.github.com> Co-authored-by: Aharon Abramson <aharon.abramson@mobileye.com>
This commit is contained in:
committed by
GitHub
parent
b3c89ebde0
commit
b6941b6c61
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2024 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -73,9 +73,9 @@ static void PrintUsage(void);
|
||||
test_status InitCL(cl_device_id device);
|
||||
|
||||
|
||||
const char *gTypeNames[kTypeCount] = { "uchar", "char", "ushort", "short",
|
||||
"uint", "int", "float", "double",
|
||||
"ulong", "long" };
|
||||
const char *gTypeNames[kTypeCount] = { "uchar", "char", "ushort", "short",
|
||||
"uint", "int", "half", "float",
|
||||
"double", "ulong", "long" };
|
||||
|
||||
const char *gRoundingModeNames[kRoundingModeCount] = { "", "_rte", "_rtp",
|
||||
"_rtn", "_rtz" };
|
||||
@@ -83,9 +83,9 @@ const char *gRoundingModeNames[kRoundingModeCount] = { "", "_rte", "_rtp",
|
||||
const char *gSaturationNames[2] = { "", "_sat" };
|
||||
|
||||
size_t gTypeSizes[kTypeCount] = {
|
||||
sizeof(cl_uchar), sizeof(cl_char), sizeof(cl_ushort), sizeof(cl_short),
|
||||
sizeof(cl_uint), sizeof(cl_int), sizeof(cl_float), sizeof(cl_double),
|
||||
sizeof(cl_ulong), sizeof(cl_long),
|
||||
sizeof(cl_uchar), sizeof(cl_char), sizeof(cl_ushort), sizeof(cl_short),
|
||||
sizeof(cl_uint), sizeof(cl_int), sizeof(cl_half), sizeof(cl_float),
|
||||
sizeof(cl_double), sizeof(cl_ulong), sizeof(cl_long),
|
||||
};
|
||||
|
||||
char appName[64] = "ctest";
|
||||
@@ -221,13 +221,17 @@ static int ParseArgs(int argc, const char **argv)
|
||||
switch (*arg)
|
||||
{
|
||||
case 'd': gTestDouble ^= 1; break;
|
||||
case 'h': gTestHalfs ^= 1; break;
|
||||
case 'l': gSkipTesting ^= 1; break;
|
||||
case 'm': gMultithread ^= 1; break;
|
||||
case 'w': gWimpyMode ^= 1; break;
|
||||
case '[':
|
||||
parseWimpyReductionFactor(arg, gWimpyReductionFactor);
|
||||
break;
|
||||
case 'z': gForceFTZ ^= 1; break;
|
||||
case 'z':
|
||||
gForceFTZ ^= 1;
|
||||
gForceHalfFTZ ^= 1;
|
||||
break;
|
||||
case 't': gTimeResults ^= 1; break;
|
||||
case 'a': gReportAverageTimes ^= 1; break;
|
||||
case '1':
|
||||
@@ -355,7 +359,6 @@ static void PrintUsage(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
test_status InitCL(cl_device_id device)
|
||||
{
|
||||
int error, i;
|
||||
@@ -412,6 +415,50 @@ test_status InitCL(cl_device_id device)
|
||||
}
|
||||
gTestDouble &= gHasDouble;
|
||||
|
||||
if (is_extension_available(device, "cl_khr_fp16"))
|
||||
{
|
||||
gHasHalfs = 1;
|
||||
|
||||
cl_device_fp_config floatCapabilities = 0;
|
||||
if ((error = clGetDeviceInfo(device, CL_DEVICE_HALF_FP_CONFIG,
|
||||
sizeof(floatCapabilities),
|
||||
&floatCapabilities, NULL)))
|
||||
floatCapabilities = 0;
|
||||
|
||||
if (0 == (CL_FP_DENORM & floatCapabilities)) gForceHalfFTZ ^= 1;
|
||||
|
||||
if (0 == (floatCapabilities & CL_FP_ROUND_TO_NEAREST))
|
||||
{
|
||||
char profileStr[128] = "";
|
||||
// Verify that we are an embedded profile device
|
||||
if ((error = clGetDeviceInfo(device, CL_DEVICE_PROFILE,
|
||||
sizeof(profileStr), profileStr, NULL)))
|
||||
{
|
||||
vlog_error("FAILURE: Could not get device profile: error %d\n",
|
||||
error);
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
if (strcmp(profileStr, "EMBEDDED_PROFILE"))
|
||||
{
|
||||
vlog_error(
|
||||
"FAILURE: non-embedded profile device does not support "
|
||||
"CL_FP_ROUND_TO_NEAREST\n");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
if (0 == (floatCapabilities & CL_FP_ROUND_TO_ZERO))
|
||||
{
|
||||
vlog_error("FAILURE: embedded profile device supports neither "
|
||||
"CL_FP_ROUND_TO_NEAREST or CL_FP_ROUND_TO_ZERO\n");
|
||||
return TEST_FAIL;
|
||||
}
|
||||
|
||||
gIsHalfRTZ = 1;
|
||||
}
|
||||
}
|
||||
gTestHalfs &= gHasHalfs;
|
||||
|
||||
// detect whether profile of the device is embedded
|
||||
char profile[1024] = "";
|
||||
if ((error = clGetDeviceInfo(device, CL_DEVICE_PROFILE, sizeof(profile),
|
||||
@@ -492,8 +539,12 @@ test_status InitCL(cl_device_id device)
|
||||
vlog("\tSubnormal values supported for floats? %s\n",
|
||||
no_yes[0 != (CL_FP_DENORM & floatCapabilities)]);
|
||||
vlog("\tTesting with FTZ mode ON for floats? %s\n", no_yes[0 != gForceFTZ]);
|
||||
vlog("\tTesting with FTZ mode ON for halfs? %s\n",
|
||||
no_yes[0 != gForceHalfFTZ]);
|
||||
vlog("\tTesting with default RTZ mode for floats? %s\n",
|
||||
no_yes[0 != gIsRTZ]);
|
||||
vlog("\tTesting with default RTZ mode for halfs? %s\n",
|
||||
no_yes[0 != gIsHalfRTZ]);
|
||||
vlog("\tHas Double? %s\n", no_yes[0 != gHasDouble]);
|
||||
if (gHasDouble) vlog("\tTest Double? %s\n", no_yes[0 != gTestDouble]);
|
||||
vlog("\tHas Long? %s\n", no_yes[0 != gHasLong]);
|
||||
@@ -503,5 +554,3 @@ test_status InitCL(cl_device_id device)
|
||||
vlog("\n");
|
||||
return TEST_PASS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user