From 2131aff0e902c97eef796cc78677a1145bb9119b Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:10:21 +0000 Subject: [PATCH] Migrate compiler suite to the new test registration framework (#2319) Contributes to #2181. Signed-off-by: Ahmed Hesham --- test_conformance/compiler/main.cpp | 97 +--- test_conformance/compiler/procs.h | 272 ----------- test_conformance/compiler/testBase.h | 32 +- .../compiler/test_async_build.cpp | 7 +- .../compiler/test_build_helpers.cpp | 91 ++-- .../compiler/test_build_options.cpp | 48 +- test_conformance/compiler/test_compile.cpp | 405 +++++++--------- .../test_compiler_defines_for_extensions.cpp | 2 +- .../compiler/test_feature_macro.cpp | 115 ++--- .../compiler/test_image_macro.cpp | 12 +- .../compiler/test_opencl_c_versions.cpp | 3 +- .../compiler/test_pragma_unroll.cpp | 91 ++-- .../compiler/test_preprocessor.cpp | 451 ++++++++++-------- .../test_unload_platform_compiler.cpp | 40 +- 14 files changed, 664 insertions(+), 1002 deletions(-) delete mode 100644 test_conformance/compiler/procs.h diff --git a/test_conformance/compiler/main.cpp b/test_conformance/compiler/main.cpp index 8f9ffb15..20a62f26 100644 --- a/test_conformance/compiler/main.cpp +++ b/test_conformance/compiler/main.cpp @@ -13,103 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "harness/compat.h" - #include "harness/testHarness.h" -#include "procs.h" -#include -#include - -#if !defined(_WIN32) -#include -#endif - -test_definition test_list[] = { - ADD_TEST(load_program_source), - ADD_TEST(load_multistring_source), - ADD_TEST(load_two_kernel_source), - ADD_TEST(load_null_terminated_source), - ADD_TEST(load_null_terminated_multi_line_source), - ADD_TEST(load_null_terminated_partial_multi_line_source), - ADD_TEST(load_discreet_length_source), - ADD_TEST(get_program_source), - ADD_TEST(get_program_build_info), - ADD_TEST(get_program_info), - ADD_TEST(get_program_info_kernel_names), - ADD_TEST(get_program_info_mult_devices), - - ADD_TEST(large_compile), - ADD_TEST(async_build), - - ADD_TEST(options_build_optimizations), - ADD_TEST(options_build_macro), - ADD_TEST(options_build_macro_existence), - ADD_TEST(options_include_directory), - ADD_TEST(options_denorm_cache), - - ADD_TEST(preprocessor_define_udef), - ADD_TEST(preprocessor_include), - ADD_TEST(preprocessor_line_error), - ADD_TEST(preprocessor_pragma), - - ADD_TEST(opencl_c_versions), - ADD_TEST(compiler_defines_for_extensions), - ADD_TEST(image_macro), - - ADD_TEST(simple_compile_only), - ADD_TEST(simple_static_compile_only), - ADD_TEST(simple_extern_compile_only), - ADD_TEST(simple_compile_with_callback), - ADD_TEST(simple_embedded_header_compile), - ADD_TEST(simple_link_only), - ADD_TEST(two_file_regular_variable_access), - ADD_TEST(two_file_regular_struct_access), - ADD_TEST(two_file_regular_function_access), - ADD_TEST(simple_link_with_callback), - ADD_TEST(simple_embedded_header_link), - ADD_TEST(execute_after_simple_compile_and_link), - ADD_TEST(execute_after_simple_compile_and_link_no_device_info), - ADD_TEST(execute_after_simple_compile_and_link_with_defines), - ADD_TEST(execute_after_simple_compile_and_link_with_callbacks), - ADD_TEST(execute_after_simple_library_with_link), - ADD_TEST(execute_after_two_file_link), - ADD_TEST(execute_after_embedded_header_link), - ADD_TEST(execute_after_included_header_link), - ADD_TEST(execute_after_serialize_reload_object), - ADD_TEST(execute_after_serialize_reload_library), - ADD_TEST(simple_library_only), - ADD_TEST(simple_library_with_callback), - ADD_TEST(simple_library_with_link), - ADD_TEST(two_file_link), - ADD_TEST(multi_file_libraries), - ADD_TEST(multiple_files), - ADD_TEST(multiple_libraries), - ADD_TEST(multiple_files_multiple_libraries), - ADD_TEST(multiple_embedded_headers), - - ADD_TEST(program_binary_type), - ADD_TEST(compile_and_link_status_options_log), - - ADD_TEST_VERSION(pragma_unroll, Version(2, 0)), - - ADD_TEST_VERSION(features_macro, Version(3, 0)), - ADD_TEST(features_macro_coupling), - - ADD_TEST(unload_valid), - // ADD_TEST(unload_invalid), // disabling temporarily, see GitHub #977 - ADD_TEST(unload_repeated), - ADD_TEST(unload_compile_unload_link), - ADD_TEST(unload_build_unload_create_kernel), - ADD_TEST(unload_link_different), - ADD_TEST(unload_build_threaded), - ADD_TEST(unload_build_info), - ADD_TEST(unload_program_binaries), - -}; - -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); } diff --git a/test_conformance/compiler/procs.h b/test_conformance/compiler/procs.h deleted file mode 100644 index 13420e9d..00000000 --- a/test_conformance/compiler/procs.h +++ /dev/null @@ -1,272 +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/conversions.h" -#include "harness/errorHelpers.h" -#include "harness/kernelHelpers.h" -#include "harness/mt19937.h" -#include "harness/typeWrappers.h" - -// This is a macro rather than a function to be able to use and act like the -// existing test_error macro. -// -// Not all compiler tests need to use this macro, only those that don't use the -// test harness compiler helpers. -#define check_compiler_available(DEVICE) \ - { \ - cl_bool compilerAvailable = CL_FALSE; \ - cl_int error = clGetDeviceInfo((DEVICE), CL_DEVICE_COMPILER_AVAILABLE, \ - sizeof(compilerAvailable), \ - &compilerAvailable, NULL); \ - test_error(error, "Unable to query CL_DEVICE_COMPILER_AVAILABLE"); \ - if (compilerAvailable == CL_FALSE) \ - { \ - log_info("Skipping test - no compiler is available.\n"); \ - return TEST_SKIPPED_ITSELF; \ - } \ - } - -extern int test_load_program_source(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_load_multistring_source(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_load_two_kernel_source(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_load_null_terminated_source(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_load_null_terminated_multi_line_source(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_load_null_terminated_partial_multi_line_source( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements); -extern int test_load_discreet_length_source(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_get_program_source(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_get_program_build_info(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_get_program_info(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_get_program_info_mult_devices(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_large_compile(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_async_build(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_options_build_optimizations(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_options_build_macro(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_options_build_macro_existence(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_options_include_directory(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_options_denorm_cache(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_preprocessor_define_udef(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_preprocessor_include(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_preprocessor_line_error(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_preprocessor_pragma(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_opencl_c_versions(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_compiler_defines_for_extensions(cl_device_id device, - cl_context context, - cl_command_queue queue, - int n_elems); -extern int test_image_macro(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_simple_compile_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_simple_static_compile_only(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_simple_extern_compile_only(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_simple_compile_with_callback(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_simple_embedded_header_compile(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_simple_link_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_two_file_regular_variable_access(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_two_file_regular_struct_access(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_two_file_regular_function_access(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_simple_link_with_callback(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_simple_embedded_header_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_execute_after_simple_compile_and_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_execute_after_simple_compile_and_link_no_device_info( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements); -extern int test_execute_after_simple_compile_and_link_with_defines( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements); -extern int test_execute_after_simple_compile_and_link_with_callbacks( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements); -extern int test_execute_after_simple_library_with_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_execute_after_two_file_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_execute_after_embedded_header_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_execute_after_included_header_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_execute_after_serialize_reload_object(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_execute_after_serialize_reload_library(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_simple_library_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_simple_library_with_callback(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_simple_library_with_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_two_file_link(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_multi_file_libraries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_multiple_libraries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_multiple_files(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_multiple_files_multiple_libraries(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_multiple_embedded_headers(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_program_binary_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_compile_and_link_status_options_log(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_pragma_unroll(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_features_macro(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_features_macro_coupling(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_unload_valid(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_unload_invalid(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_unload_repeated(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_unload_compile_unload_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_unload_build_unload_create_kernel(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_unload_link_different(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_unload_build_threaded(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_unload_build_info(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_unload_program_binaries(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); diff --git a/test_conformance/compiler/testBase.h b/test_conformance/compiler/testBase.h index 7edfb2da..70c42b5d 100644 --- a/test_conformance/compiler/testBase.h +++ b/test_conformance/compiler/testBase.h @@ -16,14 +16,34 @@ #ifndef _testBase_h #define _testBase_h -#include "harness/compat.h" - -#include -#include -#include #include +#include + +#include + +#include "harness/conversions.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" + +// This is a macro rather than a function to be able to use and act like the +// existing test_error macro. +// +// Not all compiler tests need to use this macro, only those that don't use the +// test harness compiler helpers. +#define check_compiler_available(DEVICE) \ + { \ + cl_bool compilerAvailable = CL_FALSE; \ + cl_int error = clGetDeviceInfo((DEVICE), CL_DEVICE_COMPILER_AVAILABLE, \ + sizeof(compilerAvailable), \ + &compilerAvailable, NULL); \ + test_error(error, "Unable to query CL_DEVICE_COMPILER_AVAILABLE"); \ + if (compilerAvailable == CL_FALSE) \ + { \ + log_info("Skipping test - no compiler is available.\n"); \ + return TEST_SKIPPED_ITSELF; \ + } \ + } -#include "procs.h" // scope guard helper to ensure proper releasing of sub devices struct SubDevicesScopeGuarded diff --git a/test_conformance/compiler/test_async_build.cpp b/test_conformance/compiler/test_async_build.cpp index d1533624..d6c4cf51 100644 --- a/test_conformance/compiler/test_async_build.cpp +++ b/test_conformance/compiler/test_async_build.cpp @@ -94,8 +94,7 @@ void CL_CALLBACK test_notify_build_complete(cl_program program, void *userData) } } -int test_async_build(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(async_build) { cl_int error; @@ -119,9 +118,9 @@ int test_async_build(cl_device_id deviceID, cl_context context, test_error(error, "Unable to create program from source"); // Start an asynchronous build, registering the completion callback - TestData testData = { deviceID, testDef.expectedStatus }; + TestData testData = { device, testDef.expectedStatus }; callbackResult = 0; - error = clBuildProgram(program, 1, &deviceID, NULL, + error = clBuildProgram(program, 1, &device, NULL, test_notify_build_complete, (void *)&testData); // Allow implementations to return synchronous build failures. // They still need to call the callback. diff --git a/test_conformance/compiler/test_build_helpers.cpp b/test_conformance/compiler/test_build_helpers.cpp index 05dac356..a4945350 100644 --- a/test_conformance/compiler/test_build_helpers.cpp +++ b/test_conformance/compiler/test_build_helpers.cpp @@ -88,7 +88,7 @@ __kernel void sample_test_C(__global float *src, __global int *dst) )"; -int test_load_program_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_program_source) { int error; clProgramWrapper program; @@ -132,7 +132,7 @@ int test_load_program_source(cl_device_id deviceID, cl_context context, cl_comma return 0; } -int test_load_multistring_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_multistring_source) { int error; clProgramWrapper program; @@ -159,7 +159,7 @@ int test_load_multistring_source(cl_device_id deviceID, cl_context context, cl_c } /* Try compiling */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build multi-line program source" ); /* Should probably check binary here to verify the same results... */ @@ -169,7 +169,7 @@ int test_load_multistring_source(cl_device_id deviceID, cl_context context, cl_c return 0; } -int test_load_two_kernel_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_two_kernel_source) { int error; cl_program program; @@ -195,7 +195,7 @@ int test_load_two_kernel_source(cl_device_id deviceID, cl_context context, cl_co } /* Try compiling */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build two-kernel program source" ); /* Should probably check binary here to verify the same results... */ @@ -207,7 +207,7 @@ int test_load_two_kernel_source(cl_device_id deviceID, cl_context context, cl_co return 0; } -int test_load_null_terminated_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_null_terminated_source) { int error; cl_program program; @@ -222,7 +222,7 @@ int test_load_null_terminated_source(cl_device_id deviceID, cl_context context, } /* Try compiling */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build null-terminated program source" ); /* Should probably check binary here to verify the same results... */ @@ -234,7 +234,7 @@ int test_load_null_terminated_source(cl_device_id deviceID, cl_context context, return 0; } -int test_load_null_terminated_multi_line_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_null_terminated_multi_line_source) { int error; cl_program program; @@ -252,7 +252,7 @@ int test_load_null_terminated_multi_line_source(cl_device_id deviceID, cl_contex } /* Try compiling */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build null-terminated program source" ); /* Should probably check binary here to verify the same results... */ @@ -264,7 +264,7 @@ int test_load_null_terminated_multi_line_source(cl_device_id deviceID, cl_contex return 0; } -int test_load_discreet_length_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_discreet_length_source) { int error; cl_program program; @@ -295,7 +295,7 @@ int test_load_discreet_length_source(cl_device_id deviceID, cl_context context, } /* Try compiling */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build null-terminated program source" ); /* Should probably check binary here to verify the same results... */ @@ -307,7 +307,7 @@ int test_load_discreet_length_source(cl_device_id deviceID, cl_context context, return 0; } -int test_load_null_terminated_partial_multi_line_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_null_terminated_partial_multi_line_source) { int error; cl_program program; @@ -337,7 +337,7 @@ int test_load_null_terminated_partial_multi_line_source(cl_device_id deviceID, c } /* Try compiling */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build null-terminated program source" ); /* Should probably check binary here to verify the same results... */ @@ -349,7 +349,7 @@ int test_load_null_terminated_partial_multi_line_source(cl_device_id deviceID, c return 0; } -int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(get_program_info) { int error; cl_program program; @@ -373,7 +373,7 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_ test_error( error, "Unable to get device of program" ); /* Object comparability test. */ - test_assert_error(device1 == deviceID, + test_assert_error(device1 == device, "Unexpected result returned by CL_PROGRAM_DEVICES query"); cl_uint devCount; @@ -439,9 +439,7 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_ 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) { int error = CL_SUCCESS; size_t total_kernels = 0; @@ -474,8 +472,7 @@ int test_get_program_info_kernel_names(cl_device_id deviceID, // returned. Query CL_PROGRAM_KERNEL_NAMES and check that the right // kernel names are returned. { - error = - clBuildProgram(program, 1, &deviceID, nullptr, nullptr, nullptr); + error = clBuildProgram(program, 1, &device, nullptr, nullptr, nullptr); test_error(error, "clBuildProgram failed"); error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS, @@ -517,7 +514,7 @@ int test_get_program_info_kernel_names(cl_device_id deviceID, // kernel names are returned. { const char *build_options = "-DUSE_SAMPLE_TEST_B"; - error = clBuildProgram(program, 1, &deviceID, build_options, nullptr, + error = clBuildProgram(program, 1, &device, build_options, nullptr, nullptr); test_error(error, "clBuildProgram failed"); @@ -553,14 +550,12 @@ int test_get_program_info_kernel_names(cl_device_id deviceID, return CL_SUCCESS; } -int test_get_program_info_mult_devices(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(get_program_info_mult_devices) { size_t size = 0; // query multi-device context and perform objects comparability test - cl_int err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_PROPERTIES, 0, + cl_int err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_PROPERTIES, 0, nullptr, &size); test_error_fail(err, "clGetDeviceInfo failed"); @@ -572,7 +567,7 @@ int test_get_program_info_mult_devices(cl_device_id deviceID, std::vector supported_props( size / sizeof(cl_device_partition_property), 0); - err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_PROPERTIES, + err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_PROPERTIES, supported_props.size() * sizeof(cl_device_partition_property), supported_props.data(), &size); @@ -585,7 +580,7 @@ int test_get_program_info_mult_devices(cl_device_id deviceID, } cl_uint maxComputeUnits = 0; - err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, + err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(maxComputeUnits), &maxComputeUnits, nullptr); test_error_ret(err, "Unable to get maximal number of compute units", TEST_FAIL); @@ -607,14 +602,14 @@ int test_get_program_info_mult_devices(cl_device_id deviceID, if (sup_prop == prop[0]) { // how many sub-devices can we create? - err = clCreateSubDevices(deviceID, prop.data(), 0, nullptr, + err = clCreateSubDevices(device, prop.data(), 0, nullptr, &num_devices); test_error_fail(err, "clCreateSubDevices failed"); if (num_devices < 2) continue; // get the list of subDevices scope_guard.reset(new SubDevicesScopeGuarded(num_devices)); - err = clCreateSubDevices(deviceID, prop.data(), num_devices, + err = clCreateSubDevices(device, prop.data(), num_devices, scope_guard->sub_devices.data(), &num_devices); test_error_fail(err, "clCreateSubDevices failed"); @@ -681,7 +676,7 @@ int test_get_program_info_mult_devices(cl_device_id deviceID, return TEST_PASS; } -int test_get_program_source(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(get_program_source) { cl_program program; int error; @@ -736,7 +731,7 @@ int test_get_program_source(cl_device_id deviceID, cl_context context, cl_comman return 0; } -int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(get_program_build_info) { cl_program program; int error; @@ -753,7 +748,8 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co } /* Make sure getting the length works */ - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_STATUS, 0, NULL, &length ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, 0, + NULL, &length); test_error( error, "Unable to get program build status length" ); if( length != sizeof( status ) ) { @@ -762,10 +758,11 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co } /* Now actually build it and verify the status */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build program source" ); - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_STATUS, sizeof( status ), &status, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, + sizeof(status), &status, NULL); test_error( error, "Unable to get program build status" ); if( status != CL_BUILD_SUCCESS ) { @@ -776,7 +773,8 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co /***** Build log *****/ /* Try getting the length */ - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_LOG, 0, NULL, &length ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, + NULL, &length); test_error( error, "Unable to get program build log length" ); log_info("Build log is %zu long.\n", length); @@ -784,7 +782,8 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co buffer = (char*)malloc(length); /* Try normal source */ - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_LOG, length, buffer, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, length, + buffer, NULL); test_error( error, "Unable to get program build log" ); if( buffer[length-1] != '\0' ) @@ -794,23 +793,27 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co } /* Try both at once */ - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_LOG, length, buffer, &newLength ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, length, + buffer, &newLength); test_error( error, "Unable to get program build log" ); free(buffer); /***** Build options *****/ - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_OPTIONS, 0, NULL, &length ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_OPTIONS, 0, + NULL, &length); test_error( error, "Unable to get program build options length" ); buffer = (char*)malloc(length); /* Try normal source */ - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_OPTIONS, length, buffer, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_OPTIONS, + length, buffer, NULL); test_error( error, "Unable to get program build options" ); /* Try both at once */ - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_OPTIONS, length, buffer, &newLength ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_OPTIONS, + length, buffer, &newLength); test_error( error, "Unable to get program build options" ); free(buffer); @@ -826,19 +829,21 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co return -1; } - error = clBuildProgram( program, 1, &deviceID, "-cl-opt-disable", NULL, NULL ); + error = clBuildProgram(program, 1, &device, "-cl-opt-disable", NULL, NULL); if( error != CL_SUCCESS ) { print_error( error, "Building with valid options failed!" ); return -1; } - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_OPTIONS, 0, NULL, &length ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_OPTIONS, 0, + NULL, &length); test_error( error, "Unable to get program build options" ); buffer = (char*)malloc(length); - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_OPTIONS, length, buffer, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_OPTIONS, + length, buffer, NULL); test_error( error, "Unable to get program build options" ); if( strcmp( (char *)buffer, "-cl-opt-disable" ) != 0 ) { diff --git a/test_conformance/compiler/test_build_options.cpp b/test_conformance/compiler/test_build_options.cpp index c25fd10f..daba1b0e 100644 --- a/test_conformance/compiler/test_build_options.cpp +++ b/test_conformance/compiler/test_build_options.cpp @@ -88,7 +88,7 @@ cl_int get_result_from_program( cl_context context, cl_command_queue queue, cl_p return CL_SUCCESS; } -int test_options_build_optimizations(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(options_build_optimizations) { int error; cl_build_status status; @@ -105,10 +105,12 @@ int test_options_build_optimizations(cl_device_id deviceID, cl_context context, /* Build with the macro defined */ log_info("Testing optimization option '%s'\n", optimization_options[i]); - error = clBuildProgram( program, 1, &deviceID, optimization_options[i], NULL, NULL ); + error = clBuildProgram(program, 1, &device, optimization_options[i], + NULL, NULL); test_error( error, "Test program did not properly build" ); - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_STATUS, sizeof( status ), &status, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, + sizeof(status), &status, NULL); test_error( error, "Unable to get program build status" ); if( (int)status != CL_BUILD_SUCCESS ) @@ -121,7 +123,7 @@ int test_options_build_optimizations(cl_device_id deviceID, cl_context context, return 0; } -int test_options_build_macro(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(options_build_macro) { int error; clProgramWrapper program; @@ -136,10 +138,11 @@ int test_options_build_macro(cl_device_id deviceID, cl_context context, cl_comma } /* Build with the macro defined */ - error = clBuildProgram( program, 1, &deviceID, "-DTEST_MACRO=1 ", NULL, NULL ); + error = clBuildProgram(program, 1, &device, "-DTEST_MACRO=1 ", NULL, NULL); test_error( error, "Test program did not properly build" ); - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_STATUS, sizeof( status ), &status, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, + sizeof(status), &status, NULL); test_error( error, "Unable to get program build status" ); if( (int)status != CL_BUILD_SUCCESS ) @@ -162,7 +165,7 @@ int test_options_build_macro(cl_device_id deviceID, cl_context context, cl_comma } // Rebuild with a different value for the define macro, to make sure caching behaves properly - error = clBuildProgram( program, 1, &deviceID, "-DTEST_MACRO=5 ", NULL, NULL ); + error = clBuildProgram(program, 1, &device, "-DTEST_MACRO=5 ", NULL, NULL); test_error( error, "Test program did not properly rebuild" ); error = get_result_from_program( context, queue, program, &secondResult ); @@ -180,7 +183,7 @@ int test_options_build_macro(cl_device_id deviceID, cl_context context, cl_comma return 0; } -int test_options_build_macro_existence(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(options_build_macro_existence) { int error; clProgramWrapper program; @@ -195,7 +198,7 @@ int test_options_build_macro_existence(cl_device_id deviceID, cl_context context } /* Build without the macro defined */ - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Test program did not properly build" ); // Go ahead and run the program to verify results @@ -211,7 +214,7 @@ int test_options_build_macro_existence(cl_device_id deviceID, cl_context context } // Now compile again with the macro defined and verify a change in results - error = clBuildProgram( program, 1, &deviceID, "-DTEST_MACRO", NULL, NULL ); + error = clBuildProgram(program, 1, &device, "-DTEST_MACRO", NULL, NULL); test_error( error, "Test program did not properly build" ); error = get_result_from_program( context, queue, program, &secondResult ); @@ -229,7 +232,7 @@ int test_options_build_macro_existence(cl_device_id deviceID, cl_context context return 0; } -int test_options_include_directory(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(options_include_directory) { int error; @@ -252,10 +255,12 @@ int test_options_include_directory(cl_device_id deviceID, cl_context context, cl include_dir = "-I " + path + sep + "includeTestDirectory"; // log_info("%s\n", include_dir); - error = clBuildProgram( program, 1, &deviceID, include_dir.c_str(), NULL, NULL ); + error = + clBuildProgram(program, 1, &device, include_dir.c_str(), NULL, NULL); test_error( error, "Test program did not properly build" ); - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_STATUS, sizeof( status ), &status, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, + sizeof(status), &status, NULL); test_error( error, "Unable to get program build status" ); if( (int)status != CL_BUILD_SUCCESS ) @@ -278,7 +283,8 @@ int test_options_include_directory(cl_device_id deviceID, cl_context context, cl // Rebuild with a different include directory include_dir = "-I " + path + sep + "secondIncludeTestDirectory"; - error = clBuildProgram( program, 1, &deviceID, include_dir.c_str(), NULL, NULL ); + error = + clBuildProgram(program, 1, &device, include_dir.c_str(), NULL, NULL); test_error( error, "Test program did not properly rebuild" ); error = get_result_from_program( context, queue, program, &secondResult ); @@ -334,7 +340,7 @@ cl_int get_float_result_from_program( cl_context context, cl_command_queue queue return CL_SUCCESS; } -int test_options_denorm_cache(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(options_denorm_cache) { int error; @@ -344,7 +350,8 @@ int test_options_denorm_cache(cl_device_id deviceID, cl_context context, cl_comm // If denorms aren't even supported, testing this flag is pointless cl_device_fp_config floatCaps = 0; - error = clGetDeviceInfo( deviceID, CL_DEVICE_SINGLE_FP_CONFIG, sizeof(floatCaps), &floatCaps, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_SINGLE_FP_CONFIG, + sizeof(floatCaps), &floatCaps, NULL); test_error( error, "Unable to get device FP config" ); if( ( floatCaps & CL_FP_DENORM ) == 0 ) { @@ -356,10 +363,12 @@ int test_options_denorm_cache(cl_device_id deviceID, cl_context context, cl_comm test_error( error, "Unable to create test program" ); // Build first WITH the denorm flush flag - error = clBuildProgram( program, 1, &deviceID, "-cl-denorms-are-zero", NULL, NULL ); + error = + clBuildProgram(program, 1, &device, "-cl-denorms-are-zero", NULL, NULL); test_error( error, "Test program did not properly build" ); - error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_STATUS, sizeof( status ), &status, NULL ); + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, + sizeof(status), &status, NULL); test_error( error, "Unable to get program build status" ); if( (int)status != CL_BUILD_SUCCESS ) @@ -382,7 +391,7 @@ int test_options_denorm_cache(cl_device_id deviceID, cl_context context, cl_comm // valid, there isn't anything we can to do validate results for now // Rebuild without flushing flag set - error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error( error, "Test program did not properly rebuild" ); error = get_float_result_from_program( context, queue, program, *input, *input, &secondResult ); @@ -406,4 +415,3 @@ int test_options_denorm_cache(cl_device_id deviceID, cl_context context, cl_comm return 0; } - diff --git a/test_conformance/compiler/test_compile.cpp b/test_conformance/compiler/test_compile.cpp index 0ca37b3f..907de9cb 100644 --- a/test_conformance/compiler/test_compile.cpp +++ b/test_conformance/compiler/test_compile.cpp @@ -155,8 +155,8 @@ const char *link_static_function_access = // use with compile_static_function "extern int foo(int, int);\n" "int access_foo() { int blah = foo(3, 4); return blah + 5; }\n"; -int test_large_single_compile(cl_context context, cl_device_id deviceID, - unsigned int numLines) +static int test_large_single_compile(cl_context context, cl_device_id deviceID, + unsigned int numLines) { int error; cl_program program; @@ -219,8 +219,7 @@ int test_large_single_compile(cl_context context, cl_device_id deviceID, return 0; } -int test_large_compile(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(large_compile) { unsigned int toTest[] = { 64, 128, 256, 512, 1024, 2048, 4096, 0 @@ -240,7 +239,7 @@ int test_large_compile(cl_device_id deviceID, cl_context context, gettimeofday(&time1, NULL); #endif - if (test_large_single_compile(context, deviceID, toTest[i]) != 0) + if (test_large_single_compile(context, device, toTest[i]) != 0) { log_error( "ERROR: long program test failed for %d lines! (in %s:%d)\n", @@ -270,8 +269,10 @@ static int verifyCopyBuffer(cl_context context, cl_command_queue queue, #define _strdup strdup #endif -int test_large_multi_file_library(cl_context context, cl_device_id deviceID, - cl_command_queue queue, unsigned int numLines) +static int test_large_multi_file_library(cl_context context, + cl_device_id deviceID, + cl_command_queue queue, + unsigned int numLines) { int error; cl_program program; @@ -419,8 +420,7 @@ int test_large_multi_file_library(cl_context context, cl_device_id deviceID, return 0; } -int test_multi_file_libraries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(multi_file_libraries) { unsigned int toTest[] = { 2, 4, 8, 16, 32, 64, 128, 256, 0 @@ -440,7 +440,7 @@ int test_multi_file_libraries(cl_device_id deviceID, cl_context context, gettimeofday(&time1, NULL); #endif - if (test_large_multi_file_library(context, deviceID, queue, toTest[i]) + if (test_large_multi_file_library(context, device, queue, toTest[i]) != 0) { log_error("ERROR: multi-file library program test failed for %d " @@ -464,10 +464,10 @@ int test_multi_file_libraries(cl_device_id deviceID, cl_context context, return 0; } -int test_large_multiple_embedded_headers(cl_context context, - cl_device_id deviceID, - cl_command_queue queue, - unsigned int numLines) +static int test_large_multiple_embedded_headers(cl_context context, + cl_device_id deviceID, + cl_command_queue queue, + unsigned int numLines) { int error; cl_program program; @@ -641,8 +641,7 @@ int test_large_multiple_embedded_headers(cl_context context, return 0; } -int test_multiple_embedded_headers(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(multiple_embedded_headers) { unsigned int toTest[] = { 2, 4, 8, 16, 32, 64, 128, 256, 0 @@ -663,7 +662,7 @@ int test_multiple_embedded_headers(cl_device_id deviceID, cl_context context, gettimeofday(&time1, NULL); #endif - if (test_large_multiple_embedded_headers(context, deviceID, queue, + if (test_large_multiple_embedded_headers(context, device, queue, toTest[i]) != 0) { @@ -690,8 +689,10 @@ int test_multiple_embedded_headers(cl_device_id deviceID, cl_context context, double logbase(double a, double base) { return log(a) / log(base); } -int test_large_multiple_libraries(cl_context context, cl_device_id deviceID, - cl_command_queue queue, unsigned int numLines) +static int test_large_multiple_libraries(cl_context context, + cl_device_id deviceID, + cl_command_queue queue, + unsigned int numLines) { int error; cl_program *simple_kernels; @@ -846,8 +847,7 @@ int test_large_multiple_libraries(cl_context context, cl_device_id deviceID, return 0; } -int test_multiple_libraries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(multiple_libraries) { unsigned int toTest[] = { 2, 8, 32, 128, 256, 0 @@ -867,7 +867,7 @@ int test_multiple_libraries(cl_device_id deviceID, cl_context context, gettimeofday(&time1, NULL); #endif - if (test_large_multiple_libraries(context, deviceID, queue, toTest[i]) + if (test_large_multiple_libraries(context, device, queue, toTest[i]) != 0) { log_error("ERROR: multiple library program test failed for %d " @@ -891,10 +891,10 @@ int test_multiple_libraries(cl_device_id deviceID, cl_context context, return 0; } -int test_large_multiple_files_multiple_libraries(cl_context context, - cl_device_id deviceID, - cl_command_queue queue, - unsigned int numLines) +static int test_large_multiple_files_multiple_libraries(cl_context context, + cl_device_id deviceID, + cl_command_queue queue, + unsigned int numLines) { int error; cl_program *simple_kernels; @@ -1060,10 +1060,7 @@ int test_large_multiple_files_multiple_libraries(cl_context context, return 0; } -int test_multiple_files_multiple_libraries(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(multiple_files_multiple_libraries) { unsigned int toTest[] = { 8, 32, 128, 256, 0 }; // 512, 2048, 8192, 32768, 0 }; @@ -1083,8 +1080,8 @@ int test_multiple_files_multiple_libraries(cl_device_id deviceID, gettimeofday(&time1, NULL); #endif - if (test_large_multiple_files_multiple_libraries(context, deviceID, - queue, toTest[i]) + if (test_large_multiple_files_multiple_libraries(context, device, queue, + toTest[i]) != 0) { log_error("ERROR: multiple files, multiple libraries program test " @@ -1108,8 +1105,9 @@ int test_multiple_files_multiple_libraries(cl_device_id deviceID, return 0; } -int test_large_multiple_files(cl_context context, cl_device_id deviceID, - cl_command_queue queue, unsigned int numLines) +static int test_large_multiple_files(cl_context context, cl_device_id deviceID, + cl_command_queue queue, + unsigned int numLines) { int error; const char **lines; @@ -1232,8 +1230,7 @@ int test_large_multiple_files(cl_context context, cl_device_id deviceID, return 0; } -int test_multiple_files(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(multiple_files) { unsigned int toTest[] = { 8, 32, 128, 256, 0 }; // 512, 2048, 8192, 32768, 0 }; @@ -1253,7 +1250,7 @@ int test_multiple_files(cl_device_id deviceID, cl_context context, gettimeofday(&time1, NULL); #endif - if (test_large_multiple_files(context, deviceID, queue, toTest[i]) != 0) + if (test_large_multiple_files(context, device, queue, toTest[i]) != 0) { log_error("ERROR: multiple files program test failed for %d lines! " "(in %s:%d)\n\n", @@ -1276,8 +1273,7 @@ int test_multiple_files(cl_device_id deviceID, cl_context context, return 0; } -int test_simple_compile_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_compile_only) { int error; cl_program program; @@ -1293,8 +1289,8 @@ int test_simple_compile_only(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); /* All done! */ @@ -1304,8 +1300,7 @@ int test_simple_compile_only(cl_device_id deviceID, cl_context context, return 0; } -int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_static_compile_only) { int error; cl_program program; @@ -1323,8 +1318,8 @@ int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, } log_info("Compiling a static variable...\n"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple static variable program"); /* All done! */ @@ -1342,8 +1337,8 @@ int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, } log_info("Compiling a static struct...\n"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple static variable program"); /* All done! */ @@ -1361,8 +1356,8 @@ int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, } log_info("Compiling a static function...\n"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple static function program"); /* All done! */ @@ -1372,8 +1367,7 @@ int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, return 0; } -int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_extern_compile_only) { int error; cl_program program; @@ -1390,8 +1384,8 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, } log_info("Compiling an extern kernel...\n"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple extern kernel program"); /* All done! */ @@ -1409,8 +1403,8 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, } log_info("Compiling an extern variable...\n"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple extern variable program"); /* All done! */ @@ -1428,8 +1422,8 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, } log_info("Compiling an extern struct...\n"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple extern variable program"); /* All done! */ @@ -1447,8 +1441,8 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, } log_info("Compiling an extern function...\n"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple extern function program"); /* All done! */ @@ -1500,8 +1494,7 @@ static void CL_CALLBACK simple_compile_callback(cl_program program, "compile_program_completion_event!\n"); } -int test_simple_compile_with_callback(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_compile_with_callback) { int error; cl_program program; @@ -1525,7 +1518,7 @@ int test_simple_compile_with_callback(cl_device_id deviceID, cl_context context, once_upon_a_midnight_dreary, compile_program_completion_event }; - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, simple_compile_callback, (void *)&simple_compile_user_data); test_error(error, "Unable to compile a simple program with a callback"); @@ -1545,10 +1538,7 @@ int test_simple_compile_with_callback(cl_device_id deviceID, cl_context context, return 0; } -int test_simple_embedded_header_compile(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(simple_embedded_header_compile) { int error; cl_program program, header; @@ -1574,7 +1564,7 @@ int test_simple_embedded_header_compile(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 1, &header, + error = clCompileProgram(program, 1, &device, NULL, 1, &header, &simple_header_name, NULL, NULL); test_error(error, "Unable to compile a simple program with embedded header"); @@ -1589,8 +1579,7 @@ int test_simple_embedded_header_compile(cl_device_id deviceID, return 0; } -int test_simple_link_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_link_only) { int error; cl_program program; @@ -1606,12 +1595,12 @@ int test_simple_link_only(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program my_newly_linked_program = clLinkProgram( - context, 1, &deviceID, NULL, 1, &program, NULL, NULL, &error); + context, 1, &device, NULL, 1, &program, NULL, NULL, &error); test_error(error, "Unable to link a simple program"); /* All done! */ @@ -1624,10 +1613,7 @@ int test_simple_link_only(cl_device_id deviceID, cl_context context, return 0; } -int test_two_file_regular_variable_access(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(two_file_regular_variable_access) { int error; cl_program program, second_program, my_newly_linked_program; @@ -1647,8 +1633,8 @@ int test_two_file_regular_variable_access(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program with regular function"); @@ -1662,14 +1648,14 @@ int test_two_file_regular_variable_access(cl_device_id deviceID, return -1; } - error = clCompileProgram(second_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(second_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error( error, "Unable to compile a program that tries to access a regular variable"); cl_program two_programs[2] = { program, second_program }; - my_newly_linked_program = clLinkProgram(context, 1, &deviceID, NULL, 2, + my_newly_linked_program = clLinkProgram(context, 1, &device, NULL, 2, two_programs, NULL, NULL, &error); test_error(error, "clLinkProgram: Expected a different error code while linking a " @@ -1688,10 +1674,7 @@ int test_two_file_regular_variable_access(cl_device_id deviceID, return 0; } -int test_two_file_regular_struct_access(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(two_file_regular_struct_access) { int error; cl_program program, second_program, my_newly_linked_program; @@ -1711,8 +1694,8 @@ int test_two_file_regular_struct_access(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program with regular struct"); error = create_single_kernel_helper_create_program( @@ -1725,14 +1708,14 @@ int test_two_file_regular_struct_access(cl_device_id deviceID, return -1; } - error = clCompileProgram(second_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(second_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error( error, "Unable to compile a program that tries to access a regular struct"); cl_program two_programs[2] = { program, second_program }; - my_newly_linked_program = clLinkProgram(context, 1, &deviceID, NULL, 2, + my_newly_linked_program = clLinkProgram(context, 1, &device, NULL, 2, two_programs, NULL, NULL, &error); test_error(error, "clLinkProgram: Expected a different error code while linking a " @@ -1752,10 +1735,7 @@ int test_two_file_regular_struct_access(cl_device_id deviceID, } -int test_two_file_regular_function_access(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(two_file_regular_function_access) { int error; cl_program program, second_program, my_newly_linked_program; @@ -1775,8 +1755,8 @@ int test_two_file_regular_function_access(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program with regular function"); @@ -1790,14 +1770,14 @@ int test_two_file_regular_function_access(cl_device_id deviceID, return -1; } - error = clCompileProgram(second_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(second_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error( error, "Unable to compile a program that tries to access a regular function"); cl_program two_programs[2] = { program, second_program }; - my_newly_linked_program = clLinkProgram(context, 1, &deviceID, NULL, 2, + my_newly_linked_program = clLinkProgram(context, 1, &device, NULL, 2, two_programs, NULL, NULL, &error); test_error(error, "clLinkProgram: Expected a different error code while linking a " @@ -1816,8 +1796,7 @@ int test_two_file_regular_function_access(cl_device_id deviceID, return 0; } -int test_simple_embedded_header_link(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_embedded_header_link) { int error; cl_program program, header, simple_program; @@ -1843,7 +1822,7 @@ int test_simple_embedded_header_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 1, &header, + error = clCompileProgram(program, 1, &device, NULL, 1, &header, &simple_header_name, NULL, NULL); test_error(error, "Unable to compile a simple program with embedded header"); @@ -1858,13 +1837,13 @@ int test_simple_embedded_header_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(simple_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(simple_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program two_programs[2] = { program, simple_program }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, two_programs, NULL, NULL, &error); + context, 1, &device, "", 2, two_programs, NULL, NULL, &error); test_error(error, "Unable to create an executable from two binaries, one compiled " "with embedded header"); @@ -1920,8 +1899,7 @@ static void CL_CALLBACK simple_link_callback(cl_program program, "link_program_completion_event event!\n"); } -int test_simple_link_with_callback(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_link_with_callback) { int error; cl_program program; @@ -1938,8 +1916,8 @@ int test_simple_link_with_callback(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); link_program_completion_event = clCreateUserEvent(context, &error); @@ -1949,7 +1927,7 @@ int test_simple_link_with_callback(cl_device_id deviceID, cl_context context, link_program_completion_event }; cl_program my_linked_library = clLinkProgram( - context, 1, &deviceID, NULL, 1, &program, simple_link_callback, + context, 1, &device, NULL, 1, &program, simple_link_callback, (void *)&simple_link_user_data, &error); test_error(error, "Unable to link a simple program"); @@ -2108,10 +2086,7 @@ static int verifyCopyBuffer(cl_context context, cl_command_queue queue, return result; } -int test_execute_after_simple_compile_and_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_simple_compile_and_link) { int error; cl_program program; @@ -2127,12 +2102,12 @@ int test_execute_after_simple_compile_and_link(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program my_newly_linked_program = clLinkProgram( - context, 1, &deviceID, NULL, 1, &program, NULL, NULL, &error); + context, 1, &device, NULL, 1, &program, NULL, NULL, &error); test_error(error, "Unable to link a simple program"); cl_kernel kernel = @@ -2155,9 +2130,7 @@ int test_execute_after_simple_compile_and_link(cl_device_id deviceID, return 0; } -int test_execute_after_simple_compile_and_link_no_device_info( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_simple_compile_and_link_no_device_info) { int error; cl_program program; @@ -2201,9 +2174,7 @@ int test_execute_after_simple_compile_and_link_no_device_info( return 0; } -int test_execute_after_simple_compile_and_link_with_defines( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_simple_compile_and_link_with_defines) { int error; cl_program program; @@ -2221,12 +2192,12 @@ int test_execute_after_simple_compile_and_link_with_defines( return -1; } - error = clCompileProgram(program, 1, &deviceID, "-DFIRST=5 -DSECOND=37", 0, + error = clCompileProgram(program, 1, &device, "-DFIRST=5 -DSECOND=37", 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program my_newly_linked_program = clLinkProgram( - context, 1, &deviceID, NULL, 1, &program, NULL, NULL, &error); + context, 1, &device, NULL, 1, &program, NULL, NULL, &error); test_error(error, "Unable to link a simple program"); cl_kernel kernel = @@ -2249,10 +2220,7 @@ int test_execute_after_simple_compile_and_link_with_defines( return 0; } -int test_execute_after_serialize_reload_object(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_serialize_reload_object) { int error; cl_program program; @@ -2271,8 +2239,8 @@ int test_execute_after_serialize_reload_object(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); // Get the size of the resulting binary (only one device) @@ -2320,13 +2288,12 @@ int test_execute_after_serialize_reload_object(cl_device_id deviceID, // use clCreateProgramWithBinary cl_program program_with_binary = clCreateProgramWithBinary( - context, 1, &deviceID, &binarySize, (const unsigned char **)buffers, + context, 1, &device, &binarySize, (const unsigned char **)buffers, loadErrors, &error); test_error(error, "Unable to create program with binary"); - cl_program my_newly_linked_program = - clLinkProgram(context, 1, &deviceID, NULL, 1, &program_with_binary, - NULL, NULL, &error); + cl_program my_newly_linked_program = clLinkProgram( + context, 1, &device, NULL, 1, &program_with_binary, NULL, NULL, &error); test_error(error, "Unable to link a simple program"); cl_kernel kernel = @@ -2354,10 +2321,7 @@ int test_execute_after_serialize_reload_object(cl_device_id deviceID, return 0; } -int test_execute_after_serialize_reload_library(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_serialize_reload_library) { int error; cl_program program, another_program; @@ -2377,13 +2341,13 @@ int test_execute_after_serialize_reload_library(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program my_newly_minted_library = - clLinkProgram(context, 1, &deviceID, "-create-library", 1, &program, - NULL, NULL, &error); + clLinkProgram(context, 1, &device, "-create-library", 1, &program, NULL, + NULL, &error); test_error(error, "Unable to create a simple library"); @@ -2432,7 +2396,7 @@ int test_execute_after_serialize_reload_library(cl_device_id deviceID, // use clCreateProgramWithBinary cl_program library_with_binary = clCreateProgramWithBinary( - context, 1, &deviceID, &binarySize, (const unsigned char **)buffers, + context, 1, &device, &binarySize, (const unsigned char **)buffers, loadErrors, &error); test_error(error, "Unable to create program with binary"); @@ -2446,14 +2410,14 @@ int test_execute_after_serialize_reload_library(cl_device_id deviceID, return -1; } - error = clCompileProgram(another_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(another_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program program_and_archive[2] = { another_program, library_with_binary }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, program_and_archive, NULL, NULL, &error); + context, 1, &device, "", 2, program_and_archive, NULL, NULL, &error); test_error(error, "Unable to create an executable from a binary and a library"); @@ -2540,9 +2504,7 @@ static void CL_CALLBACK program_link_completion_callback(cl_program program, "link_program_completion_event event!\n"); } -int test_execute_after_simple_compile_and_link_with_callbacks( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_simple_compile_and_link_with_callbacks) { int error; cl_program program; @@ -2563,7 +2525,7 @@ int test_execute_after_simple_compile_and_link_with_callbacks( compile_program_completion_event = clCreateUserEvent(context, &error); test_error(error, "Unable to create a user event"); - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, program_compile_completion_callback, (void *)compile_program_completion_event); test_error(error, "Unable to compile a simple program"); @@ -2580,7 +2542,7 @@ int test_execute_after_simple_compile_and_link_with_callbacks( test_error(error, "Unable to create a user event"); cl_program my_newly_linked_program = - clLinkProgram(context, 1, &deviceID, NULL, 1, &program, + clLinkProgram(context, 1, &device, NULL, 1, &program, program_link_completion_callback, (void *)link_program_completion_event, &error); test_error(error, "Unable to link a simple program"); @@ -2613,8 +2575,7 @@ int test_execute_after_simple_compile_and_link_with_callbacks( return 0; } -int test_simple_library_only(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_library_only) { int error; cl_program program; @@ -2630,13 +2591,13 @@ int test_simple_library_only(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program my_newly_minted_library = - clLinkProgram(context, 1, &deviceID, "-create-library", 1, &program, - NULL, NULL, &error); + clLinkProgram(context, 1, &device, "-create-library", 1, &program, NULL, + NULL, &error); test_error(error, "Unable to create a simple library"); /* All done! */ @@ -2649,8 +2610,7 @@ int test_simple_library_only(cl_device_id deviceID, cl_context context, return 0; } -int test_simple_library_with_callback(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_library_with_callback) { int error; cl_program program; @@ -2667,8 +2627,8 @@ int test_simple_library_with_callback(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); link_program_completion_event = clCreateUserEvent(context, &error); @@ -2678,7 +2638,7 @@ int test_simple_library_with_callback(cl_device_id deviceID, cl_context context, link_program_completion_event }; cl_program my_newly_minted_library = clLinkProgram( - context, 1, &deviceID, "-create-library", 1, &program, + context, 1, &device, "-create-library", 1, &program, simple_link_callback, (void *)&simple_link_user_data, &error); test_error(error, "Unable to create a simple library"); @@ -2700,8 +2660,7 @@ int test_simple_library_with_callback(cl_device_id deviceID, cl_context context, return 0; } -int test_simple_library_with_link(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(simple_library_with_link) { int error; cl_program program, another_program; @@ -2717,13 +2676,13 @@ int test_simple_library_with_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program my_newly_minted_library = - clLinkProgram(context, 1, &deviceID, "-create-library", 1, &program, - NULL, NULL, &error); + clLinkProgram(context, 1, &device, "-create-library", 1, &program, NULL, + NULL, &error); test_error(error, "Unable to create a simple library"); error = create_single_kernel_helper_create_program( @@ -2736,14 +2695,14 @@ int test_simple_library_with_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(another_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(another_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program program_and_archive[2] = { another_program, my_newly_minted_library }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, program_and_archive, NULL, NULL, &error); + context, 1, &device, "", 2, program_and_archive, NULL, NULL, &error); test_error(error, "Unable to create an executable from a binary and a library"); @@ -2763,10 +2722,7 @@ int test_simple_library_with_link(cl_device_id deviceID, cl_context context, return 0; } -int test_execute_after_simple_library_with_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_simple_library_with_link) { int error; cl_program program, another_program; @@ -2783,13 +2739,13 @@ int test_execute_after_simple_library_with_link(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program my_newly_minted_library = - clLinkProgram(context, 1, &deviceID, "-create-library", 1, &program, - NULL, NULL, &error); + clLinkProgram(context, 1, &device, "-create-library", 1, &program, NULL, + NULL, &error); test_error(error, "Unable to create a simple library"); error = create_single_kernel_helper_create_program( @@ -2802,14 +2758,14 @@ int test_execute_after_simple_library_with_link(cl_device_id deviceID, return -1; } - error = clCompileProgram(another_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(another_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program program_and_archive[2] = { another_program, my_newly_minted_library }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, program_and_archive, NULL, NULL, &error); + context, 1, &device, "", 2, program_and_archive, NULL, NULL, &error); test_error(error, "Unable to create an executable from a binary and a library"); @@ -2849,8 +2805,7 @@ int test_execute_after_simple_library_with_link(cl_device_id deviceID, return 0; } -int test_two_file_link(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(two_file_link) { int error; cl_program program, another_program; @@ -2866,8 +2821,8 @@ int test_two_file_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); @@ -2881,13 +2836,13 @@ int test_two_file_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(another_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(another_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program two_programs[2] = { program, another_program }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, two_programs, NULL, NULL, &error); + context, 1, &device, "", 2, two_programs, NULL, NULL, &error); test_error(error, "Unable to create an executable from two binaries"); /* All done! */ @@ -2903,8 +2858,7 @@ int test_two_file_link(cl_device_id deviceID, cl_context context, return 0; } -int test_execute_after_two_file_link(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(execute_after_two_file_link) { int error; cl_program program, another_program; @@ -2921,8 +2875,8 @@ int test_execute_after_two_file_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); error = create_single_kernel_helper_create_program( @@ -2935,13 +2889,13 @@ int test_execute_after_two_file_link(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(another_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(another_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program two_programs[2] = { program, another_program }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, two_programs, NULL, NULL, &error); + context, 1, &device, "", 2, two_programs, NULL, NULL, &error); test_error(error, "Unable to create an executable from two binaries"); cl_kernel kernel = @@ -2977,10 +2931,7 @@ int test_execute_after_two_file_link(cl_device_id deviceID, cl_context context, return 0; } -int test_execute_after_embedded_header_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_embedded_header_link) { int error; cl_program program, header, simple_program; @@ -3007,7 +2958,7 @@ int test_execute_after_embedded_header_link(cl_device_id deviceID, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 1, &header, + error = clCompileProgram(program, 1, &device, NULL, 1, &header, &simple_header_name, NULL, NULL); test_error(error, "Unable to compile a simple program with embedded header"); @@ -3022,13 +2973,13 @@ int test_execute_after_embedded_header_link(cl_device_id deviceID, return -1; } - error = clCompileProgram(simple_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(simple_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program two_programs[2] = { program, simple_program }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, two_programs, NULL, NULL, &error); + context, 1, &device, "", 2, two_programs, NULL, NULL, &error); test_error(error, "Unable to create an executable from two binaries, one compiled " "with embedded header"); @@ -3078,10 +3029,7 @@ int test_execute_after_embedded_header_link(cl_device_id deviceID, #include #endif -int test_execute_after_included_header_link(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(execute_after_included_header_link) { int error; cl_program program, simple_program; @@ -3154,10 +3102,10 @@ int test_execute_after_included_header_link(cl_device_id deviceID, return -1; } #if (defined(__linux__) || defined(__APPLE__)) && (!defined(__ANDROID__)) - error = clCompileProgram(program, 1, &deviceID, "-I/tmp/foo/bar", 0, NULL, + error = clCompileProgram(program, 1, &device, "-I/tmp/foo/bar", 0, NULL, NULL, NULL, NULL); #else - error = clCompileProgram(program, 1, &deviceID, "-Ifoo/bar", 0, NULL, NULL, + error = clCompileProgram(program, 1, &device, "-Ifoo/bar", 0, NULL, NULL, NULL, NULL); #endif test_error(error, @@ -3206,13 +3154,13 @@ int test_execute_after_included_header_link(cl_device_id deviceID, return -1; } - error = clCompileProgram(simple_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(simple_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program two_programs[2] = { program, simple_program }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, two_programs, NULL, NULL, &error); + context, 1, &device, "", 2, two_programs, NULL, NULL, &error); test_error(error, "Unable to create an executable from two binaries, one compiled " "with embedded header"); @@ -3250,8 +3198,7 @@ int test_execute_after_included_header_link(cl_device_id deviceID, return 0; } -int test_program_binary_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(program_binary_type) { int error; cl_program program, another_program, program_with_binary, @@ -3272,11 +3219,11 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, - NULL); + error = + clCompileProgram(program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); - error = clGetProgramBuildInfo(program, deviceID, CL_PROGRAM_BINARY_TYPE, + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), &program_type, NULL); test_error(error, "Unable to get program binary type"); @@ -3335,12 +3282,12 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, // use clCreateProgramWithBinary program_with_binary = clCreateProgramWithBinary( - context, 1, &deviceID, &binarySize, (const unsigned char **)buffers, + context, 1, &device, &binarySize, (const unsigned char **)buffers, loadErrors, &error); test_error(error, "Unable to create program with binary"); error = clGetProgramBuildInfo( - program_with_binary, deviceID, CL_PROGRAM_BINARY_TYPE, + program_with_binary, device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), &program_type, NULL); test_error(error, "Unable to get program binary type"); if (program_type != CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT) @@ -3356,11 +3303,11 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, } cl_program my_newly_minted_library = - clLinkProgram(context, 1, &deviceID, "-create-library", 1, + clLinkProgram(context, 1, &device, "-create-library", 1, &program_with_binary, NULL, NULL, &error); test_error(error, "Unable to create a simple library"); error = clGetProgramBuildInfo( - my_newly_minted_library, deviceID, CL_PROGRAM_BINARY_TYPE, + my_newly_minted_library, device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), &program_type, NULL); test_error(error, "Unable to get program binary type"); if (program_type != CL_PROGRAM_BINARY_TYPE_LIBRARY) @@ -3417,11 +3364,11 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, // use clCreateProgramWithBinary cl_program library_with_binary = clCreateProgramWithBinary( - context, 1, &deviceID, &binarySize, (const unsigned char **)buffers, + context, 1, &device, &binarySize, (const unsigned char **)buffers, loadErrors, &error); test_error(error, "Unable to create program with binary"); error = clGetProgramBuildInfo( - library_with_binary, deviceID, CL_PROGRAM_BINARY_TYPE, + library_with_binary, device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), &program_type, NULL); test_error(error, "Unable to get program binary type"); if (program_type != CL_PROGRAM_BINARY_TYPE_LIBRARY) @@ -3444,19 +3391,19 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, return -1; } - error = clCompileProgram(another_program, 1, &deviceID, NULL, 0, NULL, NULL, + error = clCompileProgram(another_program, 1, &device, NULL, 0, NULL, NULL, NULL, NULL); test_error(error, "Unable to compile a simple program"); cl_program program_and_archive[2] = { another_program, library_with_binary }; cl_program fully_linked_program = clLinkProgram( - context, 1, &deviceID, "", 2, program_and_archive, NULL, NULL, &error); + context, 1, &device, "", 2, program_and_archive, NULL, NULL, &error); test_error(error, "Unable to create an executable from a binary and a library"); error = clGetProgramBuildInfo( - fully_linked_program, deviceID, CL_PROGRAM_BINARY_TYPE, + fully_linked_program, device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), &program_type, NULL); test_error(error, "Unable to get program binary type"); if (program_type != CL_PROGRAM_BINARY_TYPE_EXECUTABLE) @@ -3515,12 +3462,12 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, // use clCreateProgramWithBinary fully_linked_program_with_binary = clCreateProgramWithBinary( - context, 1, &deviceID, &binarySize, (const unsigned char **)buffers, + context, 1, &device, &binarySize, (const unsigned char **)buffers, loadErrors, &error); test_error(error, "Unable to create program with binary"); error = clGetProgramBuildInfo( - fully_linked_program_with_binary, deviceID, CL_PROGRAM_BINARY_TYPE, + fully_linked_program_with_binary, device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), &program_type, NULL); test_error(error, "Unable to get program binary type"); if (program_type != CL_PROGRAM_BINARY_TYPE_EXECUTABLE) @@ -3535,7 +3482,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, free(binary); } - error = clBuildProgram(fully_linked_program_with_binary, 1, &deviceID, NULL, + error = clBuildProgram(fully_linked_program_with_binary, 1, &device, NULL, NULL, NULL); test_error(error, "Unable to build a simple program"); @@ -3575,9 +3522,9 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, return -1; } - error = clBuildProgram(program, 1, &deviceID, NULL, NULL, NULL); + error = clBuildProgram(program, 1, &device, NULL, NULL, NULL); test_error(error, "Unable to build a simple program"); - error = clGetProgramBuildInfo(program, deviceID, CL_PROGRAM_BINARY_TYPE, + error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), &program_type, NULL); test_error(error, "Unable to get program binary type"); @@ -3666,10 +3613,9 @@ void CL_CALLBACK test_notify_link_complete(cl_program program, void *userData) log_info("\n <-- program successfully linked\n"); } -int test_large_compile_and_link_status_options_log(cl_context context, - cl_device_id deviceID, - cl_command_queue queue, - unsigned int numLines) +static int test_large_compile_and_link_status_options_log( + cl_context context, cl_device_id deviceID, cl_command_queue queue, + unsigned int numLines) { int error; cl_program program; @@ -3987,10 +3933,7 @@ int test_large_compile_and_link_status_options_log(cl_context context, return 0; } -int test_compile_and_link_status_options_log(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(compile_and_link_status_options_log) { unsigned int toTest[] = { 256, 0 }; // 512, 1024, 8192, 16384, 32768, 0 }; unsigned int i; @@ -4009,7 +3952,7 @@ int test_compile_and_link_status_options_log(cl_device_id deviceID, gettimeofday(&time1, NULL); #endif - if (test_large_compile_and_link_status_options_log(context, deviceID, + if (test_large_compile_and_link_status_options_log(context, device, queue, toTest[i]) != 0) { diff --git a/test_conformance/compiler/test_compiler_defines_for_extensions.cpp b/test_conformance/compiler/test_compiler_defines_for_extensions.cpp index 0b5dd449..c5c62e17 100644 --- a/test_conformance/compiler/test_compiler_defines_for_extensions.cpp +++ b/test_conformance/compiler/test_compiler_defines_for_extensions.cpp @@ -131,7 +131,7 @@ bool string_has_prefix(const char *str, const char *prefix) return strncmp(str, prefix, strlen(prefix)) == 0; } -int test_compiler_defines_for_extensions(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems ) +REGISTER_TEST(compiler_defines_for_extensions) { int error; diff --git a/test_conformance/compiler/test_feature_macro.cpp b/test_conformance/compiler/test_feature_macro.cpp index 2f973eec..93776a8b 100644 --- a/test_conformance/compiler/test_feature_macro.cpp +++ b/test_conformance/compiler/test_feature_macro.cpp @@ -205,10 +205,10 @@ int feature_macro_verify_results(std::string test_macro_name, return error; } -int test_feature_macro_atomic_order_acq_rel(cl_device_id deviceID, - cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_atomic_order_acq_rel(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -233,10 +233,10 @@ int test_feature_macro_atomic_order_acq_rel(cl_device_id deviceID, compiler_status, supported); } -int test_feature_macro_atomic_order_seq_cst(cl_device_id deviceID, - cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_atomic_order_seq_cst(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -262,10 +262,10 @@ int test_feature_macro_atomic_order_seq_cst(cl_device_id deviceID, compiler_status, supported); } -int test_feature_macro_atomic_scope_device(cl_device_id deviceID, - cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_atomic_scope_device(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -289,10 +289,9 @@ int test_feature_macro_atomic_scope_device(cl_device_id deviceID, compiler_status, supported); } -int test_feature_macro_atomic_scope_all_devices(cl_device_id deviceID, - cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_atomic_scope_all_devices( + cl_device_id deviceID, cl_context context, std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -316,10 +315,10 @@ int test_feature_macro_atomic_scope_all_devices(cl_device_id deviceID, compiler_status, supported); } -int test_feature_macro_3d_image_writes(cl_device_id deviceID, - cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_3d_image_writes(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -343,9 +342,10 @@ int test_feature_macro_3d_image_writes(cl_device_id deviceID, compiler_status, supported); } -int test_feature_macro_device_enqueue(cl_device_id deviceID, cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_device_enqueue(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -371,10 +371,10 @@ int test_feature_macro_device_enqueue(cl_device_id deviceID, cl_context context, compiler_status, supported); } -int test_feature_macro_generic_address_space(cl_device_id deviceID, - cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_generic_address_space(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -398,8 +398,9 @@ int test_feature_macro_generic_address_space(cl_device_id deviceID, compiler_status, supported); } -int test_feature_macro_pipes(cl_device_id deviceID, cl_context context, - std::string test_macro_name, cl_bool& supported) +static int test_feature_macro_pipes(cl_device_id deviceID, cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -423,7 +424,7 @@ int test_feature_macro_pipes(cl_device_id deviceID, cl_context context, compiler_status, supported); } -int test_feature_macro_program_scope_global_variables( +static int test_feature_macro_program_scope_global_variables( cl_device_id deviceID, cl_context context, std::string test_macro_name, cl_bool& supported) { @@ -449,10 +450,10 @@ int test_feature_macro_program_scope_global_variables( compiler_status, supported); } -int test_feature_macro_read_write_images(cl_device_id deviceID, - cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_read_write_images(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -476,9 +477,10 @@ int test_feature_macro_read_write_images(cl_device_id deviceID, compiler_status, supported); } -int test_feature_macro_subgroups(cl_device_id deviceID, cl_context context, - std::string test_macro_name, - cl_bool& supported) +static int test_feature_macro_subgroups(cl_device_id deviceID, + cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -502,7 +504,7 @@ int test_feature_macro_subgroups(cl_device_id deviceID, cl_context context, compiler_status, supported); } -int test_feature_macro_work_group_collective_functions( +static int test_feature_macro_work_group_collective_functions( cl_device_id deviceID, cl_context context, std::string test_macro_name, cl_bool& supported) { @@ -529,8 +531,9 @@ int test_feature_macro_work_group_collective_functions( compiler_status, supported); } -int test_feature_macro_images(cl_device_id deviceID, cl_context context, - std::string test_macro_name, cl_bool& supported) +static int test_feature_macro_images(cl_device_id deviceID, cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -554,8 +557,9 @@ int test_feature_macro_images(cl_device_id deviceID, cl_context context, compiler_status, supported); } -int test_feature_macro_fp64(cl_device_id deviceID, cl_context context, - std::string test_macro_name, cl_bool& supported) +static int test_feature_macro_fp64(cl_device_id deviceID, cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -580,7 +584,7 @@ int test_feature_macro_fp64(cl_device_id deviceID, cl_context context, compiler_status, supported); } -int test_feature_macro_integer_dot_product_input_4x8bit_packed( +static int test_feature_macro_integer_dot_product_input_4x8bit_packed( cl_device_id deviceID, cl_context context, std::string test_macro_name, cl_bool& supported) { @@ -616,7 +620,7 @@ int test_feature_macro_integer_dot_product_input_4x8bit_packed( compiler_status, supported); } -int test_feature_macro_integer_dot_product_input_4x8bit( +static int test_feature_macro_integer_dot_product_input_4x8bit( cl_device_id deviceID, cl_context context, std::string test_macro_name, cl_bool& supported) { @@ -652,8 +656,9 @@ int test_feature_macro_integer_dot_product_input_4x8bit( compiler_status, supported); } -int test_feature_macro_int64(cl_device_id deviceID, cl_context context, - std::string test_macro_name, cl_bool& supported) +static int test_feature_macro_int64(cl_device_id deviceID, cl_context context, + std::string test_macro_name, + cl_bool& supported) { cl_int error = TEST_FAIL; cl_bool api_status; @@ -722,8 +727,8 @@ int test_feature_macro_int64(cl_device_id deviceID, cl_context context, compiler_status, supported); } -int test_consistency_c_features_list(cl_device_id deviceID, - std::vector vec_to_cmp) +static int test_consistency_c_features_list(cl_device_id deviceID, + std::vector vec_to_cmp) { log_info("\nComparison list of features: CL_DEVICE_OPENCL_C_FEATURES vs " "API/compiler queries.\n"); @@ -792,13 +797,12 @@ int test_consistency_c_features_list(cl_device_id deviceID, #define NEW_FEATURE_MACRO_TEST(feat) \ test_macro_name = "__opencl_c_" #feat; \ - error |= test_feature_macro_##feat(deviceID, context, test_macro_name, \ + error |= test_feature_macro_##feat(device, context, test_macro_name, \ supported); \ if (supported) supported_features_vec.push_back(test_macro_name); -int test_features_macro(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(features_macro, Version(3, 0)) { // Note: Not checking that the feature array is empty for the compiler not @@ -806,7 +810,7 @@ int test_features_macro(cl_device_id deviceID, cl_context context, // support compilation from OpenCL C source, this query may return an empty // array." It "may" return an empty array implies that an implementation // also "may not". - check_compiler_available(deviceID); + check_compiler_available(device); int error = TEST_PASS; cl_bool supported = CL_FALSE; @@ -830,17 +834,16 @@ int test_features_macro(cl_device_id deviceID, cl_context context, NEW_FEATURE_MACRO_TEST(integer_dot_product_input_4x8bit); NEW_FEATURE_MACRO_TEST(integer_dot_product_input_4x8bit_packed); - error |= test_consistency_c_features_list(deviceID, supported_features_vec); + error |= test_consistency_c_features_list(device, supported_features_vec); return error; } // This test checks that a supported feature comes with other required features -int test_features_macro_coupling(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(features_macro_coupling) { OpenCLCFeatures features; - int error = get_device_cl_c_features(deviceID, features); + int error = get_device_cl_c_features(device, features); if (error) { log_error("Couldn't query OpenCL C features for the device!\n"); diff --git a/test_conformance/compiler/test_image_macro.cpp b/test_conformance/compiler/test_image_macro.cpp index 8a5c6707..6e9b0404 100644 --- a/test_conformance/compiler/test_image_macro.cpp +++ b/test_conformance/compiler/test_image_macro.cpp @@ -36,21 +36,22 @@ const char * image_not_supported_source = "kernel void not_enabled(global int * "\r\n } \r\n"; -int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(image_macro) { cl_bool image_support; char buf[256]; int status; cl_program program; - status = clGetDeviceInfo( deviceID, CL_DEVICE_NAME, sizeof( buf ), buf, NULL ); + status = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(buf), buf, NULL); if( status ) { log_error( "getting device info (name): %d\n", status ); exit(-1); } - status = clGetDeviceInfo( deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof( image_support ), &image_support, NULL ); + status = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, + sizeof(image_support), &image_support, NULL); if( status ) { log_error( "getting device info (image support): %d\n", status ); @@ -67,7 +68,7 @@ int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue return status; } - status = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + status = clBuildProgram(program, 1, &device, NULL, NULL, NULL); if( status ) log_error("CL_DEVICE_IMAGE_SUPPORT is set, __IMAGE_SUPPORT__ macro not set \n"); else @@ -82,7 +83,7 @@ int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue return status; } - status = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); + status = clBuildProgram(program, 1, &device, NULL, NULL, NULL); if( status ) log_error("CL_DEVICE_IMAGE_SUPPORT not set, __IMAGE_SUPPORT__ macro is set \n"); else @@ -98,4 +99,3 @@ int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue return status; } - diff --git a/test_conformance/compiler/test_opencl_c_versions.cpp b/test_conformance/compiler/test_opencl_c_versions.cpp index d750366e..5b24160f 100644 --- a/test_conformance/compiler/test_opencl_c_versions.cpp +++ b/test_conformance/compiler/test_opencl_c_versions.cpp @@ -286,8 +286,7 @@ static int test_CL_DEVICE_OPENCL_C_VERSION_versions(cl_device_id device, return TEST_PASS; } -int test_opencl_c_versions(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(opencl_c_versions) { check_compiler_available(device); diff --git a/test_conformance/compiler/test_pragma_unroll.cpp b/test_conformance/compiler/test_pragma_unroll.cpp index 682faa7f..8e90c22c 100644 --- a/test_conformance/compiler/test_pragma_unroll.cpp +++ b/test_conformance/compiler/test_pragma_unroll.cpp @@ -248,49 +248,60 @@ const char *pragma_unroll_kernels[] = { "}\n", }; -int test_pragma_unroll(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { - const size_t ELEMENT_NUM = 100; - const size_t KERNEL_NUM = 24; +REGISTER_TEST_VERSION(pragma_unroll, Version(2, 0)) +{ + const size_t ELEMENT_NUM = 100; + const size_t KERNEL_NUM = 24; - cl_int error; + cl_int error; - //execute all kernels and check if the results are as expected - for (size_t kernelIdx = 0; kernelIdx < KERNEL_NUM; ++kernelIdx) { - clProgramWrapper program; - clKernelWrapper kernel; - if (create_single_kernel_helper( - context, &program, &kernel, 1, - (const char **)&pragma_unroll_kernels[kernelIdx], "pragma_unroll")) + // execute all kernels and check if the results are as expected + for (size_t kernelIdx = 0; kernelIdx < KERNEL_NUM; ++kernelIdx) { - log_error("The program we attempted to compile was: \n%s\n", - pragma_unroll_kernels[kernelIdx]); - return -1; + clProgramWrapper program; + clKernelWrapper kernel; + if (create_single_kernel_helper( + context, &program, &kernel, 1, + (const char **)&pragma_unroll_kernels[kernelIdx], + "pragma_unroll")) + { + log_error("The program we attempted to compile was: \n%s\n", + pragma_unroll_kernels[kernelIdx]); + return -1; + } + + clMemWrapper buffer = + clCreateBuffer(context, CL_MEM_READ_WRITE, + ELEMENT_NUM * sizeof(cl_uint), NULL, &error); + test_error(error, "clCreateBuffer failed"); + + error = clSetKernelArg(kernel, 0, sizeof(buffer), &buffer); + test_error(error, "clSetKernelArg failed"); + + // only one thread should be enough to verify if kernel is fully + // functional + size_t workSize = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &workSize, NULL, + 0, NULL, NULL); + test_error(error, "clEnqueueNDRangeKernel failed"); + + std::vector results(ELEMENT_NUM, 0); + error = clEnqueueReadBuffer(queue, buffer, CL_TRUE, 0, + ELEMENT_NUM * sizeof(cl_uint), &results[0], + 0, NULL, NULL); + test_error(error, "clEnqueueReadBuffer failed"); + + for (size_t i = 0; i < ELEMENT_NUM; ++i) + { + if (results[i] != i) + { + log_error("Kernel %zu returned invalid result. Test: %d, " + "expected: %zu\n", + kernelIdx + 1, results[i], i); + return -1; + } + } } - clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, ELEMENT_NUM * sizeof(cl_uint), NULL, &error); - test_error(error, "clCreateBuffer failed"); - - error = clSetKernelArg(kernel, 0, sizeof(buffer), &buffer); - test_error(error, "clSetKernelArg failed"); - - //only one thread should be enough to verify if kernel is fully functional - size_t workSize = 1; - error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &workSize, NULL, 0, NULL, NULL); - test_error(error, "clEnqueueNDRangeKernel failed"); - - std::vector results(ELEMENT_NUM, 0); - error = clEnqueueReadBuffer(queue, buffer, CL_TRUE, 0, ELEMENT_NUM * sizeof(cl_uint), &results[0], 0, NULL, NULL); - test_error(error, "clEnqueueReadBuffer failed"); - - for (size_t i = 0; i < ELEMENT_NUM; ++i) { - if (results[i] != i) { - log_error( - "Kernel %zu returned invalid result. Test: %d, expected: %zu\n", - kernelIdx + 1, results[i], i); - return -1; - } - } - } - - return 0; + return 0; } diff --git a/test_conformance/compiler/test_preprocessor.cpp b/test_conformance/compiler/test_preprocessor.cpp index 3c5c2045..12891b2b 100644 --- a/test_conformance/compiler/test_preprocessor.cpp +++ b/test_conformance/compiler/test_preprocessor.cpp @@ -37,85 +37,100 @@ const char *define_kernel_code[] = { "}\n"}; +REGISTER_TEST(preprocessor_define_udef) +{ + cl_int error; + clKernelWrapper kernel; + clProgramWrapper program; + clMemWrapper buffer[3]; + cl_int *srcData, *resultData; + int i; + MTdata d; + + error = create_single_kernel_helper(context, &program, &kernel, 1, + define_kernel_code, "define_test"); + if (error) return -1; + + buffer[0] = clCreateBuffer(context, CL_MEM_READ_WRITE, + num_elements * sizeof(cl_int), NULL, &error); + test_error(error, "clCreateBuffer failed"); + buffer[1] = clCreateBuffer(context, CL_MEM_READ_WRITE, + num_elements * sizeof(cl_int), NULL, &error); + test_error(error, "clCreateBuffer failed"); + buffer[2] = clCreateBuffer(context, CL_MEM_READ_WRITE, + num_elements * sizeof(cl_int), NULL, &error); + test_error(error, "clCreateBuffer failed"); + + srcData = (cl_int *)malloc(sizeof(cl_int) * num_elements); + if (srcData == NULL) + { + log_error("Failed to allocate storage for source data (%d cl_ints).\n", + num_elements); + return -1; + } + + d = init_genrand(gRandomSeed); + for (i = 0; i < num_elements; i++) + srcData[i] = (int)get_random_float(-1024, 1024, d); + free_mtdata(d); + d = NULL; + + resultData = (cl_int *)malloc(sizeof(cl_int) * num_elements); + if (resultData == NULL) + { + free(srcData); + log_error("Failed to allocate storage for result data (%d cl_ints).\n", + num_elements); + return -1; + } + + error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]); + test_error(error, "clSetKernelArg failed"); + error = clSetKernelArg(kernel, 1, sizeof(buffer[1]), &buffer[1]); + test_error(error, "clSetKernelArg failed"); + error = clSetKernelArg(kernel, 2, sizeof(buffer[2]), &buffer[2]); + test_error(error, "clSetKernelArg failed"); -int test_preprocessor_define_udef(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { + error = clEnqueueWriteBuffer(queue, buffer[0], CL_TRUE, 0, + num_elements * sizeof(cl_int), srcData, 0, + NULL, NULL); + test_error(error, "clEnqueueWriteBuffer failed"); - cl_int error; - clKernelWrapper kernel; - clProgramWrapper program; - clMemWrapper buffer[3]; - cl_int *srcData, *resultData; - int i; - MTdata d; + size_t threads[3] = { (size_t)num_elements, 0, 0 }; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, + NULL, NULL); + test_error(error, "clEnqueueNDRangeKernel failed"); - error = create_single_kernel_helper(context, &program, &kernel, 1, define_kernel_code, "define_test"); - if (error) - return -1; + error = clEnqueueReadBuffer(queue, buffer[1], CL_TRUE, 0, + num_elements * sizeof(cl_int), resultData, 0, + NULL, NULL); + test_error(error, "clEnqueueReadBuffer failed"); - buffer[0] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); - test_error( error, "clCreateBuffer failed"); - buffer[1] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); - test_error( error, "clCreateBuffer failed"); - buffer[2] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); - test_error( error, "clCreateBuffer failed"); + for (i = 0; i < num_elements; i++) + if (resultData[i] != srcData[i] * 2) + { + free(srcData); + free(resultData); + return -1; + } - srcData = (cl_int*)malloc(sizeof(cl_int)*num_elements); - if (srcData == NULL) { - log_error("Failed to allocate storage for source data (%d cl_ints).\n", num_elements); - return -1; - } + error = clEnqueueReadBuffer(queue, buffer[2], CL_TRUE, 0, + num_elements * sizeof(cl_int), resultData, 0, + NULL, NULL); + test_error(error, "clEnqueueReadBuffer failed"); - d = init_genrand( gRandomSeed ); - for (i=0; i