Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/cl/test/UnitCL/include/kts/execution.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ class HalfParamExecution : public ExecutionWithParam<unsigned> {
/// @brief Returns true if parameter at index has a scalar type
/// @param[in] Index of parameter to check
bool IsArgScalar(unsigned index) const;

/// @brief Returns a vector of edge cases that need extra testing.
virtual const std::vector<cl_ushort> &GetEdgeCases() const;
Comment thread
hvdijk marked this conversation as resolved.
};

template <typename T>
Expand Down
14 changes: 11 additions & 3 deletions source/cl/test/UnitCL/source/kts/fp16_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,23 @@ bool HalfParamExecution::IsArgScalar(unsigned index) const {
std::find(scalar_arg_indices.begin(), scalar_arg_indices.end(), index);
}

const std::vector<cl_ushort> &HalfParamExecution::GetEdgeCases() const {
static const std::vector<cl_ushort> EdgeCases =
std::vector<cl_ushort>(InputGenerator::half_edge_cases.begin(),
InputGenerator::half_edge_cases.end());
return EdgeCases;
}

template <size_t N>
unsigned HalfParamExecution::FillInputBuffers(
std::array<input_details_t, N> &inputs) {
const auto &edge_cases = GetEdgeCases();

// The more parameters a functions takes, the more data we need for verifying
// it's behaviour across the increased range of input combinations. Even in
// wimpy mode we want to test at least all the combinations of edge case
// values which have been known to cause failures.
const unsigned edge_case_len = InputGenerator::half_edge_cases.size();
const unsigned edge_case_len = edge_cases.size();
size_t cartesian_len = edge_case_len;
for (size_t i = 1; i < N; i++) {
cartesian_len *= edge_case_len;
Expand Down Expand Up @@ -136,8 +145,7 @@ unsigned HalfParamExecution::FillInputBuffers(
edge_idx = i / div;
}

input[i] =
cargo::bit_cast<cl_half>(InputGenerator::half_edge_cases[edge_idx]);
input[i] = cargo::bit_cast<cl_half>(edge_cases[edge_idx]);
}
}

Expand Down
19 changes: 16 additions & 3 deletions source/cl/test/UnitCL/source/ktst_precision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@ UCL_EXECUTION_TEST_SUITE_P(HalfOperatorTest, testing::Values(OPENCL_C),

using HalfMathBuiltins = HalfParamExecution;

struct HalfMathBuiltinsPow : HalfMathBuiltins {
const std::vector<cl_ushort> &GetEdgeCases() const override {
static const std::vector<cl_ushort> EdgeCases = [&] {
std::vector<cl_ushort> EdgeCases = HalfMathBuiltins::GetEdgeCases();
EdgeCases.push_back(0x39f6);
return EdgeCases;
}();
return EdgeCases;
}
};

TEST_P(HalfMathBuiltins, Precision_08_Half_Ldexp) {
if (!UCL::hasHalfSupport(device)) {
GTEST_SKIP();
Expand Down Expand Up @@ -1774,7 +1785,7 @@ TEST_P(HalfMathBuiltins, Precision_79_Half_tanh) {
TestAgainstRef<2_ULP>(tanh_ref);
}

TEST_P(HalfMathBuiltins, Precision_80_Half_pow) {
TEST_P(HalfMathBuiltinsPow, Precision_80_Half_pow) {
if (!UCL::hasHalfSupport(device)) {
GTEST_SKIP();
}
Expand All @@ -1797,7 +1808,7 @@ TEST_P(HalfMathBuiltins, Precision_80_Half_pow) {
}

// TODO: OCK-523
TEST_P(HalfMathBuiltins, DISABLED_Precision_81_Half_powr) {
TEST_P(HalfMathBuiltinsPow, DISABLED_Precision_81_Half_powr) {
if (!UCL::hasHalfSupport(device)) {
GTEST_SKIP();
}
Expand Down Expand Up @@ -1833,7 +1844,7 @@ TEST_P(HalfMathBuiltins, DISABLED_Precision_81_Half_powr) {
TestAgainstRef<4_ULP>(powr_ref);
}

TEST_P(HalfMathBuiltins, Precision_82_Half_pown) {
TEST_P(HalfMathBuiltinsPow, Precision_82_Half_pown) {
if (!UCL::hasHalfSupport(device)) {
GTEST_SKIP();
}
Expand Down Expand Up @@ -1894,6 +1905,8 @@ TEST_P(HalfMathBuiltins, Precision_83_Half_rootn) {
// Miss out half3 to avoid complications with having sizeof(half4)
UCL_EXECUTION_TEST_SUITE_P(HalfMathBuiltins, testing::Values(OPENCL_C),
testing::Values(1, 2, 4, 8, 16));
UCL_EXECUTION_TEST_SUITE_P(HalfMathBuiltinsPow, testing::Values(OPENCL_C),
testing::Values(1, 2, 4, 8, 16));

TEST_P(Execution, Precision_84_Double_Remquo) {
// Whether or not the kernel will be vectorized at a global size of 1 is
Expand Down