mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-24 15:59:03 +00:00
Fp16 conversions staging (#1864)
* Added unification of existing conversions test as preparation for cl_khr_fp16 adaptation * Unified initialization procedures for conversions test. * Completed unification of data structures to handle cl_khr_fp16 * Added support for selective launch of the test * Added half support for test_conversions, work in progres (issue #142, conversions) * Added more work on halfs support for conversions test (issue #142, conversions) * Added cosmetic corrections * Added more cosmetic corrections before opening draft PR * Added corrections related to pre-submit windows build * Added more pre-build related corrections * Added pre-submit ubuntu build related correction * Added more pre-submit related corrections * Divided structures into separate source files (issue #142, conversions) * Added more corrections related to presubmit check * Removed redeclarations due to presubmit check * Added more corrections related to presubmit check arm build * Added cosmetic correction * Adapted modifications from related PR #1719 to avoid merging conflicts * fixed clang format * Added corrections related to code review (cl_khr_fp16 suuport according to issue #142) * Corrections related to macos CI check fail * fix for unclear clang format discrepancy * More corrections related to code review (cl_khr_fp16 for conversions #142) --------- Co-authored-by: Ewan Crawford <ewan@codeplay.com>
This commit is contained in:
@@ -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