aboutsummaryrefslogtreecommitdiff
path: root/test_conformance/commonfns/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test_conformance/commonfns/main.cpp')
-rw-r--r--test_conformance/commonfns/main.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/test_conformance/commonfns/main.cpp b/test_conformance/commonfns/main.cpp
index 3e4b0b8e..645d3f70 100644
--- a/test_conformance/commonfns/main.cpp
+++ b/test_conformance/commonfns/main.cpp
@@ -1,6 +1,6 @@
//
-// 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.
// You may obtain a copy of the License at
@@ -18,8 +18,10 @@
#include <string.h>
#include "procs.h"
#include "test_base.h"
+#include "harness/kernelHelpers.h"
std::map<size_t, std::string> BaseFunctionTest::type2name;
+cl_half_rounding_mode BaseFunctionTest::halfRoundingMode = CL_HALF_RTE;
int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount];
int g_arrStrangeVectorSizes[kStrangeVectorSizeCount] = {3};
@@ -45,17 +47,38 @@ test_definition test_list[] = {
const int test_num = ARRAY_SIZE( test_list );
-int main(int argc, const char *argv[])
+test_status InitCL(cl_device_id device)
{
- initVecSizes();
-
- if (BaseFunctionTest::type2name.empty())
+ if (is_extension_available(device, "cl_khr_fp16"))
{
- BaseFunctionTest::type2name[sizeof(half)] = "half";
- BaseFunctionTest::type2name[sizeof(float)] = "float";
- BaseFunctionTest::type2name[sizeof(double)] = "double";
+ const cl_device_fp_config fpConfigHalf =
+ get_default_rounding_mode(device, CL_DEVICE_HALF_FP_CONFIG);
+ if ((fpConfigHalf & CL_FP_ROUND_TO_NEAREST) != 0)
+ {
+ BaseFunctionTest::halfRoundingMode = CL_HALF_RTE;
+ }
+ else if ((fpConfigHalf & CL_FP_ROUND_TO_ZERO) != 0)
+ {
+ BaseFunctionTest::halfRoundingMode = CL_HALF_RTZ;
+ }
+ else
+ {
+ log_error("Error while acquiring half rounding mode");
+ return TEST_FAIL;
+ }
}
- return runTestHarness(argc, argv, test_num, test_list, false, 0);
+ return TEST_PASS;
}
+int main(int argc, const char *argv[])
+{
+ initVecSizes();
+
+ BaseFunctionTest::type2name[sizeof(half)] = "half";
+ BaseFunctionTest::type2name[sizeof(float)] = "float";
+ BaseFunctionTest::type2name[sizeof(double)] = "double";
+
+ return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0,
+ InitCL);
+}