Merge branch 'main' into cl_khr_unified_svm

This commit is contained in:
Ben Ashbaugh
2025-02-03 22:15:02 -08:00
194 changed files with 5232 additions and 4979 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# Build dir
[Bb]uild/

View File

@@ -104,7 +104,6 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang"
# Enable more warnings if not doing a release build.
add_cxx_flag_if_supported(-Wall)
endif()
add_cxx_flag_if_supported(-Wno-format)
add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive
add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785
add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784

View File

@@ -111,6 +111,7 @@ const char *IGetErrorString(int clErrorCode)
return "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR";
case CL_INVALID_COMMAND_BUFFER_KHR:
return "CL_INVALID_COMMAND_BUFFER_KHR";
case CL_INVALID_SEMAPHORE_KHR: return "CL_INVALID_SEMAPHORE_KHR";
default: return "(unknown)";
}
}

View File

@@ -133,7 +133,7 @@ template <typename T> T *register_test(const char *name, Version version)
}
#define REGISTER_TEST_VERSION(name, version) \
extern int test_##name(cl_device_id deviceID, cl_context context, \
extern int test_##name(cl_device_id device, cl_context context, \
cl_command_queue queue, int num_elements); \
class test_##name##_class : public test { \
private: \
@@ -145,11 +145,22 @@ template <typename T> T *register_test(const char *name, Version version)
}; \
test_##name##_class *var_##name = \
register_test<test_##name##_class>(#name, version); \
int test_##name(cl_device_id deviceID, cl_context context, \
int test_##name(cl_device_id device, cl_context context, \
cl_command_queue queue, int num_elements)
#define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2))
#define REQUIRE_EXTENSION(name) \
do \
{ \
if (!is_extension_available(deviceID, name)) \
{ \
log_info(name \
" is not supported on this device. Skipping test.\n"); \
return TEST_SKIPPED_ITSELF; \
} \
} while (0)
extern int gFailCount;
extern int gTestCount;
extern cl_uint gReSeed;

View File

