mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
api: Enable cl_khr_fp16 when using half types in kernel (#1327)
This commit is contained in:
committed by
GitHub
parent
ddca0f802b
commit
4fb5deeec1
@@ -167,7 +167,8 @@ static std::string generate_argument(const KernelArgInfo& kernel_arg)
|
||||
/* This function generates a kernel source and allows for multiple arguments to
|
||||
* be passed in and subsequently queried. */
|
||||
static std::string generate_kernel(const std::vector<KernelArgInfo>& all_args,
|
||||
const bool supports_3d_image_writes = false)
|
||||
const bool supports_3d_image_writes = false,
|
||||
const bool kernel_uses_half_type = false)
|
||||
{
|
||||
|
||||
std::string ret;
|
||||
@@ -175,6 +176,10 @@ static std::string generate_kernel(const std::vector<KernelArgInfo>& all_args,
|
||||
{
|
||||
ret += "#pragma OPENCL EXTENSION cl_khr_3d_image_writes: enable\n";
|
||||
}
|
||||
if (kernel_uses_half_type)
|
||||
{
|
||||
ret += "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n";
|
||||
}
|
||||
ret += "kernel void get_kernel_arg_info(\n";
|
||||
for (int i = 0; i < all_args.size(); ++i)
|
||||
{
|
||||
@@ -673,8 +678,8 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID)
|
||||
if (param_size + total_param_size >= max_param_size
|
||||
|| all_args.size() == MAX_NUMBER_OF_KERNEL_ARGS)
|
||||
{
|
||||
const std::string kernel_src =
|
||||
generate_kernel(all_args);
|
||||
const std::string kernel_src = generate_kernel(
|
||||
all_args, false, device_supports_half(deviceID));
|
||||
failed_tests += compare_kernel_with_expected(
|
||||
context, deviceID, kernel_src.c_str(),
|
||||
expected_args);
|
||||
@@ -696,7 +701,8 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID)
|
||||
}
|
||||
}
|
||||
}
|
||||
const std::string kernel_src = generate_kernel(all_args);
|
||||
const std::string kernel_src =
|
||||
generate_kernel(all_args, false, device_supports_half(deviceID));
|
||||
failed_tests += compare_kernel_with_expected(
|
||||
context, deviceID, kernel_src.c_str(), expected_args);
|
||||
return failed_tests;
|
||||
|
||||
Reference in New Issue
Block a user