Added cl_khr_fp16 extension support for test_fpmath from basic (#1718)

* Added half and double support for fpmath test from basic (issue #142, basic)

* Cosmetic corrections due to code review

* Removed unnecessary casting

* Added corrections due to code review

* Tuning range of input generation to avoid hitting infinity

* Moved string helpers procedures due to request from test_commonfns PR #1695
This commit is contained in:
Marcin Hajder
2023-06-20 17:42:57 +02:00
committed by GitHub
parent 44b2578ac7
commit 0e229b8f01
7 changed files with 427 additions and 211 deletions

View File

@@ -1,5 +1,5 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2023 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.
@@ -22,14 +22,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <CL/cl_half.h>
#include "harness/testHarness.h"
#include "procs.h"
test_definition test_list[] = {
ADD_TEST(hostptr),
ADD_TEST(fpmath_float),
ADD_TEST(fpmath_float2),
ADD_TEST(fpmath_float4),
ADD_TEST(fpmath),
ADD_TEST(intmath_int),
ADD_TEST(intmath_int2),
ADD_TEST(intmath_int4),
@@ -164,9 +165,35 @@ test_definition test_list[] = {
};
const int test_num = ARRAY_SIZE( test_list );
cl_half_rounding_mode halfRoundingMode = CL_HALF_RTE;
test_status InitCL(cl_device_id device)
{
if (is_extension_available(device, "cl_khr_fp16"))
{
const cl_device_fp_config fpConfigHalf =
get_default_rounding_mode(device, CL_DEVICE_HALF_FP_CONFIG);
if ((fpConfigHalf & CL_FP_ROUND_TO_NEAREST) != 0)
{
halfRoundingMode = CL_HALF_RTE;
}
else if ((fpConfigHalf & CL_FP_ROUND_TO_ZERO) != 0)
{
halfRoundingMode = CL_HALF_RTZ;
}
else
{
log_error("Error while acquiring half rounding mode");
return TEST_FAIL;
}
}
return TEST_PASS;
}
int main(int argc, const char *argv[])
{
return runTestHarness(argc, argv, test_num, test_list, false, 0);
return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0,
InitCL);
}