OpenCL 3.0 CL_SAMPLER_PROPERTIES tests. (#858)

* OpenCL 3.0 CL_SAMPLER_PROPERTIES tests.

* Test CL_SAMPLER_PROPERTIES - fix misspelling

* Test CL_SAMPLER_PROPERTIES - fix results verification
This commit is contained in:
Grzegorz Wawiorko
2020-08-06 11:02:46 +02:00
committed by GitHub
parent b3db418e06
commit c9f4ef23f6

View File

@@ -17,6 +17,7 @@
#include "harness/imageHelpers.h"
#include <stdlib.h>
#include <ctype.h>
#include <algorithm>
int test_get_platform_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
{
@@ -209,6 +210,75 @@ int test_get_sampler_info(cl_device_id deviceID, cl_context context, cl_command_
return -1;
}
Version version = get_device_cl_version(deviceID);
if (version >= Version(3, 0))
{
std::vector<cl_sampler_properties> get_properties;
std::vector<cl_sampler_properties> set_properties(
properties, properties + ARRAY_SIZE(properties));
size_t set_size;
cl_uint number_of_props = 0;
error = clGetSamplerInfo(sampler, CL_SAMPLER_PROPERTIES, 0, NULL,
&set_size);
test_error(error, "clGetSamplerInfo failed.");
if (set_size != set_properties.size() * sizeof(cl_sampler_properties))
{
test_error(error,
"Incorrect size of CL_SAMPLER_PROPERTIES returned by "
"clGetSamplerInfo");
}
number_of_props = set_size / sizeof(cl_sampler_properties);
get_properties.resize(number_of_props);
error = clGetSamplerInfo(sampler, CL_SAMPLER_PROPERTIES, set_size,
get_properties.data(), 0);
test_error(error, "clGetSamplerInfo failed.");
if (get_properties.back() != 0)
{
log_error(
"ERROR: Incorrect last properties value - should be 0!\n");
return TEST_FAIL;
}
get_properties.pop_back();
set_properties.pop_back();
if (set_properties != get_properties)
{
for (cl_uint i = 0; i < set_properties.size(); i = i + 2)
{
cl_sampler_properties set_property = set_properties[i];
cl_sampler_properties set_property_value =
set_properties[i + 1];
std::vector<cl_sampler_properties>::iterator it = std::find(
get_properties.begin(), get_properties.end(), set_property);
if (it == get_properties.end())
{
log_error("ERROR: Property name not found ... 0x%x\n",
set_property);
return TEST_FAIL;
}
else
{
if (set_property_value != *std::next(it))
{
log_error(
"ERROR: Incorrect preperty value expected 0x%x, "
"obtained 0x%x\n",
set_property_value, *std::next(it));
return TEST_FAIL;
}
}
}
log_error("ERROR: ALL properties and values matched but order "
"incorrect!\n");
return TEST_FAIL;
}
}
return 0;
}