#ifndef TEST_CONFORMANCE_CLCPP_RELATIONAL_FUNCS_COMMON_HPP
#define TEST_CONFORMANCE_CLCPP_RELATIONAL_FUNCS_COMMON_HPP
#include <type_traits>
#include <cmath>
#include "../common.hpp"
#include "../funcs_test_utils.hpp"
#include "half_utils.hpp"
#include <CL/cl_half.h>
std::vector<cl_half> generate_half_input(size_t count,
const cl_float& min,
const cl_float& max,
const std::vector<cl_half> special_cases)
{
std::vector<cl_half> input(count);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<cl_float> dis(min, max);
for(auto& i : input)
{
i = cl_half_from_float(dis(gen), CL_HALF_RTE);
}
input.insert(input.begin(), special_cases.begin(), special_cases.end());
input.resize(count);
return input;
}
template <class type>
std::vector<type> vload_vstore_generate_input(size_t count,
const type& min,
const type& max,
const std::vector<type> special_cases,
const bool generate_half,
typename std::enable_if<
std::is_same<type, cl_half>::value
>::type* = 0)
{
if(!generate_half)
{
return generate_input<type>(count, min, max, special_cases);
}
return generate_half_input(count, -(CL_HALF_MAX/4.f), (CL_HALF_MAX/4.f), special_cases);
}
template <class type>
std::vector<type> vload_vstore_generate_input(size_t count,
const type& min,
const type& max,
const std::vector<type> special_cases,
const bool generate_half,
typename std::enable_if<
!std::is_same<type, cl_half>::value
>::type* = 0)
{
return generate_input<type>(count, min, max, special_cases);
}
#endif