mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Added cl_khr_fp16 extension support for test_commonfns (#1695)
* Added cl_khr_fp16 extension support for commonfns test (issue #142, commonfns) * Added missing header due to presubmit check * Corrected radians/degrees ulp calculations + cosmetic fixes * Corrected presubmit code format * Corrections related to code review * Moved string format helper to test_common in separate header * Added clang format for last commit * Corrections related to code review * Modified mix verification procedure for half type to only report max error * Removed redundant condition for logging mix verification * Corrected generator limits for half tests
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include "harness/stringHelpers.h"
|
||||
|
||||
#include <CL/cl_half.h>
|
||||
|
||||
#include "test_comparisons_fp.h"
|
||||
@@ -83,29 +85,6 @@ extension,
|
||||
// clang-format on
|
||||
|
||||
|
||||
std::string concat_kernel(const char* sstr[], int num)
|
||||
{
|
||||
std::string res;
|
||||
for (int i = 0; i < num; i++) res += std::string(sstr[i]);
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
std::string string_format(const std::string& format, Args... args)
|
||||
{
|
||||
int size_s = std::snprintf(nullptr, 0, format.c_str(), args...)
|
||||
+ 1; // Extra space for '\0'
|
||||
if (size_s <= 0)
|
||||
{
|
||||
throw std::runtime_error("Error during formatting.");
|
||||
}
|
||||
auto size = static_cast<size_t>(size_s);
|
||||
std::unique_ptr<char[]> buf(new char[size]);
|
||||
std::snprintf(buf.get(), size, format.c_str(), args...);
|
||||
return std::string(buf.get(),
|
||||
buf.get() + size - 1); // We don't want the '\0' inside
|
||||
}
|
||||
|
||||
template <typename T, typename F> bool verify(const T& A, const T& B)
|
||||
{
|
||||
return F()(A, B);
|
||||
@@ -226,14 +205,14 @@ int RelationalsFPTest::test_equiv_kernel(unsigned int vecSize,
|
||||
auto str =
|
||||
concat_kernel(equivTestKerPat_3,
|
||||
sizeof(equivTestKerPat_3) / sizeof(const char*));
|
||||
kernelSource = string_format(str, fnName.c_str(), opName.c_str());
|
||||
kernelSource = str_sprintf(str, fnName.c_str(), opName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto str = concat_kernel(equivTestKerPatLessGreater_3,
|
||||
sizeof(equivTestKerPatLessGreater_3)
|
||||
/ sizeof(const char*));
|
||||
kernelSource = string_format(str, fnName.c_str());
|
||||
kernelSource = str_sprintf(str, fnName.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -243,14 +222,14 @@ int RelationalsFPTest::test_equiv_kernel(unsigned int vecSize,
|
||||
auto str =
|
||||
concat_kernel(equivTestKernPat,
|
||||
sizeof(equivTestKernPat) / sizeof(const char*));
|
||||
kernelSource = string_format(str, fnName.c_str(), opName.c_str());
|
||||
kernelSource = str_sprintf(str, fnName.c_str(), opName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto str = concat_kernel(equivTestKernPatLessGreater,
|
||||
sizeof(equivTestKernPatLessGreater)
|
||||
/ sizeof(const char*));
|
||||
kernelSource = string_format(str, fnName.c_str());
|
||||
kernelSource = str_sprintf(str, fnName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user