@@ -50,14 +50,13 @@ REGISTER_TEST(svm_allocate_shared_buffer)
clCommandQueueWrapper queues[MAXQ];
cl_device_svm_capabilities caps;
err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES,
err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES,
sizeof(cl_device_svm_capabilities), &caps, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");
// under construction...
err =
create_cl_objects(deviceID, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (err) return -1;

View File

@@ -50,14 +50,13 @@ REGISTER_TEST(svm_allocate_shared_buffer_negative)
clCommandQueueWrapper queues[MAXQ];
cl_device_svm_capabilities caps;
err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES,
err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES,
sizeof(cl_device_svm_capabilities), &caps, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");
// under construction...
err =
create_cl_objects(deviceID, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (err) return err;

View File

@@ -58,7 +58,7 @@ REGISTER_TEST(svm_byte_granularity)
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
err = create_cl_objects(deviceID, &byte_manipulation_kernels[0],
err = create_cl_objects(device, &byte_manipulation_kernels[0],
&contextWrapper, &program, &queues[0], &num_devices,
CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
context = contextWrapper;

View File

@@ -136,7 +136,7 @@ REGISTER_TEST(svm_cross_buffer_pointers_coarse_grain)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &SVMCrossBufferPointers_test_kernel[0],
error = create_cl_objects(device, &SVMCrossBufferPointers_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;

View File

@@ -80,7 +80,7 @@ REGISTER_TEST(svm_enqueue_api)
cl_int error = CL_SUCCESS;
RandomSeed seed(0);
error = create_cl_objects(deviceID, NULL, &contextWrapper, NULL, &queues[0],
error = create_cl_objects(device, NULL, &contextWrapper, NULL, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (error) return TEST_FAIL;

View File

@@ -158,7 +158,7 @@ REGISTER_TEST(svm_fine_grain_memory_consistency)
char *source[] = { hash_table_kernel };
err = create_cl_objects(
deviceID, (const char **)source, &contextWrapper, &program, &queues[0],
device, (const char **)source, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS,
required_extensions);
context = contextWrapper;

View File

@@ -52,10 +52,9 @@ REGISTER_TEST(svm_fine_grain_sync_buffers)
cl_int err = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
err = create_cl_objects(deviceID, &find_targets_kernel[0], &contextWrapper,
&program, &queues[0], &num_devices,
CL_DEVICE_SVM_FINE_GRAIN_BUFFER
| CL_DEVICE_SVM_ATOMICS);
err = create_cl_objects(
device, &find_targets_kernel[0], &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS);
context = contextWrapper;
if (err == 1)
return 0; // no devices capable of requested SVM level, so don't execute

View File

@@ -92,7 +92,7 @@ REGISTER_TEST(svm_migrate)
clProgramWrapper program;
cl_int error;
error = create_cl_objects(deviceID, &sources[0], &contextWrapper, &program,
error = create_cl_objects(device, &sources[0], &contextWrapper, &program,
&queues[0], &num_devices,
CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
@@ -202,7 +202,7 @@ REGISTER_TEST(svm_migrate)
// Check the event command type for clEnqueueSVMMigrateMem (OpenCL 3.0 and
// newer)
Version version = get_device_cl_version(deviceID);
Version version = get_device_cl_version(device);
if (version >= Version(3, 0))
{
cl_command_type commandType;

View File

@@ -43,7 +43,7 @@ REGISTER_TEST(svm_pointer_passing)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &SVMPointerPassing_test_kernel[0],
error = create_cl_objects(device, &SVMPointerPassing_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
@@ -127,10 +127,10 @@ REGISTER_TEST(svm_pointer_passing)
return -1;
}
}
}
error = clFinish(cmdq);
test_error(error, "clFinish failed");
error = clFinish(cmdq);
test_error(error, "clFinish failed");
}
}

View File

@@ -50,8 +50,11 @@ REGISTER_TEST(svm_set_kernel_exec_info_svm_ptrs)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
//error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN);
error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &c, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
// error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0],
// &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN);
error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0],
&c, &program, &queues[0], &num_devices,
CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(error == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(error < 0) return -1; // fail test.

View File

@@ -274,12 +274,12 @@ int shared_address_space_coarse_grain(cl_device_id deviceID, cl_context context2
REGISTER_TEST(svm_shared_address_space_coarse_grain_old_api)
{
return shared_address_space_coarse_grain(deviceID, context, queue,
return shared_address_space_coarse_grain(device, context, queue,
num_elements, CL_FALSE);
}
REGISTER_TEST(svm_shared_address_space_coarse_grain_new_api)
{
return shared_address_space_coarse_grain(deviceID, context, queue,
return shared_address_space_coarse_grain(device, context, queue,
num_elements, CL_TRUE);
}

View File

@@ -28,9 +28,9 @@ REGISTER_TEST(svm_shared_address_space_fine_grain)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(
deviceID, &linked_list_create_and_verify_kernels[0], &contextWrapper,
&program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM);
error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM);
context = contextWrapper;
if (error == 1)
return 0; // no devices capable of requested SVM level, so don't execute

View File

@@ -69,9 +69,9 @@ REGISTER_TEST(svm_shared_address_space_fine_grain_buffers)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(
deviceID, &linked_list_create_and_verify_kernels[0], &contextWrapper,
&program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
context = contextWrapper;
if (error == 1)
return 0; // no devices capable of requested SVM level, so don't execute

View File

@@ -133,7 +133,7 @@ REGISTER_TEST(svm_shared_sub_buffers)
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &shared_sub_buffers_test_kernel[0],
error = create_cl_objects(device, &shared_sub_buffers_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;

View File

@@ -272,48 +272,28 @@ int doTest(cl_device_id device, cl_context context, cl_command_queue queue,
return failure_counts;
}
int test_buffer(cl_device_id device, cl_context context, cl_command_queue queue,
int num_elements)
{
return doTest(device, context, queue, BUFFER);
}
int test_image2d_read(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(buffer) { return doTest(device, context, queue, BUFFER); }
REGISTER_TEST(image2d_read)
{
return doTest(device, context, queue, IMAGE_READ);
}
int test_image2d_write(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(image2d_write)
{
return doTest(device, context, queue, IMAGE_WRITE);
}
int test_buffer_non_blocking(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(buffer_non_blocking)
{
return doTest(device, context, queue, BUFFER_NON_BLOCKING);
}
int test_image2d_read_non_blocking(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(image2d_read_non_blocking)
{
return doTest(device, context, queue, IMAGE_READ_NON_BLOCKING);
}
int test_image2d_write_non_blocking(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(image2d_write_non_blocking)
{
return doTest(device, context, queue, IMAGE_WRITE_NON_BLOCKING);
}
test_definition test_list[] = {
ADD_TEST(buffer),
ADD_TEST(image2d_read),
ADD_TEST(image2d_write),
ADD_TEST(buffer_non_blocking),
ADD_TEST(image2d_read_non_blocking),
ADD_TEST(image2d_write_non_blocking),
};
const int test_num = ARRAY_SIZE(test_list);
int main(int argc, const char *argv[])
{
char *endPtr;
@@ -382,8 +362,9 @@ int main(int argc, const char *argv[])
}
}
int ret = runTestHarnessWithCheck(argCount, argList, test_num, test_list,
false, 0, init_cl);
int ret = runTestHarnessWithCheck(
argCount, argList, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0, init_cl);
free(argList);
return ret;
@@ -416,8 +397,8 @@ void printUsage(const char *execName)
"of the memory objects.\n");
log_info("\n");
log_info("Test names (Allocation Types):\n");
for (int i = 0; i < test_num; i++)
for (int i = 0; i < test_registry::getInstance().num_tests(); i++)
{
log_info("\t%s\n", test_list[i].name);
log_info("\t%s\n", test_registry::getInstance().definitions()[i].name);
}
}

View File

@@ -38,6 +38,7 @@ set(${MODULE_NAME}_SOURCES
test_queue_properties_queries.cpp
test_pipe_properties_queries.cpp
test_wg_suggested_local_work_size.cpp
test_device_command_queue.cpp
)
include(../CMakeCommon.txt)

View File

@@ -13,162 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "harness/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "procs.h"
#include "harness/testHarness.h"
#if !defined(_WIN32)
#include <unistd.h>
#endif
// FIXME: To use certain functions in harness/imageHelpers.h
// (for example, generate_random_image_data()), the tests are required to
// declare the following variables (<rdar://problem/11111245>):
test_definition test_list[] = {
ADD_TEST(get_platform_info),
ADD_TEST_VERSION(get_sampler_info, Version(2, 0)),
ADD_TEST(get_sampler_info_compatibility),
ADD_TEST_VERSION(get_command_queue_info, Version(2, 0)),
ADD_TEST(get_command_queue_info_compatibility),
ADD_TEST(get_context_info),
ADD_TEST(get_device_info),
ADD_TEST(enqueue_task),
ADD_TEST(binary_get),
ADD_TEST(binary_create),
ADD_TEST(kernel_required_group_size),
ADD_TEST(release_kernel_order),
ADD_TEST(release_during_execute),
ADD_TEST(load_single_kernel),
ADD_TEST(load_two_kernels),
ADD_TEST(load_two_kernels_in_one),
ADD_TEST(load_two_kernels_manually),
ADD_TEST(get_program_info_kernel_names),
ADD_TEST(get_kernel_arg_info),
ADD_TEST(create_kernels_in_program),
ADD_TEST(get_kernel_info),
ADD_TEST(kernel_private_memory_size),
ADD_TEST(execute_kernel_local_sizes),
ADD_TEST(set_kernel_arg_by_index),
ADD_TEST(set_kernel_arg_constant),
ADD_TEST(set_kernel_arg_struct_array),
ADD_TEST(kernel_global_constant),
ADD_TEST(kernel_attributes),
ADD_TEST(min_max_thread_dimensions),
ADD_TEST(min_max_work_items_sizes),
ADD_TEST(min_max_work_group_size),
ADD_TEST(min_max_read_image_args),
ADD_TEST(min_max_write_image_args),
ADD_TEST(min_max_mem_alloc_size),
ADD_TEST(min_max_image_2d_width),
ADD_TEST(min_max_image_2d_height),
ADD_TEST(min_max_image_3d_width),
ADD_TEST(min_max_image_3d_height),
ADD_TEST(min_max_image_3d_depth),
ADD_TEST(min_max_image_array_size),
ADD_TEST(min_max_image_buffer_size),
ADD_TEST(min_max_parameter_size),
ADD_TEST(min_max_samplers),
ADD_TEST(min_max_constant_buffer_size),
ADD_TEST(min_max_constant_args),
ADD_TEST(min_max_compute_units),
ADD_TEST(min_max_address_bits),
ADD_TEST(min_max_single_fp_config),
ADD_TEST(min_max_double_fp_config),
ADD_TEST(min_max_local_mem_size),
ADD_TEST(min_max_kernel_preferred_work_group_size_multiple),
ADD_TEST(min_max_execution_capabilities),
ADD_TEST(min_max_queue_properties),
ADD_TEST(min_max_device_version),
ADD_TEST(min_max_language_version),
ADD_TEST(kernel_arg_changes),
ADD_TEST(kernel_arg_multi_setup_random),
ADD_TEST(native_kernel),
ADD_TEST(create_context_from_type),
ADD_TEST(create_context_from_type_device_type_all),
ADD_TEST(create_context_from_type_device_type_default),
ADD_TEST(platform_extensions),
ADD_TEST(get_platform_ids),
ADD_TEST(bool_type),
ADD_TEST(repeated_setup_cleanup),
ADD_TEST(retain_queue_single),
ADD_TEST(retain_queue_multiple),
ADD_TEST(retain_mem_object_single),
ADD_TEST(retain_mem_object_multiple),
ADD_TEST(retain_mem_object_set_kernel_arg),
ADD_TEST(min_data_type_align_size_alignment),
ADD_TEST_VERSION(context_destructor_callback, Version(3, 0)),
ADD_TEST(mem_object_destructor_callback),
ADD_TEST(null_buffer_arg),
ADD_TEST(get_buffer_info),
ADD_TEST(get_image2d_info),
ADD_TEST(get_image3d_info),
ADD_TEST(get_image1d_info),
ADD_TEST(get_image1d_array_info),
ADD_TEST(get_image2d_array_info),
ADD_TEST(queue_flush_on_release),
ADD_TEST(queue_hint),
ADD_TEST(queue_properties),
ADD_TEST_VERSION(sub_group_dispatch, Version(2, 1)),
ADD_TEST_VERSION(clone_kernel, Version(2, 1)),
ADD_TEST_VERSION(zero_sized_enqueue, Version(2, 1)),
ADD_TEST_VERSION(buffer_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(image_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(queue_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(pipe_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(consistency_svm, Version(3, 0)),
ADD_TEST_VERSION(consistency_memory_model, Version(3, 0)),
ADD_TEST_VERSION(consistency_device_enqueue, Version(3, 0)),
ADD_TEST_VERSION(consistency_pipes, Version(3, 0)),
ADD_TEST_VERSION(consistency_progvar, Version(3, 0)),
ADD_TEST_VERSION(consistency_non_uniform_work_group, Version(3, 0)),
ADD_TEST_VERSION(consistency_read_write_images, Version(3, 0)),
ADD_TEST_VERSION(consistency_2d_image_from_buffer, Version(3, 0)),
ADD_TEST_VERSION(consistency_depth_images, Version(3, 0)),
ADD_TEST_VERSION(consistency_device_and_host_timer, Version(3, 0)),
ADD_TEST_VERSION(consistency_il_programs, Version(3, 0)),
ADD_TEST_VERSION(consistency_subgroups, Version(3, 0)),
ADD_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0)),
ADD_TEST_VERSION(consistency_3d_image_writes, Version(3, 0)),
ADD_TEST(consistency_requirements_fp64),
ADD_TEST(consistency_requirements_fp16),
ADD_TEST(min_image_formats),
ADD_TEST(set_command_queue_property),
ADD_TEST(negative_get_platform_info),
ADD_TEST(negative_get_platform_ids),
ADD_TEST(work_group_suggested_local_size_1D),
ADD_TEST(work_group_suggested_local_size_2D),
ADD_TEST(work_group_suggested_local_size_3D),
ADD_TEST(negative_create_command_queue),
ADD_TEST_VERSION(negative_create_command_queue_with_properties,
Version(2, 0)),
ADD_TEST(negative_create_command_queue_with_properties_khr),
ADD_TEST(kernel_local_memory_size),
};
const int test_num = ARRAY_SIZE(test_list);
int main(int argc, const char *argv[])
{
return runTestHarness(argc, argv, test_num, test_list, false, 0);
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0);
}

View File

@@ -16,8 +16,7 @@
#include "testBase.h"
int test_negative_get_platform_ids(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(negative_get_platform_ids)
{
cl_platform_id platform;
cl_int err = clGetPlatformIDs(0, &platform, nullptr);
@@ -37,10 +36,9 @@ int test_negative_get_platform_ids(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_negative_get_platform_info(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(negative_get_platform_info)
{
cl_platform_id platform = getPlatformFromDevice(deviceID);
cl_platform_id platform = getPlatformFromDevice(device);
constexpr cl_platform_info INVALID_PARAM_VALUE = 0;
cl_int err =

View File

@@ -16,12 +16,10 @@
#include "testBase.h"
#include "harness/typeWrappers.h"
int test_negative_create_command_queue(cl_device_id deviceID,
cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(negative_create_command_queue)
{
cl_command_queue_properties device_props = 0;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES,
cl_int error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");
@@ -40,7 +38,7 @@ int test_negative_create_command_queue(cl_device_id deviceID,
// code
cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_queue = clCreateCommandQueue(
context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &test_error);
context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &test_error);
test_failure_error_ret(
test_error, CL_INVALID_QUEUE_PROPERTIES,
@@ -52,18 +50,16 @@ int test_negative_create_command_queue(cl_device_id deviceID,
return TEST_PASS;
}
int test_negative_create_command_queue_with_properties(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST_VERSION(negative_create_command_queue_with_properties,
Version(2, 0))
{
cl_command_queue_properties device_props = 0;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES,
cl_int error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");
cl_command_queue_properties device_on_host_props = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
sizeof(device_on_host_props), &device_on_host_props,
NULL);
test_error(error,
@@ -97,7 +93,7 @@ int test_negative_create_command_queue_with_properties(cl_device_id deviceID,
cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_queue = clCreateCommandQueueWithProperties(
context, deviceID, queue_prop_def, &test_error);
context, device, queue_prop_def, &test_error);
test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES,
"clCreateCommandQueueWithProperties should "
@@ -110,17 +106,15 @@ int test_negative_create_command_queue_with_properties(cl_device_id deviceID,
return TEST_PASS;
}
int test_negative_create_command_queue_with_properties_khr(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements)
REGISTER_TEST(negative_create_command_queue_with_properties_khr)
{
if (!is_extension_available(deviceID, "cl_khr_create_command_queue"))
if (!is_extension_available(device, "cl_khr_create_command_queue"))
{
return TEST_SKIPPED_ITSELF;
}
cl_platform_id platform;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM,
cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(cl_platform_id), &platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed");
@@ -136,7 +130,7 @@ int test_negative_create_command_queue_with_properties_khr(
}
cl_command_queue_properties device_props = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");
@@ -160,7 +154,7 @@ int test_negative_create_command_queue_with_properties_khr(
cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_khr_queue =
clCreateCommandQueueWithPropertiesKHR(context, deviceID, queue_prop_def,
clCreateCommandQueueWithPropertiesKHR(context, device, queue_prop_def,
&test_error);
test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES,

View File

@@ -1,254 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "harness/errorHelpers.h"
#include "harness/kernelHelpers.h"
#include "harness/typeWrappers.h"
#include "harness/clImageHelper.h"
#include "harness/imageHelpers.h"
extern float calculate_ulperror(float a, float b);
extern int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_load_two_kernels_manually(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_platform_extensions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_platform_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_sampler_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_sampler_info_compatibility(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_command_queue_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_command_queue_info_compatibility(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_context_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_release_kernel_order(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_release_during_execute(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_kernel_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_private_memory_size(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_execute_kernel_local_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_by_index(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_struct(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_command_queue_property(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_work_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_read_image_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_write_image_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_parameter_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_samplers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_constant_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_compute_units(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_address_bits(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_single_fp_config(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_double_fp_config(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_kernel_preferred_work_group_size_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_execution_capabilities(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_queue_properties(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_device_version(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_language_version(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems );
extern int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_create_context_from_type_device_type_all(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_create_context_from_type_device_type_default(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements);
extern int test_get_platform_ids(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_arg_changes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_arg_multi_setup_random(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_queue_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_queue_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_mem_object_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_mem_object_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_mem_object_set_kernel_arg(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_data_type_align_size_alignment(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems );
extern int test_context_destructor_callback(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_mem_object_destructor_callback(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_null_buffer_arg( cl_device_id device_id, cl_context context, cl_command_queue queue, int num_elements );
extern int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image2d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image3d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image1d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image1d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image2d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_kernel_arg_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
extern int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_queue_properties( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
extern int test_queue_flush_on_release(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_buffer_properties_queries(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_image_properties_queries(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_queue_properties_queries(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
int test_pipe_properties_queries(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_svm(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_memory_model(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_device_enqueue(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_pipes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_progvar(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_non_uniform_work_group(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_read_write_images(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_depth_images(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_il_programs(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_prog_ctor_dtor(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_3d_image_writes(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_requirements_fp64(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_requirements_fp16(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_min_image_formats(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_kernel_local_memory_size(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_negative_get_platform_info(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_negative_get_platform_ids(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_kernel_attributes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_work_group_suggested_local_size_1D(cl_device_id device,
cl_context context,
cl_command_queue queue,
int n_elems);
extern int test_work_group_suggested_local_size_2D(cl_device_id device,
cl_context context,
cl_command_queue queue,
int n_elems);
extern int test_work_group_suggested_local_size_3D(cl_device_id device,
cl_context context,
cl_command_queue queue,
int n_elems);
extern int test_negative_create_command_queue(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_negative_create_command_queue_with_properties(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements);
extern int test_negative_create_command_queue_with_properties_khr(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements);

View File

@@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -17,15 +17,14 @@
#define _testBase_h
#include "harness/compat.h"
#include "harness/testHarness.h"
#include "harness/typeWrappers.h"
#include "harness/imageHelpers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#endif // _testBase_h

View File

@@ -25,8 +25,7 @@ __kernel void test(__global int* dst) {
}
)CLC";
int test_consistency_svm(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_svm, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_SVM_CAPABILITIES:
// May return 0, indicating that device does not support Shared Virtual
@@ -39,8 +38,8 @@ int test_consistency_svm(cl_device_id deviceID, cl_context context,
clKernelWrapper kernel;
cl_device_svm_capabilities svmCaps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES,
sizeof(svmCaps), &svmCaps, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES, sizeof(svmCaps),
&svmCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_SVM_CAPABILITIES");
if (svmCaps == 0)
@@ -202,13 +201,12 @@ static int check_atomic_capabilities(cl_device_atomic_capabilities atomicCaps,
return TEST_PASS;
}
int test_consistency_memory_model(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_memory_model, Version(3, 0))
{
cl_int error;
cl_device_atomic_capabilities atomicCaps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES,
error = clGetDeviceInfo(device, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES,
sizeof(atomicCaps), &atomicCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES");
@@ -221,7 +219,7 @@ int test_consistency_memory_model(cl_device_id deviceID, cl_context context,
return error;
}
error = clGetDeviceInfo(deviceID, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES,
error = clGetDeviceInfo(device, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES,
sizeof(atomicCaps), &atomicCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_ATOMIC_FENCE_CAPABILITIES");
@@ -238,8 +236,7 @@ int test_consistency_memory_model(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_device_enqueue, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES
// May return 0, indicating that device does not support Device-Side Enqueue
@@ -247,7 +244,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
cl_int error;
cl_device_device_enqueue_capabilities dseCaps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES,
error = clGetDeviceInfo(device, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES,
sizeof(dseCaps), &dseCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES");
@@ -258,7 +255,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
// On-Device Queues.
cl_command_queue_properties devQueueProps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
sizeof(devQueueProps), &devQueueProps, NULL);
test_error(error,
"Unable to query CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES");
@@ -278,7 +275,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
cl_uint u = 0;
error =
clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE,
clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE,
sizeof(u), &u, NULL);
test_error(error,
"Unable to query CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE");
@@ -287,7 +284,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
"but CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE "
"returned a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE");
test_assert_error(
@@ -295,7 +292,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 but "
"CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE returned a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_ON_DEVICE_QUEUES,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_QUEUES,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_ON_DEVICE_QUEUES");
test_assert_error(
@@ -303,7 +300,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 but "
"CL_DEVICE_MAX_ON_DEVICE_QUEUES returned a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_ON_DEVICE_EVENTS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_EVENTS,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_ON_DEVICE_EVENTS");
test_assert_error(
@@ -334,7 +331,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
// clSetDefaultDeviceCommandQueue
// Returns CL_INVALID_OPERATION if device does not support On-Device
// Queues.
error = clSetDefaultDeviceCommandQueue(context, deviceID, NULL);
error = clSetDefaultDeviceCommandQueue(context, device, NULL);
test_failure_error(error, CL_INVALID_OPERATION,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 "
"but clSetDefaultDeviceCommandQueue did not return "
@@ -347,7 +344,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
// clSetDefaultDeviceCommandQueue
// Returns CL_INVALID_OPERATION if device does not support a
// replaceable default On-Device Queue.
error = clSetDefaultDeviceCommandQueue(context, deviceID, NULL);
error = clSetDefaultDeviceCommandQueue(context, device, NULL);
test_failure_error(
error, CL_INVALID_OPERATION,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES did not "
@@ -371,9 +368,9 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
if ((dseCaps & CL_DEVICE_QUEUE_SUPPORTED) != 0)
{
cl_bool b;
error = clGetDeviceInfo(deviceID,
CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
error =
clGetDeviceInfo(device, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
test_error(
error,
"Unable to query CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT");
@@ -387,16 +384,15 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_pipes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_pipes, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_PIPE_SUPPORT
// May return CL_FALSE, indicating that device does not support Pipes.
cl_int error;
cl_bool pipeSupport = CL_FALSE;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_SUPPORT,
sizeof(pipeSupport), &pipeSupport, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PIPE_SUPPORT, sizeof(pipeSupport),
&pipeSupport, NULL);
test_error(error, "Unable to query CL_DEVICE_PIPE_SUPPORT");
if (pipeSupport == CL_FALSE)
@@ -409,16 +405,15 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
cl_uint u = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PIPE_ARGS, sizeof(u),
&u, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_PIPE_ARGS, sizeof(u), &u,
NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_PIPE_ARGS");
test_assert_error(u == 0,
"CL_DEVICE_PIPE_SUPPORT returned CL_FALSE, but "
"CL_DEVICE_MAX_PIPE_ARGS returned a non-zero value");
error =
clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS,
sizeof(u), &u, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS,
sizeof(u), &u, NULL);
test_error(error,
"Unable to query CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS");
test_assert_error(u == 0,
@@ -426,7 +421,7 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
"CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS returned "
"a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_PIPE_MAX_PACKET_SIZE");
test_assert_error(
@@ -461,9 +456,8 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
// Devices that support pipes must also return CL_TRUE
// for CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT.
cl_bool b;
error =
clGetDeviceInfo(deviceID, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
test_error(error,
"Unable to query CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT");
test_assert_error(
@@ -475,8 +469,7 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_progvar(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_progvar, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE
// May return 0, indicating that device does not support Program Scope
@@ -487,7 +480,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
clKernelWrapper kernel;
size_t maxGlobalVariableSize = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE,
sizeof(maxGlobalVariableSize),
&maxGlobalVariableSize, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE");
@@ -506,7 +499,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
// CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE
// Returns 0 if device does not support Program Scope Global Variables.
error = clGetDeviceInfo(deviceID,
error = clGetDeviceInfo(device,
CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE,
sizeof(sz), &sz, NULL);
test_error(
@@ -523,7 +516,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
// Returns 0 if device does not support Program Scope Global Variables.
error = clGetProgramBuildInfo(
program, deviceID, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE,
program, device, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE,
sizeof(sz), &sz, NULL);
test_error(
error,
@@ -537,10 +530,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_non_uniform_work_group(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST_VERSION(consistency_non_uniform_work_group, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT:
// May return CL_FALSE, indicating that device does not support Non-Uniform
@@ -553,7 +543,7 @@ int test_consistency_non_uniform_work_group(cl_device_id deviceID,
clKernelWrapper kernel;
cl_bool nonUniformWorkGroupSupport = CL_FALSE;
error = clGetDeviceInfo(deviceID, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT,
error = clGetDeviceInfo(device, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT,
sizeof(nonUniformWorkGroupSupport),
&nonUniformWorkGroupSupport, NULL);
test_error(error,
@@ -620,9 +610,7 @@ int test_consistency_non_uniform_work_group(cl_device_id deviceID,
return TEST_PASS;
}
int test_consistency_read_write_images(cl_device_id deviceID,
cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_read_write_images, Version(3, 0))
{
// clGetDeviceInfo, passing
// CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS May return 0,
@@ -630,7 +618,7 @@ int test_consistency_read_write_images(cl_device_id deviceID,
cl_int error;
cl_uint maxReadWriteImageArgs = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS,
sizeof(maxReadWriteImageArgs),
&maxReadWriteImageArgs, NULL);
test_error(error,
@@ -683,10 +671,7 @@ int test_consistency_read_write_images(cl_device_id deviceID,
return TEST_PASS;
}
int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST_VERSION(consistency_2d_image_from_buffer, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_IMAGE_PITCH_ALIGNMENT or
// CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT
@@ -703,7 +688,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
clMemWrapper image;
cl_uint imagePitchAlignment = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
sizeof(imagePitchAlignment), &imagePitchAlignment,
NULL);
test_error(error,
@@ -711,7 +696,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
"CL_DEVICE_IMAGE_PITCH_ALIGNMENT");
cl_uint imageBaseAddressAlignment = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
sizeof(imageBaseAddressAlignment),
&imageBaseAddressAlignment, NULL);
test_error(error,
@@ -719,7 +704,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
"CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT");
bool supports_cl_khr_image2d_from_buffer =
is_extension_available(deviceID, "cl_khr_image2d_from_buffer");
is_extension_available(device, "cl_khr_image2d_from_buffer");
if (imagePitchAlignment == 0 || imageBaseAddressAlignment == 0)
{
@@ -790,8 +775,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
// All of the sRGB Image Channel Orders (such as CL_sRGBA) are optional for
// devices supporting OpenCL 3.0.
int test_consistency_depth_images(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_depth_images, Version(3, 0))
{
// The CL_DEPTH Image Channel Order is optional for devices supporting
// OpenCL 3.0.
@@ -830,7 +814,7 @@ int test_consistency_depth_images(cl_device_id deviceID, cl_context context,
}
bool supports_cl_khr_depth_images =
is_extension_available(deviceID, "cl_khr_depth_images");
is_extension_available(device, "cl_khr_depth_images");
if (totalDepthImageFormats == 0)
{
@@ -848,10 +832,7 @@ int test_consistency_depth_images(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST_VERSION(consistency_device_and_host_timer, Version(3, 0))
{
// clGetPlatformInfo, passing CL_PLATFORM_HOST_TIMER_RESOLUTION
// May return 0, indicating that platform does not support Device and Host
@@ -859,7 +840,7 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_int error;
cl_platform_id platform = NULL;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform),
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "Unable to query CL_DEVICE_PLATFORM");
@@ -878,13 +859,13 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_ulong dt = 0;
cl_ulong ht = 0;
error = clGetDeviceAndHostTimer(deviceID, &dt, &ht);
error = clGetDeviceAndHostTimer(device, &dt, &ht);
test_failure_error(
error, CL_INVALID_OPERATION,
"CL_PLATFORM_HOST_TIMER_RESOLUTION returned 0 but "
"clGetDeviceAndHostTimer did not return CL_INVALID_OPERATION");
error = clGetHostTimer(deviceID, &ht);
error = clGetHostTimer(device, &ht);
test_failure_error(
error, CL_INVALID_OPERATION,
"CL_PLATFORM_HOST_TIMER_RESOLUTION returned 0 but "
@@ -894,8 +875,7 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID,
return TEST_PASS;
}
int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_il_programs, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_IL_VERSION or
// CL_DEVICE_ILS_WITH_VERSION
@@ -909,14 +889,14 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
// Even if the device does not support Intermediate Language Programs the
// size of the string query should not be zero.
size_t sz = SIZE_MAX;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IL_VERSION, 0, NULL, &sz);
error = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &sz);
test_error(error, "Unable to query CL_DEVICE_IL_VERSION");
test_assert_error(sz != 0,
"CL_DEVICE_IL_VERSION should return a non-zero size");
std::string ilVersion = get_device_il_version_string(deviceID);
std::string ilVersion = get_device_il_version_string(device);
error = clGetDeviceInfo(deviceID, CL_DEVICE_ILS_WITH_VERSION, 0, NULL, &sz);
error = clGetDeviceInfo(device, CL_DEVICE_ILS_WITH_VERSION, 0, NULL, &sz);
test_error(error, "Unable to query CL_DEVICE_ILS_WITH_VERSION");
if (ilVersion == "" || sz == 0)
@@ -935,7 +915,7 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
"but CL_DEVICE_IL_VERSION returned an empty string");
bool supports_cl_khr_il_program =
is_extension_available(deviceID, "cl_khr_il_program");
is_extension_available(device, "cl_khr_il_program");
test_assert_error(supports_cl_khr_il_program == false,
"Device does not support IL Programs but does "
"support cl_khr_il_program");
@@ -985,8 +965,7 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_subgroups, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_MAX_NUM_SUB_GROUPS
// May return 0, indicating that device does not support Subgroups.
@@ -996,7 +975,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
clKernelWrapper kernel;
cl_uint maxNumSubGroups = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_NUM_SUB_GROUPS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_NUM_SUB_GROUPS,
sizeof(maxNumSubGroups), &maxNumSubGroups, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_NUM_SUB_GROUPS");
@@ -1014,7 +993,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
cl_bool ifp = CL_FALSE;
error = clGetDeviceInfo(
deviceID, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
device, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
sizeof(ifp), &ifp, NULL);
test_error(
error,
@@ -1029,7 +1008,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
// device does not support Subgroups.
bool supports_cl_khr_subgroups =
is_extension_available(deviceID, "cl_khr_subgroups");
is_extension_available(device, "cl_khr_subgroups");
test_assert_error(supports_cl_khr_subgroups == false,
"Device does not support Subgroups but does "
"support cl_khr_subgroups");
@@ -1038,7 +1017,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
// Returns CL_INVALID_OPERATION if device does not support Subgroups.
size_t sz = SIZE_MAX;
error = clGetKernelSubGroupInfo(kernel, deviceID,
error = clGetKernelSubGroupInfo(kernel, device,
CL_KERNEL_MAX_NUM_SUB_GROUPS, 0, NULL,
sizeof(sz), &sz, NULL);
test_failure_error(
@@ -1052,8 +1031,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
static void CL_CALLBACK program_callback(cl_program, void*) {}
int test_consistency_prog_ctor_dtor(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0))
{
cl_int error;
@@ -1099,8 +1077,7 @@ int test_consistency_prog_ctor_dtor(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_3d_image_writes, Version(3, 0))
{
// clGetSupportedImageFormats, passing CL_MEM_OBJECT_IMAGE3D and one of
// CL_MEM_WRITE_ONLY, CL_MEM_READ_WRITE, or CL_MEM_KERNEL_READ_AND_WRITE
@@ -1131,7 +1108,7 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context,
}
bool supports_cl_khr_3d_image_writes =
is_extension_available(deviceID, "cl_khr_3d_image_writes");
is_extension_available(device, "cl_khr_3d_image_writes");
if (total3DImageWriteFormats == 0)
{
@@ -1152,18 +1129,16 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_requirements_fp64(cl_device_id deviceID,
cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(consistency_requirements_fp64)
{
cl_int error = CL_SUCCESS;
cl_device_fp_config value = 0;
if (is_extension_available(deviceID, "cl_khr_fp64"))
if (is_extension_available(device, "cl_khr_fp64"))
{
const Version version = get_device_cl_version(deviceID);
const Version version = get_device_cl_version(device);
error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG,
error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG,
sizeof(value), &value, nullptr);
test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG");
test_assert_error(
@@ -1187,9 +1162,8 @@ int test_consistency_requirements_fp64(cl_device_id deviceID,
"for OpenCL 2.0 or newer devices");
}
error =
clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(
error,
"Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE");
@@ -1197,7 +1171,7 @@ int test_consistency_requirements_fp64(cl_device_id deviceID,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return "
"nonzero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE");
@@ -1207,15 +1181,14 @@ int test_consistency_requirements_fp64(cl_device_id deviceID,
}
else
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG,
error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG,
sizeof(value), &value, nullptr);
test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG");
test_assert_error(value == 0,
"CL_DEVICE_DOUBLE_FP_CONFIG must return 0");
error =
clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(
error,
"Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE");
@@ -1223,7 +1196,7 @@ int test_consistency_requirements_fp64(cl_device_id deviceID,
value == 0,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return 0");
error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE");
@@ -1234,17 +1207,15 @@ int test_consistency_requirements_fp64(cl_device_id deviceID,
return TEST_PASS;
}
int test_consistency_requirements_fp16(cl_device_id deviceID,
cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(consistency_requirements_fp16)
{
cl_int error = CL_SUCCESS;
cl_device_fp_config value = 0;
if (is_extension_available(deviceID, "cl_khr_fp16"))
if (is_extension_available(device, "cl_khr_fp16"))
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_HALF_FP_CONFIG,
sizeof(value), &value, nullptr);
error = clGetDeviceInfo(device, CL_DEVICE_HALF_FP_CONFIG, sizeof(value),
&value, nullptr);
test_error(error, "Unable to get device CL_DEVICE_HALF_FP_CONFIG");
test_assert_error(value > 0,
"CL_DEVICE_HALF_FP_CONFIG must return nonzero value");
@@ -1253,7 +1224,7 @@ int test_consistency_requirements_fp16(cl_device_id deviceID,
|| (value & CL_FP_ROUND_TO_ZERO),
"Reported half fp config doesn't meet minimum set");
error = clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF,
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(
error,
@@ -1262,7 +1233,7 @@ int test_consistency_requirements_fp16(cl_device_id deviceID,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return "
"nonzero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF,
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF");
@@ -1272,14 +1243,14 @@ int test_consistency_requirements_fp16(cl_device_id deviceID,
}
else
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_HALF_FP_CONFIG,
sizeof(value), &value, nullptr);
error = clGetDeviceInfo(device, CL_DEVICE_HALF_FP_CONFIG, sizeof(value),
&value, nullptr);
test_failure_error(
error, CL_INVALID_VALUE,
"cl_khr_fp16 is not available; CL_DEVICE_HALF_FP_CONFIG must fail "
"with CL_INVALID_VALUE");
error = clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF,
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(
error,
@@ -1288,7 +1259,7 @@ int test_consistency_requirements_fp16(cl_device_id deviceID,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return "
"0");
error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF,
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF");

View File

@@ -115,8 +115,7 @@ const char *sample_const_max_arg_kernel_pattern =
#define MAX_REDUCTION_FACTOR 4
int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_thread_dimensions)
{
int error, retVal;
unsigned int maxThreadDim, threadDim, i;
@@ -129,7 +128,7 @@ int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context,
/* Get the max thread dimensions */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
sizeof(maxThreadDim), &maxThreadDim, NULL);
test_error(error, "Unable to get max work item dimensions from device");
@@ -202,22 +201,21 @@ int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context,
}
int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_work_items_sizes)
{
int error;
size_t *deviceMaxWorkItemSize;
unsigned int maxWorkItemDim;
/* Get the max work item dimensions */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
sizeof(maxWorkItemDim), &maxWorkItemDim, NULL);
test_error(error, "Unable to get max work item dimensions from device");
log_info("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS returned %d\n",
maxWorkItemDim);
deviceMaxWorkItemSize = (size_t *)malloc(sizeof(size_t) * maxWorkItemDim);
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_SIZES,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES,
sizeof(size_t) * maxWorkItemDim,
deviceMaxWorkItemSize, NULL);
test_error(error, "clDeviceInfo for CL_DEVICE_MAX_WORK_ITEM_SIZES failed");
@@ -246,14 +244,13 @@ int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context,
}
int test_min_max_work_group_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_work_group_size)
{
int error;
size_t deviceMaxThreadSize;
/* Get the max thread dimensions */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_GROUP_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE,
sizeof(deviceMaxThreadSize), &deviceMaxThreadSize,
NULL);
test_error(error, "Unable to get max work group size from device");
@@ -268,8 +265,7 @@ int test_min_max_work_group_size(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_read_image_args(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_read_image_args)
{
int error;
unsigned int maxReadImages, i;
@@ -290,12 +286,12 @@ int test_min_max_read_image_args(cl_device_id deviceID, cl_context context,
cl_uint minRequiredReadImages = gIsEmbedded ? 8 : 128;
cl_device_type deviceType;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
image_format_desc.image_channel_order = CL_RGBA;
image_format_desc.image_channel_data_type = CL_FLOAT;
/* Get the max read image arg count */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_READ_IMAGE_ARGS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_READ_IMAGE_ARGS,
sizeof(maxReadImages), &maxReadImages, NULL);
test_error(error, "Unable to get max read image arg count from device");
@@ -310,19 +306,19 @@ int test_min_max_read_image_args(cl_device_id deviceID, cl_context context,
log_info("Reported %d max read image args.\n", maxReadImages);
error =
clGetDeviceInfo(deviceID, CL_DEVICE_ADDRESS_BITS,
clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS,
sizeof(deviceAddressSize), &deviceAddressSize, NULL);
test_error(error, "Unable to query CL_DEVICE_ADDRESS_BITS for device");
deviceAddressSize /= 8; // convert from bits to bytes
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE,
sizeof(maxParameterSize), &maxParameterSize, NULL);
test_error(error, "Unable to get max parameter size from device");
if (!gIsEmbedded && maxReadImages >= 128 && maxParameterSize == 1024)
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(deviceType),
error = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(deviceType),
&deviceType, NULL);
test_error(error, "Unable to get device type from device");
@@ -434,8 +430,7 @@ int test_min_max_read_image_args(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_write_image_args(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_write_image_args)
{
int error;
unsigned int maxWriteImages, i;
@@ -452,12 +447,12 @@ int test_min_max_write_image_args(cl_device_id deviceID, cl_context context,
cl_uint minRequiredWriteImages = gIsEmbedded ? 1 : 8;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
image_format_desc.image_channel_order = CL_RGBA;
image_format_desc.image_channel_data_type = CL_UNORM_INT8;
/* Get the max read image arg count */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WRITE_IMAGE_ARGS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WRITE_IMAGE_ARGS,
sizeof(maxWriteImages), &maxWriteImages, NULL);
test_error(error, "Unable to get max write image arg count from device");
@@ -480,7 +475,7 @@ int test_min_max_write_image_args(cl_device_id deviceID, cl_context context,
log_info("Reported %d max write image args.\n", maxWriteImages);
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE,
sizeof(maxParameterSize), &maxParameterSize, NULL);
test_error(error, "Unable to get max parameter size from device");
@@ -563,8 +558,7 @@ int test_min_max_write_image_args(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_mem_alloc_size)
{
int error;
cl_ulong maxAllocSize, memSize, minSizeToTry, currentSize;
@@ -580,9 +574,9 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context,
/* Get the max mem alloc size, limit the alloc to half of the available
* memory */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
memSize = get_device_info_global_mem_size(deviceID,
MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
memSize =
get_device_info_global_mem_size(device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if (memSize < maxAllocSize)
{
@@ -635,8 +629,7 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context,
return -1;
}
int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_image_2d_width)
{
int error;
size_t maxDimension;
@@ -645,9 +638,9 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context,
cl_ulong maxAllocSize;
cl_uint minRequiredDimension;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
auto version = get_device_cl_version(deviceID);
auto version = get_device_cl_version(device);
if (version == Version(1, 0))
{
minRequiredDimension = gIsEmbedded ? 2048 : 4096;
@@ -664,7 +657,7 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context,
test_error(error, "Unable to obtain suitable image format to test with!");
/* Get the max 2d image width */
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE2D_MAX_WIDTH,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH,
sizeof(maxDimension), &maxDimension, NULL);
test_error(error, "Unable to get max image 2d width from device");
@@ -689,7 +682,7 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context,
/* Verify that we can actually allocate an image that large */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
{
log_error("Can not allocate a large enough image (min size: %" PRIu64
@@ -713,8 +706,7 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_image_2d_height)
{
int error;
size_t maxDimension;
@@ -723,9 +715,9 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context,
cl_ulong maxAllocSize;
cl_uint minRequiredDimension;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
auto version = get_device_cl_version(deviceID);
auto version = get_device_cl_version(device);
if (version == Version(1, 0))
{
minRequiredDimension = gIsEmbedded ? 2048 : 4096;
@@ -741,7 +733,7 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context,
test_error(error, "Unable to obtain suitable image format to test with!");
/* Get the max 2d image width */
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
sizeof(maxDimension), &maxDimension, NULL);
test_error(error, "Unable to get max image 2d height from device");
@@ -766,7 +758,7 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context,
/* Verify that we can actually allocate an image that large */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
{
log_error("Can not allocate a large enough image (min size: %" PRIu64
@@ -790,8 +782,7 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_image_3d_width)
{
int error;
size_t maxDimension;
@@ -800,7 +791,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context,
cl_ulong maxAllocSize;
PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device)
/* Just get any ol format to test with */
error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE3D,
@@ -808,7 +799,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context,
test_error(error, "Unable to obtain suitable image format to test with!");
/* Get the max 2d image width */
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE3D_MAX_WIDTH,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_WIDTH,
sizeof(maxDimension), &maxDimension, NULL);
test_error(error, "Unable to get max image 3d width from device");
@@ -833,7 +824,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context,
/* Verify that we can actually allocate an image that large */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize)
{
log_error("Can not allocate a large enough image (min size: %" PRIu64
@@ -858,8 +849,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_image_3d_height)
{
int error;
size_t maxDimension;
@@ -868,7 +858,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context,
cl_ulong maxAllocSize;
PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device)
/* Just get any ol format to test with */
error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE3D,
@@ -876,7 +866,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context,
test_error(error, "Unable to obtain suitable image format to test with!");
/* Get the max 2d image width */
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE3D_MAX_HEIGHT,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_HEIGHT,
sizeof(maxDimension), &maxDimension, NULL);
test_error(error, "Unable to get max image 3d height from device");
@@ -901,7 +891,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context,
/* Verify that we can actually allocate an image that large */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize)
{
log_error("Can not allocate a large enough image (min size: %" PRIu64
@@ -927,8 +917,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context,
}
int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_image_3d_depth)
{
int error;
size_t maxDimension;
@@ -937,7 +926,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context,
cl_ulong maxAllocSize;
PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device)
/* Just get any ol format to test with */
error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE3D,
@@ -945,7 +934,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context,
test_error(error, "Unable to obtain suitable image format to test with!");
/* Get the max 2d image width */
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE3D_MAX_DEPTH,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH,
sizeof(maxDimension), &maxDimension, NULL);
test_error(error, "Unable to get max image 3d depth from device");
@@ -970,7 +959,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context,
/* Verify that we can actually allocate an image that large */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
{
log_error("Can not allocate a large enough image (min size: %" PRIu64
@@ -994,8 +983,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_image_array_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_image_array_size)
{
int error;
size_t maxDimension;
@@ -1004,7 +992,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context,
cl_ulong maxAllocSize;
size_t minRequiredDimension = gIsEmbedded ? 256 : 2048;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID);
PASSIVE_REQUIRE_IMAGE_SUPPORT(device);
/* Just get any ol format to test with */
error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE2D_ARRAY,
@@ -1012,7 +1000,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context,
test_error(error, "Unable to obtain suitable image format to test with!");
/* Get the max image array width */
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE,
sizeof(maxDimension), &maxDimension, NULL);
test_error(error, "Unable to get max image array size from device");
@@ -1038,7 +1026,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context,
/* Verify that we can actually allocate an image that large */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize)
{
log_error("Can not allocate a large enough image (min size: %" PRIu64
@@ -1064,8 +1052,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_image_buffer_size)
{
int error;
size_t maxDimensionPixels;
@@ -1076,15 +1063,15 @@ int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context,
unsigned int i = 0;
size_t pixelBytes = 0;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID);
PASSIVE_REQUIRE_IMAGE_SUPPORT(device);
/* Get the max memory allocation size, divide it */
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
/* Get the max image array width */
error =
clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE,
clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE,
sizeof(maxDimensionPixels), &maxDimensionPixels, NULL);
test_error(error, "Unable to get max image buffer size from device");
@@ -1154,8 +1141,7 @@ int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context,
}
int test_min_max_parameter_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_parameter_size)
{
int error, i;
size_t maxSize;
@@ -1174,7 +1160,7 @@ int test_min_max_parameter_size(cl_device_id deviceID, cl_context context,
/* Get the max param size */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE,
sizeof(maxSize), &maxSize, NULL);
test_error(error, "Unable to get max parameter size from device");
@@ -1407,8 +1393,7 @@ int test_min_max_parameter_size(cl_device_id deviceID, cl_context context,
return -1;
}
int test_min_max_samplers(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_samplers)
{
int error;
cl_uint maxSamplers, i;
@@ -1421,11 +1406,11 @@ int test_min_max_samplers(cl_device_id deviceID, cl_context context,
cl_uint minRequiredSamplers = gIsEmbedded ? 8 : 16;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
/* Get the max value */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_SAMPLERS,
sizeof(maxSamplers), &maxSamplers, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_SAMPLERS, sizeof(maxSamplers),
&maxSamplers, NULL);
test_error(error, "Unable to get max sampler count from device");
if (maxSamplers < minRequiredSamplers)
@@ -1438,7 +1423,7 @@ int test_min_max_samplers(cl_device_id deviceID, cl_context context,
log_info("Reported max %d samplers.\n", maxSamplers);
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE,
sizeof(maxParameterSize), &maxParameterSize, NULL);
test_error(error, "Unable to get max parameter size from device");
@@ -1531,8 +1516,7 @@ int test_min_max_samplers(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_constant_buffer_size)
{
int error;
clProgramWrapper program;
@@ -1547,7 +1531,7 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
/* Verify our test buffer won't be bigger than allowed */
maxSize = get_device_info_max_constant_buffer_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if ((0 == gIsEmbedded
&& (maxSize * MAX_DEVICE_MEMORY_SIZE_DIVISOR) < 64L * 1024L)
@@ -1564,12 +1548,12 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
/* We have four buffers allocations */
maxGlobalSize = get_device_info_global_mem_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR * 4);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR * 4);
if (maxSize > maxGlobalSize) maxSize = maxGlobalSize;
maxAllocSize = get_device_info_max_mem_alloc_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if (maxSize > maxAllocSize) maxSize = maxAllocSize;
@@ -1731,8 +1715,7 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context,
return -1;
}
int test_min_max_constant_args(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_constant_args)
{
int error;
clProgramWrapper program;
@@ -1751,11 +1734,11 @@ int test_min_max_constant_args(cl_device_id deviceID, cl_context context,
/* Verify our test buffer won't be bigger than allowed */
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_CONSTANT_ARGS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_CONSTANT_ARGS,
sizeof(maxArgs), &maxArgs, 0);
test_error(error, "Unable to get max constant arg count");
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE,
sizeof(maxParameterSize), &maxParameterSize, NULL);
test_error(error, "Unable to get max parameter size from device");
@@ -1782,7 +1765,7 @@ int test_min_max_constant_args(cl_device_id deviceID, cl_context context,
}
maxSize = get_device_info_max_constant_buffer_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
individualBufferSize = ((int)maxSize / 2) / maxArgs;
log_info("Reported max constant arg count of %u and max constant buffer "
@@ -1873,15 +1856,14 @@ int test_min_max_constant_args(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_compute_units(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_compute_units)
{
int error;
cl_uint value;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(value), &value, 0);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(value),
&value, 0);
test_error(error, "Unable to get compute unit count");
if (value < 1)
@@ -1897,14 +1879,13 @@ int test_min_max_compute_units(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_address_bits(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_address_bits)
{
int error;
cl_uint value;
error = clGetDeviceInfo(deviceID, CL_DEVICE_ADDRESS_BITS, sizeof(value),
error = clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(value),
&value, 0);
test_error(error, "Unable to get address bit count");
@@ -1921,19 +1902,18 @@ int test_min_max_address_bits(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_single_fp_config(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_single_fp_config)
{
int error;
cl_device_fp_config value;
char profile[128] = "";
error = clGetDeviceInfo(deviceID, CL_DEVICE_SINGLE_FP_CONFIG, sizeof(value),
error = clGetDeviceInfo(device, CL_DEVICE_SINGLE_FP_CONFIG, sizeof(value),
&value, 0);
test_error(error, "Unable to get device single fp config");
// Check to see if we are an embedded profile device
if ((error = clGetDeviceInfo(deviceID, CL_DEVICE_PROFILE, sizeof(profile),
if ((error = clGetDeviceInfo(device, CL_DEVICE_PROFILE, sizeof(profile),
profile, NULL)))
{
log_error("FAILURE: Unable to get CL_DEVICE_PROFILE: error %d\n",
@@ -1965,13 +1945,12 @@ int test_min_max_single_fp_config(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_double_fp_config(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_double_fp_config)
{
int error;
cl_device_fp_config value;
error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(value),
error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(value),
&value, 0);
test_error(error, "Unable to get device double fp config");
@@ -1991,8 +1970,7 @@ int test_min_max_double_fp_config(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_local_mem_size)
{
int error;
clProgramWrapper program;
@@ -2007,13 +1985,13 @@ int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context,
MTdata d;
/* Verify our test buffer won't be bigger than allowed */
error = clGetDeviceInfo(deviceID, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(maxSize),
error = clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(maxSize),
&maxSize, 0);
test_error(error, "Unable to get max local buffer size");
try
{
device_version = get_device_cl_version(deviceID);
device_version = get_device_cl_version(device);
} catch (const std::runtime_error &e)
{
log_error("%s", e.what());
@@ -2052,7 +2030,7 @@ int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context,
return -1;
}
error = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE,
error = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_LOCAL_MEM_SIZE,
sizeof(kernelLocalUsage),
&kernelLocalUsage, NULL);
test_error(error,
@@ -2142,9 +2120,7 @@ int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context,
return err;
}
int test_min_max_kernel_preferred_work_group_size_multiple(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements)
REGISTER_TEST(min_max_kernel_preferred_work_group_size_multiple)
{
int err;
clProgramWrapper program;
@@ -2157,17 +2133,17 @@ int test_min_max_kernel_preferred_work_group_size_multiple(
sample_local_arg_kernel, "sample_test");
test_error(err, "Failed to build kernel/program.");
err = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_WORK_GROUP_SIZE,
err = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_WORK_GROUP_SIZE,
sizeof(max_workgroup_size),
&max_workgroup_size, NULL);
test_error(err, "clGetKernelWorkgroupInfo failed.");
err = clGetKernelWorkGroupInfo(
kernel, deviceID, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE,
kernel, device, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE,
sizeof(preferred_workgroup_size), &preferred_workgroup_size, NULL);
test_error(err, "clGetKernelWorkgroupInfo failed.");
err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_SIZES,
err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES,
sizeof(max_local_workgroup_size),
max_local_workgroup_size, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_MAX_WORK_ITEM_SIZES");
@@ -2188,16 +2164,13 @@ int test_min_max_kernel_preferred_work_group_size_multiple(
return 0;
}
int test_min_max_execution_capabilities(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST(min_max_execution_capabilities)
{
int error;
cl_device_exec_capabilities value;
error = clGetDeviceInfo(deviceID, CL_DEVICE_EXECUTION_CAPABILITIES,
error = clGetDeviceInfo(device, CL_DEVICE_EXECUTION_CAPABILITIES,
sizeof(value), &value, 0);
test_error(error, "Unable to get execution capabilities");
@@ -2211,14 +2184,13 @@ int test_min_max_execution_capabilities(cl_device_id deviceID,
return 0;
}
int test_min_max_queue_properties(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_queue_properties)
{
int error;
cl_command_queue_properties value;
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
sizeof(value), &value, 0);
test_error(error, "Unable to get queue properties");
@@ -2232,11 +2204,10 @@ int test_min_max_queue_properties(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_device_version(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_device_version)
{
// Query for the device version.
Version device_cl_version = get_device_cl_version(deviceID);
Version device_cl_version = get_device_cl_version(device);
log_info("Returned version %s.\n", device_cl_version.to_string().c_str());
// Make sure 2.x devices support required extensions for 2.x
@@ -2264,7 +2235,7 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context,
"devices...\n");
for (size_t i = 0; i < ARRAY_SIZE(requiredExtensions11); i++)
{
if (!is_extension_available(deviceID, requiredExtensions11[i]))
if (!is_extension_available(device, requiredExtensions11[i]))
{
log_error("ERROR: Required extension for 1.1 and greater "
"devices is not in extension string: %s\n",
@@ -2283,13 +2254,13 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context,
// cl_khr_fp64 and it is only required if double precision is
// supported.
cl_device_fp_config doubles_supported;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG,
cl_int error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG,
sizeof(doubles_supported),
&doubles_supported, 0);
test_error(error, "Unable to get device double fp config");
if (doubles_supported)
{
if (!is_extension_available(deviceID, "cl_khr_fp64"))
if (!is_extension_available(device, "cl_khr_fp64"))
{
log_error(
"ERROR: Required extension for 1.2 and greater devices "
@@ -2309,7 +2280,7 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context,
"2.2 devices...\n");
for (size_t i = 0; i < ARRAY_SIZE(requiredExtensions2x); i++)
{
if (!is_extension_available(deviceID, requiredExtensions2x[i]))
if (!is_extension_available(device, requiredExtensions2x[i]))
{
log_error("ERROR: Required extension for 2.0, 2.1 and 2.2 "
"devices is not in extension string: %s\n",
@@ -2329,16 +2300,15 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context,
return 0;
}
int test_min_max_language_version(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_max_language_version)
{
cl_int error;
cl_char buffer[4098];
size_t length;
// Device version should fit the regex "OpenCL [0-9]+\.[0-9]+ *.*"
error = clGetDeviceInfo(deviceID, CL_DEVICE_OPENCL_C_VERSION,
sizeof(buffer), buffer, &length);
error = clGetDeviceInfo(device, CL_DEVICE_OPENCL_C_VERSION, sizeof(buffer),
buffer, &length);
test_error(error, "Unable to get device opencl c version string");
if (memcmp(buffer, "OpenCL C ", strlen("OpenCL C ")) != 0)
{

View File

@@ -25,7 +25,7 @@ static const char *sample_binary_kernel_source[] = {
"}\n" };
int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(binary_get)
{
int error;
clProgramWrapper program;
@@ -71,7 +71,7 @@ int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue
}
int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(binary_create)
{
/* To test this in a self-contained fashion, we have to create a program with
source, then get the binary, then use that binary to reload the program, and then verify */
@@ -103,12 +103,13 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que
test_error( error, "Unable to get program binary" );
cl_int loadErrors[ 1 ];
program_from_binary = clCreateProgramWithBinary( context, 1, &deviceID, &binarySize, buffers, loadErrors, &error );
program_from_binary = clCreateProgramWithBinary(
context, 1, &device, &binarySize, buffers, loadErrors, &error);
test_error( error, "Unable to load valid program binary" );
test_error( loadErrors[ 0 ], "Unable to load valid device binary into program" );
error = clBuildProgram( program_from_binary, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build binary program" );
error = clBuildProgram(program_from_binary, 1, &device, NULL, NULL, NULL);
test_error(error, "Unable to build binary program");
// Get the size of the binary built from the first binary
size_t binary2Size;
@@ -123,10 +124,11 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que
// Try again, this time without passing the status ptr in, to make sure we still
// get a valid binary
clProgramWrapper programWithoutStatus = clCreateProgramWithBinary( context, 1, &deviceID, &binary2Size, buffers, NULL, &error );
clProgramWrapper programWithoutStatus = clCreateProgramWithBinary(
context, 1, &device, &binary2Size, buffers, NULL, &error);
test_error( error, "Unable to load valid program binary when binary_status pointer is NULL" );
error = clBuildProgram( programWithoutStatus, 1, &deviceID, NULL, NULL, NULL );
error = clBuildProgram(programWithoutStatus, 1, &device, NULL, NULL, NULL);
test_error( error, "Unable to build binary program created without binary_status" );
// Get the size of the binary created without passing binary_status
@@ -214,5 +216,3 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que
free(out_data_binary);
return 0;
}

View File

@@ -35,7 +35,7 @@ const char *kernel_with_bool[] = {
"}\n"
};
int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(bool_type)
{
clProgramWrapper program;
@@ -48,4 +48,3 @@ int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue q
"kernel_with_bool" );
return err;
}

View File

@@ -92,7 +92,9 @@ struct structArg
float f;
};
int test_image_arg_shallow_clone(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, void* pbufRes, clMemWrapper& bufOut)
int test_image_arg_shallow_clone(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements,
void* pbufRes, clMemWrapper& bufOut)
{
int error;
cl_image_format img_format;
@@ -191,7 +193,9 @@ int test_image_arg_shallow_clone(cl_device_id deviceID, cl_context context, cl_c
return 0;
}
int test_double_arg_clone(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, void* pbufRes, clMemWrapper& bufOut)
int test_double_arg_clone(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements,
void* pbufRes, clMemWrapper& bufOut)
{
int error = 0;
clProgramWrapper program;
@@ -228,7 +232,7 @@ int test_double_arg_clone(cl_device_id deviceID, cl_context context, cl_command_
return 0;
}
int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(clone_kernel, Version(2, 1))
{
int error;
clProgramWrapper program;
@@ -250,11 +254,12 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu
cl_bool bimg = CL_FALSE;
cl_bool bdouble = CL_FALSE;
// test image support
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &bimg, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool),
&bimg, NULL);
test_error( error, "clGetDeviceInfo failed." );
// test double support
if (is_extension_available(deviceID, "cl_khr_fp64"))
if (is_extension_available(device, "cl_khr_fp64"))
{
bdouble = CL_TRUE;
}
@@ -377,13 +382,15 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu
if (bimg)
{
error = test_image_arg_shallow_clone(deviceID, context, queue, num_elements, pbufRes, bufOut);
error = test_image_arg_shallow_clone(device, context, queue,
num_elements, pbufRes, bufOut);
test_error( error, "image arg shallow clone test failed." );
}
if (bdouble)
{
error = test_double_arg_clone(deviceID, context, queue, num_elements, pbufRes, bufOut);
error = test_double_arg_clone(device, context, queue, num_elements,
pbufRes, bufOut);
test_error( error, "double arg clone test failed." );
}
@@ -392,4 +399,3 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu
return 0;
}

View File

@@ -26,12 +26,11 @@ void CL_CALLBACK context_destructor_callback(cl_context context, void *userData)
*userPtr = ++sDestructorIndex;
}
int test_context_destructor_callback(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(context_destructor_callback, Version(3, 0))
{
cl_int error;
clContextWrapper localContext =
clCreateContext(NULL, 1, &deviceID, NULL, NULL, &error);
clCreateContext(NULL, 1, &device, NULL, NULL, &error);
test_error(error, "Unable to create local context");
// Set up some variables to catch the order in which callbacks are called

View File

@@ -23,7 +23,7 @@
#include "harness/conversions.h"
#include <bitset>
int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(create_context_from_type)
{
int error;
clProgramWrapper program;
@@ -47,11 +47,12 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_
"}\n" };
cl_device_type type;
error = clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n");
cl_platform_id platform;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n");
cl_context_properties properties[3] = {
@@ -67,7 +68,7 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_
return -1;
}
queue_to_test = clCreateCommandQueue(context_to_test, deviceID, 0, &error);
queue_to_test = clCreateCommandQueue(context_to_test, device, 0, &error);
test_error(error, "clCreateCommandQueue failed");
if (queue_to_test == NULL) {
log_error("clCreateCommandQueue returned NULL, but error was CL_SUCCESS.");
@@ -128,14 +129,11 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_
return 0;
}
int test_create_context_from_type_device_type_all(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST(create_context_from_type_device_type_all)
{
cl_device_type type;
cl_int error =
clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n");
std::bitset<sizeof(cl_device_type)> type_bits(type);
@@ -148,7 +146,7 @@ int test_create_context_from_type_device_type_all(cl_device_id deviceID,
return -1;
}
cl_platform_id platform;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform),
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n");
@@ -172,14 +170,11 @@ int test_create_context_from_type_device_type_all(cl_device_id deviceID,
return 0;
}
int test_create_context_from_type_device_type_default(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST(create_context_from_type_device_type_default)
{
cl_device_type type;
cl_int error =
clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n");
std::bitset<sizeof(cl_device_type)> type_bits(type);
@@ -192,7 +187,7 @@ int test_create_context_from_type_device_type_default(cl_device_id deviceID,
return -1;
}
cl_platform_id platform;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform),
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n");

View File

@@ -72,8 +72,7 @@ const char *repeate_test_kernel =
"}\n";
int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_single_kernel)
{
int error;
clProgramWrapper program;
@@ -159,7 +158,7 @@ int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_comman
return 0;
}
int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_two_kernels)
{
int error;
clProgramWrapper program;
@@ -239,7 +238,7 @@ int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_
return 0;
}
int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_two_kernels_in_one)
{
int error;
clProgramWrapper program;
@@ -320,7 +319,7 @@ int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_c
return 0;
}
int test_load_two_kernels_manually( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_two_kernels_manually)
{
clProgramWrapper program;
clKernelWrapper kernel1, kernel2;
@@ -351,7 +350,7 @@ int test_load_two_kernels_manually( cl_device_id deviceID, cl_context context, c
return 0;
}
int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(get_program_info_kernel_names)
{
clProgramWrapper program;
clKernelWrapper kernel1, kernel2;
@@ -442,7 +441,7 @@ static const char *single_task_kernel[] = {
"\n"
"}\n" };
int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(enqueue_task)
{
int error;
clProgramWrapper program;
@@ -491,9 +490,8 @@ int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queu
}
#define TEST_SIZE 1000
int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(repeated_setup_cleanup)
{
cl_context local_context;
@@ -519,10 +517,11 @@ int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_co
for (i=0; i<100; i++) {
memset(outData, 0, sizeof(cl_int)*TEST_SIZE);
local_context = clCreateContext(NULL, 1, &deviceID, notify_callback, NULL, &error);
local_context =
clCreateContext(NULL, 1, &device, notify_callback, NULL, &error);
test_error( error, "clCreateContext failed");
local_queue = clCreateCommandQueue(local_context, deviceID, 0, &error);
local_queue = clCreateCommandQueue(local_context, device, 0, &error);
test_error( error, "clCreateCommandQueue failed");
error = create_single_kernel_helper(
@@ -590,6 +589,3 @@ int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_co
return 0;
}

View File

@@ -0,0 +1,85 @@
//
// Copyright (c) 2021 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "testBase.h"
#include <array>
using namespace std;
int test_command_queue_helper(cl_context context, cl_device_id deviceID,
cl_command_queue queue)
{
cl_int error;
cl_command_queue check_queue;
error = clSetDefaultDeviceCommandQueue(context, deviceID, queue);
test_error(error, "clSetDefaultDeviceCommandQueue failed ");
error = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE_DEFAULT,
sizeof(check_queue), &check_queue, nullptr);
test_error(error,
"clGetCommandQueueInfo failed for CL_QUEUE_DEVICE_DEFAULT");
test_assert_error(
(check_queue == queue),
"Expected the queue to be returned as default device queue failed");
return TEST_PASS;
}
REGISTER_TEST_VERSION(set_default_device_command_queue, Version(2, 1))
{
cl_int error;
constexpr cl_command_queue_properties PROPERTIES = CL_QUEUE_ON_DEVICE
| CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE;
std::array<cl_queue_properties, 3> properties = {
CL_QUEUE_PROPERTIES, (PROPERTIES | CL_QUEUE_ON_DEVICE_DEFAULT), 0
};
if (get_device_cl_version(device) >= Version(3, 0))
{
cl_device_device_enqueue_capabilities dseCaps = 0;
error = clGetDeviceInfo(device, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES,
sizeof(dseCaps), &dseCaps, NULL);
test_error(error,
"Unable to query CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES");
if (0 == (dseCaps & CL_DEVICE_QUEUE_REPLACEABLE_DEFAULT))
return TEST_SKIPPED_ITSELF;
}
clCommandQueueWrapper cmd_queue_1 = clCreateCommandQueueWithProperties(
context, device, properties.data(), &error);
test_error(error, "clCreateCommandQueueWithProperties failed");
properties[1] = PROPERTIES;
clCommandQueueWrapper cmd_queue_2 = clCreateCommandQueueWithProperties(
context, device, properties.data(), &error);
test_error(error, "clCreateCommandQueueWithProperties failed");
// cmd_queue_1
if (test_command_queue_helper(context, device, cmd_queue_1) != 0)
{
test_fail("test_command_queue_helper failed for cmd_queue_1.\n");
}
// cmd_queue_2 - without CL_QUEUE_ON_DEVICE_DEFAULT
if (test_command_queue_helper(context, device, cmd_queue_2) != 0)
{
test_fail("test_command_queue_helper failed for cmd_queue_2.\n");
}
return TEST_PASS;
}

View File

@@ -25,36 +25,41 @@ int IsAPowerOfTwo( unsigned long x )
}
int test_min_data_type_align_size_alignment(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems )
REGISTER_TEST(min_data_type_align_size_alignment)
{
cl_uint min_alignment;
cl_uint min_alignment;
if (gHasLong)
min_alignment = sizeof(cl_long)*16;
else
min_alignment = sizeof(cl_int)*16;
if (gHasLong)
min_alignment = sizeof(cl_long) * 16;
else
min_alignment = sizeof(cl_int) * 16;
int error = 0;
cl_uint alignment;
int error = 0;
cl_uint alignment;
error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(alignment), &alignment, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_MEM_BASE_ADDR_ALIGN failed");
log_info("Device reported CL_DEVICE_MEM_BASE_ADDR_ALIGN = %lu bits.\n", (unsigned long)alignment);
error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN,
sizeof(alignment), &alignment, NULL);
test_error(error,
"clGetDeviceInfo for CL_DEVICE_MEM_BASE_ADDR_ALIGN failed");
log_info("Device reported CL_DEVICE_MEM_BASE_ADDR_ALIGN = %lu bits.\n",
(unsigned long)alignment);
// Verify the size is large enough
if (alignment < min_alignment*8) {
log_error("ERROR: alignment too small. Minimum alignment for %s16 is %lu bits, device reported %lu bits.",
(gHasLong) ? "long" : "int",
(unsigned long)(min_alignment*8), (unsigned long)alignment);
return -1;
}
// Verify the size is large enough
if (alignment < min_alignment * 8)
{
log_error("ERROR: alignment too small. Minimum alignment for %s16 is "
"%lu bits, device reported %lu bits.",
(gHasLong) ? "long" : "int",
(unsigned long)(min_alignment * 8), (unsigned long)alignment);
return -1;
}
// Verify the size is a power of two
if (!IsAPowerOfTwo((unsigned long)alignment)) {
log_error("ERROR: alignment is not a power of two.\n");
return -1;
}
return 0;
// Verify the size is a power of two
if (!IsAPowerOfTwo((unsigned long)alignment))
{
log_error("ERROR: alignment is not a power of two.\n");
return -1;
}
return 0;
}

View File

@@ -32,7 +32,7 @@ const char *inspect_image_kernel_source[] = {
#define NUM_TRIES 100
#define NUM_THREADS 2048
int test_kernel_arg_changes(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(kernel_arg_changes)
{
clProgramWrapper program;
clKernelWrapper kernel;
@@ -137,5 +137,3 @@ int test_kernel_arg_changes(cl_device_id device, cl_context context, cl_command_
// If we got here, everything verified successfully
return 0;
}

View File

@@ -300,16 +300,16 @@ static int compare_expected_actual(const KernelArgInfo& expected,
return ret;
}
static bool device_supports_pipes(cl_device_id deviceID)
static bool device_supports_pipes(cl_device_id device)
{
auto version = get_device_cl_version(deviceID);
auto version = get_device_cl_version(device);
if (version < MINIMUM_OPENCL_PIPE_VERSION)
{
return false;
}
cl_uint max_packet_size = 0;
cl_int err =
clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
sizeof(max_packet_size), &max_packet_size, nullptr);
test_error_ret(err, "clGetDeviceInfo", false);
if ((max_packet_size == 0) && (version >= Version(3, 0)))
@@ -319,14 +319,14 @@ static bool device_supports_pipes(cl_device_id deviceID)
return true;
}
static std::string get_build_options(cl_device_id deviceID)
static std::string get_build_options(cl_device_id device)
{
std::string ret = "-cl-kernel-arg-info";
if (get_device_cl_version(deviceID) >= MINIMUM_OPENCL_PIPE_VERSION)
if (get_device_cl_version(device) >= MINIMUM_OPENCL_PIPE_VERSION)
{
if (device_supports_pipes(deviceID))
if (device_supports_pipes(device))
{
if (get_device_cl_version(deviceID) >= Version(3, 0))
if (get_device_cl_version(device) >= Version(3, 0))
{
ret += " -cl-std=CL3.0";
}
@@ -435,8 +435,7 @@ create_expected_arg_info(const KernelArgInfo& kernel_argument, bool is_pointer)
/* There are too many vector arguments for it to be worth writing down
* statically and are instead generated here and combined with all of the scalar
* and unsigned scalar types in a single data structure */
static std::vector<std::string>
generate_all_type_arguments(cl_device_id deviceID)
static std::vector<std::string> generate_all_type_arguments(cl_device_id device)
{
std::vector<std::string> ret = {
"char", "short", "int", "float",
@@ -460,11 +459,11 @@ generate_all_type_arguments(cl_device_id deviceID)
vector_types.push_back("long");
vector_types.push_back("ulong");
}
if (device_supports_half(deviceID))
if (device_supports_half(device))
{
vector_types.push_back("half");
}
if (device_supports_double(deviceID))
if (device_supports_double(device))
{
vector_types.push_back("double");
}
@@ -481,7 +480,7 @@ generate_all_type_arguments(cl_device_id deviceID)
}
static int
compare_kernel_with_expected(cl_context context, cl_device_id deviceID,
compare_kernel_with_expected(cl_context context, cl_device_id device,
const char* kernel_src,
const std::vector<KernelArgInfo>& expected_args)
{
@@ -490,7 +489,7 @@ compare_kernel_with_expected(cl_context context, cl_device_id deviceID,
clProgramWrapper program;
cl_int err = create_single_kernel_helper_with_build_options(
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info",
get_build_options(deviceID).c_str());
get_build_options(device).c_str());
test_error(err, "create_single_kernel_helper_with_build_options");
for (size_t i = 0; i < expected_args.size(); ++i)
{
@@ -525,7 +524,7 @@ compare_kernel_with_expected(cl_context context, cl_device_id deviceID,
return failed_tests;
}
size_t get_param_size(const std::string& arg_type, cl_device_id deviceID,
size_t get_param_size(const std::string& arg_type, cl_device_id device,
bool is_pipe)
{
if (is_pipe)
@@ -535,7 +534,7 @@ size_t get_param_size(const std::string& arg_type, cl_device_id deviceID,
if (arg_type.find("*") != std::string::npos)
{
cl_uint device_address_bits = 0;
cl_int err = clGetDeviceInfo(deviceID, CL_DEVICE_ADDRESS_BITS,
cl_int err = clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS,
sizeof(device_address_bits),
&device_address_bits, NULL);
test_error_ret(err, "clGetDeviceInfo", 0);
@@ -595,12 +594,12 @@ size_t get_param_size(const std::string& arg_type, cl_device_id deviceID,
return ret;
}
static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID)
static int run_scalar_vector_tests(cl_context context, cl_device_id device)
{
int failed_tests = 0;
std::vector<std::string> type_arguments =
generate_all_type_arguments(deviceID);
generate_all_type_arguments(device);
const std::vector<cl_kernel_arg_access_qualifier> access_qualifiers = {
CL_KERNEL_ARG_ACCESS_NONE, CL_KERNEL_ARG_ACCESS_READ_ONLY,
@@ -608,7 +607,7 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID)
};
std::vector<KernelArgInfo> all_args, expected_args;
size_t max_param_size = get_max_param_size(deviceID);
size_t max_param_size = get_max_param_size(device);
size_t total_param_size(0);
for (auto address_qualifier : address_qualifiers)
{
@@ -671,15 +670,14 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID)
arg_type += "*";
}
size_t param_size =
get_param_size(arg_type, deviceID, is_pipe);
get_param_size(arg_type, device, is_pipe);
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, false, device_supports_half(deviceID));
all_args, false, device_supports_half(device));
failed_tests += compare_kernel_with_expected(
context, deviceID, kernel_src.c_str(),
expected_args);
context, device, kernel_src.c_str(), expected_args);
all_args.clear();
expected_args.clear();
total_param_size = 0;
@@ -699,36 +697,36 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID)
}
}
const std::string kernel_src =
generate_kernel(all_args, false, device_supports_half(deviceID));
generate_kernel(all_args, false, device_supports_half(device));
failed_tests += compare_kernel_with_expected(
context, deviceID, kernel_src.c_str(), expected_args);
context, device, kernel_src.c_str(), expected_args);
return failed_tests;
}
static cl_uint get_max_number_of_pipes(cl_device_id deviceID, cl_int& err)
static cl_uint get_max_number_of_pipes(cl_device_id device, cl_int& err)
{
cl_uint ret(0);
err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PIPE_ARGS, sizeof(ret), &ret,
err = clGetDeviceInfo(device, CL_DEVICE_MAX_PIPE_ARGS, sizeof(ret), &ret,
nullptr);
return ret;
}
static int run_pipe_tests(cl_context context, cl_device_id deviceID)
static int run_pipe_tests(cl_context context, cl_device_id device)
{
int failed_tests = 0;
cl_kernel_arg_address_qualifier address_qualifier =
CL_KERNEL_ARG_ADDRESS_PRIVATE;
std::vector<std::string> type_arguments =
generate_all_type_arguments(deviceID);
generate_all_type_arguments(device);
const std::vector<cl_kernel_arg_access_qualifier> access_qualifiers = {
CL_KERNEL_ARG_ACCESS_READ_ONLY, CL_KERNEL_ARG_ACCESS_WRITE_ONLY
};
std::vector<KernelArgInfo> all_args, expected_args;
size_t max_param_size = get_max_param_size(deviceID);
size_t max_param_size = get_max_param_size(device);
size_t total_param_size(0);
cl_int err = CL_SUCCESS;
cl_uint max_number_of_pipes = get_max_number_of_pipes(deviceID, err);
cl_uint max_number_of_pipes = get_max_number_of_pipes(device, err);
test_error_ret(err, "get_max_number_of_pipes", TEST_FAIL);
cl_uint number_of_pipes(0);
@@ -747,13 +745,13 @@ static int run_pipe_tests(cl_context context, cl_device_id deviceID)
continue;
}
size_t param_size = get_param_size(arg_type, deviceID, is_pipe);
size_t param_size = get_param_size(arg_type, device, is_pipe);
if (param_size + total_param_size >= max_param_size
|| number_of_pipes == max_number_of_pipes)
{
const std::string kernel_src = generate_kernel(all_args);
failed_tests += compare_kernel_with_expected(
context, deviceID, kernel_src.c_str(), expected_args);
context, device, kernel_src.c_str(), expected_args);
all_args.clear();
expected_args.clear();
total_param_size = 0;
@@ -775,11 +773,11 @@ static int run_pipe_tests(cl_context context, cl_device_id deviceID)
}
const std::string kernel_src = generate_kernel(all_args);
failed_tests += compare_kernel_with_expected(
context, deviceID, kernel_src.c_str(), expected_args);
context, device, kernel_src.c_str(), expected_args);
return failed_tests;
}
static int run_sampler_test(cl_context context, cl_device_id deviceID)
static int run_sampler_test(cl_context context, cl_device_id device)
{
cl_kernel_arg_address_qualifier address_qualifier =
CL_KERNEL_ARG_ADDRESS_PRIVATE;
@@ -797,27 +795,27 @@ static int run_sampler_test(cl_context context, cl_device_id deviceID)
const std::string kernel_src = generate_kernel({ kernel_argument });
return compare_kernel_with_expected(context, deviceID, kernel_src.c_str(),
return compare_kernel_with_expected(context, device, kernel_src.c_str(),
{ expected });
}
static int run_image_tests(cl_context context, cl_device_id deviceID)
static int run_image_tests(cl_context context, cl_device_id device)
{
int failed_tests = 0;
bool supports_3d_image_writes =
is_extension_available(deviceID, "cl_khr_3d_image_writes");
is_extension_available(device, "cl_khr_3d_image_writes");
bool is_pointer = false;
cl_kernel_arg_type_qualifier type_qualifier = CL_KERNEL_ARG_TYPE_NONE;
cl_kernel_arg_address_qualifier address_qualifier =
CL_KERNEL_ARG_ADDRESS_GLOBAL;
Version version = get_device_cl_version(deviceID);
Version version = get_device_cl_version(device);
bool supports_read_write_images = false;
if (version >= Version(3, 0))
{
cl_uint maxReadWriteImageArgs = 0;
cl_int error = clGetDeviceInfo(
deviceID, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS,
device, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS,
sizeof(maxReadWriteImageArgs), &maxReadWriteImageArgs, NULL);
test_error(error,
"Unable to query "
@@ -862,23 +860,23 @@ static int run_image_tests(cl_context context, cl_device_id deviceID)
generate_kernel({ kernel_argument }, supports_3d_image_writes);
failed_tests += compare_kernel_with_expected(
context, deviceID, kernel_src.c_str(), { expected });
context, device, kernel_src.c_str(), { expected });
}
}
failed_tests += run_sampler_test(context, deviceID);
failed_tests += run_sampler_test(context, device);
return failed_tests;
}
/* Ensure clGetKernelArgInfo returns successfully when param_value is
* set to null */
static int test_null_param(cl_context context, cl_device_id deviceID,
static int test_null_param(cl_context context, cl_device_id device,
char const* kernel_src)
{
clProgramWrapper program;
clKernelWrapper kernel;
cl_int err = create_single_kernel_helper_with_build_options(
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info",
get_build_options(deviceID).c_str());
get_build_options(device).c_str());
test_error_ret(err, "create_single_kernel_helper_with_build_options",
TEST_FAIL);
@@ -909,7 +907,7 @@ static int test_null_param(cl_context context, cl_device_id deviceID,
/* Ensure clGetKernelArgInfo returns the correct size in bytes for the
* kernel arg name */
static int test_arg_name_size(cl_context context, cl_device_id deviceID,
static int test_arg_name_size(cl_context context, cl_device_id device,
char const* kernel_src)
{
size_t size;
@@ -920,7 +918,7 @@ static int test_arg_name_size(cl_context context, cl_device_id deviceID,
clKernelWrapper kernel;
cl_int err = create_single_kernel_helper_with_build_options(
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info",
get_build_options(deviceID).c_str());
get_build_options(device).c_str());
test_error_ret(err, "create_single_kernel_helper_with_build_options",
TEST_FAIL);
@@ -939,7 +937,7 @@ static int test_arg_name_size(cl_context context, cl_device_id deviceID,
}
}
static int run_boundary_tests(cl_context context, cl_device_id deviceID)
static int run_boundary_tests(cl_context context, cl_device_id device)
{
int failed_tests = 0;
@@ -952,9 +950,9 @@ static int run_boundary_tests(cl_context context, cl_device_id deviceID)
arg_type, SINGLE_KERNEL_ARG_NUMBER);
const std::string kernel_src = generate_kernel({ arg_info });
failed_tests += test_arg_name_size(context, deviceID, kernel_src.c_str());
failed_tests += test_arg_name_size(context, device, kernel_src.c_str());
if (test_null_param(context, deviceID, kernel_src.c_str()) != TEST_PASS)
if (test_null_param(context, device, kernel_src.c_str()) != TEST_PASS)
{
failed_tests++;
}
@@ -962,10 +960,10 @@ static int run_boundary_tests(cl_context context, cl_device_id deviceID)
return failed_tests;
}
static int run_all_tests(cl_context context, cl_device_id deviceID)
static int run_all_tests(cl_context context, cl_device_id device)
{
int failed_scalar_tests = run_scalar_vector_tests(context, deviceID);
int failed_scalar_tests = run_scalar_vector_tests(context, device);
if (failed_scalar_tests == 0)
{
log_info("All Data Type Tests Passed\n");
@@ -976,9 +974,9 @@ static int run_all_tests(cl_context context, cl_device_id deviceID)
}
int failed_image_tests = 0;
if (checkForImageSupport(deviceID) == 0)
if (checkForImageSupport(device) == 0)
{
failed_image_tests = run_image_tests(context, deviceID);
failed_image_tests = run_image_tests(context, device);
if (failed_image_tests == 0)
{
log_info("All Image Tests Passed\n");
@@ -992,7 +990,7 @@ static int run_all_tests(cl_context context, cl_device_id deviceID)
// TODO https://github.com/KhronosGroup/OpenCL-CTS/issues/1244
if (false)
{
failed_pipe_tests = run_pipe_tests(context, deviceID);
failed_pipe_tests = run_pipe_tests(context, device);
if (failed_pipe_tests == 0)
{
log_info("All Pipe Tests Passed\n");
@@ -1003,7 +1001,7 @@ static int run_all_tests(cl_context context, cl_device_id deviceID)
}
}
int failed_boundary_tests = run_boundary_tests(context, deviceID);
int failed_boundary_tests = run_boundary_tests(context, device);
if (failed_boundary_tests == 0)
{
log_info("All Edge Case Tests Passed\n");
@@ -1017,10 +1015,9 @@ static int run_all_tests(cl_context context, cl_device_id deviceID)
+ failed_boundary_tests);
}
int test_get_kernel_arg_info(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(get_kernel_arg_info)
{
int failed_tests = run_all_tests(context, deviceID);
int failed_tests = run_all_tests(context, device);
if (failed_tests != 0)
{
log_error("%d Test(s) Failed\n", failed_tests);

View File

@@ -240,7 +240,7 @@ int test_kernel_arg_multi_setup_exhaustive(cl_device_id device, cl_context conte
return 0;
}
int test_kernel_arg_multi_setup_random(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(kernel_arg_multi_setup_random)
{
// Loop through a selection of combinations
ExplicitType types[] = { kChar, kShort, kInt, kFloat, kNumExplicitTypes };
@@ -282,7 +282,3 @@ int test_kernel_arg_multi_setup_random(cl_device_id device, cl_context context,
}
return 0;
}

View File

@@ -17,7 +17,7 @@
#include <vector>
#include <string>
#include <algorithm>
#include "procs.h"
#include "harness/errorHelpers.h"
#include "harness/typeWrappers.h"
#include "harness/parseParameters.h"
@@ -57,7 +57,7 @@ AttributePermutations reqd_vect_work_tests;
// Generate a vector with vec_type_hint(<data_type>) so that it can be used to
// generate different kernels
static KernelAttributes generate_vec_type_hint_data(cl_device_id deviceID)
static KernelAttributes generate_vec_type_hint_data(cl_device_id device)
{
KernelAttributes vec_type_hint_data;
// TODO Test for signed vectors (char/short/int/etc)
@@ -67,11 +67,11 @@ static KernelAttributes generate_vec_type_hint_data(cl_device_id deviceID)
{
vector_types.push_back("ulong");
}
if (device_supports_half(deviceID))
if (device_supports_half(device))
{
vector_types.push_back("half");
}
if (device_supports_double(deviceID))
if (device_supports_double(device))
{
vector_types.push_back("double");
}
@@ -239,7 +239,7 @@ generate_attribute_tests(const KernelAttributes& vec_type_hint_data,
}
static const std::vector<AttributePermutations*>
initialise_attribute_data(cl_device_id deviceID)
initialise_attribute_data(cl_device_id device)
{
// This vector stores different work group dimensions that can be used by
// the reqd_work_group_size and work_group_size_hint attributes. It
@@ -248,7 +248,7 @@ initialise_attribute_data(cl_device_id deviceID)
static const std::vector<WorkGroupDimensions> work_group_dimensions = {
{ 1, 1, 1 }
};
KernelAttributes vec_type_hint_data = generate_vec_type_hint_data(deviceID);
KernelAttributes vec_type_hint_data = generate_vec_type_hint_data(device);
KernelAttributes work_group_size_hint_data =
generate_work_group_size_data(work_group_dimensions);
KernelAttributes reqd_work_group_size_data =
@@ -261,7 +261,7 @@ initialise_attribute_data(cl_device_id deviceID)
reqd_work_group_size_data);
}
static bool run_test(cl_context context, cl_device_id deviceID,
static bool run_test(cl_context context, cl_device_id device,
const AttributePermutations& permutations)
{
bool success = true;
@@ -322,18 +322,17 @@ static bool run_test(cl_context context, cl_device_id deviceID,
return success;
}
int test_kernel_attributes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(kernel_attributes)
{
bool success = true;
// Vector to store all of the tests
const std::vector<AttributePermutations*> all_tests =
initialise_attribute_data(deviceID);
initialise_attribute_data(device);
for (auto permutations : all_tests)
{
success = success && run_test(context, deviceID, *permutations);
success = success && run_test(context, device, *permutations);
}
return success ? TEST_PASS : TEST_FAIL;
}

View File

@@ -78,8 +78,7 @@ __kernel void local_param_local_memory_kernel(__local int* local_ptr,
}
)CLC";
int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(kernel_local_memory_size)
{
int error;
clProgramWrapper program;
@@ -97,7 +96,7 @@ int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context,
}
error = clGetKernelWorkGroupInfo(
kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage),
kernel, device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage),
&kernel_local_usage, &param_value_size_ret);
test_error(error,
"clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed");
@@ -194,7 +193,7 @@ int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context,
test_error(error, "clEnqueueReadBuffer failed");
error = clGetKernelWorkGroupInfo(
kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage),
kernel, device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage),
&kernel_local_usage, &param_value_size_ret);
test_error(error,
"clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed");
@@ -268,7 +267,7 @@ int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context,
error = clGetKernelWorkGroupInfo(
kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage),
kernel, device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage),
&kernel_local_usage, &param_value_size_ret);
test_error(error,
"clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed");

View File

@@ -16,10 +16,8 @@
#include "harness/errorHelpers.h"
#include "harness/typeWrappers.h"
#include <iostream>
#include "procs.h"
int test_kernel_private_memory_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(kernel_private_memory_size)
{
const char* TEST_KERNEL =
R"(__kernel void private_memory( __global uint *buffer ){
@@ -33,7 +31,7 @@ int test_kernel_private_memory_size(cl_device_id deviceID, cl_context context,
&TEST_KERNEL, "private_memory");
test_error(err, "create_single_kernel_helper");
cl_ulong size = CL_ULONG_MAX;
err = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_PRIVATE_MEM_SIZE,
err = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_PRIVATE_MEM_SIZE,
sizeof(cl_ulong), &size, nullptr);
test_error(err, "clGetKernelWorkGroupInfo");

View File

@@ -76,9 +76,7 @@ const char *sample_two_kernel_program[] = {
"}\n" };
int test_get_kernel_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(get_kernel_info)
{
int error;
cl_program program, testProgram;
@@ -171,7 +169,7 @@ int test_get_kernel_info(cl_device_id deviceID, cl_context context, cl_command_q
return 0;
}
int test_execute_kernel_local_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(execute_kernel_local_sizes)
{
int error;
clProgramWrapper program;
@@ -302,7 +300,7 @@ int test_execute_kernel_local_sizes(cl_device_id deviceID, cl_context context, c
return 0;
}
int test_set_kernel_arg_by_index(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(set_kernel_arg_by_index)
{
int error;
clProgramWrapper program;
@@ -372,7 +370,7 @@ int test_set_kernel_arg_by_index(cl_device_id deviceID, cl_context context, cl_c
return 0;
}
int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(set_kernel_arg_constant)
{
int error;
clProgramWrapper program;
@@ -390,7 +388,7 @@ int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_c
/* Verify our test buffer won't be bigger than allowed */
maxSize = get_device_info_max_constant_buffer_size(
deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
device, MAX_DEVICE_MEMORY_SIZE_DIVISOR);
if (maxSize < sizeof(cl_int) * num_elements)
{
log_error( "ERROR: Unable to test constant argument to kernel: max size of constant buffer is reported as %d!\n", (int)maxSize );
@@ -459,7 +457,7 @@ int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_c
return 0;
}
int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(set_kernel_arg_struct_array)
{
int error;
clProgramWrapper program;
@@ -536,7 +534,7 @@ int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context,
return 0;
}
int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(create_kernels_in_program)
{
int error;
cl_program program;
@@ -565,7 +563,7 @@ int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl
return 0;
}
int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(kernel_global_constant)
{
int error;
clProgramWrapper program;
@@ -633,6 +631,3 @@ int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_co
return 0;
}

View File

@@ -56,7 +56,7 @@ get_image_dim(MTdata *d, unsigned int mod)
}
int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements )
REGISTER_TEST(get_buffer_info)
{
int error;
size_t size;
@@ -150,7 +150,8 @@ int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_
// Get the address alignment, so we can make sure the sub-buffer test later works properly.
cl_uint addressAlignBits;
error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(addressAlignBits), &addressAlignBits, NULL );
error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN,
sizeof(addressAlignBits), &addressAlignBits, NULL);
size_t addressAlign = addressAlignBits/8;
if ( addressAlign < 128 )
@@ -420,7 +421,8 @@ int test_get_imageObject_info( cl_mem * image, cl_mem_flags objectFlags, cl_imag
}
int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_object_type type )
int test_get_image_info(cl_device_id device, cl_context context,
cl_mem_object_type type)
{
int error;
size_t size;
@@ -494,7 +496,7 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec
MTdataHolder d_holder(gRandomSeed);
MTdata d = static_cast<MTdata>(d_holder);
PASSIVE_REQUIRE_IMAGE_SUPPORT( deviceID )
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
cl_image_format imageFormat;
size_t pixelSize = 4;
@@ -530,7 +532,7 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec
break;
case CL_MEM_OBJECT_IMAGE3D:
error = checkFor3DImageSupport(deviceID);
error = checkFor3DImageSupport(device);
if (error == CL_IMAGE_FORMAT_NOT_SUPPORTED)
{
log_info("Device doesn't support 3D images. Skipping test.\n");
@@ -738,29 +740,27 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec
}
int test_get_image2d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements )
REGISTER_TEST(get_image2d_info)
{
return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE2D);
return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE2D);
}
int test_get_image3d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements )
REGISTER_TEST(get_image3d_info)
{
return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE3D);
return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE3D);
}
int test_get_image1d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements )
REGISTER_TEST(get_image1d_info)
{
return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE1D);
return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE1D);
}
int test_get_image1d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements )
REGISTER_TEST(get_image1d_array_info)
{
return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE1D_ARRAY);
return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE1D_ARRAY);
}
int test_get_image2d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements )
REGISTER_TEST(get_image2d_array_info)
{
return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE2D_ARRAY);
return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE2D_ARRAY);
}

View File

@@ -271,13 +271,12 @@ static int run_test_query_properties(cl_context context, cl_command_queue queue,
return TEST_PASS;
}
int test_image_properties_queries(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(image_properties_queries, Version(3, 0))
{
int error = CL_SUCCESS;
cl_bool supports_images = CL_TRUE;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT,
sizeof(supports_images), &supports_images, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_IMAGE_SUPPORT failed");
@@ -321,8 +320,7 @@ int test_image_properties_queries(cl_device_id deviceID, cl_context context,
return error;
}
int test_buffer_properties_queries(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(buffer_properties_queries, Version(3, 0))
{
int error = CL_SUCCESS;

View File

@@ -83,10 +83,7 @@ int test_mem_object_destructor_callback_single(clMemWrapper &memObject)
return (numErrors > 0) ? TEST_FAIL : TEST_PASS;
}
int test_mem_object_destructor_callback(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST(mem_object_destructor_callback)
{
clMemWrapper testBuffer, testImage;
cl_int error;
@@ -102,7 +99,7 @@ int test_mem_object_destructor_callback(cl_device_id deviceID,
return TEST_FAIL;
}
if (checkForImageSupport(deviceID) == 0)
if (checkForImageSupport(device) == 0)
{
cl_image_format imageFormat = { CL_RGBA, CL_SIGNED_INT8 };
testImage = create_image_2d(context, CL_MEM_READ_ONLY, &imageFormat, 16,

View File

@@ -15,8 +15,7 @@
//
#include "testBase.h"
int test_min_image_formats(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(min_image_formats)
{
int missingFormats = 0;

View File

@@ -33,7 +33,7 @@ static void CL_CALLBACK test_native_kernel_fn( void *userData )
args->dest[ i ] = args->source[ i ];
}
int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems )
REGISTER_TEST(native_kernel)
{
int error;
RandomSeed seed( gRandomSeed );
@@ -46,7 +46,7 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue
}
clMemWrapper streams[ 2 ];
std::vector<cl_int> inBuffer(n_elems), outBuffer(n_elems);
std::vector<cl_int> inBuffer(num_elements), outBuffer(num_elements);
clEventWrapper finishEvent;
struct arg_struct
@@ -58,21 +58,22 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue
// Create some input values
generate_random_data(kInt, n_elems, seed, inBuffer.data());
generate_random_data(kInt, num_elements, seed, inBuffer.data());
// Create I/O streams
streams[0] =
clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, n_elems * sizeof(cl_int),
inBuffer.data(), &error);
clCreateBuffer(context, CL_MEM_COPY_HOST_PTR,
num_elements * sizeof(cl_int), inBuffer.data(), &error);
test_error( error, "Unable to create I/O stream" );
streams[ 1 ] = clCreateBuffer( context, 0, n_elems * sizeof(cl_int), NULL, &error );
streams[1] =
clCreateBuffer(context, 0, num_elements * sizeof(cl_int), NULL, &error);
test_error( error, "Unable to create I/O stream" );
// Set up the arrays to call with
args.inputStream = streams[ 0 ];
args.outputStream = streams[ 1 ];
args.count = n_elems;
args.count = num_elements;
void * memLocs[ 2 ] = { &args.inputStream, &args.outputStream };
@@ -94,11 +95,11 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue
// Now read the results and verify
error = clEnqueueReadBuffer(queue, streams[1], CL_TRUE, 0,
n_elems * sizeof(cl_int), outBuffer.data(), 0,
NULL, NULL);
num_elements * sizeof(cl_int), outBuffer.data(),
0, NULL, NULL);
test_error( error, "Unable to read results" );
for( int i = 0; i < n_elems; i++ )
for (int i = 0; i < num_elements; i++)
{
if (inBuffer[i] != outBuffer[i])
{
@@ -111,8 +112,3 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue
return 0;
}

View File

@@ -24,8 +24,6 @@
#include "testBase.h"
#include "harness/typeWrappers.h"
#include "harness/testHarness.h"
#include "procs.h"
enum { SUCCESS, FAILURE };
typedef enum { NON_NULL_PATH, ADDROF_NULL_PATH, NULL_PATH } test_type;
@@ -150,8 +148,7 @@ static int test_setargs_and_execution(cl_command_queue queue, cl_kernel kernel,
return test_success;
}
int test_null_buffer_arg(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(null_buffer_arg)
{
unsigned int test_success = 0;
unsigned int buffer_size;

View File

@@ -71,14 +71,13 @@ static int create_pipe_and_check_array_properties(
return TEST_FAIL;
}
int test_pipe_properties_queries(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(pipe_properties_queries, Version(3, 0))
{
cl_int error = CL_SUCCESS;
cl_bool pipeSupport = CL_FALSE;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_SUPPORT,
sizeof(pipeSupport), &pipeSupport, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PIPE_SUPPORT, sizeof(pipeSupport),
&pipeSupport, NULL);
test_error(error, "Unable to query CL_DEVICE_PIPE_SUPPORT");
if (pipeSupport == CL_FALSE)

View File

@@ -21,8 +21,7 @@
#define PRINT_EXTENSION_INFO 0
int test_platform_extensions(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(platform_extensions)
{
const char * extensions[] = {
"cl_khr_byte_addressable_store",
@@ -64,17 +63,14 @@ int test_platform_extensions(cl_device_id deviceID, cl_context context,
char device_extensions[EXTENSION_NAME_BUF_SIZE];
// Okay, so what we're going to do is just check the device indicated by
// deviceID against the platform that includes this device
// device against the platform that includes this device
// pass CL_DEVICE_PLATFORM to clGetDeviceInfo
// to get a result of type cl_platform_id
err = clGetDeviceInfo(deviceID,
CL_DEVICE_PLATFORM,
sizeof(cl_platform_id),
(void *)(&platformID),
NULL);
err = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id),
(void *)(&platformID), NULL);
if(err != CL_SUCCESS)
{
@@ -115,11 +111,9 @@ int test_platform_extensions(cl_device_id deviceID, cl_context context,
// and then we grab the set of extensions specified by the device
// (this can be turned into a "loop over all devices in this platform")
err = clGetDeviceInfo(deviceID,
CL_DEVICE_EXTENSIONS,
sizeof(device_extensions),
(void *)(&device_extensions[0]),
NULL);
err =
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(device_extensions),
(void *)(&device_extensions[0]), NULL);
if(err != CL_SUCCESS)
{
vlog_error("test_platform_extensions : could not get extension string from device\n");
@@ -149,186 +143,206 @@ int test_platform_extensions(cl_device_id deviceID, cl_context context,
return 0;
}
int test_get_platform_ids(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) {
cl_platform_id platforms[16];
cl_uint num_platforms;
char *string_returned;
REGISTER_TEST(get_platform_ids)
{
cl_platform_id platforms[16];
cl_uint num_platforms;
char *string_returned;
string_returned = (char*)malloc(8192);
string_returned = (char *)malloc(8192);
int total_errors = 0;
int err = CL_SUCCESS;
int total_errors = 0;
int err = CL_SUCCESS;
err = clGetPlatformIDs(16, platforms, &num_platforms);
test_error(err, "clGetPlatformIDs failed");
err = clGetPlatformIDs(16, platforms, &num_platforms);
test_error(err, "clGetPlatformIDs failed");
if (num_platforms <= 16) {
// Try with NULL
err = clGetPlatformIDs(num_platforms, platforms, NULL);
test_error(err, "clGetPlatformIDs failed with NULL for return size");
}
if (num_platforms < 1) {
log_error("Found 0 platforms.\n");
return -1;
}
log_info("Found %d platforms.\n", num_platforms);
for (int p=0; p<(int)num_platforms; p++) {
cl_device_id *devices;
cl_uint num_devices;
size_t size;
log_info("Platform %d (%p):\n", p, platforms[p]);
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_PROFILE, 8192, string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_PROFILE failed");
log_info("\tCL_PLATFORM_PROFILE: %s\n", string_returned);
if (strlen(string_returned)+1 != size) {
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VERSION, 8192, string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_VERSION failed");
log_info("\tCL_PLATFORM_VERSION: %s\n", string_returned);
if (strlen(string_returned)+1 != size) {
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_NAME, 8192, string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_NAME failed");
log_info("\tCL_PLATFORM_NAME: %s\n", string_returned);
if (strlen(string_returned)+1 != size) {
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VENDOR, 8192, string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_VENDOR failed");
log_info("\tCL_PLATFORM_VENDOR: %s\n", string_returned);
if (strlen(string_returned)+1 != size) {
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_EXTENSIONS, 8192, string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_EXTENSIONS failed");
log_info("\tCL_PLATFORM_EXTENSIONS: %s\n", string_returned);
if (strlen(string_returned)+1 != size) {
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
test_error(err, "clGetDeviceIDs failed.\n");
if (num_devices == 0)
if (num_platforms <= 16)
{
log_error("clGetDeviceIDs must return at least one device\n");
total_errors++;
// Try with NULL
err = clGetPlatformIDs(num_platforms, platforms, NULL);
test_error(err, "clGetPlatformIDs failed with NULL for return size");
}
devices = (cl_device_id *)malloc(num_devices*sizeof(cl_device_id));
memset(devices, 0, sizeof(cl_device_id)*num_devices);
err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, num_devices, devices, NULL);
test_error(err, "clGetDeviceIDs failed.\n");
log_info("\tPlatform has %d devices.\n", (int)num_devices);
for (int d = 0; d < (int)num_devices; d++)
if (num_platforms < 1)
{
size_t returned_size;
cl_platform_id returned_platform;
cl_context context;
cl_context_properties properties[] = {
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[p], 0
};
log_error("Found 0 platforms.\n");
return -1;
}
log_info("Found %d platforms.\n", num_platforms);
err = clGetDeviceInfo(devices[d], CL_DEVICE_PLATFORM,
sizeof(cl_platform_id), &returned_platform,
&returned_size);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_PLATFORM\n");
if (returned_size != sizeof(cl_platform_id))
for (int p = 0; p < (int)num_platforms; p++)
{
cl_device_id *devices;
cl_uint num_devices;
size_t size;
log_info("Platform %d (%p):\n", p, platforms[p]);
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_PROFILE, 8192,
string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_PROFILE failed");
log_info("\tCL_PLATFORM_PROFILE: %s\n", string_returned);
if (strlen(string_returned) + 1 != size)
{
log_error("Reported return size (%zu) does not match expected size "
"(%zu).\n",
returned_size, sizeof(cl_platform_id));
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetDeviceInfo(devices[d], CL_DEVICE_NAME, 8192, string_returned,
NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_NAME\n");
log_info("\t\tPlatform for device %d (%s) is %p.\n", d, string_returned,
returned_platform);
log_info("\t\t\tTesting clCreateContext for the platform/device...\n");
// Try creating a context for the platform
context = clCreateContext(properties, 1, &devices[d], NULL, NULL, &err);
test_error(
err,
"\t\tclCreateContext failed for device with platform properties\n");
memset(properties, 0, sizeof(cl_context_properties) * 3);
err = clGetContextInfo(context, CL_CONTEXT_PROPERTIES,
sizeof(cl_context_properties) * 3, properties,
&returned_size);
test_error(err, "clGetContextInfo for CL_CONTEXT_PROPERTIES failed");
if (returned_size != sizeof(cl_context_properties) * 3)
{
log_error("Invalid size returned from clGetContextInfo for "
"CL_CONTEXT_PROPERTIES. Got %zu, expected %zu.\n",
returned_size, sizeof(cl_context_properties) * 3);
total_errors++;
}
if (properties[0] != (cl_context_properties)CL_CONTEXT_PLATFORM
|| properties[1] != (cl_context_properties)platforms[p])
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VERSION, 8192,
string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_VERSION failed");
log_info("\tCL_PLATFORM_VERSION: %s\n", string_returned);
if (strlen(string_returned) + 1 != size)
{
log_error(
"Wrong properties returned. Expected: [%p %p], got [%p %p]\n",
(void *)CL_CONTEXT_PLATFORM, platforms[p],
(void *)properties[0], (void *)properties[1]);
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
err = clReleaseContext(context);
test_error(err, "clReleaseContext failed");
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_NAME, 8192,
string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_NAME failed");
log_info("\tCL_PLATFORM_NAME: %s\n", string_returned);
if (strlen(string_returned) + 1 != size)
{
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VENDOR, 8192,
string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_VENDOR failed");
log_info("\tCL_PLATFORM_VENDOR: %s\n", string_returned);
if (strlen(string_returned) + 1 != size)
{
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetPlatformInfo(platforms[p], CL_PLATFORM_EXTENSIONS, 8192,
string_returned, &size);
test_error(err, "clGetPlatformInfo for CL_PLATFORM_EXTENSIONS failed");
log_info("\tCL_PLATFORM_EXTENSIONS: %s\n", string_returned);
if (strlen(string_returned) + 1 != size)
{
log_error(
"Returned string length %zu does not equal reported one %zu.\n",
strlen(string_returned) + 1, size);
total_errors++;
}
err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, 0, NULL,
&num_devices);
test_error(err, "clGetDeviceIDs failed.\n");
if (num_devices == 0)
{
log_error("clGetDeviceIDs must return at least one device\n");
total_errors++;
}
devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id));
memset(devices, 0, sizeof(cl_device_id) * num_devices);
err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, num_devices,
devices, NULL);
test_error(err, "clGetDeviceIDs failed.\n");
log_info("\tPlatform has %d devices.\n", (int)num_devices);
for (int d = 0; d < (int)num_devices; d++)
{
size_t returned_size;
cl_platform_id returned_platform;
cl_context context;
cl_context_properties properties[] = {
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[p], 0
};
err = clGetDeviceInfo(devices[d], CL_DEVICE_PLATFORM,
sizeof(cl_platform_id), &returned_platform,
&returned_size);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_PLATFORM\n");
if (returned_size != sizeof(cl_platform_id))
{
log_error(
"Reported return size (%zu) does not match expected size "
"(%zu).\n",
returned_size, sizeof(cl_platform_id));
total_errors++;
}
memset(string_returned, 0, 8192);
err = clGetDeviceInfo(devices[d], CL_DEVICE_NAME, 8192,
string_returned, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_NAME\n");
log_info("\t\tPlatform for device %d (%s) is %p.\n", d,
string_returned, returned_platform);
log_info(
"\t\t\tTesting clCreateContext for the platform/device...\n");
// Try creating a context for the platform
context =
clCreateContext(properties, 1, &devices[d], NULL, NULL, &err);
test_error(err,
"\t\tclCreateContext failed for device with platform "
"properties\n");
memset(properties, 0, sizeof(cl_context_properties) * 3);
err = clGetContextInfo(context, CL_CONTEXT_PROPERTIES,
sizeof(cl_context_properties) * 3,
properties, &returned_size);
test_error(err,
"clGetContextInfo for CL_CONTEXT_PROPERTIES failed");
if (returned_size != sizeof(cl_context_properties) * 3)
{
log_error("Invalid size returned from clGetContextInfo for "
"CL_CONTEXT_PROPERTIES. Got %zu, expected %zu.\n",
returned_size, sizeof(cl_context_properties) * 3);
total_errors++;
}
if (properties[0] != (cl_context_properties)CL_CONTEXT_PLATFORM
|| properties[1] != (cl_context_properties)platforms[p])
{
log_error("Wrong properties returned. Expected: [%p %p], got "
"[%p %p]\n",
(void *)CL_CONTEXT_PLATFORM, platforms[p],
(void *)properties[0], (void *)properties[1]);
total_errors++;
}
err = clReleaseContext(context);
test_error(err, "clReleaseContext failed");
}
free(devices);
err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_DEFAULT, 0, NULL,
&num_devices);
test_error(err, "clGetDeviceIDs failed.\n");
if (num_devices != 1)
{
log_error("clGetDeviceIDs must return exactly one device\n");
total_errors++;
}
}
free(devices);
err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_DEFAULT, 0, NULL,
&num_devices);
test_error(err, "clGetDeviceIDs failed.\n");
if (num_devices != 1)
{
log_error("clGetDeviceIDs must return exactly one device\n");
total_errors++;
}
}
free(string_returned);
free(string_returned);
return total_errors;
return total_errors;
}

View File

@@ -22,7 +22,7 @@
#include <cinttypes>
#include <vector>
int test_get_platform_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(get_platform_info)
{
cl_platform_id platform;
cl_int error;
@@ -162,7 +162,7 @@ static cl_addressing_mode addressing_mode_values[] = {
static cl_filter_mode filter_mode_values[] = { CL_FILTER_NEAREST,
CL_FILTER_LINEAR };
int test_sampler_params(cl_device_id deviceID, cl_context context,
int test_sampler_params(cl_device_id device, cl_context context,
bool is_compatibility, size_t norm_coord_num,
size_t addr_mod_num, size_t filt_mod_num)
{
@@ -218,7 +218,7 @@ int test_sampler_params(cl_device_id deviceID, cl_context context,
"normalized coords");
test_error(error, "param checking failed");
Version version = get_device_cl_version(deviceID);
Version version = get_device_cl_version(device);
if (version >= Version(3, 0))
{
std::vector<cl_sampler_properties> test_properties(
@@ -270,7 +270,7 @@ int test_sampler_params(cl_device_id deviceID, cl_context context,
return 0;
}
int get_sampler_info_params(cl_device_id deviceID, cl_context context,
int get_sampler_info_params(cl_device_id device, cl_context context,
bool is_compatibility)
{
for (size_t norm_coord_num = 0;
@@ -289,36 +289,32 @@ int get_sampler_info_params(cl_device_id deviceID, cl_context context,
for (size_t filt_mod_num = 0;
filt_mod_num < ARRAY_SIZE(filter_mode_values); filt_mod_num++)
{
int err = test_sampler_params(deviceID, context,
is_compatibility, norm_coord_num,
addr_mod_num, filt_mod_num);
int err = test_sampler_params(device, context, is_compatibility,
norm_coord_num, addr_mod_num,
filt_mod_num);
test_error(err, "testing clGetSamplerInfo params failed");
}
}
}
return 0;
}
int test_get_sampler_info(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(get_sampler_info, Version(2, 0))
{
int error;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
error = get_sampler_info_params(deviceID, context, false);
error = get_sampler_info_params(device, context, false);
test_error(error, "Test Failed");
return 0;
}
int test_get_sampler_info_compatibility(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST(get_sampler_info_compatibility)
{
int error;
PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID)
PASSIVE_REQUIRE_IMAGE_SUPPORT(device)
error = get_sampler_info_params(deviceID, context, true);
error = get_sampler_info_params(device, context, true);
test_error(error, "Test Failed");
return 0;
@@ -347,8 +343,7 @@ int command_queue_param_test(cl_command_queue queue,
return 0;
}
int check_get_command_queue_info_params(cl_device_id deviceID,
cl_context context,
int check_get_command_queue_info_params(cl_device_id device, cl_context context,
bool is_compatibility)
{
const cl_command_queue_properties host_optional[] = {
@@ -370,7 +365,7 @@ int check_get_command_queue_info_params(cl_device_id deviceID,
const size_t host_optional_size = ARRAY_SIZE(host_optional);
const size_t device_required_size = ARRAY_SIZE(device_required);
Version version = get_device_cl_version(deviceID);
Version version = get_device_cl_version(device);
const cl_device_info host_queue_query = version >= Version(2, 0)
? CL_DEVICE_QUEUE_ON_HOST_PROPERTIES
@@ -378,7 +373,7 @@ int check_get_command_queue_info_params(cl_device_id deviceID,
cl_queue_properties host_queue_props = 0;
int error =
clGetDeviceInfo(deviceID, host_queue_query, sizeof(host_queue_props),
clGetDeviceInfo(device, host_queue_query, sizeof(host_queue_props),
&host_queue_props, NULL);
test_error(error, "clGetDeviceInfo failed");
log_info("CL_DEVICE_QUEUE_ON_HOST_PROPERTIES is %" PRIu64 "\n",
@@ -387,7 +382,7 @@ int check_get_command_queue_info_params(cl_device_id deviceID,
cl_queue_properties device_queue_props = 0;
if (version >= Version(2, 0))
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
sizeof(device_queue_props), &device_queue_props,
NULL);
test_error(error, "clGetDeviceInfo failed");
@@ -430,12 +425,12 @@ int check_get_command_queue_info_params(cl_device_id deviceID,
clCommandQueueWrapper queue;
if (is_compatibility)
{
queue = clCreateCommandQueue(context, deviceID, props, &error);
queue = clCreateCommandQueue(context, device, props, &error);
test_error(error, "Unable to create command queue to test with");
}
else
{
queue = clCreateCommandQueueWithProperties(context, deviceID,
queue = clCreateCommandQueueWithProperties(context, device,
queue_props_arg, &error);
test_error(error, "Unable to create command queue to test with");
}
@@ -453,8 +448,8 @@ int check_get_command_queue_info_params(cl_device_id deviceID,
"context");
test_error(error, "param checking failed");
error = command_queue_param_test(queue, CL_QUEUE_DEVICE, deviceID,
"deviceID");
error =
command_queue_param_test(queue, CL_QUEUE_DEVICE, device, "device");
test_error(error, "param checking failed");
error = command_queue_param_test(queue, CL_QUEUE_PROPERTIES,
@@ -464,25 +459,21 @@ int check_get_command_queue_info_params(cl_device_id deviceID,
return 0;
}
int test_get_command_queue_info(cl_device_id deviceID, cl_context context,
cl_command_queue ignoreQueue, int num_elements)
REGISTER_TEST_VERSION(get_command_queue_info, Version(2, 0))
{
int error = check_get_command_queue_info_params(deviceID, context, false);
int error = check_get_command_queue_info_params(device, context, false);
test_error(error, "Test Failed");
return 0;
}
int test_get_command_queue_info_compatibility(cl_device_id deviceID,
cl_context context,
cl_command_queue ignoreQueue,
int num_elements)
REGISTER_TEST(get_command_queue_info_compatibility)
{
int error = check_get_command_queue_info_params(deviceID, context, true);
int error = check_get_command_queue_info_params(device, context, true);
test_error(error, "Test Failed");
return 0;
}
int test_get_context_info(cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements)
REGISTER_TEST(get_context_info)
{
int error;
size_t size;
@@ -534,16 +525,18 @@ return -1; \
} \
log_info( "\tReported device " name " : " type "\n", (int)( val / div ) );
int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements)
REGISTER_TEST(get_device_info)
{
int error;
size_t size;
cl_uint vendorID;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_VENDOR_ID, vendorID, "vendor ID", "0x%08x", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_VENDOR_ID, vendorID, "vendor ID",
"0x%08x", int)
char extensions[ 10240 ];
error = clGetDeviceInfo( deviceID, CL_DEVICE_EXTENSIONS, sizeof( extensions ), &extensions, &size );
error = clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(extensions),
&extensions, &size);
test_error( error, "Unable to get device extensions" );
if( size != strlen( extensions ) + 1 )
{
@@ -553,25 +546,33 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q
log_info( "\tReported device extensions: %s \n", extensions );
cl_uint preferred;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, preferred, "preferred vector char width", "%d", int )
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, preferred, "preferred vector short width", "%d", int )
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, preferred, "preferred vector int width", "%d", int )
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, preferred, "preferred vector long width", "%d", int )
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, preferred, "preferred vector float width", "%d", int )
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, preferred, "preferred vector double width", "%d", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, preferred,
"preferred vector char width", "%d", int)
TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, preferred,
"preferred vector short width", "%d", int)
TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, preferred,
"preferred vector int width", "%d", int)
TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, preferred,
"preferred vector long width", "%d", int)
TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, preferred,
"preferred vector float width", "%d", int)
TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
preferred, "preferred vector double width", "%d", int)
// Note that even if cl_khr_fp64, the preferred width for double can be non-zero. For example, vendors
// extensions can support double but may not support cl_khr_fp64, which implies math library support.
cl_uint baseAddrAlign;
TEST_DEVICE_PARAM(deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, baseAddrAlign,
TEST_DEVICE_PARAM(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, baseAddrAlign,
"base address alignment", "%d bits", int)
cl_uint maxDataAlign;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, maxDataAlign, "min data type alignment", "%d bytes", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, maxDataAlign,
"min data type alignment", "%d bytes", int)
cl_device_mem_cache_type cacheType;
error = clGetDeviceInfo( deviceID, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, sizeof( cacheType ), &cacheType, &size );
error = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE,
sizeof(cacheType), &cacheType, &size);
test_error( error, "Unable to get device global mem cache type" );
if( size != sizeof( cacheType ) )
{
@@ -582,16 +583,21 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q
log_info( "\tReported device global mem cache type: %s \n", cacheTypeName );
cl_uint cachelineSize;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cachelineSize, "global mem cacheline size", "%d bytes", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE,
cachelineSize, "global mem cacheline size", "%d bytes",
int)
cl_ulong cacheSize;
TEST_DEVICE_PARAM_MEM( deviceID, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cacheSize, "global mem cache size", "%d KB", 1024 )
TEST_DEVICE_PARAM_MEM(device, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cacheSize,
"global mem cache size", "%d KB", 1024)
cl_ulong memSize;
TEST_DEVICE_PARAM_MEM( deviceID, CL_DEVICE_GLOBAL_MEM_SIZE, memSize, "global mem size", "%d MB", ( 1024 * 1024 ) )
TEST_DEVICE_PARAM_MEM(device, CL_DEVICE_GLOBAL_MEM_SIZE, memSize,
"global mem size", "%d MB", (1024 * 1024))
cl_device_local_mem_type localMemType;
error = clGetDeviceInfo( deviceID, CL_DEVICE_LOCAL_MEM_TYPE, sizeof( localMemType ), &localMemType, &size );
error = clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_TYPE,
sizeof(localMemType), &localMemType, &size);
test_error( error, "Unable to get device local mem type" );
if( size != sizeof( cacheType ) )
{
@@ -603,22 +609,29 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q
cl_bool errSupport;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_ERROR_CORRECTION_SUPPORT, errSupport, "error correction support", "%d", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_ERROR_CORRECTION_SUPPORT, errSupport,
"error correction support", "%d", int)
size_t timerResolution;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PROFILING_TIMER_RESOLUTION, timerResolution, "profiling timer resolution", "%ld nanoseconds", long )
TEST_DEVICE_PARAM(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION,
timerResolution, "profiling timer resolution",
"%ld nanoseconds", long)
cl_bool endian;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_ENDIAN_LITTLE, endian, "little endian flag", "%d", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_ENDIAN_LITTLE, endian,
"little endian flag", "%d", int)
cl_bool avail;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_AVAILABLE, avail, "available flag", "%d", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_AVAILABLE, avail, "available flag",
"%d", int)
cl_bool compilerAvail;
TEST_DEVICE_PARAM( deviceID, CL_DEVICE_COMPILER_AVAILABLE, compilerAvail, "compiler available flag", "%d", int )
TEST_DEVICE_PARAM(device, CL_DEVICE_COMPILER_AVAILABLE, compilerAvail,
"compiler available flag", "%d", int)
char profile[ 1024 ];
error = clGetDeviceInfo( deviceID, CL_DEVICE_PROFILE, sizeof( profile ), &profile, &size );
error = clGetDeviceInfo(device, CL_DEVICE_PROFILE, sizeof(profile),
&profile, &size);
test_error( error, "Unable to get device profile" );
if( size != strlen( profile ) + 1 )
{
@@ -644,8 +657,6 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q
}
static const char *sample_compile_size[2] = {
"__kernel void sample_test(__global int *src, __global int *dst)\n"
"{\n"
@@ -660,7 +671,7 @@ static const char *sample_compile_size[2] = {
"\n"
"}\n" };
int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(kernel_required_group_size)
{
int error;
size_t realSize;
@@ -670,7 +681,8 @@ int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, c
cl_uint max_dimensions;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(max_dimensions), &max_dimensions, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
sizeof(max_dimensions), &max_dimensions, NULL);
test_error(error, "clGetDeviceInfo failed for CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS");
log_info("Device reported CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = %d.\n", (int)max_dimensions);
@@ -682,12 +694,17 @@ int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, c
if( error != 0 )
return error;
error = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_WORK_GROUP_SIZE, sizeof(kernel_max_workgroup_size), &kernel_max_workgroup_size, NULL);
error =
clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_WORK_GROUP_SIZE,
sizeof(kernel_max_workgroup_size),
&kernel_max_workgroup_size, NULL);
test_error( error, "clGetKernelWorkGroupInfo failed for CL_KERNEL_WORK_GROUP_SIZE");
log_info("The CL_KERNEL_WORK_GROUP_SIZE for the kernel is %d.\n", (int)kernel_max_workgroup_size);
size_t size[ 3 ];
error = clGetKernelWorkGroupInfo( kernel, deviceID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, sizeof( size ), size, &realSize );
error = clGetKernelWorkGroupInfo(kernel, device,
CL_KERNEL_COMPILE_WORK_GROUP_SIZE,
sizeof(size), size, &realSize);
test_error( error, "Unable to get work group info" );
if( size[ 0 ] != 0 || size[ 1 ] != 0 || size[ 2 ] != 0 )
@@ -735,7 +752,9 @@ int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, c
return error;
size_t size[ 3 ];
error = clGetKernelWorkGroupInfo( kernel, deviceID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, sizeof( size ), size, &realSize );
error = clGetKernelWorkGroupInfo(kernel, device,
CL_KERNEL_COMPILE_WORK_GROUP_SIZE,
sizeof(size), size, &realSize);
test_error( error, "Unable to get work group info" );
if( size[ 0 ] != local[0] || size[ 1 ] != local[1] || size[ 2 ] != local[2] )

View File

@@ -1,5 +1,5 @@
//
// Copyright (c) 2020 The Khronos Group Inc.
// Copyright (c) 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -18,13 +18,12 @@
#include "testBase.h"
#include "harness/typeWrappers.h"
int test_queue_flush_on_release(cl_device_id deviceID, cl_context context,
cl_command_queue defaultQueue, int num_elements)
REGISTER_TEST(queue_flush_on_release)
{
cl_int err;
// Create a command queue
cl_command_queue queue = clCreateCommandQueue(context, deviceID, 0, &err);
cl_command_queue cmd_queue = clCreateCommandQueue(context, device, 0, &err);
test_error(err, "Could not create command queue");
// Create a kernel
@@ -38,12 +37,12 @@ int test_queue_flush_on_release(cl_device_id deviceID, cl_context context,
// Enqueue the kernel
size_t gws = 1;
clEventWrapper event;
err = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &gws, nullptr, 0,
nullptr, &event);
err = clEnqueueNDRangeKernel(cmd_queue, kernel, 1, nullptr, &gws, nullptr,
0, nullptr, &event);
test_error(err, "Could not enqueue kernel");
// Release the queue
err = clReleaseCommandQueue(queue);
err = clReleaseCommandQueue(cmd_queue);
// Wait for kernel to execute since the queue must flush on release
bool success = poll_until(2000, 50, [&event]() {
@@ -59,3 +58,61 @@ int test_queue_flush_on_release(cl_device_id deviceID, cl_context context,
return success ? TEST_PASS : TEST_FAIL;
}
REGISTER_TEST(multi_queue_flush_on_release)
{
cl_int err;
// Create A command queue
cl_command_queue queue_A = clCreateCommandQueue(context, device, 0, &err);
test_error(err, "Could not create command queue A");
// Create B command queue
cl_command_queue queue_B = clCreateCommandQueue(context, device, 0, &err);
test_error(err, "Could not create command queue B");
// Create a kernel
clProgramWrapper program;
clKernelWrapper kernel;
const char *source = "void kernel test(){}";
err = create_single_kernel_helper(context, &program, &kernel, 1, &source,
"test");
test_error(err, "Could not create kernel");
// Enqueue the kernel on queue_A and obtain event to synchronize with
// queue_B
size_t gws = num_elements;
clEventWrapper event_A;
err = clEnqueueNDRangeKernel(queue_A, kernel, 1, nullptr, &gws, nullptr, 0,
nullptr, &event_A);
test_error(err, "Could not enqueue kernel");
// Enqueue the kernel on queue_B using event_A for synchronization and
// create event_B to track completion
clEventWrapper event_B;
err = clEnqueueNDRangeKernel(queue_B, kernel, 1, nullptr, &gws, nullptr, 1,
&event_A, &event_B);
test_error(err, "Could not enqueue kernel");
// Release queue_A, which performs an implicit flush to issue any previously
// queued OpenCL commands
err = clReleaseCommandQueue(queue_A);
test_error(err, "clReleaseCommandQueue failed");
err = clFlush(queue_B);
test_error(err, "clFlush failed");
// Wait for kernel to execute since the queue must flush on release
bool success = poll_until(2000, 50, [&event_B]() {
cl_int status;
cl_int err = clGetEventInfo(event_B, CL_EVENT_COMMAND_EXECUTION_STATUS,
sizeof(cl_int), &status, nullptr);
if ((err != CL_SUCCESS) || (status != CL_COMPLETE))
{
return false;
}
return true;
});
return success ? TEST_PASS : TEST_FAIL;
}

View File

@@ -73,9 +73,7 @@ int test_enqueue(cl_context context, clCommandQueueWrapper& queue, clKernelWrapp
}
int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(queue_hint)
{
if (num_elements <= 0)
{
@@ -94,7 +92,7 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue
return err;
}
if (is_extension_available(deviceID, "cl_khr_priority_hints"))
if (is_extension_available(device, "cl_khr_priority_hints"))
{
log_info("Testing cl_khr_priority_hints...\n");
@@ -116,7 +114,8 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue
for (int i = 0; i < 3; ++i)
{
clCommandQueueWrapper q = clCreateCommandQueueWithProperties(context, deviceID, queue_prop[i], &err);
clCommandQueueWrapper q = clCreateCommandQueueWithProperties(
context, device, queue_prop[i], &err);
test_error(err, "clCreateCommandQueueWithProperties failed");
err = test_enqueue(context, q, kernel, (size_t)num_elements);
@@ -131,7 +130,7 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue
log_info("cl_khr_priority_hints is not supported.\n");
}
if (is_extension_available(deviceID, "cl_khr_throttle_hints"))
if (is_extension_available(device, "cl_khr_throttle_hints"))
{
log_info("Testing cl_khr_throttle_hints...\n");
cl_queue_properties queue_prop[][3] =
@@ -152,7 +151,8 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue
for (int i = 0; i < 3; ++i)
{
clCommandQueueWrapper q = clCreateCommandQueueWithProperties(context, deviceID, queue_prop[i], &err);
clCommandQueueWrapper q = clCreateCommandQueueWithProperties(
context, device, queue_prop[i], &err);
test_error(err, "clCreateCommandQueueWithProperties failed");
err = test_enqueue(context, q, kernel, (size_t)num_elements);
@@ -170,4 +170,3 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue
return 0;
}

View File

@@ -37,7 +37,10 @@ const char *queue_test_kernel[] = {
"\n"
"}\n" };
int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop_def, cl_device_id deviceID, clKernelWrapper& kernel, size_t num_elements)
int enqueue_kernel(cl_context context,
const cl_queue_properties_khr *queue_prop_def,
cl_device_id device, clKernelWrapper &kernel,
size_t num_elements)
{
clMemWrapper streams[2];
int error;
@@ -46,7 +49,8 @@ int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop
cl_platform_id platform;
clEventWrapper event;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id),
&platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed");
clCreateCommandQueueWithPropertiesKHR = (clCreateCommandQueueWithPropertiesKHR_fn) clGetExtensionFunctionAddressForPlatform(platform, "clCreateCommandQueueWithPropertiesKHR");
@@ -56,7 +60,8 @@ int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop
return -1;
}
clCommandQueueWrapper queue = clCreateCommandQueueWithPropertiesKHR(context, deviceID, queue_prop_def, &error);
clCommandQueueWrapper queue = clCreateCommandQueueWithPropertiesKHR(
context, device, queue_prop_def, &error);
test_error(error, "clCreateCommandQueueWithPropertiesKHR failed");
for (size_t i = 0; i < num_elements; ++i)
@@ -96,7 +101,7 @@ int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop
return 0;
}
int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(queue_properties)
{
if (num_elements <= 0)
{
@@ -111,7 +116,7 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_
0 };
// Query extension
if (!is_extension_available(deviceID, "cl_khr_create_command_queue"))
if (!is_extension_available(device, "cl_khr_create_command_queue"))
{
log_info("extension cl_khr_create_command_queue is not supported.\n");
return 0;
@@ -121,17 +126,19 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_
test_error(error, "create_single_kernel_helper failed");
log_info("Queue property NULL. Testing ... \n");
error = enqueue_kernel(context, NULL,deviceID, kernel, (size_t)num_elements);
error = enqueue_kernel(context, NULL, device, kernel, (size_t)num_elements);
test_error(error, "enqueue_kernel failed");
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, sizeof(device_props), &device_props, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");
if (device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
{
log_info("Queue property CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE supported. Testing ... \n");
queue_prop_def[1] = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
error = enqueue_kernel(context, queue_prop_def, deviceID, kernel, (size_t)num_elements);
error = enqueue_kernel(context, queue_prop_def, device, kernel,
(size_t)num_elements);
test_error(error, "enqueue_kernel failed");
} else
{
@@ -142,7 +149,8 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_
{
log_info("Queue property CL_QUEUE_PROFILING_ENABLE supported. Testing ... \n");
queue_prop_def[1] = CL_QUEUE_PROFILING_ENABLE;
error = enqueue_kernel(context, queue_prop_def, deviceID, kernel, (size_t)num_elements);
error = enqueue_kernel(context, queue_prop_def, device, kernel,
(size_t)num_elements);
test_error(error, "enqueue_kernel failed");
} else
{
@@ -153,7 +161,8 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_
{
log_info("Queue property CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE & CL_QUEUE_PROFILING_ENABLE supported. Testing ... \n");
queue_prop_def[1] = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE|CL_QUEUE_PROFILING_ENABLE;
error = enqueue_kernel(context, queue_prop_def, deviceID, kernel, (size_t)num_elements);
error = enqueue_kernel(context, queue_prop_def, device, kernel,
(size_t)num_elements);
test_error(error, "enqueue_kernel failed");
}
else

View File

@@ -26,7 +26,7 @@ struct test_queue_array_properties_data
};
int verify_if_properties_supported(
cl_device_id deviceID, cl_command_queue_properties requested_bitfield,
cl_device_id device, cl_command_queue_properties requested_bitfield,
cl_uint requested_size)
{
int error = CL_SUCCESS;
@@ -40,7 +40,7 @@ int verify_if_properties_supported(
{
cl_uint max_queue_size = 0;
error =
clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE,
clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE,
sizeof(max_queue_size), &max_queue_size, NULL);
test_error(error,
"clGetDeviceInfo for "
@@ -71,7 +71,7 @@ int verify_if_properties_supported(
if (on_host_queue)
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
sizeof(supported_properties),
&supported_properties, NULL);
test_error(error,
@@ -80,7 +80,7 @@ int verify_if_properties_supported(
}
else
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
sizeof(supported_properties),
&supported_properties, NULL);
test_error(error,
@@ -107,7 +107,7 @@ int verify_if_properties_supported(
}
static int create_queue_and_check_array_properties(
cl_context context, cl_device_id deviceID,
cl_context context, cl_device_id device,
test_queue_array_properties_data test_case)
{
cl_int error = CL_SUCCESS;
@@ -117,13 +117,13 @@ static int create_queue_and_check_array_properties(
if (test_case.properties.size() > 0)
{
test_queue = clCreateCommandQueueWithProperties(
context, deviceID, test_case.properties.data(), &error);
context, device, test_case.properties.data(), &error);
test_error(error, "clCreateCommandQueueWithProperties failed");
}
else
{
test_queue =
clCreateCommandQueueWithProperties(context, deviceID, NULL, &error);
clCreateCommandQueueWithProperties(context, device, NULL, &error);
test_error(error, "clCreateCommandQueueWithProperties failed");
}
@@ -162,7 +162,7 @@ static int create_queue_and_check_array_properties(
}
static int
run_test_queue_array_properties(cl_context context, cl_device_id deviceID,
run_test_queue_array_properties(cl_context context, cl_device_id device,
test_queue_array_properties_data test_case)
{
int error = TEST_PASS;
@@ -189,7 +189,7 @@ run_test_queue_array_properties(cl_context context, cl_device_id deviceID,
}
}
error = verify_if_properties_supported(deviceID, requested_bitfield,
error = verify_if_properties_supported(device, requested_bitfield,
requested_size);
if (error == TEST_SKIPPED_ITSELF)
{
@@ -201,16 +201,14 @@ run_test_queue_array_properties(cl_context context, cl_device_id deviceID,
}
// continue testing if supported user properties
error =
create_queue_and_check_array_properties(context, deviceID, test_case);
error = create_queue_and_check_array_properties(context, device, test_case);
test_error(error, "create_queue_and_check_array_properties failed.\n");
log_info("TC result: passed\n");
return TEST_PASS;
}
int test_queue_properties_queries(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(queue_properties_queries, Version(3, 0))
{
int error = TEST_PASS;
std::vector<test_queue_array_properties_data> test_cases;
@@ -264,13 +262,12 @@ int test_queue_properties_queries(cl_device_id deviceID, cl_context context,
for (auto test_case : test_cases)
{
error |= run_test_queue_array_properties(context, deviceID, test_case);
error |= run_test_queue_array_properties(context, device, test_case);
}
return error;
}
int test_set_command_queue_property(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(set_command_queue_property)
{
int err;
@@ -281,7 +278,7 @@ int test_set_command_queue_property(cl_device_id deviceID, cl_context context,
// Add other supported properties combinations
cl_command_queue_properties supported_queue_props;
clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES,
clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(supported_queue_props), &supported_queue_props,
NULL);
if (supported_queue_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
@@ -297,7 +294,7 @@ int test_set_command_queue_property(cl_device_id deviceID, cl_context context,
queue_property_options)
{
clCommandQueueWrapper test_queue =
clCreateCommandQueue(context, deviceID, initial_properties, &err);
clCreateCommandQueue(context, device, initial_properties, &err);
test_error(err, "clCreateCommandQueue failed");
cl_command_queue_properties old_properties, set_properties,

View File

@@ -30,28 +30,28 @@
log_error( "ERROR: Instance count for test object is not valid! (should be %d, really is %d)\n", rightValue, c ); \
return -1; }
int test_retain_queue_single(cl_device_id deviceID, cl_context context, cl_command_queue queueNotUsed, int num_elements)
REGISTER_TEST(retain_queue_single)
{
cl_command_queue queue;
cl_command_queue cmd_queue;
cl_uint numInstances;
int err;
/* Create a test queue */
queue = clCreateCommandQueue( context, deviceID, 0, &err );
cmd_queue = clCreateCommandQueue(context, device, 0, &err);
test_error( err, "Unable to create command queue to test with" );
/* Test the instance count */
GET_QUEUE_INSTANCE_COUNT( queue );
GET_QUEUE_INSTANCE_COUNT(cmd_queue);
test_error( err, "Unable to get queue instance count" );
VERIFY_INSTANCE_COUNT( numInstances, 1 );
/* Now release the program */
clReleaseCommandQueue( queue );
clReleaseCommandQueue(cmd_queue);
#ifdef VERIFY_AFTER_RELEASE
/* We're not allowed to get the instance count after the object has been completely released. But that's
exactly how we can tell the release worked--by making sure getting the instance count fails! */
GET_QUEUE_INSTANCE_COUNT( queue );
GET_QUEUE_INSTANCE_COUNT(cmd_queue);
if( err != CL_INVALID_COMMAND_QUEUE )
{
print_error( err, "Command queue was not properly released" );
@@ -62,65 +62,65 @@ int test_retain_queue_single(cl_device_id deviceID, cl_context context, cl_comma
return 0;
}
int test_retain_queue_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queueNotUsed, int num_elements)
REGISTER_TEST(retain_queue_multiple)
{
cl_command_queue queue;
cl_command_queue cmd_queue;
unsigned int numInstances, i;
int err;
/* Create a test program */
queue = clCreateCommandQueue( context, deviceID, 0, &err );
cmd_queue = clCreateCommandQueue(context, device, 0, &err);
test_error( err, "Unable to create command queue to test with" );
/* Increment 9 times, which should bring the count to 10 */
for( i = 0; i < 9; i++ )
{
clRetainCommandQueue( queue );
clRetainCommandQueue(cmd_queue);
}
/* Test the instance count */
GET_QUEUE_INSTANCE_COUNT( queue );
GET_QUEUE_INSTANCE_COUNT(cmd_queue);
test_error( err, "Unable to get queue instance count" );
VERIFY_INSTANCE_COUNT( numInstances, 10 );
/* Now release 5 times, which should take us to 5 */
for( i = 0; i < 5; i++ )
{
clReleaseCommandQueue( queue );
clReleaseCommandQueue(cmd_queue);
}
GET_QUEUE_INSTANCE_COUNT( queue );
GET_QUEUE_INSTANCE_COUNT(cmd_queue);
test_error( err, "Unable to get queue instance count" );
VERIFY_INSTANCE_COUNT( numInstances, 5 );
/* Retain again three times, which should take us to 8 */
for( i = 0; i < 3; i++ )
{
clRetainCommandQueue( queue );
clRetainCommandQueue(cmd_queue);
}
GET_QUEUE_INSTANCE_COUNT( queue );
GET_QUEUE_INSTANCE_COUNT(cmd_queue);
test_error( err, "Unable to get queue instance count" );
VERIFY_INSTANCE_COUNT( numInstances, 8 );
/* Release 7 times, which should take it to 1 */
for( i = 0; i < 7; i++ )
{
clReleaseCommandQueue( queue );
clReleaseCommandQueue(cmd_queue);
}
GET_QUEUE_INSTANCE_COUNT( queue );
GET_QUEUE_INSTANCE_COUNT(cmd_queue);
test_error( err, "Unable to get queue instance count" );
VERIFY_INSTANCE_COUNT( numInstances, 1 );
/* And one last one */
clReleaseCommandQueue( queue );
clReleaseCommandQueue(cmd_queue);
#ifdef VERIFY_AFTER_RELEASE
/* We're not allowed to get the instance count after the object has been completely released. But that's
exactly how we can tell the release worked--by making sure getting the instance count fails! */
GET_QUEUE_INSTANCE_COUNT( queue );
GET_QUEUE_INSTANCE_COUNT(cmd_queue);
if( err != CL_INVALID_COMMAND_QUEUE )
{
print_error( err, "Command queue was not properly released" );
@@ -131,7 +131,7 @@ int test_retain_queue_multiple(cl_device_id deviceID, cl_context context, cl_com
return 0;
}
int test_retain_mem_object_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(retain_mem_object_single)
{
cl_mem object;
cl_uint numInstances;
@@ -163,7 +163,7 @@ int test_retain_mem_object_single(cl_device_id deviceID, cl_context context, cl_
return 0;
}
int test_retain_mem_object_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(retain_mem_object_multiple)
{
cl_mem object;
unsigned int numInstances, i;
@@ -232,7 +232,7 @@ int test_retain_mem_object_multiple(cl_device_id deviceID, cl_context context, c
return 0;
}
int test_retain_mem_object_set_kernel_arg(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(retain_mem_object_set_kernel_arg)
{
int err;
cl_mem buffer = nullptr;

View File

@@ -21,7 +21,7 @@
#include "harness/compat.h"
int test_release_kernel_order(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(release_kernel_order)
{
cl_program program;
cl_kernel kernel;
@@ -50,7 +50,7 @@ const char *sample_delay_kernel[] = {
"\n"
"}\n" };
int test_release_during_execute( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(release_during_execute)
{
int error;
cl_program program;
@@ -100,5 +100,3 @@ int test_release_during_execute( cl_device_id deviceID, cl_context context, cl_c
return 0;
}

View File

@@ -54,7 +54,7 @@ cl_int get_sub_group_num(cl_command_queue queue, cl_kernel kernel, clMemWrapper&
return error;
}
int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(sub_group_dispatch, Version(2, 1))
{
int error;
size_t realSize;
@@ -73,12 +73,12 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
size_t ret_ndrange2d_flattened;
size_t ret_ndrange3d_flattened;
if (get_device_cl_version(deviceID) >= Version(3, 0))
if (get_device_cl_version(device) >= Version(3, 0))
{
int error;
cl_uint max_num_sub_groups;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_NUM_SUB_GROUPS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_NUM_SUB_GROUPS,
sizeof(max_num_sub_groups), &max_num_sub_groups,
NULL);
if (error != CL_SUCCESS)
@@ -102,16 +102,20 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
out = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, sizeof(size_t), NULL, &error);
test_error(error, "clCreateBuffer failed");
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &max_local, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE,
sizeof(size_t), &max_local, NULL);
test_error(error, "clGetDeviceInfo failed");
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), (void *)&platform, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
(void *)&platform, NULL);
test_error(error, "clDeviceInfo failed for CL_DEVICE_PLATFORM");
// Get the max subgroup size
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE,
sizeof(max_local), &max_local, sizeof(kernel_max_subgroup_size), (void *)&kernel_max_subgroup_size, &realSize);
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE,
sizeof(max_local), &max_local, sizeof(kernel_max_subgroup_size),
(void *)&kernel_max_subgroup_size, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE");
log_info("The CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE for the kernel is %d.\n", (int)kernel_max_subgroup_size);
@@ -121,8 +125,10 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
}
// Get the number of subgroup for max local size
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE,
sizeof(max_local), &max_local, sizeof(kernel_subgroup_count), (void *)&kernel_subgroup_count, &realSize);
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE,
sizeof(max_local), &max_local, sizeof(kernel_subgroup_count),
(void *)&kernel_subgroup_count, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE");
log_info("The CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE for the kernel is %d.\n", (int)kernel_subgroup_count);
@@ -138,7 +144,9 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
{
// test all 3 different dimention of requested local size
size_t kernel_ret_size = 0;
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), &i, sizeof(ret_ndrange1d), &ret_ndrange1d, &realSize);
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i),
&i, sizeof(ret_ndrange1d), &ret_ndrange1d, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
if (realSize != sizeof(ret_ndrange1d)) {
log_error( "ERROR: Returned size of sub group count not valid! (Expected %d, got %d)\n", (int)sizeof(kernel_subgroup_count), (int)realSize );
@@ -153,7 +161,9 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
return -1;
}
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), &i, sizeof(ret_ndrange2d), ret_ndrange2d, &realSize);
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i),
&i, sizeof(ret_ndrange2d), ret_ndrange2d, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
if (realSize != sizeof(ret_ndrange2d)) {
log_error( "ERROR: Returned size of sub group count not valid! (Expected %d, got %d)\n", (int)sizeof(kernel_subgroup_count), (int)realSize );
@@ -170,7 +180,9 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
return -1;
}
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), &i, sizeof(ret_ndrange3d), ret_ndrange3d, &realSize);
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i),
&i, sizeof(ret_ndrange3d), ret_ndrange3d, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
if (realSize != sizeof(ret_ndrange3d)) {
log_error( "ERROR: Returned size of sub group count not valid! (Expected %d, got %d)\n", (int)sizeof(kernel_subgroup_count), (int)realSize );
@@ -191,16 +203,26 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
// test when input subgroup count exceeds max wg size:
// there can be at most the local size of (1 WI) subgroups
size_t large_sg_size = max_local + 1;
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(size_t), &large_sg_size, sizeof(ret_ndrange1d), &ret_ndrange1d, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT,
sizeof(size_t), &large_sg_size, sizeof(ret_ndrange1d), &ret_ndrange1d,
&realSize);
test_error(error,
"clGetKernelSubGroupInfo failed for "
"CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
if (ret_ndrange1d != 0)
{
log_error( "ERROR: Incorrect value returned for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT! (Expected %d, got %d)\n", 0, (int)ret_ndrange1d );
return -1;
}
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(size_t), &large_sg_size, sizeof(ret_ndrange2d), ret_ndrange2d, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT,
sizeof(size_t), &large_sg_size, sizeof(ret_ndrange2d), ret_ndrange2d,
&realSize);
test_error(error,
"clGetKernelSubGroupInfo failed for "
"CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
if (ret_ndrange2d[0] != 0 ||
ret_ndrange2d[1] != 0)
{
@@ -208,8 +230,13 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman
return -1;
}
error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(size_t), &large_sg_size, sizeof(ret_ndrange3d), ret_ndrange3d, &realSize);
test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
error = clGetKernelSubGroupInfo(
kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT,
sizeof(size_t), &large_sg_size, sizeof(ret_ndrange3d), ret_ndrange3d,
&realSize);
test_error(error,
"clGetKernelSubGroupInfo failed for "
"CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT");
if (ret_ndrange3d[0] != 0 ||
ret_ndrange3d[1] != 0 ||
ret_ndrange3d[2] != 0)

View File

@@ -14,6 +14,7 @@
// limitations under the License.
//
#include "harness/compat.h"
#include "harness/typeWrappers.h"
#include <stdio.h>
#include <iostream>
@@ -21,7 +22,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#include <CL/cl_ext.h>
const char* wg_scan_local_work_group_size = R"(
@@ -276,9 +277,7 @@ int do_test_work_group_suggested_local_size(
return err;
}
int test_work_group_suggested_local_size_1D(cl_device_id device,
cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(work_group_suggested_local_size_1D)
{
if (!is_extension_available(device, "cl_khr_suggested_local_work_size"))
{
@@ -380,9 +379,7 @@ int test_work_group_suggested_local_size_1D(cl_device_id device,
return err;
}
int test_work_group_suggested_local_size_2D(cl_device_id device,
cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(work_group_suggested_local_size_2D)
{
if (!is_extension_available(device, "cl_khr_suggested_local_work_size"))
{
@@ -485,9 +482,7 @@ int test_work_group_suggested_local_size_2D(cl_device_id device,
return err;
}
int test_work_group_suggested_local_size_3D(cl_device_id device,
cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(work_group_suggested_local_size_3D)
{
if (!is_extension_available(device, "cl_khr_suggested_local_work_size"))
{

View File

@@ -58,7 +58,8 @@ cl_int test_zero_sized_enqueue_and_test_output_buffer(cl_command_queue queue, cl
return clEnqueueUnmapMemObject(queue, buf, output, 0, NULL, NULL);
}
int test_zero_sized_enqueue_helper(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
int test_zero_sized_enqueue_helper(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
int error;
clProgramWrapper program;
@@ -185,9 +186,10 @@ int test_zero_sized_enqueue_helper(cl_device_id deviceID, cl_context context, cl
}
int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(zero_sized_enqueue, Version(2, 1))
{
int res = test_zero_sized_enqueue_helper(deviceID, context, queue, num_elements);
int res =
test_zero_sized_enqueue_helper(device, context, queue, num_elements);
if (res != 0)
{
return res;
@@ -195,7 +197,9 @@ int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_comman
// now test out of order queue
cl_command_queue_properties props;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, sizeof(cl_command_queue_properties), &props, NULL);
cl_int error =
clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(cl_command_queue_properties), &props, NULL);
test_error( error, "clGetDeviceInfo failed.");
if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
@@ -207,10 +211,12 @@ int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_comman
0
};
clCommandQueueWrapper ooqueue = clCreateCommandQueueWithProperties(context, deviceID, queue_prop_def, &error);
clCommandQueueWrapper ooqueue = clCreateCommandQueueWithProperties(
context, device, queue_prop_def, &error);
test_error( error, "clCreateCommandQueueWithProperties failed.");
res = test_zero_sized_enqueue_helper(deviceID, context, ooqueue, num_elements);
res = test_zero_sized_enqueue_helper(device, context, ooqueue,
num_elements);
}
return res;

View File

@@ -13,39 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "harness/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "procs.h"
#include "harness/testHarness.h"
#if !defined(_WIN32)
#include <unistd.h>
#endif
// clang-format off
test_definition test_list[] = {
ADD_TEST( atomic_add ),
ADD_TEST( atomic_sub ),
ADD_TEST( atomic_xchg ),
ADD_TEST( atomic_min ),
ADD_TEST( atomic_max ),
ADD_TEST( atomic_inc ),
ADD_TEST( atomic_dec ),
ADD_TEST( atomic_cmpxchg ),
ADD_TEST( atomic_and ),
ADD_TEST( atomic_or ),
ADD_TEST( atomic_xor ),
ADD_TEST( atomic_add_index ),
ADD_TEST( atomic_add_index_bin ),
};
// clang-format on
const int test_num = ARRAY_SIZE(test_list);
int main(int argc, const char *argv[])
{
return runTestHarness(argc, argv, test_num, test_list, false, 0);
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0);
}

View File

@@ -1,51 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "harness/errorHelpers.h"
#include "harness/kernelHelpers.h"
#include "harness/typeWrappers.h"
extern int create_program_and_kernel(const char *source,
const char *kernel_name,
cl_program *program_ret,
cl_kernel *kernel_ret);
extern int test_atomic_add(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_sub(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_xchg(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_min(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_max(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_inc(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_dec(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_cmpxchg(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_and(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_or(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_xor(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_add_index(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_atomic_add_index_bin(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);

View File

@@ -1,28 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef _testBase_h
#define _testBase_h
#include "harness/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#endif // _testBase_h

View File

@@ -13,13 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "testBase.h"
#include "harness/conversions.h"
#ifndef _WIN32
#include <unistd.h>
#endif
#include "harness/typeWrappers.h"
#include <cinttypes>
#include <vector>
#define INT_TEST_VALUE 402258822
#define LONG_TEST_VALUE 515154531254381446LL
@@ -136,12 +134,12 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
int error;
size_t threads[1];
clMemWrapper streams[2];
void *refValues, *startRefValues;
std::vector<char> refValues;
std::vector<char> startRefValues;
size_t threadSize, groupSize;
const char *programLines[4];
char pragma[512];
char programHeader[512];
MTdata d;
size_t typeSize = get_explicit_type_size(dataType);
@@ -247,23 +245,20 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
log_info("\t(thread count %d, group size %d)\n", (int)threadSize,
(int)groupSize);
refValues = (cl_int *)malloc(typeSize * threadSize);
refValues.resize(typeSize * threadSize);
if (testFns.GenerateRefsIntFn != NULL)
{
// We have a ref generator provided
d = init_genrand(gRandomSeed);
startRefValues = malloc(typeSize * threadSize);
MTdataHolder d_holder(gRandomSeed);
startRefValues.resize(typeSize * threadSize);
if (typeSize == 4)
testFns.GenerateRefsIntFn(threadSize, (cl_int *)startRefValues, d);
testFns.GenerateRefsIntFn(
threadSize, (cl_int *)startRefValues.data(), d_holder);
else
testFns.GenerateRefsLongFn(threadSize, (cl_long *)startRefValues,
d);
free_mtdata(d);
d = NULL;
testFns.GenerateRefsLongFn(
threadSize, (cl_long *)startRefValues.data(), d_holder);
}
else
startRefValues = NULL;
// If we're given a num_results function, we need to determine how many
// result objects we need. If we don't have it, we assume it's just 1
@@ -271,28 +266,26 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
? testFns.NumResultsFn(threadSize, dataType)
: 1;
char *destItems = new char[typeSize * numDestItems];
if (destItems == NULL)
{
log_error("ERROR: Unable to allocate memory!\n");
return -1;
}
std::vector<char> destItems(typeSize * numDestItems);
void *startValue = (typeSize == 4) ? (void *)&testFns.mIntStartValue
: (void *)&testFns.mLongStartValue;
for (size_t i = 0; i < numDestItems; i++)
memcpy(destItems + i * typeSize, startValue, typeSize);
memcpy(destItems.data() + i * typeSize, startValue, typeSize);
streams[0] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR,
typeSize * numDestItems, destItems, NULL);
streams[0] =
clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, typeSize * numDestItems,
destItems.data(), NULL);
if (!streams[0])
{
log_error("ERROR: Creating output array failed!\n");
return -1;
}
streams[1] = clCreateBuffer(
context,
((startRefValues != NULL ? CL_MEM_COPY_HOST_PTR : CL_MEM_READ_WRITE)),
typeSize * threadSize, startRefValues, NULL);
streams[1] =
clCreateBuffer(context,
((startRefValues.data() != NULL ? CL_MEM_COPY_HOST_PTR
: CL_MEM_READ_WRITE)),
typeSize * threadSize, startRefValues.data(), NULL);
if (!streams[1])
{
log_error("ERROR: Creating reference array failed!\n");
@@ -310,7 +303,7 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
error = clSetKernelArg(kernel, 2, typeSize * numDestItems, NULL);
test_error(error, "Unable to set indexed local kernel argument");
cl_int numDestItemsInt = (cl_int)numDestItems;
cl_int numDestItemsInt = numDestItems;
error = clSetKernelArg(kernel, 3, sizeof(cl_int), &numDestItemsInt);
test_error(error, "Unable to set indexed kernel argument");
}
@@ -323,12 +316,12 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
error =
clEnqueueReadBuffer(queue, streams[0], true, 0, typeSize * numDestItems,
destItems, 0, NULL, NULL);
destItems.data(), 0, NULL, NULL);
test_error(error, "Unable to read result value!");
error =
clEnqueueReadBuffer(queue, streams[1], true, 0, typeSize * threadSize,
refValues, 0, NULL, NULL);
refValues.data(), 0, NULL, NULL);
test_error(error, "Unable to read reference values!");
// If we have an expectedFn, then we need to generate a final value to
@@ -345,27 +338,29 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
{
// Int version
intVal = testFns.ExpectedValueIntFn(
threadSize, (cl_int *)startRefValues, i);
threadSize, (cl_int *)startRefValues.data(), i);
memcpy(expected, &intVal, sizeof(intVal));
}
else
{
// Long version
longVal = testFns.ExpectedValueLongFn(
threadSize, (cl_long *)startRefValues, i);
threadSize, (cl_long *)startRefValues.data(), i);
memcpy(expected, &longVal, sizeof(longVal));
}
if (memcmp(expected, destItems + i * typeSize, typeSize) != 0)
if (memcmp(expected, destItems.data() + i * typeSize, typeSize)
!= 0)
{
if (typeSize == 4)
{
cl_int *outValue = (cl_int *)(destItems + i * typeSize);
cl_int *outValue =
(cl_int *)(destItems.data() + i * typeSize);
log_error("ERROR: Result %zu from kernel does not "
"validate! (should be %d, was %d)\n",
i, intVal, *outValue);
cl_int *startRefs = (cl_int *)startRefValues;
cl_int *refs = (cl_int *)refValues;
cl_int *startRefs = (cl_int *)startRefValues.data();
cl_int *refs = (cl_int *)refValues.data();
for (i = 0; i < threadSize; i++)
{
if (startRefs != NULL)
@@ -377,13 +372,14 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
}
else
{
cl_long *outValue = (cl_long *)(destItems + i * typeSize);
cl_long *outValue =
(cl_long *)(destItems.data() + i * typeSize);
log_error("ERROR: Result %zu from kernel does not "
"validate! (should be %" PRId64 ", was %" PRId64
")\n",
i, longVal, *outValue);
cl_long *startRefs = (cl_long *)startRefValues;
cl_long *refs = (cl_long *)refValues;
cl_long *startRefs = (cl_long *)startRefValues.data();
cl_long *refs = (cl_long *)refValues.data();
for (i = 0; i < threadSize; i++)
{
if (startRefs != NULL)
@@ -403,9 +399,9 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
/* Use the verify function to also check the results */
if (dataType == kFloat)
{
cl_float *outValue = (cl_float *)destItems;
if (!testFns.VerifyRefsFloatFn(threadSize, (cl_float *)refValues,
*outValue)
cl_float *outValue = (cl_float *)destItems.data();
if (!testFns.VerifyRefsFloatFn(
threadSize, (cl_float *)refValues.data(), *outValue)
!= 0)
{
log_error("ERROR: Reference values did not validate!\n");
@@ -414,8 +410,8 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
}
else if (typeSize == 4)
{
cl_int *outValue = (cl_int *)destItems;
if (!testFns.VerifyRefsIntFn(threadSize, (cl_int *)refValues,
cl_int *outValue = (cl_int *)destItems.data();
if (!testFns.VerifyRefsIntFn(threadSize, (cl_int *)refValues.data(),
*outValue)
!= 0)
{
@@ -425,9 +421,9 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
}
else
{
cl_long *outValue = (cl_long *)destItems;
if (!testFns.VerifyRefsLongFn(threadSize, (cl_long *)refValues,
*outValue)
cl_long *outValue = (cl_long *)destItems.data();
if (!testFns.VerifyRefsLongFn(
threadSize, (cl_long *)refValues.data(), *outValue)
!= 0)
{
log_error("ERROR: Reference values did not validate!\n");
@@ -445,10 +441,10 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
/* Re-write the starting value */
for (size_t i = 0; i < numDestItems; i++)
memcpy(destItems + i * typeSize, startValue, typeSize);
error =
clEnqueueWriteBuffer(queue, streams[0], true, 0,
typeSize * numDestItems, destItems, 0, NULL, NULL);
memcpy(destItems.data() + i * typeSize, startValue, typeSize);
error = clEnqueueWriteBuffer(queue, streams[0], true, 0,
typeSize * numDestItems, destItems.data(), 0,
NULL, NULL);
test_error(error, "Unable to write starting values!");
/* Run the kernel once for a single thread, so we can verify that the
@@ -458,16 +454,16 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
NULL, NULL);
test_error(error, "Unable to execute test kernel");
error = clEnqueueReadBuffer(queue, streams[1], true, 0, typeSize, refValues,
0, NULL, NULL);
error = clEnqueueReadBuffer(queue, streams[1], true, 0, typeSize,
refValues.data(), 0, NULL, NULL);
test_error(error, "Unable to read reference values!");
if (memcmp(refValues, destItems, typeSize) != 0)
if (memcmp(refValues.data(), destItems.data(), typeSize) != 0)
{
if (typeSize == 4)
{
cl_int *s = (cl_int *)destItems;
cl_int *r = (cl_int *)refValues;
cl_int *s = (cl_int *)destItems.data();
cl_int *r = (cl_int *)refValues.data();
log_error("ERROR: atomic function operated correctly but did NOT "
"return correct 'old' value "
" (should have been %d, returned %d)!\n",
@@ -475,8 +471,8 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
}
else
{
cl_long *s = (cl_long *)destItems;
cl_long *r = (cl_long *)refValues;
cl_long *s = (cl_long *)destItems.data();
cl_long *r = (cl_long *)refValues.data();
log_error("ERROR: atomic function operated correctly but did NOT "
"return correct 'old' value "
" (should have been %" PRId64 ", returned %" PRId64
@@ -486,10 +482,6 @@ int test_atomic_function(cl_device_id deviceID, cl_context context,
return -1;
}
delete[] destItems;
free(refValues);
if (startRefValues != NULL) free(startRefValues);
return 0;
}
@@ -568,8 +560,7 @@ cl_long test_atomic_add_result_long(size_t size, cl_long *startRefValues,
return total;
}
int test_atomic_add(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_add)
{
TestFns set = { 0,
0LL,
@@ -582,12 +573,12 @@ int test_atomic_add(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_add_core, set, false,
device, context, queue, num_elements, atom_add_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_add_core, set, false,
device, context, queue, num_elements, atomic_add_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -618,8 +609,7 @@ cl_long test_atomic_sub_result_long(size_t size, cl_long *startRefValues,
return total;
}
int test_atomic_sub(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_sub)
{
TestFns set = { INT_TEST_VALUE,
LONG_TEST_VALUE,
@@ -632,12 +622,12 @@ int test_atomic_sub(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_sub_core, set, false,
device, context, queue, num_elements, atom_sub_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_sub_core, set, false,
device, context, queue, num_elements, atomic_sub_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -659,12 +649,11 @@ bool test_atomic_xchg_verify_int(size_t size, cl_int *refValues,
{
/* For xchg, each value from 0 to size - 1 should have an entry in the ref
* array, and ONLY one entry */
char *valids;
std::vector<char> valids(sizeof(char) * size);
size_t i;
char originalValidCount = 0;
valids = (char *)malloc(sizeof(char) * size);
memset(valids, 0, sizeof(char) * size);
memset(valids.data(), 0, sizeof(char) * size);
for (i = 0; i < size; i++)
{
@@ -715,7 +704,6 @@ bool test_atomic_xchg_verify_int(size_t size, cl_int *refValues,
}
}
free(valids);
return true;
}
@@ -724,12 +712,11 @@ bool test_atomic_xchg_verify_long(size_t size, cl_long *refValues,
{
/* For xchg, each value from 0 to size - 1 should have an entry in the ref
* array, and ONLY one entry */
char *valids;
std::vector<char> valids(sizeof(char) * size);
size_t i;
char originalValidCount = 0;
valids = (char *)malloc(sizeof(char) * size);
memset(valids, 0, sizeof(char) * size);
memset(valids.data(), 0, sizeof(char) * size);
for (i = 0; i < size; i++)
{
@@ -782,7 +769,6 @@ bool test_atomic_xchg_verify_long(size_t size, cl_long *refValues,
}
}
free(valids);
return true;
}
@@ -791,12 +777,11 @@ bool test_atomic_xchg_verify_float(size_t size, cl_float *refValues,
{
/* For xchg, each value from 0 to size - 1 should have an entry in the ref
* array, and ONLY one entry */
char *valids;
std::vector<char> valids(sizeof(char) * size);
size_t i;
char originalValidCount = 0;
valids = (char *)malloc(sizeof(char) * size);
memset(valids, 0, sizeof(char) * size);
memset(valids.data(), 0, sizeof(char) * size);
for (i = 0; i < size; i++)
{
@@ -848,12 +833,10 @@ bool test_atomic_xchg_verify_float(size_t size, cl_float *refValues,
}
}
free(valids);
return true;
}
int test_atomic_xchg(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_xchg)
{
TestFns set = { INT_TEST_VALUE,
LONG_TEST_VALUE,
@@ -868,17 +851,17 @@ int test_atomic_xchg(cl_device_id deviceID, cl_context context,
NULL,
test_atomic_xchg_verify_float };
int errors = test_atomic_function_set(
deviceID, context, queue, num_elements, atom_xchg_core, set, false,
true, /*usingAtomicPrefix*/ false);
errors |= test_atomic_function_set(deviceID, context, queue, num_elements,
int errors = test_atomic_function_set(device, context, queue, num_elements,
atom_xchg_core, set, false, true,
/*usingAtomicPrefix*/ false);
errors |= test_atomic_function_set(device, context, queue, num_elements,
atomic_xchg_core, set, false, true,
/*usingAtomicPrefix*/ true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atomic_xchg_float_core, set, false, false,
kFloat, true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atomic_xchg_float_core, set, false, true,
kFloat, true);
@@ -931,8 +914,7 @@ void test_atomic_min_gen_long(size_t size, cl_long *startRefValues, MTdata d)
| (((cl_long)genrand_int32(d) & 0x7fffffffL) << 16));
}
int test_atomic_min(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_min)
{
TestFns set = { 0x7fffffffL,
0x7fffffffffffffffLL,
@@ -945,12 +927,12 @@ int test_atomic_min(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_min_core, set, true,
device, context, queue, num_elements, atom_min_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_min_core, set, true,
device, context, queue, num_elements, atomic_min_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -1003,8 +985,7 @@ void test_atomic_max_gen_long(size_t size, cl_long *startRefValues, MTdata d)
| (((cl_long)genrand_int32(d) & 0x7fffffffL) << 16));
}
int test_atomic_max(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_max)
{
TestFns set = { 0,
0,
@@ -1017,12 +998,12 @@ int test_atomic_max(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_max_core, set, true,
device, context, queue, num_elements, atom_max_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_max_core, set, true,
device, context, queue, num_elements, atomic_max_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -1050,8 +1031,7 @@ cl_long test_atomic_inc_result_long(size_t size, cl_long *startRefValues,
return LONG_TEST_VALUE + size;
}
int test_atomic_inc(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_inc)
{
TestFns set = { INT_TEST_VALUE,
LONG_TEST_VALUE,
@@ -1064,12 +1044,12 @@ int test_atomic_inc(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_inc_core, set, false,
device, context, queue, num_elements, atom_inc_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_inc_core, set, false,
device, context, queue, num_elements, atomic_inc_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -1097,8 +1077,7 @@ cl_long test_atomic_dec_result_long(size_t size, cl_long *startRefValues,
return LONG_TEST_VALUE - size;
}
int test_atomic_dec(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_dec)
{
TestFns set = { INT_TEST_VALUE,
LONG_TEST_VALUE,
@@ -1111,12 +1090,12 @@ int test_atomic_dec(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_dec_core, set, false,
device, context, queue, num_elements, atom_dec_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_dec_core, set, false,
device, context, queue, num_elements, atomic_dec_core, set, false,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -1172,8 +1151,7 @@ cl_long test_atomic_cmpxchg_result_long(size_t size, cl_long *startRefValues,
return total;
}
int test_atomic_cmpxchg(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_cmpxchg)
{
TestFns set = { INT_TEST_VALUE,
LONG_TEST_VALUE,
@@ -1189,42 +1167,42 @@ int test_atomic_cmpxchg(cl_device_id deviceID, cl_context context,
log_info(" Testing atom_ functions...\n");
errors |=
test_atomic_function(deviceID, context, queue, num_elements,
test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg_core, set, false, false, kInt, true);
errors |=
test_atomic_function(deviceID, context, queue, num_elements,
test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg_core, set, false, false, kUInt, true);
errors |=
test_atomic_function(deviceID, context, queue, num_elements,
test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg_core, set, false, true, kInt, true);
errors |=
test_atomic_function(deviceID, context, queue, num_elements,
test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg_core, set, false, true, kUInt, true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg64_core, set, false, false,
kLong, true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg64_core, set, false, false,
kULong, true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg64_core, set, false, true, kLong,
true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atom_cmpxchg64_core, set, false, true,
kULong, true);
log_info(" Testing atomic_ functions...\n");
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atomic_cmpxchg_core, set, false, false, kInt,
true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atomic_cmpxchg_core, set, false, false,
kUInt, true);
errors |=
test_atomic_function(deviceID, context, queue, num_elements,
test_atomic_function(device, context, queue, num_elements,
atomic_cmpxchg_core, set, false, true, kInt, true);
errors |= test_atomic_function(deviceID, context, queue, num_elements,
errors |= test_atomic_function(device, context, queue, num_elements,
atomic_cmpxchg_core, set, false, true, kUInt,
true);
@@ -1289,8 +1267,7 @@ cl_long test_atomic_and_result_long(size_t size, cl_long *startRefValues,
return bits;
}
int test_atomic_and(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_and)
{
TestFns set = { (cl_int)0xffffffff,
(cl_long)0xffffffffffffffffLL,
@@ -1303,12 +1280,12 @@ int test_atomic_and(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_and_core, set, true,
device, context, queue, num_elements, atom_and_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_and_core, set, true,
device, context, queue, num_elements, atomic_and_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -1362,8 +1339,7 @@ cl_long test_atomic_or_result_long(size_t size, cl_long *startRefValues,
return bits;
}
int test_atomic_or(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_or)
{
TestFns set = {
0, 0LL, test_bitwise_num_results, test_atomic_or_result_int,
@@ -1372,12 +1348,12 @@ int test_atomic_or(cl_device_id deviceID, cl_context context,
};
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_or_core, set, true,
device, context, queue, num_elements, atom_or_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_or_core, set, true,
device, context, queue, num_elements, atomic_or_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;
@@ -1415,8 +1391,7 @@ cl_long test_atomic_xor_result_long(size_t size, cl_long *startRefValues,
return total;
}
int test_atomic_xor(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_xor)
{
TestFns set = { 0x2f08ab41,
0x2f08ab418ba0541LL,
@@ -1429,12 +1404,12 @@ int test_atomic_xor(cl_device_id deviceID, cl_context context,
NULL };
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atom_xor_core, set, true,
device, context, queue, num_elements, atom_xor_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ false)
!= 0)
return -1;
if (test_atomic_function_set(
deviceID, context, queue, num_elements, atomic_xor_core, set, true,
device, context, queue, num_elements, atomic_xor_core, set, true,
/*matchGroupSize*/ false, /*usingAtomicPrefix*/ true)
!= 0)
return -1;

View File

@@ -16,8 +16,8 @@
#include <memory>
#include "testBase.h"
#include "harness/conversions.h"
#include "harness/typeWrappers.h"
// clang-format off
const char *atomic_index_source =
@@ -36,8 +36,7 @@ const char *atomic_index_source =
"}";
// clang-format on
int test_atomic_add_index(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_add_index)
{
clProgramWrapper program;
clKernelWrapper kernel;
@@ -46,7 +45,7 @@ int test_atomic_add_index(cl_device_id deviceID, cl_context context,
int fail = 0, err;
/* Check if atomics are supported. */
if (!is_extension_available(deviceID, "cl_khr_global_int32_base_atomics"))
if (!is_extension_available(device, "cl_khr_global_int32_base_atomics"))
{
log_info("Base atomics not supported "
"(cl_khr_global_int32_base_atomics). Skipping test.\n");
@@ -474,8 +473,7 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue,
}
}
int test_atomic_add_index_bin(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(atomic_add_index_bin)
{
//===== add_index_bin test
size_t numGlobalThreads = 2048;
@@ -484,7 +482,7 @@ int test_atomic_add_index_bin(cl_device_id deviceID, cl_context context,
MTdata d = init_genrand(gRandomSeed);
/* Check if atomics are supported. */
if (!is_extension_available(deviceID, "cl_khr_global_int32_base_atomics"))
if (!is_extension_available(device, "cl_khr_global_int32_base_atomics"))
{
log_info("Base atomics not supported "
"(cl_khr_global_int32_base_atomics). Skipping test.\n");

View File

@@ -71,6 +71,6 @@ if(APPLE)
list(APPEND ${MODULE_NAME}_SOURCES test_queue_priority.cpp)
endif(APPLE)
set_gnulike_module_compile_flags("-Wno-sign-compare")
set_gnulike_module_compile_flags("-Wno-sign-compare -Wno-format")
include(../CMakeCommon.txt)

View File

@@ -99,6 +99,8 @@ test_definition test_list[] = {
ADD_TEST(enqueue_map_image),
ADD_TEST(work_item_functions),
ADD_TEST(work_item_functions_out_of_range),
ADD_TEST(work_item_functions_out_of_range_hardcoded),
ADD_TEST(astype),

View File

@@ -98,6 +98,13 @@ extern int test_enqueue_map_buffer(cl_device_id deviceID, cl_context contex
extern int test_enqueue_map_image(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_work_item_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_work_item_functions_out_of_range(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_work_item_functions_out_of_range_hardcoded(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements);
extern int test_astype(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);

View File

@@ -37,7 +37,8 @@ int test_arrayimagecopy_single_format(cl_device_id device, cl_context context,
cl_mem_object_type image_type,
const cl_image_format *format)
{
std::unique_ptr<cl_uchar> bufptr, imgptr;
std::unique_ptr<cl_uchar, decltype(&free)> bufptr{ nullptr, free },
imgptr{ nullptr, free };
clMemWrapper buffer, image;
int img_width = 512;
int img_height = 512;

View File

@@ -37,7 +37,8 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context,
cl_mem_object_type image_type,
const cl_image_format *format)
{
std::unique_ptr<cl_uchar> bufptr, imgptr;
std::unique_ptr<cl_uchar, decltype(&free)> bufptr{ nullptr, free },
imgptr{ nullptr, free };
clMemWrapper buffer, image;
const int img_width = 512;
const int img_height = 512;

View File

@@ -15,6 +15,7 @@
//
#include "harness/compat.h"
#include <array>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -26,6 +27,8 @@
#include "harness/conversions.h"
#include "harness/typeWrappers.h"
namespace {
struct work_item_data
{
cl_uint workDim;
@@ -35,146 +38,542 @@ struct work_item_data
cl_uint localID[ 3 ];
cl_uint numGroups[ 3 ];
cl_uint groupID[ 3 ];
cl_uint globalOffset[3];
cl_uint enqueuedLocalSize[3];
};
static const char *workItemKernelCode =
"typedef struct {\n"
" uint workDim;\n"
" uint globalSize[ 3 ];\n"
" uint globalID[ 3 ];\n"
" uint localSize[ 3 ];\n"
" uint localID[ 3 ];\n"
" uint numGroups[ 3 ];\n"
" uint groupID[ 3 ];\n"
" } work_item_data;\n"
"\n"
"__kernel void sample_kernel( __global work_item_data *outData )\n"
"{\n"
" int id = get_global_id(0);\n"
" outData[ id ].workDim = (uint)get_work_dim();\n"
" for( uint i = 0; i < get_work_dim(); i++ )\n"
" {\n"
" outData[ id ].globalSize[ i ] = (uint)get_global_size( i );\n"
" outData[ id ].globalID[ i ] = (uint)get_global_id( i );\n"
" outData[ id ].localSize[ i ] = (uint)get_local_size( i );\n"
" outData[ id ].localID[ i ] = (uint)get_local_id( i );\n"
" outData[ id ].numGroups[ i ] = (uint)get_num_groups( i );\n"
" outData[ id ].groupID[ i ] = (uint)get_group_id( i );\n"
" }\n"
"}";
const char *workItemKernelCode =
R"(typedef struct {
uint workDim;
uint globalSize[ 3 ];
uint globalID[ 3 ];
uint localSize[ 3 ];
uint localID[ 3 ];
uint numGroups[ 3 ];
uint groupID[ 3 ];
uint globalOffset[ 3 ];
uint enqueuedLocalSize[ 3 ];
} work_item_data;
__kernel void sample_kernel( __global work_item_data *outData )
{
int id = get_global_id(0);
outData[ id ].workDim = (uint)get_work_dim();
for( uint i = 0; i < get_work_dim(); i++ )
{
outData[ id ].globalSize[ i ] = (uint)get_global_size( i );
outData[ id ].globalID[ i ] = (uint)get_global_id( i );
outData[ id ].localSize[ i ] = (uint)get_local_size( i );
outData[ id ].localID[ i ] = (uint)get_local_id( i );
outData[ id ].numGroups[ i ] = (uint)get_num_groups( i );
outData[ id ].groupID[ i ] = (uint)get_group_id( i );
}
})";
struct work_item_data_out_of_range
{
cl_uint workDim;
cl_uint globalSize;
cl_uint globalID;
cl_uint localSize;
cl_uint localID;
cl_uint numGroups;
cl_uint groupID;
cl_uint globalOffset;
cl_uint enqueuedLocalSize;
};
const char *outOfRangeWorkItemKernelCode =
R"(typedef struct {
uint workDim;
uint globalSize;
uint globalID;
uint localSize;
uint localID;
uint numGroups;
uint groupID;
uint globalOffset;
uint enqueuedLocalSize;
} work_item_data;
__kernel void sample_kernel( __global work_item_data *outData, int dim_param )
{
int ind_mul=1;
int ind=0;
for( uint i = 0; i < get_work_dim(); i++ )
{
ind += (uint)get_global_id(i) * ind_mul;
ind_mul *= get_global_size(i);
}
outData[ind].workDim = (uint)get_work_dim();
uint dimindx=dim_param;
outData[ind].globalSize = (uint)get_global_size(dimindx);
outData[ind].globalID = (uint)get_global_id(dimindx);
outData[ind].localSize = (uint)get_local_size(dimindx);
outData[ind].localID = (uint)get_local_id(dimindx);
outData[ind].numGroups = (uint)get_num_groups(dimindx);
outData[ind].groupID = (uint)get_group_id(dimindx);
#if __OPENCL_VERSION__ >= CL_VERSION_2_0
outData[ind].enqueuedLocalSize = (uint)get_enqueued_local_size(dimindx);
outData[ind].globalOffset = (uint)get_global_offset(dimindx);
#elif __OPENCL_VERSION__ >= CL_VERSION_1_1
outData[ind].globalOffset = (uint)get_global_offset(dimindx);
#endif
})";
const char *outOfRangeWorkItemHardcodedKernelCode =
R"(typedef struct {
uint workDim;
uint globalSize;
uint globalID;
uint localSize;
uint localID;
uint numGroups;
uint groupID;
uint globalOffset;
uint enqueuedLocalSize;
} work_item_data;
__kernel void sample_kernel( __global work_item_data *outData, int dim_param )
{
int ind_mul=1;
int ind=0;
for( uint i = 0; i < get_work_dim(); i++ )
{
ind += (uint)get_global_id(i) * ind_mul;
ind_mul *= get_global_size(i);
}
outData[ind].workDim = (uint)get_work_dim();
outData[ind].globalSize = (uint)get_global_size(4);
outData[ind].globalID = (uint)get_global_id(4);
outData[ind].localSize = (uint)get_local_size(4);
outData[ind].localID = (uint)get_local_id(4);
outData[ind].numGroups = (uint)get_num_groups(4);
outData[ind].groupID = (uint)get_group_id(4);
#if __OPENCL_VERSION__ >= CL_VERSION_2_0
outData[ind].enqueuedLocalSize = (uint)get_enqueued_local_size(4);
outData[ind].globalOffset = (uint)get_global_offset(4);
#elif __OPENCL_VERSION__ >= CL_VERSION_1_1
outData[ind].globalOffset = (uint)get_global_offset(4);
#endif
})";
#define NUM_TESTS 1
int test_work_item_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
struct TestWorkItemFns
{
int error;
TestWorkItemFns(cl_device_id deviceID, cl_context context,
cl_command_queue queue)
: device(deviceID), context(context), queue(queue), program(nullptr),
kernel(nullptr), outData(nullptr), d_holder(gRandomSeed),
testData(10240)
{}
clProgramWrapper program;
clKernelWrapper kernel;
clMemWrapper outData;
std::vector<work_item_data> testData(10240);
size_t threads[3], localThreads[3];
MTdata d;
error = create_single_kernel_helper( context, &program, &kernel, 1, &workItemKernelCode, "sample_kernel" );
test_error( error, "Unable to create testing kernel" );
outData =
clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(work_item_data) * testData.size(), NULL, &error);
test_error( error, "Unable to create output buffer" );
error = clSetKernelArg( kernel, 0, sizeof( outData ), &outData );
test_error( error, "Unable to set kernel arg" );
d = init_genrand( gRandomSeed );
for( size_t dim = 1; dim <= 3; dim++ )
cl_int SetUp(const char *src)
{
for( int i = 0; i < NUM_TESTS; i++ )
cl_int error = create_single_kernel_helper(context, &program, &kernel,
1, &src, "sample_kernel");
test_error(error, "Unable to create testing kernel");
outData = clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(work_item_data) * testData.size(), NULL,
&error);
test_error(error, "Unable to create output buffer");
error = clSetKernelArg(kernel, 0, sizeof(outData), &outData);
test_error(error, "Unable to set kernel arg");
return CL_SUCCESS;
}
cl_int Run()
{
cl_int error = SetUp(workItemKernelCode);
test_error(error, "SetUp failed");
size_t threads[3] = { 0, 0, 0 };
size_t localThreads[3] = { 0, 0, 0 };
for (size_t dim = 1; dim <= 3; dim++)
{
for( size_t j = 0; j < dim; j++ )
for (int i = 0; i < NUM_TESTS; i++)
{
// All of our thread sizes should be within the max local sizes, since they're all <= 20
threads[ j ] = (size_t)random_in_range( 1, 20, d );
localThreads[ j ] = threads[ j ] / (size_t)random_in_range( 1, (int)threads[ j ], d );
while( localThreads[ j ] > 1 && ( threads[ j ] % localThreads[ j ] != 0 ) )
localThreads[ j ]--;
// Hack for now: localThreads > 1 are iffy
localThreads[ j ] = 1;
}
error = clEnqueueNDRangeKernel( queue, kernel, (cl_uint)dim, NULL, threads, localThreads, 0, NULL, NULL );
test_error( error, "Unable to run kernel" );
error =
clEnqueueReadBuffer(queue, outData, CL_TRUE, 0,
sizeof(work_item_data) * testData.size(),
testData.data(), 0, NULL, NULL);
test_error( error, "Unable to read results" );
// Validate
for( size_t q = 0; q < threads[0]; q++ )
{
// We can't really validate the actual value of each one, but we can validate that they're within a sane range
if( testData[ q ].workDim != (cl_uint)dim )
for (size_t j = 0; j < dim; j++)
{
log_error( "ERROR: get_work_dim() did not return proper value for %d dimensions (expected %d, got %d)\n", (int)dim, (int)dim, (int)testData[ q ].workDim );
free_mtdata(d);
return -1;
// All of our thread sizes should be within the max local
// sizes, since they're all <= 20
threads[j] = (size_t)random_in_range(1, 20, d_holder);
localThreads[j] = threads[j]
/ (size_t)random_in_range(1, (int)threads[j], d_holder);
while (localThreads[j] > 1
&& (threads[j] % localThreads[j] != 0))
localThreads[j]--;
// Hack for now: localThreads > 1 are iffy
localThreads[j] = 1;
}
for( size_t j = 0; j < dim; j++ )
error = clEnqueueNDRangeKernel(queue, kernel, (cl_uint)dim,
NULL, threads, localThreads, 0,
NULL, NULL);
test_error(error, "Unable to run kernel");
error = clEnqueueReadBuffer(queue, outData, CL_TRUE, 0,
sizeof(work_item_data)
* testData.size(),
testData.data(), 0, NULL, NULL);
test_error(error, "Unable to read results");
// Validate
for (size_t q = 0; q < threads[0]; q++)
{
if( testData[ q ].globalSize[ j ] != (cl_uint)threads[ j ] )
// We can't really validate the actual value of each one,
// but we can validate that they're within a sane range
if (testData[q].workDim != (cl_uint)dim)
{
log_error( "ERROR: get_global_size(%d) did not return proper value for %d dimensions (expected %d, got %d)\n",
(int)j, (int)dim, (int)threads[ j ], (int)testData[ q ].globalSize[ j ] );
free_mtdata(d);
log_error(
"ERROR: get_work_dim() did not return proper value "
"for %d dimensions (expected %d, got %d)\n",
(int)dim, (int)dim, (int)testData[q].workDim);
return -1;
}
if (testData[q].globalID[j] >= (cl_uint)threads[j])
for (size_t j = 0; j < dim; j++)
{
log_error( "ERROR: get_global_id(%d) did not return proper value for %d dimensions (max %d, got %d)\n",
(int)j, (int)dim, (int)threads[ j ], (int)testData[ q ].globalID[ j ] );
free_mtdata(d);
return -1;
}
if( testData[ q ].localSize[ j ] != (cl_uint)localThreads[ j ] )
{
log_error( "ERROR: get_local_size(%d) did not return proper value for %d dimensions (expected %d, got %d)\n",
(int)j, (int)dim, (int)localThreads[ j ], (int)testData[ q ].localSize[ j ] );
free_mtdata(d);
return -1;
}
if (testData[q].localID[j] >= (cl_uint)localThreads[j])
{
log_error( "ERROR: get_local_id(%d) did not return proper value for %d dimensions (max %d, got %d)\n",
(int)j, (int)dim, (int)localThreads[ j ], (int)testData[ q ].localID[ j ] );
free_mtdata(d);
return -1;
}
size_t groupCount = ( threads[ j ] + localThreads[ j ] - 1 ) / localThreads[ j ];
if( testData[ q ].numGroups[ j ] != (cl_uint)groupCount )
{
log_error( "ERROR: get_num_groups(%d) did not return proper value for %d dimensions (expected %d with global dim %d and local dim %d, got %d)\n",
(int)j, (int)dim, (int)groupCount, (int)threads[ j ], (int)localThreads[ j ], (int)testData[ q ].numGroups[ j ] );
free_mtdata(d);
return -1;
}
if (testData[q].groupID[j] >= (cl_uint)groupCount)
{
log_error( "ERROR: get_group_id(%d) did not return proper value for %d dimensions (max %d, got %d)\n",
(int)j, (int)dim, (int)groupCount, (int)testData[ q ].groupID[ j ] );
free_mtdata(d);
return -1;
if (testData[q].globalSize[j] != (cl_uint)threads[j])
{
log_error("ERROR: get_global_size(%d) did not "
"return proper value for %d dimensions "
"(expected %d, got %d)\n",
(int)j, (int)dim, (int)threads[j],
(int)testData[q].globalSize[j]);
return -1;
}
if (testData[q].globalID[j] >= (cl_uint)threads[j])
{
log_error("ERROR: get_global_id(%d) did not return "
"proper value for %d dimensions (max %d, "
"got %d)\n",
(int)j, (int)dim, (int)threads[j],
(int)testData[q].globalID[j]);
return -1;
}
if (testData[q].localSize[j]
!= (cl_uint)localThreads[j])
{
log_error("ERROR: get_local_size(%d) did not "
"return proper value for %d dimensions "
"(expected %d, got %d)\n",
(int)j, (int)dim, (int)localThreads[j],
(int)testData[q].localSize[j]);
return -1;
}
if (testData[q].localID[j] >= (cl_uint)localThreads[j])
{
log_error(
"ERROR: get_local_id(%d) did not return proper "
"value for %d dimensions (max %d, got %d)\n",
(int)j, (int)dim, (int)localThreads[j],
(int)testData[q].localID[j]);
return -1;
}
size_t groupCount = (threads[j] + localThreads[j] - 1)
/ localThreads[j];
if (testData[q].numGroups[j] != (cl_uint)groupCount)
{
log_error("ERROR: get_num_groups(%d) did not "
"return proper value for %d dimensions "
"(expected %d with global dim %d and "
"local dim %d, got %d)\n",
(int)j, (int)dim, (int)groupCount,
(int)threads[j], (int)localThreads[j],
(int)testData[q].numGroups[j]);
return -1;
}
if (testData[q].groupID[j] >= (cl_uint)groupCount)
{
log_error(
"ERROR: get_group_id(%d) did not return proper "
"value for %d dimensions (max %d, got %d)\n",
(int)j, (int)dim, (int)groupCount,
(int)testData[q].groupID[j]);
return -1;
}
}
}
}
}
return 0;
}
free_mtdata(d);
return 0;
cl_device_id device;
cl_context context;
cl_command_queue queue;
clProgramWrapper program;
clKernelWrapper kernel;
clMemWrapper outData;
MTdataHolder d_holder;
std::vector<work_item_data> testData;
};
struct TestWorkItemFnsOutOfRange
{
size_t threads[3] = { 0, 0, 0 };
TestWorkItemFnsOutOfRange(cl_device_id deviceID, cl_context context,
cl_command_queue queue, const char *ksrc)
: device(deviceID), context(context), queue(queue), program(nullptr),
kernel(nullptr), outData(nullptr), d_holder(gRandomSeed),
testData(10240), max_workgroup_size(0), kernel_src(ksrc)
{}
virtual cl_int SetUp(const char *src)
{
cl_int error = create_single_kernel_helper(context, &program, &kernel,
1, &src, "sample_kernel");
test_error(error, "Unable to create testing kernel");
outData = clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(work_item_data_out_of_range)
* testData.size(),
NULL, &error);
test_error(error, "Unable to create output buffer");
error = clSetKernelArg(kernel, 0, sizeof(outData), &outData);
test_error(error, "Unable to set kernel arg");
error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES,
sizeof(size_t) * maxWorkItemSizes.size(),
maxWorkItemSizes.data(), NULL);
test_error(error,
"clDeviceInfo for CL_DEVICE_MAX_WORK_ITEM_SIZES failed");
error = clGetKernelWorkGroupInfo(
kernel, device, CL_KERNEL_WORK_GROUP_SIZE,
sizeof(max_workgroup_size), &max_workgroup_size, NULL);
test_error(error, "clGetKernelWorkgroupInfo failed.");
return CL_SUCCESS;
}
bool Validate(const cl_uint dim)
{
cl_uint threads_to_verify = 1;
for (size_t j = 0; j < dim; j++) threads_to_verify *= threads[j];
for (size_t q = 0; q < threads_to_verify; q++)
{
if (testData[q].workDim != (cl_uint)dim)
{
log_error("ERROR: get_work_dim() did not return proper value "
"for %d dimensions (expected %d, got %d)\n",
(int)dim, (int)dim, (int)testData[q].workDim);
return false;
}
if (testData[q].globalSize != 1)
{
log_error("ERROR: get_global_size(%d) did not return "
"proper value for the argument out of range "
"(expected 1, got %d)\n",
(int)dim, (int)testData[q].globalSize);
return false;
}
if (testData[q].globalID != 0)
{
log_error("ERROR: get_global_id(%d) did not return "
"proper value for the argument out of range "
"(expected 0, got %d)\n",
(int)dim, (int)testData[q].globalID);
return false;
}
if (testData[q].localSize != 1)
{
log_error("ERROR: get_local_size(%d) did not return "
"proper value for the argument out of range "
"(expected 1, got %d)\n",
(int)dim, (int)testData[q].localSize);
return false;
}
if (testData[q].localID != 0)
{
log_error("ERROR: get_local_id(%d) did not return "
"proper value for the argument out of range "
"(expected 0, got %d)\n",
(int)dim, (int)testData[q].localID);
return false;
}
if (testData[q].numGroups != 1)
{
log_error("ERROR: get_num_groups(%d) did not return "
"proper value for the argument out of range "
"(expected 1, got %d)\n",
(int)dim, (int)testData[q].numGroups);
return false;
}
if (testData[q].groupID != 0)
{
log_error("ERROR: get_group_id(%d) did not return "
"proper value for the argument out of range "
"(expected 0, got %d)\n",
(int)dim, (int)testData[q].groupID);
return false;
}
}
const Version version = get_device_cl_version(device);
if (version >= Version(2, 0))
{
for (size_t q = 0; q < threads_to_verify; q++)
{
if (testData[q].globalOffset != 0)
{
log_error(
"ERROR: get_global_offset(%d) did not return "
"proper value "
"for the argument out of range (expected 0, got %d)\n",
(int)dim, (int)testData[q].globalOffset);
return false;
}
if (testData[q].enqueuedLocalSize != 1)
{
log_error(
"ERROR: get_enqueued_local_size(%d) did not return "
"proper value for the argument out of range "
"(expected 1, got %d)\n",
(int)dim, (int)testData[q].globalSize);
return false;
}
}
}
else if (version >= Version(1, 1))
{
for (size_t q = 0; q < threads_to_verify; q++)
{
if (testData[q].globalOffset != 0)
{
log_error(
"ERROR: get_global_offset(%d) did not return "
"proper value "
"for the argument out of range (expected 0, got %d)\n",
(int)dim, (int)testData[q].globalOffset);
return false;
}
}
}
return true;
}
cl_int Run()
{
cl_int error = SetUp(kernel_src);
test_error(error, "SetUp failed");
size_t localThreads[3] = { 0, 0, 0 };
for (size_t dim = 1; dim <= 3; dim++)
{
size_t local_workgroup_size[3] = { maxWorkItemSizes[0],
maxWorkItemSizes[1],
maxWorkItemSizes[2] };
// check if maximum work group size for current dimention is not
// exceeded
cl_uint work_group_size = max_workgroup_size + 1;
while (max_workgroup_size < work_group_size && work_group_size != 1)
{
work_group_size = 1;
for (size_t j = 0; j < dim; j++)
work_group_size *= local_workgroup_size[j];
if (max_workgroup_size < work_group_size)
{
for (size_t j = 0; j < dim; j++)
local_workgroup_size[j] =
std::max(1, (int)local_workgroup_size[j] / 2);
}
};
// compute max number of work groups based on buffer size and max
// group size
cl_uint max_work_groups = testData.size() / work_group_size;
// take into account number of dimentions
cl_uint work_groups_per_dim =
std::max(1, (int)pow(max_work_groups, 1.f / dim));
for (size_t j = 0; j < dim; j++)
{
// generate ranges for uniform work group size
localThreads[j] =
random_in_range(1, (int)local_workgroup_size[j], d_holder);
size_t num_groups =
(size_t)random_in_range(1, work_groups_per_dim, d_holder);
threads[j] = num_groups * localThreads[j];
}
cl_int dim_param = dim + 1;
error = clSetKernelArg(kernel, 1, sizeof(cl_int), &dim_param);
test_error(error, "Unable to set kernel arg");
error =
clEnqueueNDRangeKernel(queue, kernel, (cl_uint)dim, NULL,
threads, localThreads, 0, NULL, NULL);
test_error(error, "Unable to run kernel");
error = clEnqueueReadBuffer(queue, outData, CL_TRUE, 0,
sizeof(work_item_data_out_of_range)
* testData.size(),
testData.data(), 0, NULL, NULL);
test_error(error, "Unable to read results");
// Validate
if (!Validate(dim))
{
log_error("Validation failed");
return TEST_FAIL;
}
}
return TEST_PASS;
}
cl_device_id device;
cl_context context;
cl_command_queue queue;
clProgramWrapper program;
clKernelWrapper kernel;
clMemWrapper outData;
MTdataHolder d_holder;
std::vector<work_item_data_out_of_range> testData;
std::array<size_t, 3> maxWorkItemSizes;
size_t max_workgroup_size;
const char *kernel_src;
};
} // anonymous namespace
int test_work_item_functions(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
TestWorkItemFns fnct(deviceID, context, queue);
return fnct.Run();
}
int test_work_item_functions_out_of_range(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
{
TestWorkItemFnsOutOfRange fnct(deviceID, context, queue,
outOfRangeWorkItemKernelCode);
return fnct.Run();
}
int test_work_item_functions_out_of_range_hardcoded(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
{
TestWorkItemFnsOutOfRange fnct(deviceID, context, queue,
outOfRangeWorkItemHardcodedKernelCode);
return fnct.Run();
}

View File

@@ -344,16 +344,26 @@ int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queue
size_t sbThatFailed = find_subbuffer_by_index( subBuffers, numSubBuffers, i + j );
if ( sbThatFailed == numSubBuffers )
{
log_error( "ERROR: Validation failure outside of a sub-buffer! (Shouldn't be possible, but it happened at index %ld out of %ld...)\n", i + j, mainSize );
log_error("ERROR: Validation failure outside of a "
"sub-buffer! (Shouldn't be possible, but it "
"happened at index %zu out of %zu...)\n",
i + j, mainSize);
// Since this is a nonsensical, don't bother continuing to check
// (we will, however, print our map of sub-buffers for comparison)
for ( size_t k = 0; k < numSubBuffers; k++ )
{
log_error( "\tBuffer %ld: %ld to %ld (length %ld)\n", k, subBuffers[ k ].mOrigin, subBuffers[ k ].mOrigin + subBuffers[ k ].mSize, subBuffers[ k ].mSize );
log_error("\tBuffer %zu: %zu to %zu (length %zu)\n",
k, subBuffers[k].mOrigin,
subBuffers[k].mOrigin
+ subBuffers[k].mSize,
subBuffers[k].mSize);
}
return -1;
}
log_error( "ERROR: Validation failure on sub-buffer %ld (start: %ld, length: %ld)\n", sbThatFailed, subBuffers[ sbThatFailed ].mOrigin, subBuffers[ sbThatFailed ].mSize );
log_error("ERROR: Validation failure on sub-buffer %zu "
"(start: %zu, length: %zu)\n",
sbThatFailed, subBuffers[sbThatFailed].mOrigin,
subBuffers[sbThatFailed].mSize);
size_t newPos = subBuffers[ sbThatFailed ].mOrigin + subBuffers[ sbThatFailed ].mSize - 1;
i = newPos & ~65535;
j = newPos - i;
@@ -589,8 +599,10 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_
}
}
log_info( "\tTesting %d sub-buffers with %lld overlapping Kbytes (%d%%; as many as %ld buffers overlapping at once)\n",
16, ( delta / 1024LL ), (int)( delta * 100LL / (long long)mainSize ), maxOverlap );
log_info("\tTesting %d sub-buffers with %lld overlapping Kbytes (%d%%; as "
"many as %zu buffers overlapping at once)\n",
16, (delta / 1024LL), (int)(delta * 100LL / (long long)mainSize),
maxOverlap);
// Write some random contents to the main buffer
cl_char * contents = new cl_char[ mainSize ];
@@ -615,7 +627,7 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_
if ( memcmp( tempBuffer, contents + subBuffers[ i ].mOrigin, subBuffers[ i ].mSize ) != 0 )
{
log_error( "ERROR: Validation for sub-buffer %ld failed!\n", i );
log_error("ERROR: Validation for sub-buffer %zu failed!\n", i);
numErrors++;
}
}

View File

@@ -7,6 +7,6 @@ set(${MODULE_NAME}_SOURCES
test_atomics.cpp
)
set_gnulike_module_compile_flags("-Wno-sign-compare")
set_gnulike_module_compile_flags("-Wno-sign-compare -Wno-format")
include(../CMakeCommon.txt)

View File

@@ -464,7 +464,7 @@ getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *VulkanImageCreateInfo,
memcpy(img_fmt, &clImgFormat, sizeof(cl_image_format));
img_desc->image_type = getImageTypeFromVk(VulkanImageCreateInfo->imageType);
if (CL_INVALID_VALUE == img_desc->image_type)
if (CL_INVALID_VALUE == static_cast<cl_int>(img_desc->image_type))
{
return CL_INVALID_VALUE;
}
@@ -503,6 +503,8 @@ cl_int check_external_memory_handle_type(
errNum = clGetDeviceInfo(deviceID,
CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR,
0, NULL, &handle_type_size);
test_error(errNum, "clGetDeviceInfo failed");
handle_type =
(cl_external_memory_handle_type_khr *)malloc(handle_type_size);
@@ -539,6 +541,7 @@ cl_int check_external_semaphore_handle_type(
errNum =
clGetDeviceInfo(deviceID, queryParamName, 0, NULL, &handle_type_size);
test_error(errNum, "clGetDeviceInfo failed");
if (handle_type_size == 0)
{

View File

@@ -101,7 +101,8 @@
VK_FUNC_DECL(vkGetPhysicalDeviceSurfaceSupportKHR) \
VK_FUNC_DECL(vkImportSemaphoreFdKHR) \
VK_FUNC_DECL(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) \
VK_FUNC_DECL(vkGetImageSubresourceLayout)
VK_FUNC_DECL(vkGetImageSubresourceLayout) \
VK_FUNC_DECL(vkGetPhysicalDeviceExternalBufferProperties)
#define VK_WINDOWS_FUNC_LIST \
VK_FUNC_DECL(vkGetMemoryWin32HandleKHR) \
VK_FUNC_DECL(vkGetSemaphoreWin32HandleKHR) \
@@ -202,5 +203,7 @@
#define vkGetSemaphoreWin32HandleKHR _vkGetSemaphoreWin32HandleKHR
#define vkImportSemaphoreWin32HandleKHR _vkImportSemaphoreWin32HandleKHR
#define vkGetImageSubresourceLayout _vkGetImageSubresourceLayout
#define vkGetPhysicalDeviceExternalBufferProperties \
_vkGetPhysicalDeviceExternalBufferProperties
#endif //_vulkan_api_list_hpp_

View File

@@ -1,5 +1,5 @@
//
// Copyright (c) 2022 The Khronos Group Inc.
// Copyright (c) 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -40,13 +40,10 @@ const VulkanInstance &getVulkanInstance()
const VulkanPhysicalDevice &getVulkanPhysicalDevice()
{
size_t pdIdx;
size_t pdIdx = 0;
cl_int errNum = 0;
cl_platform_id platform = NULL;
cl_platform_id platform = nullptr;
cl_uchar uuid[CL_UUID_SIZE_KHR];
cl_device_id *devices;
char *extensions = NULL;
size_t extensionSize = 0;
cl_uint num_devices = 0;
cl_uint device_no = 0;
const size_t bufsize = BUFFERSIZE;
@@ -69,14 +66,9 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice()
throw std::runtime_error(
"Error: clGetDeviceIDs failed in returning of devices\n");
}
devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id));
if (NULL == devices)
{
throw std::runtime_error(
"Error: Unable to allocate memory for devices\n");
}
errNum = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices, devices,
NULL);
std::vector<cl_device_id> devices(num_devices);
errNum = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices,
devices.data(), NULL);
if (CL_SUCCESS != errNum)
{
throw std::runtime_error("Error: Failed to get deviceID.\n");
@@ -84,34 +76,14 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice()
bool is_selected = false;
for (device_no = 0; device_no < num_devices; device_no++)
{
errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS, 0,
NULL, &extensionSize);
if (CL_SUCCESS != errNum)
{
throw std::runtime_error("Error in clGetDeviceInfo for getting "
"device_extension size....\n");
}
extensions = (char *)malloc(extensionSize);
if (NULL == extensions)
{
throw std::runtime_error(
"Unable to allocate memory for extensions\n");
}
errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS,
extensionSize, extensions, NULL);
if (CL_SUCCESS != errNum)
{
throw std::runtime_error("Error: Error in clGetDeviceInfo for "
"getting device_extension\n");
}
errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_UUID_KHR,
CL_UUID_SIZE_KHR, uuid, &extensionSize);
CL_UUID_SIZE_KHR, uuid, nullptr);
if (CL_SUCCESS != errNum)
{
throw std::runtime_error(
"Error: clGetDeviceInfo failed with error\n");
}
free(extensions);
for (pdIdx = 0; pdIdx < physicalDeviceList.size(); pdIdx++)
{
if (!memcmp(&uuid, physicalDeviceList[pdIdx].getUUID(),
@@ -139,10 +111,48 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice()
return physicalDeviceList[pdIdx];
}
const VulkanQueueFamily &getVulkanQueueFamily(uint32_t queueFlags)
const VulkanPhysicalDevice &
getAssociatedVulkanPhysicalDevice(cl_device_id deviceId)
{
size_t pdIdx;
cl_int errNum = 0;
cl_uchar uuid[CL_UUID_SIZE_KHR];
const VulkanInstance &instance = getVulkanInstance();
const VulkanPhysicalDeviceList &physicalDeviceList =
instance.getPhysicalDeviceList();
errNum = clGetDeviceInfo(deviceId, CL_DEVICE_UUID_KHR, CL_UUID_SIZE_KHR,
uuid, nullptr);
if (CL_SUCCESS != errNum)
{
throw std::runtime_error("Error: clGetDeviceInfo failed with error\n");
}
for (pdIdx = 0; pdIdx < physicalDeviceList.size(); pdIdx++)
{
if (!memcmp(&uuid, physicalDeviceList[pdIdx].getUUID(), VK_UUID_SIZE))
{
std::cout << "Selected physical device = "
<< physicalDeviceList[pdIdx] << std::endl;
break;
}
}
if ((pdIdx >= physicalDeviceList.size())
|| (physicalDeviceList[pdIdx] == (VkPhysicalDevice)VK_NULL_HANDLE))
{
throw std::runtime_error("failed to find a suitable GPU!");
}
std::cout << "Selected physical device is: " << physicalDeviceList[pdIdx]
<< std::endl;
return physicalDeviceList[pdIdx];
}
const VulkanQueueFamily &
getVulkanQueueFamily(const VulkanPhysicalDevice &physicalDevice,
uint32_t queueFlags)
{
size_t qfIdx;
const VulkanPhysicalDevice &physicalDevice = getVulkanPhysicalDevice();
const VulkanQueueFamilyList &queueFamilyList =
physicalDevice.getQueueFamilyList();
@@ -215,7 +225,8 @@ getDefaultVulkanQueueFamilyToQueueCountMap()
}
const std::vector<VulkanExternalMemoryHandleType>
getSupportedVulkanExternalMemoryHandleTypeList()
getSupportedVulkanExternalMemoryHandleTypeList(
const VulkanPhysicalDevice &physical_device)
{
std::vector<VulkanExternalMemoryHandleType> externalMemoryHandleTypeList;
@@ -228,8 +239,23 @@ getSupportedVulkanExternalMemoryHandleTypeList()
externalMemoryHandleTypeList.push_back(
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT);
#else
externalMemoryHandleTypeList.push_back(
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD);
VkPhysicalDeviceExternalBufferInfo buffer_info = {};
buffer_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO;
buffer_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;
VkExternalBufferProperties buffer_properties = {};
buffer_properties.sType = VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES;
vkGetPhysicalDeviceExternalBufferProperties(physical_device, &buffer_info,
&buffer_properties);
if (buffer_properties.externalMemoryProperties.externalMemoryFeatures
& VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT)
{
externalMemoryHandleTypeList.push_back(
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD);
}
#endif
return externalMemoryHandleTypeList;

View File

@@ -1,5 +1,5 @@
//
// Copyright (c) 2022 The Khronos Group Inc.
// Copyright (c) 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -32,9 +32,12 @@
const VulkanInstance& getVulkanInstance();
const VulkanPhysicalDevice& getVulkanPhysicalDevice();
const VulkanQueueFamily&
getVulkanQueueFamily(uint32_t queueFlags = VULKAN_QUEUE_FLAG_GRAPHICS
| VULKAN_QUEUE_FLAG_COMPUTE);
const VulkanPhysicalDevice&
getAssociatedVulkanPhysicalDevice(cl_device_id deviceId);
const VulkanQueueFamily& getVulkanQueueFamily(
const VulkanPhysicalDevice& physicalDevice = getVulkanPhysicalDevice(),
uint32_t queueFlags = VULKAN_QUEUE_FLAG_GRAPHICS
| VULKAN_QUEUE_FLAG_COMPUTE);
const VulkanMemoryType&
getVulkanMemoryType(const VulkanDevice& device,
VulkanMemoryTypeProperty memoryTypeProperty);
@@ -44,7 +47,8 @@ const VulkanDescriptorSetLayoutList& getEmptyVulkanDescriptorSetLayoutList();
const VulkanQueueFamilyToQueueCountMap&
getDefaultVulkanQueueFamilyToQueueCountMap();
const std::vector<VulkanExternalMemoryHandleType>
getSupportedVulkanExternalMemoryHandleTypeList();
getSupportedVulkanExternalMemoryHandleTypeList(
const VulkanPhysicalDevice& physical_device);
const std::vector<VulkanExternalSemaphoreHandleType>
getSupportedVulkanExternalSemaphoreHandleTypeList(const VulkanDevice& vkDevice);
std::vector<VulkanExternalSemaphoreHandleType>

View File

@@ -145,7 +145,7 @@ public:
virtual ~VulkanDevice();
const VulkanPhysicalDevice &getPhysicalDevice() const;
VulkanQueue &
getQueue(const VulkanQueueFamily &queueFamily = getVulkanQueueFamily(),
getQueue(const VulkanQueueFamily &queueFamily /* = getVulkanQueueFamily()*/,
uint32_t queueIndex = 0);
operator VkDevice() const;
};

View File

@@ -10,4 +10,6 @@ set(${MODULE_NAME}_SOURCES
test_binary_fn.cpp
)
set_gnulike_module_compile_flags("-Wno-format")
include(../CMakeCommon.txt)

View File

@@ -16,7 +16,6 @@
#include <stdio.h>
#include <string.h>
#include "procs.h"
#include "test_base.h"
#include "harness/kernelHelpers.h"
@@ -36,17 +35,6 @@ static void initVecSizes() {
}
}
test_definition test_list[] = {
ADD_TEST(clamp), ADD_TEST(degrees), ADD_TEST(fmax),
ADD_TEST(fmaxf), ADD_TEST(fmin), ADD_TEST(fminf),
ADD_TEST(max), ADD_TEST(maxf), ADD_TEST(min),
ADD_TEST(minf), ADD_TEST(mix), ADD_TEST(mixf),
ADD_TEST(radians), ADD_TEST(step), ADD_TEST(stepf),
ADD_TEST(smoothstep), ADD_TEST(smoothstepf), ADD_TEST(sign),
};
const int test_num = ARRAY_SIZE( test_list );
test_status InitCL(cl_device_id device)
{
if (is_extension_available(device, "cl_khr_fp16"))
@@ -79,6 +67,7 @@ int main(int argc, const char *argv[])
BaseFunctionTest::type2name[sizeof(float)] = "float";
BaseFunctionTest::type2name[sizeof(double)] = "double";
return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0,
InitCL);
return runTestHarnessWithCheck(
argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0, InitCL);
}

View File

@@ -1,49 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "harness/testHarness.h"
#include "harness/kernelHelpers.h"
#include "harness/errorHelpers.h"
#include "harness/conversions.h"
#include "harness/mt19937.h"
#define kVectorSizeCount 5
#define kStrangeVectorSizeCount 1
#define kTotalVecCount (kVectorSizeCount + kStrangeVectorSizeCount)
extern int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount];
// int g_arrStrangeVectorSizes[kStrangeVectorSizeCount] = {3};
extern int test_clamp(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_degrees(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fmax(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fmaxf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fmin(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_fminf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_max(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_maxf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_minf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_mix(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_mixf(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_radians(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_step(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_stepf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_smoothstep(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_smoothstepf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);
extern int test_sign(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements);

View File

@@ -24,9 +24,17 @@
#include <CL/cl_half.h>
#include <CL/cl_ext.h>
#include "harness/conversions.h"
#include "harness/mt19937.h"
#include "harness/testHarness.h"
#include "harness/typeWrappers.h"
#define kVectorSizeCount 5
#define kStrangeVectorSizeCount 1
#define kTotalVecCount (kVectorSizeCount + kStrangeVectorSizeCount)
extern int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount];
template <typename T>
using VerifyFuncBinary = int (*)(const T *const, const T *const, const T *const,
const int num, const int vs, const int vp);

View File

@@ -24,7 +24,6 @@
#include "harness/typeWrappers.h"
#include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h"
const char *binary_fn_code_pattern =
@@ -319,58 +318,50 @@ cl_int MinTest::Run()
return error;
}
int test_min(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(min)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "min",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "min",
true);
}
int test_minf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(minf)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "min",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "min",
false);
}
int test_fmin(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fmin)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "fmin",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "fmin",
true);
}
int test_fminf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fminf)
{
return MakeAndRunTest<MinTest>(device, context, queue, n_elems, "fmin",
return MakeAndRunTest<MinTest>(device, context, queue, num_elements, "fmin",
false);
}
int test_max(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(max)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "max",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "max",
true);
}
int test_maxf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(maxf)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "max",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "max",
false);
}
int test_fmax(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fmax)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "fmax",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "fmax",
true);
}
int test_fmaxf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(fmaxf)
{
return MakeAndRunTest<MaxTest>(device, context, queue, n_elems, "fmax",
return MakeAndRunTest<MaxTest>(device, context, queue, num_elements, "fmax",
false);
}

View File

@@ -23,7 +23,6 @@
#include "harness/deviceInfo.h"
#include "harness/typeWrappers.h"
#include "procs.h"
#include "test_base.h"
#ifndef M_PI
@@ -308,8 +307,7 @@ cl_int ClampTest::Run()
return error;
}
int test_clamp(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(clamp)
{
return MakeAndRunTest<ClampTest>(device, context, queue, n_elems);
return MakeAndRunTest<ClampTest>(device, context, queue, num_elements);
}

View File

@@ -20,7 +20,6 @@
#include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h"
@@ -302,16 +301,14 @@ cl_int MixTest::Run()
return error;
}
int test_mix(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(mix)
{
return MakeAndRunTest<MixTest>(device, context, queue, n_elems, "mix",
return MakeAndRunTest<MixTest>(device, context, queue, num_elements, "mix",
true);
}
int test_mixf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(mixf)
{
return MakeAndRunTest<MixTest>(device, context, queue, n_elems, "mix",
return MakeAndRunTest<MixTest>(device, context, queue, num_elements, "mix",
false);
}

View File

@@ -20,7 +20,6 @@
#include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h"
const char *smoothstep_fn_code_pattern =
@@ -317,16 +316,14 @@ cl_int SmoothstepTest::Run()
return error;
}
int test_smoothstep(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(smoothstep)
{
return MakeAndRunTest<SmoothstepTest>(device, context, queue, n_elems,
return MakeAndRunTest<SmoothstepTest>(device, context, queue, num_elements,
"smoothstep", true);
}
int test_smoothstepf(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(smoothstepf)
{
return MakeAndRunTest<SmoothstepTest>(device, context, queue, n_elems,
return MakeAndRunTest<SmoothstepTest>(device, context, queue, num_elements,
"smoothstep", false);
}

View File

@@ -20,7 +20,6 @@
#include "harness/stringHelpers.h"
#include "procs.h"
#include "test_base.h"
const char *step_fn_code_pattern = "%s\n" /* optional pragma */
@@ -268,16 +267,14 @@ cl_int StepTest::Run()
return error;
}
int test_step(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(step)
{
return MakeAndRunTest<StepTest>(device, context, queue, n_elems, "step",
true);
return MakeAndRunTest<StepTest>(device, context, queue, num_elements,
"step", true);
}
int test_stepf(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(stepf)
{
return MakeAndRunTest<StepTest>(device, context, queue, n_elems, "step",
false);
return MakeAndRunTest<StepTest>(device, context, queue, num_elements,
"step", false);
}

View File

@@ -24,7 +24,6 @@
#include "harness/stringHelpers.h"
#include "harness/typeWrappers.h"
#include "procs.h"
#include "test_base.h"
#ifndef M_PI
@@ -385,22 +384,20 @@ cl_int SignTest::Run()
return error;
}
int test_degrees(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(degrees)
{
return MakeAndRunTest<DegreesTest>(device, context, queue, n_elems,
return MakeAndRunTest<DegreesTest>(device, context, queue, num_elements,
"degrees");
}
int test_radians(cl_device_id device, cl_context context,
cl_command_queue queue, int n_elems)
REGISTER_TEST(radians)
{
return MakeAndRunTest<RadiansTest>(device, context, queue, n_elems,
return MakeAndRunTest<RadiansTest>(device, context, queue, num_elements,
"radians");
}
int test_sign(cl_device_id device, cl_context context, cl_command_queue queue,
int n_elems)
REGISTER_TEST(sign)
{
return MakeAndRunTest<SignTest>(device, context, queue, n_elems, "sign");
return MakeAndRunTest<SignTest>(device, context, queue, num_elements,
"sign");
}

View File

@@ -84,8 +84,8 @@ int test_load_program_source(cl_device_id deviceID, cl_context context, cl_comma
// Note: according to spec section 5.4.5, the length returned should include the null terminator
if (length != line_length + 1)
{
log_error("ERROR: Length of program (%ld) does not match reference "
"length (%ld)!\n",
log_error("ERROR: Length of program (%zu) does not match reference "
"length (%zu)!\n",
length, line_length + 1);
return -1;
}
@@ -520,7 +520,7 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co
error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_LOG, 0, NULL, &length );
test_error( error, "Unable to get program build log length" );
log_info("Build log is %ld long.\n", length);
log_info("Build log is %zu long.\n", length);
buffer = (char*)malloc(length);

View File

@@ -1999,14 +1999,14 @@ static int verifyCopyBuffer(cl_context context, cl_command_queue queue,
if (srcBuffer == NULL)
{
log_error("ERROR: Unable to allocate srcBuffer float array with %lu "
log_error("ERROR: Unable to allocate srcBuffer float array with %zu "
"floats! (in %s:%d)\n",
cnDimension, __FILE__, __LINE__);
return -1;
}
if (dstBuffer == NULL)
{
log_error("ERROR: Unable to allocate dstBuffer float array with %lu "
log_error("ERROR: Unable to allocate dstBuffer float array with %zu "
"floats! (in %s:%d)\n",
cnDimension, __FILE__, __LINE__);
return -1;
@@ -2067,7 +2067,7 @@ static int verifyCopyBuffer(cl_context context, cl_command_queue queue,
{
if (mismatch < 4)
{
log_info("Offset %08lX: Expected %08X, Got %08X\n", i * 4,
log_info("Offset %08zX: Expected %08X, Got %08X\n", i * 4,
pSrc[i], pDst[i]);
}
else
@@ -2292,7 +2292,7 @@ int test_execute_after_serialize_reload_object(cl_device_id deviceID,
binary = (unsigned char *)malloc(sizeof(unsigned char) * binarySize);
if (binary == NULL)
{
log_error("ERROR: Unable to allocate binary character array with %lu "
log_error("ERROR: Unable to allocate binary character array with %zu "
"characters! (in %s:%d)\n",
binarySize, __FILE__, __LINE__);
return -1;
@@ -2404,7 +2404,7 @@ int test_execute_after_serialize_reload_library(cl_device_id deviceID,
binary = (unsigned char *)malloc(sizeof(unsigned char) * binarySize);
if (binary == NULL)
{
log_error("ERROR: Unable to allocate binary character array with %lu "
log_error("ERROR: Unable to allocate binary character array with %zu "
"characters (in %s:%d)!",
binarySize, __FILE__, __LINE__);
return -1;
@@ -3308,7 +3308,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context,
if (binary == NULL)
{
log_error("ERROR: Unable to allocate binary character array with "
"%lu characters! (in %s:%d)\n",
"%zu characters! (in %s:%d)\n",
binarySize, __FILE__, __LINE__);
return -1;
}
@@ -3389,7 +3389,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context,
binary = (unsigned char *)malloc(sizeof(unsigned char) * binarySize);
if (binary == NULL)
{
log_error("ERROR: Unable to allocate binary character array with %lu "
log_error("ERROR: Unable to allocate binary character array with %zu "
"characters! (in %s:%d)\n",
binarySize, __FILE__, __LINE__);
return -1;
@@ -3487,7 +3487,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context,
if (binary == NULL)
{
log_error("ERROR: Unable to allocate binary character array with "
"%lu characters! (in %s:%d)\n",
"%zu characters! (in %s:%d)\n",
binarySize, __FILE__, __LINE__);
return -1;
}

View File

@@ -16,6 +16,7 @@
#include "testBase.h"
#include <limits.h>
#include <ctype.h>
#include <cinttypes>
#ifndef _WIN32
#include <unistd.h>
#endif
@@ -216,7 +217,9 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context
char *extension = (char *)malloc((extension_length + 1) * sizeof(char));
if (extension == NULL)
{
log_error( "Error: unable to allocate memory to hold extension name: %ld chars\n", extension_length );
log_error("Error: unable to allocate memory to hold extension "
"name: %" PRIdPTR " chars\n",
extension_length);
return -1;
}
extensions_supported[num_of_supported_extensions] = extension;

View File

@@ -736,7 +736,7 @@ void dumpConfigInfo(config_info* info)
}
break;
case type_cl_device_id:
log_info("\t%s == %ld\n", info->opcode_name,
log_info("\t%s == %" PRIdPTR "\n", info->opcode_name,
(intptr_t)info->config.device_id);
break;
case type_cl_device_affinity_domain:

View File

@@ -976,7 +976,7 @@ static int RunTest( int testNumber )
for( i = 0; i < sizeof(args ) / sizeof( args[0]); i++ )
if( (error = clSetKernelArg(k, i, sizeof( cl_mem ), args + i) ))
{
vlog_error( "Error %d setting kernel arg # %ld\n", error, i );
vlog_error("Error %d setting kernel arg # %zu\n", error, i);
return error;
}
@@ -1021,24 +1021,72 @@ static int RunTest( int testNumber )
switch( testNumber )
{
// Zeros for these should be positive
case 0: vlog_error( "%ld) Error for %s %s: %a * %a + %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
case 1: vlog_error( "%ld) Error for %s %s: %a * %a - %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
case 2: vlog_error( "%ld) Error for %s %s: %a + %a * %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
case 3: vlog_error( "%ld) Error for %s %s: %a - %a * %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
case 0:
vlog_error("%zu) Error for %s %s: %a * %a + %a = *%a "
"vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
case 1:
vlog_error("%zu) Error for %s %s: %a * %a - %a = *%a "
"vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
case 2:
vlog_error("%zu) Error for %s %s: %a + %a * %a = *%a "
"vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
case 3:
vlog_error("%zu) Error for %s %s: %a - %a * %a = *%a "
"vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
// Zeros for these should be negative
case 4: vlog_error( "%ld) Error for %s %s: -(%a * %a + %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
case 5: vlog_error( "%ld) Error for %s %s: -(%a * %a - %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
case 6: vlog_error( "%ld) Error for %s %s: -(%a + %a * %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
case 7: vlog_error( "%ld) Error for %s %s: -(%a - %a * %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1;
// Zeros for these shouzu be negative
case 4:
vlog_error("%zu) Error for %s %s: -(%a * %a + %a) = "
"*%a vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
case 5:
vlog_error("%zu) Error for %s %s: -(%a * %a - %a) = "
"*%a vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
case 6:
vlog_error("%zu) Error for %s %s: -(%a + %a * %a) = "
"*%a vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
case 7:
vlog_error("%zu) Error for %s %s: -(%a - %a * %a) = "
"*%a vs. %a\n",
i, sizeNames[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
clReleaseKernel(k);
return -1;
default:
vlog_error( "error: Unknown test number!\n" );
clReleaseKernel(k);
@@ -1097,7 +1145,7 @@ static int RunTest_Double( int testNumber )
for( i = 0; i < sizeof(args ) / sizeof( args[0]); i++ )
if( (error = clSetKernelArg(k, i, sizeof( cl_mem ), args + i) ))
{
vlog_error( "Error %d setting kernel arg # %ld\n", error, i );
vlog_error("Error %d setting kernel arg # %zu\n", error, i);
return error;
}
@@ -1138,24 +1186,64 @@ static int RunTest_Double( int testNumber )
switch( testNumber )
{
// Zeros for these should be positive
case 0: vlog_error( "%ld) Error for %s %s: %a * %a + %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1;
case 1: vlog_error( "%ld) Error for %s %s: %a * %a - %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1;
case 2: vlog_error( "%ld) Error for %s %s: %a + %a * %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1;
case 3: vlog_error( "%ld) Error for %s %s: %a - %a * %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1;
case 0:
vlog_error("%zu) Error for %s %s: %a * %a + %a = *%a "
"vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
return -1;
case 1:
vlog_error("%zu) Error for %s %s: %a * %a - %a = *%a "
"vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
return -1;
case 2:
vlog_error("%zu) Error for %s %s: %a + %a * %a = *%a "
"vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
return -1;
case 3:
vlog_error("%zu) Error for %s %s: %a - %a * %a = *%a "
"vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
return -1;
// Zeros for these should be negative
case 4: vlog_error( "%ld) Error for %s %s: -(%a * %a + %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1;
case 5: vlog_error( "%ld) Error for %s %s: -(%a * %a - %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1;
case 6: vlog_error( "%ld) Error for %s %s: -(%a + %a * %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1;
case 7: vlog_error( "%ld) Error for %s %s: -(%a - %a * %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ],
c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1;
// Zeros for these shouzu be negative
case 4:
vlog_error("%zu) Error for %s %s: -(%a * %a + %a) = "
"*%a vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
return -1;
case 5:
vlog_error("%zu) Error for %s %s: -(%a * %a - %a) = "
"*%a vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], a[i], b[i], c[i],
correct[testNumber][i], test[i]);
return -1;
case 6:
vlog_error("%zu) Error for %s %s: -(%a + %a * %a) = "
"*%a vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
return -1;
case 7:
vlog_error("%zu) Error for %s %s: -(%a - %a * %a) = "
"*%a vs. %a\n",
i, sizeNames_double[vectorSize],
kernelName[testNumber], c[i], a[i], b[i],
correct[testNumber][i], test[i]);
return -1;
default:
vlog_error( "error: Unknown test number!\n" );
return -2;

View File

@@ -12,6 +12,6 @@ if("${CLConform_TARGET_ARCH}" STREQUAL "ARM" OR "${CLConform_TARGET_ARCH}" STREQ
list(APPEND ${MODULE_NAME}_SOURCES fplib.cpp)
endif()
set_gnulike_module_compile_flags("-Wno-sign-compare")
set_gnulike_module_compile_flags("-Wno-sign-compare -Wno-format")
include(../CMakeCommon.txt)

View File

@@ -534,7 +534,7 @@ test_status InitCL(cl_device_id device)
vlog("\tCL C Version: %s\n", c);
clGetDeviceInfo(device, CL_DRIVER_VERSION, sizeof(c), c, NULL);
vlog("\tDriver Version: %s\n", c);
vlog("\tProcessing with %ld devices\n", gComputeDevices);
vlog("\tProcessing with %zu devices\n", gComputeDevices);
vlog("\tDevice Frequency: %d MHz\n", gDeviceFrequency);
vlog("\tSubnormal values supported for floats? %s\n",
no_yes[0 != (CL_FP_DENORM & floatCapabilities)]);

View File

@@ -229,11 +229,14 @@ int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices
RandomSeed seed( gRandomSeed );
if (queueCount > MAX_QUEUES) {
log_error("Number of queues (%ld) is greater than the number for which the test was written (%d).", queueCount, MAX_QUEUES);
log_error("Number of queues (%zu) is greater than the number for which "
"the test was written (%d).",
queueCount, MAX_QUEUES);
return -1;
}
log_info("Testing with %ld queues on %ld devices, %ld kernel executions.\n", queueCount, deviceCount, queueCount*num_elements/TEST_SIZE);
log_info("Testing with %zu queues on %zu devices, %zu kernel executions.\n",
queueCount, deviceCount, queueCount * num_elements / TEST_SIZE);
for (i=0; i<deviceCount; i++) {
size_t deviceNameSize;
@@ -242,7 +245,7 @@ int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices
char *deviceName = (char *)alloca(deviceNameSize * (sizeof(char)));
error = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, deviceNameSize, deviceName, NULL);
test_error(error, "clGetDeviceInfo CL_DEVICE_NAME failed");
log_info("Device %ld is \"%s\".\n", i, deviceName);
log_info("Device %zu is \"%s\".\n", i, deviceName);
}
/* Create a context */
@@ -332,11 +335,15 @@ int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices
{
if( expectedResults[ i ] != outputData[ i ] )
{
log_error( "ERROR: Sample data did not verify for queue %d on device %ld (sample %d, expected %d, got %d)\n",
q, q % deviceCount, (int)i, expectedResults[ i ], outputData[ i ] );
log_error("ERROR: Sample data did not verify for queue %d on "
"device %zu (sample %zu, expected %d, got %d)\n",
q, q % deviceCount, i, expectedResults[i],
outputData[i]);
for (size_t j=0; j<deviceCount; j++) {
if (expectedResultsOneDevice[j][i] == outputData[i])
log_info("Sample consistent with only device %ld having modified the data.\n", j);
log_info("Sample consistent with only device %zu "
"having modified the data.\n",
j);
}
errorsThisTime++;
break;

View File

@@ -14,6 +14,7 @@
// limitations under the License.
//
#include <stdio.h>
#include <cinttypes>
#include <CL/cl.h>
#include "harness/errorHelpers.h"
#include "harness/compat.h"
@@ -35,14 +36,14 @@ REGISTER_TEST(device_and_host_timers)
cl_ulong observedDiff;
cl_ulong allowedDiff;
result = clGetDeviceAndHostTimer(deviceID, &deviceStartTime, &hostStartTime);
result = clGetDeviceAndHostTimer(device, &deviceStartTime, &hostStartTime);
if (result != CL_SUCCESS) {
log_error("clGetDeviceAndHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
goto End;
}
result = clGetHostTimer(deviceID, &hostOnlyStartTime);
result = clGetHostTimer(device, &hostOnlyStartTime);
if (result != CL_SUCCESS) {
log_error("clGetHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
@@ -52,14 +53,14 @@ REGISTER_TEST(device_and_host_timers)
// Wait for a while to allow the timers to increment substantially.
sleep(5);
result = clGetDeviceAndHostTimer(deviceID, &deviceEndTime, &hostEndTime);
result = clGetDeviceAndHostTimer(device, &deviceEndTime, &hostEndTime);
if (result != CL_SUCCESS) {
log_error("clGetDeviceAndHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
goto End;
}
result = clGetHostTimer(deviceID, &hostOnlyEndTime);
result = clGetHostTimer(device, &hostOnlyEndTime);
if (result != CL_SUCCESS) {
log_error("clGetHostTimer failed with error %s\n", IGetErrorString(result));
errors++;
@@ -74,13 +75,16 @@ REGISTER_TEST(device_and_host_timers)
if (deviceEndTime <= deviceStartTime) {
log_error("Device timer is not monotonically increasing.\n");
log_error(" deviceStartTime: %lu, deviceEndTime: %lu\n", deviceStartTime, deviceEndTime);
log_error(" deviceStartTime: %" PRIu64 ", deviceEndTime: %" PRIu64
"\n",
deviceStartTime, deviceEndTime);
errors++;
}
if (hostEndTime <= hostStartTime) {
log_error("Error: Host timer is not monotonically increasing.\n");
log_error(" hostStartTime: %lu, hostEndTime: %lu\n", hostStartTime, hostEndTime);
log_error(" hostStartTime: %" PRIu64 ", hostEndTime: %" PRIu64 "\n",
hostStartTime, hostEndTime);
errors++;
}
@@ -95,7 +99,9 @@ REGISTER_TEST(device_and_host_timers)
if (observedDiff > allowedDiff) {
log_error("Error: Device and host timers did not increase by same amount\n");
log_error(" Observed difference between timers %lu (max allowed %lu).\n", observedDiff, allowedDiff);
log_error(" Observed difference between timers %" PRIu64
" (max allowed %" PRIu64 ").\n",
observedDiff, allowedDiff);
errors++;
}
@@ -103,21 +109,26 @@ REGISTER_TEST(device_and_host_timers)
if (hostOnlyEndTime <= hostOnlyStartTime) {
log_error("Error: Host timer is not monotonically increasing.\n");
log_error(" hostStartTime: %lu, hostEndTime: %lu\n", hostOnlyStartTime, hostOnlyEndTime);
log_error(" hostStartTime: %" PRIu64 ", hostEndTime: %" PRIu64 "\n",
hostOnlyStartTime, hostOnlyEndTime);
errors++;
}
if (hostOnlyStartTime < hostStartTime) {
log_error("Error: Host start times do not correlate.\n");
log_error("clGetDeviceAndHostTimer was called before clGetHostTimer but timers are not in that order.\n");
log_error(" clGetDeviceAndHostTimer: %lu, clGetHostTimer: %lu\n", hostStartTime, hostOnlyStartTime);
log_error(" clGetDeviceAndHostTimer: %" PRIu64
", clGetHostTimer: %" PRIu64 "\n",
hostStartTime, hostOnlyStartTime);
errors++;
}
if (hostOnlyEndTime < hostEndTime) {
log_error("Error: Host end times do not correlate.\n");
log_error("clGetDeviceAndHostTimer was called before clGetHostTimer but timers are not in that order.\n");
log_error(" clGetDeviceAndHostTimer: %lu, clGetHostTimer: %lu\n", hostEndTime, hostOnlyEndTime);
log_error(" clGetDeviceAndHostTimer: %" PRIu64
", clGetHostTimer: %" PRIu64 "\n",
hostEndTime, hostOnlyEndTime);
errors++;
}
@@ -133,19 +144,24 @@ REGISTER_TEST(timer_resolution_queries)
cl_ulong deviceTimerResolution = 0;
cl_ulong hostTimerResolution = 0;
result = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
result = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
if (result != CL_SUCCESS) {
log_error("clGetDeviceInfo(CL_DEVICE_PLATFORM) failed with error %s.\n", IGetErrorString(result));
errors++;
}
result = clGetDeviceInfo(deviceID, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(deviceTimerResolution), &deviceTimerResolution, NULL);
result = clGetDeviceInfo(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION,
sizeof(deviceTimerResolution),
&deviceTimerResolution, NULL);
if (result != CL_SUCCESS) {
log_error("clGetDeviceInfo(CL_DEVICE_PROFILING_TIMER_RESOLUTION) failed with error %s.\n", IGetErrorString(result));
errors++;
}
else {
log_info("CL_DEVICE_PROFILING_TIMER_RESOLUTION == %lu nanoseconds\n", deviceTimerResolution);
log_info("CL_DEVICE_PROFILING_TIMER_RESOLUTION == %" PRIu64
" nanoseconds\n",
deviceTimerResolution);
}
if (platform) {
@@ -155,7 +171,9 @@ REGISTER_TEST(timer_resolution_queries)
errors++;
}
else {
log_info("CL_PLATFORM_HOST_TIMER_RESOLUTION == %lu nanoseconds\n", hostTimerResolution);
log_info("CL_PLATFORM_HOST_TIMER_RESOLUTION == %" PRIu64
" nanoseconds\n",
hostTimerResolution);
}
}
else {

View File

@@ -27,7 +27,7 @@ BasicCommandBufferTest::BasicCommandBufferTest(cl_device_id device,
cl_command_queue queue)
: CommandBufferTestBase(device), context(context), queue(nullptr),
num_elements(0), simultaneous_use_support(false),
out_of_order_support(false),
out_of_order_support(false), queue_out_of_order_support(false),
// try to use simultaneous path by default
simultaneous_use_requested(true),
// due to simultaneous cases extend buffer size
@@ -52,12 +52,21 @@ bool BasicCommandBufferTest::Skip()
"Unable to query "
"CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR");
cl_command_queue_properties supported_properties;
error = clGetDeviceInfo(
device, CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR,
sizeof(supported_properties), &supported_properties, NULL);
test_error(error,
"Unable to query "
"CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR");
cl_command_queue_properties queue_properties;
error = clGetCommandQueueInfo(queue, CL_QUEUE_PROPERTIES,
sizeof(queue_properties), &queue_properties,
NULL);
test_error(error, "Unable to query CL_QUEUE_PROPERTIES");
queue_out_of_order_support =
queue_properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
// Query if device supports simultaneous use
cl_device_command_buffer_capabilities_khr capabilities;
@@ -69,7 +78,7 @@ bool BasicCommandBufferTest::Skip()
&& (capabilities & CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR)
!= 0;
out_of_order_support =
capabilities & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR;
supported_properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
device_side_enqueue_support =
(capabilities & CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR)
!= 0;

View File

@@ -75,6 +75,7 @@ protected:
// Device support query results
bool simultaneous_use_support;
bool out_of_order_support;
bool queue_out_of_order_support;
bool device_side_enqueue_support;
// user request for simultaneous use
@@ -103,11 +104,9 @@ int MakeAndRunTest(cl_device_id device, cl_context context,
cl_version extension_version =
get_extension_version(device, "cl_khr_command_buffer");
if (extension_version < CL_MAKE_VERSION(0, 9, 5))
if (extension_version != CL_MAKE_VERSION(0, 9, 6))
{
log_info("cl_khr_command_buffer version 0.9.5 or later is required "
"to run "
log_info("cl_khr_command_buffer version 0.9.6 is required to run "
"the test, skipping.\n ");
return TEST_SKIPPED_ITSELF;
}

View File

@@ -80,20 +80,24 @@ struct BasicMutableCommandBufferTest : BasicCommandBufferTest
"cl_khr_command_buffer_mutable_dispatch")
== true;
if (extension_avaliable) {
// API breaking changes occur at revision 0.9.2, check implementation
// matches tested API
Version device_version = get_device_cl_version(device);
if ((device_version >= Version(3, 0))
|| is_extension_available(device, "cl_khr_extended_versioning")) {
if (extension_avaliable)
{
Version device_version = get_device_cl_version(device);
if ((device_version >= Version(3, 0))
|| is_extension_available(device, "cl_khr_extended_versioning"))
{
cl_version extension_version =
get_extension_version(device, "cl_khr_command_buffer_mutable_dispatch");
cl_version extension_version = get_extension_version(
device, "cl_khr_command_buffer_mutable_dispatch");
if (extension_version < CL_MAKE_VERSION(0, 9, 2)) {
extension_avaliable = false;
}
}
if (extension_version != CL_MAKE_VERSION(0, 9, 3))
{
log_info("cl_khr_command_buffer_mutable_dispatch version "
"0.9.3 is "
"required to run the test, skipping.\n ");
extension_avaliable = false;
}
}
}
cl_mutable_dispatch_fields_khr mutable_capabilities;

Some files were not shown because too many files have changed in this diff Show More