Migrate compiler suite to the new test registration framework (#2319)

Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
This commit is contained in:
Ahmed Hesham
2025-03-18 17:10:21 +00:00
committed by GitHub
parent d4c292ed46
commit 2131aff0e9
14 changed files with 664 additions and 1002 deletions

View File

@@ -13,103 +13,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
#include "harness/compat.h"
#include "harness/testHarness.h" #include "harness/testHarness.h"
#include "procs.h"
#include <stdio.h>
#include <string.h>
#if !defined(_WIN32)
#include <unistd.h>
#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[]) int main(int argc, const char *argv[])
{ {
return runTestHarness(argc, argv, test_num, test_list, false, 0); return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0);
} }

View File

@@ -1,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);

View File

@@ -16,14 +16,34 @@
#ifndef _testBase_h #ifndef _testBase_h
#define _testBase_h #define _testBase_h
#include "harness/compat.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <vector>
#include <CL/cl.h>
#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 // scope guard helper to ensure proper releasing of sub devices
struct SubDevicesScopeGuarded struct SubDevicesScopeGuarded

View File

@@ -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, REGISTER_TEST(async_build)
cl_command_queue queue, int num_elements)
{ {
cl_int error; 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"); test_error(error, "Unable to create program from source");
// Start an asynchronous build, registering the completion callback // Start an asynchronous build, registering the completion callback
TestData testData = { deviceID, testDef.expectedStatus }; TestData testData = { device, testDef.expectedStatus };
callbackResult = 0; callbackResult = 0;
error = clBuildProgram(program, 1, &deviceID, NULL, error = clBuildProgram(program, 1, &device, NULL,
test_notify_build_complete, (void *)&testData); test_notify_build_complete, (void *)&testData);
// Allow implementations to return synchronous build failures. // Allow implementations to return synchronous build failures.
// They still need to call the callback. // They still need to call the callback.

View File

@@ -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; int error;
clProgramWrapper program; clProgramWrapper program;
@@ -132,7 +132,7 @@ int test_load_program_source(cl_device_id deviceID, cl_context context, cl_comma
return 0; 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; int error;
clProgramWrapper program; clProgramWrapper program;
@@ -159,7 +159,7 @@ int test_load_multistring_source(cl_device_id deviceID, cl_context context, cl_c
} }
/* Try compiling */ /* 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" ); test_error( error, "Unable to build multi-line program source" );
/* Should probably check binary here to verify the same results... */ /* 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; 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; int error;
cl_program program; cl_program program;
@@ -195,7 +195,7 @@ int test_load_two_kernel_source(cl_device_id deviceID, cl_context context, cl_co
} }
/* Try compiling */ /* 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" ); test_error( error, "Unable to build two-kernel program source" );
/* Should probably check binary here to verify the same results... */ /* 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; 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; int error;
cl_program program; cl_program program;
@@ -222,7 +222,7 @@ int test_load_null_terminated_source(cl_device_id deviceID, cl_context context,
} }
/* Try compiling */ /* 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" ); test_error( error, "Unable to build null-terminated program source" );
/* Should probably check binary here to verify the same results... */ /* 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; 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; int error;
cl_program program; cl_program program;
@@ -252,7 +252,7 @@ int test_load_null_terminated_multi_line_source(cl_device_id deviceID, cl_contex
} }
/* Try compiling */ /* 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" ); test_error( error, "Unable to build null-terminated program source" );
/* Should probably check binary here to verify the same results... */ /* 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; 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; int error;
cl_program program; cl_program program;
@@ -295,7 +295,7 @@ int test_load_discreet_length_source(cl_device_id deviceID, cl_context context,
} }
/* Try compiling */ /* 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" ); test_error( error, "Unable to build null-terminated program source" );
/* Should probably check binary here to verify the same results... */ /* 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; 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; int error;
cl_program program; cl_program program;
@@ -337,7 +337,7 @@ int test_load_null_terminated_partial_multi_line_source(cl_device_id deviceID, c
} }
/* Try compiling */ /* 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" ); test_error( error, "Unable to build null-terminated program source" );
/* Should probably check binary here to verify the same results... */ /* 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; 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; int error;
cl_program program; 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" ); test_error( error, "Unable to get device of program" );
/* Object comparability test. */ /* Object comparability test. */
test_assert_error(device1 == deviceID, test_assert_error(device1 == device,
"Unexpected result returned by CL_PROGRAM_DEVICES query"); "Unexpected result returned by CL_PROGRAM_DEVICES query");
cl_uint devCount; cl_uint devCount;
@@ -439,9 +439,7 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_
return 0; return 0;
} }
int test_get_program_info_kernel_names(cl_device_id deviceID, REGISTER_TEST(get_program_info_kernel_names)
cl_context context,
cl_command_queue queue, int num_elements)
{ {
int error = CL_SUCCESS; int error = CL_SUCCESS;
size_t total_kernels = 0; 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 // returned. Query CL_PROGRAM_KERNEL_NAMES and check that the right
// kernel names are returned. // kernel names are returned.
{ {
error = error = clBuildProgram(program, 1, &device, nullptr, nullptr, nullptr);
clBuildProgram(program, 1, &deviceID, nullptr, nullptr, nullptr);
test_error(error, "clBuildProgram failed"); test_error(error, "clBuildProgram failed");
error = clGetProgramInfo(program, CL_PROGRAM_NUM_KERNELS, 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. // kernel names are returned.
{ {
const char *build_options = "-DUSE_SAMPLE_TEST_B"; 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); nullptr);
test_error(error, "clBuildProgram failed"); test_error(error, "clBuildProgram failed");
@@ -553,14 +550,12 @@ int test_get_program_info_kernel_names(cl_device_id deviceID,
return CL_SUCCESS; return CL_SUCCESS;
} }
int test_get_program_info_mult_devices(cl_device_id deviceID, REGISTER_TEST(get_program_info_mult_devices)
cl_context context,
cl_command_queue queue, int num_elements)
{ {
size_t size = 0; size_t size = 0;
// query multi-device context and perform objects comparability test // 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); nullptr, &size);
test_error_fail(err, "clGetDeviceInfo failed"); test_error_fail(err, "clGetDeviceInfo failed");
@@ -572,7 +567,7 @@ int test_get_program_info_mult_devices(cl_device_id deviceID,
std::vector<cl_device_partition_property> supported_props( std::vector<cl_device_partition_property> supported_props(
size / sizeof(cl_device_partition_property), 0); size / sizeof(cl_device_partition_property), 0);
err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_PROPERTIES, err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_PROPERTIES,
supported_props.size() supported_props.size()
* sizeof(cl_device_partition_property), * sizeof(cl_device_partition_property),
supported_props.data(), &size); supported_props.data(), &size);
@@ -585,7 +580,7 @@ int test_get_program_info_mult_devices(cl_device_id deviceID,
} }
cl_uint maxComputeUnits = 0; cl_uint maxComputeUnits = 0;
err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(maxComputeUnits), &maxComputeUnits, nullptr); sizeof(maxComputeUnits), &maxComputeUnits, nullptr);
test_error_ret(err, "Unable to get maximal number of compute units", test_error_ret(err, "Unable to get maximal number of compute units",
TEST_FAIL); TEST_FAIL);
@@ -607,14 +602,14 @@ int test_get_program_info_mult_devices(cl_device_id deviceID,
if (sup_prop == prop[0]) if (sup_prop == prop[0])
{ {
// how many sub-devices can we create? // how many sub-devices can we create?
err = clCreateSubDevices(deviceID, prop.data(), 0, nullptr, err = clCreateSubDevices(device, prop.data(), 0, nullptr,
&num_devices); &num_devices);
test_error_fail(err, "clCreateSubDevices failed"); test_error_fail(err, "clCreateSubDevices failed");
if (num_devices < 2) continue; if (num_devices < 2) continue;
// get the list of subDevices // get the list of subDevices
scope_guard.reset(new SubDevicesScopeGuarded(num_devices)); 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(), scope_guard->sub_devices.data(),
&num_devices); &num_devices);
test_error_fail(err, "clCreateSubDevices failed"); test_error_fail(err, "clCreateSubDevices failed");
@@ -681,7 +676,7 @@ int test_get_program_info_mult_devices(cl_device_id deviceID,
return TEST_PASS; 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; cl_program program;
int error; int error;
@@ -736,7 +731,7 @@ int test_get_program_source(cl_device_id deviceID, cl_context context, cl_comman
return 0; 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; cl_program program;
int error; 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 */ /* 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" ); test_error( error, "Unable to get program build status length" );
if( length != sizeof( status ) ) 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 */ /* 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" ); 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" ); test_error( error, "Unable to get program build status" );
if( status != CL_BUILD_SUCCESS ) 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 *****/ /***** Build log *****/
/* Try getting the length */ /* 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" ); test_error( error, "Unable to get program build log length" );
log_info("Build log is %zu long.\n", 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); buffer = (char*)malloc(length);
/* Try normal source */ /* 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" ); test_error( error, "Unable to get program build log" );
if( buffer[length-1] != '\0' ) 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 */ /* 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" ); test_error( error, "Unable to get program build log" );
free(buffer); free(buffer);
/***** Build options *****/ /***** 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" ); test_error( error, "Unable to get program build options length" );
buffer = (char*)malloc(length); buffer = (char*)malloc(length);
/* Try normal source */ /* 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" ); test_error( error, "Unable to get program build options" );
/* Try both at once */ /* 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" ); test_error( error, "Unable to get program build options" );
free(buffer); free(buffer);
@@ -826,19 +829,21 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co
return -1; 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 ) if( error != CL_SUCCESS )
{ {
print_error( error, "Building with valid options failed!" ); print_error( error, "Building with valid options failed!" );
return -1; 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" ); test_error( error, "Unable to get program build options" );
buffer = (char*)malloc(length); 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" ); test_error( error, "Unable to get program build options" );
if( strcmp( (char *)buffer, "-cl-opt-disable" ) != 0 ) if( strcmp( (char *)buffer, "-cl-opt-disable" ) != 0 )
{ {

View File

@@ -88,7 +88,7 @@ cl_int get_result_from_program( cl_context context, cl_command_queue queue, cl_p
return CL_SUCCESS; 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; int error;
cl_build_status status; 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 */ /* Build with the macro defined */
log_info("Testing optimization option '%s'\n", optimization_options[i]); 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" ); 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" ); test_error( error, "Unable to get program build status" );
if( (int)status != CL_BUILD_SUCCESS ) if( (int)status != CL_BUILD_SUCCESS )
@@ -121,7 +123,7 @@ int test_options_build_optimizations(cl_device_id deviceID, cl_context context,
return 0; 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; int error;
clProgramWrapper program; 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 */ /* 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" ); 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" ); test_error( error, "Unable to get program build status" );
if( (int)status != CL_BUILD_SUCCESS ) 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 // 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" ); test_error( error, "Test program did not properly rebuild" );
error = get_result_from_program( context, queue, program, &secondResult ); 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; 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; int error;
clProgramWrapper program; clProgramWrapper program;
@@ -195,7 +198,7 @@ int test_options_build_macro_existence(cl_device_id deviceID, cl_context context
} }
/* Build without the macro defined */ /* 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" ); test_error( error, "Test program did not properly build" );
// Go ahead and run the program to verify results // 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 // 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" ); test_error( error, "Test program did not properly build" );
error = get_result_from_program( context, queue, program, &secondResult ); 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; 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; 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"; include_dir = "-I " + path + sep + "includeTestDirectory";
// log_info("%s\n", include_dir); // 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" ); 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" ); test_error( error, "Unable to get program build status" );
if( (int)status != CL_BUILD_SUCCESS ) 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 // Rebuild with a different include directory
include_dir = "-I " + path + sep + "secondIncludeTestDirectory"; 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" ); test_error( error, "Test program did not properly rebuild" );
error = get_result_from_program( context, queue, program, &secondResult ); 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; 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; 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 // If denorms aren't even supported, testing this flag is pointless
cl_device_fp_config floatCaps = 0; 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" ); test_error( error, "Unable to get device FP config" );
if( ( floatCaps & CL_FP_DENORM ) == 0 ) 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" ); test_error( error, "Unable to create test program" );
// Build first WITH the denorm flush flag // 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" ); 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" ); test_error( error, "Unable to get program build status" );
if( (int)status != CL_BUILD_SUCCESS ) 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 // valid, there isn't anything we can to do validate results for now
// Rebuild without flushing flag set // 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" ); test_error( error, "Test program did not properly rebuild" );
error = get_float_result_from_program( context, queue, program, *input, *input, &secondResult ); 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; return 0;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -131,7 +131,7 @@ bool string_has_prefix(const char *str, const char *prefix)
return strncmp(str, prefix, strlen(prefix)) == 0; 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; int error;

View File

@@ -205,10 +205,10 @@ int feature_macro_verify_results(std::string test_macro_name,
return error; return error;
} }
int test_feature_macro_atomic_order_acq_rel(cl_device_id deviceID, static int test_feature_macro_atomic_order_acq_rel(cl_device_id deviceID,
cl_context context, cl_context context,
std::string test_macro_name, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -233,10 +233,10 @@ int test_feature_macro_atomic_order_acq_rel(cl_device_id deviceID,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_atomic_order_seq_cst(cl_device_id deviceID, static int test_feature_macro_atomic_order_seq_cst(cl_device_id deviceID,
cl_context context, cl_context context,
std::string test_macro_name, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -262,10 +262,10 @@ int test_feature_macro_atomic_order_seq_cst(cl_device_id deviceID,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_atomic_scope_device(cl_device_id deviceID, static int test_feature_macro_atomic_scope_device(cl_device_id deviceID,
cl_context context, cl_context context,
std::string test_macro_name, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -289,10 +289,9 @@ int test_feature_macro_atomic_scope_device(cl_device_id deviceID,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_atomic_scope_all_devices(cl_device_id deviceID, static int test_feature_macro_atomic_scope_all_devices(
cl_context context, cl_device_id deviceID, cl_context context, std::string test_macro_name,
std::string test_macro_name, cl_bool& supported)
cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -316,10 +315,10 @@ int test_feature_macro_atomic_scope_all_devices(cl_device_id deviceID,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_3d_image_writes(cl_device_id deviceID, static int test_feature_macro_3d_image_writes(cl_device_id deviceID,
cl_context context, cl_context context,
std::string test_macro_name, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -343,9 +342,10 @@ int test_feature_macro_3d_image_writes(cl_device_id deviceID,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_device_enqueue(cl_device_id deviceID, cl_context context, static int test_feature_macro_device_enqueue(cl_device_id deviceID,
std::string test_macro_name, cl_context context,
cl_bool& supported) std::string test_macro_name,
cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -371,10 +371,10 @@ int test_feature_macro_device_enqueue(cl_device_id deviceID, cl_context context,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_generic_address_space(cl_device_id deviceID, static int test_feature_macro_generic_address_space(cl_device_id deviceID,
cl_context context, cl_context context,
std::string test_macro_name, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -398,8 +398,9 @@ int test_feature_macro_generic_address_space(cl_device_id deviceID,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_pipes(cl_device_id deviceID, cl_context context, static int test_feature_macro_pipes(cl_device_id deviceID, cl_context context,
std::string test_macro_name, cl_bool& supported) std::string test_macro_name,
cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -423,7 +424,7 @@ int test_feature_macro_pipes(cl_device_id deviceID, cl_context context,
compiler_status, supported); 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_device_id deviceID, cl_context context, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
@@ -449,10 +450,10 @@ int test_feature_macro_program_scope_global_variables(
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_read_write_images(cl_device_id deviceID, static int test_feature_macro_read_write_images(cl_device_id deviceID,
cl_context context, cl_context context,
std::string test_macro_name, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -476,9 +477,10 @@ int test_feature_macro_read_write_images(cl_device_id deviceID,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_subgroups(cl_device_id deviceID, cl_context context, static int test_feature_macro_subgroups(cl_device_id deviceID,
std::string test_macro_name, cl_context context,
cl_bool& supported) std::string test_macro_name,
cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -502,7 +504,7 @@ int test_feature_macro_subgroups(cl_device_id deviceID, cl_context context,
compiler_status, supported); 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_device_id deviceID, cl_context context, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
@@ -529,8 +531,9 @@ int test_feature_macro_work_group_collective_functions(
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_images(cl_device_id deviceID, cl_context context, static int test_feature_macro_images(cl_device_id deviceID, cl_context context,
std::string test_macro_name, cl_bool& supported) std::string test_macro_name,
cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -554,8 +557,9 @@ int test_feature_macro_images(cl_device_id deviceID, cl_context context,
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_fp64(cl_device_id deviceID, cl_context context, static int test_feature_macro_fp64(cl_device_id deviceID, cl_context context,
std::string test_macro_name, cl_bool& supported) std::string test_macro_name,
cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -580,7 +584,7 @@ int test_feature_macro_fp64(cl_device_id deviceID, cl_context context,
compiler_status, supported); 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_device_id deviceID, cl_context context, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
@@ -616,7 +620,7 @@ int test_feature_macro_integer_dot_product_input_4x8bit_packed(
compiler_status, supported); 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_device_id deviceID, cl_context context, std::string test_macro_name,
cl_bool& supported) cl_bool& supported)
{ {
@@ -652,8 +656,9 @@ int test_feature_macro_integer_dot_product_input_4x8bit(
compiler_status, supported); compiler_status, supported);
} }
int test_feature_macro_int64(cl_device_id deviceID, cl_context context, static int test_feature_macro_int64(cl_device_id deviceID, cl_context context,
std::string test_macro_name, cl_bool& supported) std::string test_macro_name,
cl_bool& supported)
{ {
cl_int error = TEST_FAIL; cl_int error = TEST_FAIL;
cl_bool api_status; cl_bool api_status;
@@ -722,8 +727,8 @@ int test_feature_macro_int64(cl_device_id deviceID, cl_context context,
compiler_status, supported); compiler_status, supported);
} }
int test_consistency_c_features_list(cl_device_id deviceID, static int test_consistency_c_features_list(cl_device_id deviceID,
std::vector<std::string> vec_to_cmp) std::vector<std::string> vec_to_cmp)
{ {
log_info("\nComparison list of features: CL_DEVICE_OPENCL_C_FEATURES vs " log_info("\nComparison list of features: CL_DEVICE_OPENCL_C_FEATURES vs "
"API/compiler queries.\n"); "API/compiler queries.\n");
@@ -792,13 +797,12 @@ int test_consistency_c_features_list(cl_device_id deviceID,
#define NEW_FEATURE_MACRO_TEST(feat) \ #define NEW_FEATURE_MACRO_TEST(feat) \
test_macro_name = "__opencl_c_" #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); \ supported); \
if (supported) supported_features_vec.push_back(test_macro_name); if (supported) supported_features_vec.push_back(test_macro_name);
int test_features_macro(cl_device_id deviceID, cl_context context, REGISTER_TEST_VERSION(features_macro, Version(3, 0))
cl_command_queue queue, int num_elements)
{ {
// Note: Not checking that the feature array is empty for the compiler not // 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 // support compilation from OpenCL C source, this query may return an empty
// array." It "may" return an empty array implies that an implementation // array." It "may" return an empty array implies that an implementation
// also "may not". // also "may not".
check_compiler_available(deviceID); check_compiler_available(device);
int error = TEST_PASS; int error = TEST_PASS;
cl_bool supported = CL_FALSE; 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);
NEW_FEATURE_MACRO_TEST(integer_dot_product_input_4x8bit_packed); 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; return error;
} }
// This test checks that a supported feature comes with other required features // This test checks that a supported feature comes with other required features
int test_features_macro_coupling(cl_device_id deviceID, cl_context context, REGISTER_TEST(features_macro_coupling)
cl_command_queue queue, int num_elements)
{ {
OpenCLCFeatures features; OpenCLCFeatures features;
int error = get_device_cl_c_features(deviceID, features); int error = get_device_cl_c_features(device, features);
if (error) if (error)
{ {
log_error("Couldn't query OpenCL C features for the device!\n"); log_error("Couldn't query OpenCL C features for the device!\n");

View File

@@ -36,21 +36,22 @@ const char * image_not_supported_source = "kernel void not_enabled(global int *
"\r\n } \r\n"; "\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; cl_bool image_support;
char buf[256]; char buf[256];
int status; int status;
cl_program program; 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 ) if( status )
{ {
log_error( "getting device info (name): %d\n", status ); log_error( "getting device info (name): %d\n", status );
exit(-1); 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 ) if( status )
{ {
log_error( "getting device info (image support): %d\n", 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; return status;
} }
status = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); status = clBuildProgram(program, 1, &device, NULL, NULL, NULL);
if( status ) if( status )
log_error("CL_DEVICE_IMAGE_SUPPORT is set, __IMAGE_SUPPORT__ macro not set \n"); log_error("CL_DEVICE_IMAGE_SUPPORT is set, __IMAGE_SUPPORT__ macro not set \n");
else else
@@ -82,7 +83,7 @@ int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue
return status; return status;
} }
status = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL ); status = clBuildProgram(program, 1, &device, NULL, NULL, NULL);
if( status ) if( status )
log_error("CL_DEVICE_IMAGE_SUPPORT not set, __IMAGE_SUPPORT__ macro is set \n"); log_error("CL_DEVICE_IMAGE_SUPPORT not set, __IMAGE_SUPPORT__ macro is set \n");
else else
@@ -98,4 +99,3 @@ int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue
return status; return status;
} }

View File

@@ -286,8 +286,7 @@ static int test_CL_DEVICE_OPENCL_C_VERSION_versions(cl_device_id device,
return TEST_PASS; return TEST_PASS;
} }
int test_opencl_c_versions(cl_device_id device, cl_context context, REGISTER_TEST(opencl_c_versions)
cl_command_queue queue, int num_elements)
{ {
check_compiler_available(device); check_compiler_available(device);

View File

@@ -248,49 +248,60 @@ const char *pragma_unroll_kernels[] = {
"}\n", "}\n",
}; };
int test_pragma_unroll(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { REGISTER_TEST_VERSION(pragma_unroll, Version(2, 0))
const size_t ELEMENT_NUM = 100; {
const size_t KERNEL_NUM = 24; 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 // execute all kernels and check if the results are as expected
for (size_t kernelIdx = 0; kernelIdx < KERNEL_NUM; ++kernelIdx) { 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"))
{ {
log_error("The program we attempted to compile was: \n%s\n", clProgramWrapper program;
pragma_unroll_kernels[kernelIdx]); clKernelWrapper kernel;
return -1; 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<cl_uint> 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); return 0;
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<cl_uint> 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;
} }

View File

@@ -37,85 +37,100 @@ const char *define_kernel_code[] = {
"}\n"}; "}\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; size_t threads[3] = { (size_t)num_elements, 0, 0 };
clKernelWrapper kernel; error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0,
clProgramWrapper program; NULL, NULL);
clMemWrapper buffer[3]; test_error(error, "clEnqueueNDRangeKernel failed");
cl_int *srcData, *resultData;
int i;
MTdata d;
error = create_single_kernel_helper(context, &program, &kernel, 1, define_kernel_code, "define_test"); error = clEnqueueReadBuffer(queue, buffer[1], CL_TRUE, 0,
if (error) num_elements * sizeof(cl_int), resultData, 0,
return -1; NULL, NULL);
test_error(error, "clEnqueueReadBuffer failed");
buffer[0] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); for (i = 0; i < num_elements; i++)
test_error( error, "clCreateBuffer failed"); if (resultData[i] != srcData[i] * 2)
buffer[1] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); {
test_error( error, "clCreateBuffer failed"); free(srcData);
buffer[2] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); free(resultData);
test_error( error, "clCreateBuffer failed"); return -1;
}
srcData = (cl_int*)malloc(sizeof(cl_int)*num_elements); error = clEnqueueReadBuffer(queue, buffer[2], CL_TRUE, 0,
if (srcData == NULL) { num_elements * sizeof(cl_int), resultData, 0,
log_error("Failed to allocate storage for source data (%d cl_ints).\n", num_elements); NULL, NULL);
return -1; test_error(error, "clEnqueueReadBuffer failed");
}
d = init_genrand( gRandomSeed ); for (i = 0; i < num_elements; i++)
for (i=0; i<num_elements; i++) if (resultData[i] != srcData[i] * 4)
srcData[i] = (int)get_random_float(-1024, 1024,d); {
free_mtdata(d); d = NULL; free(srcData);
free(resultData);
return -1;
}
resultData = (cl_int*)malloc(sizeof(cl_int)*num_elements);
if (resultData == NULL) {
free(srcData); free(srcData);
log_error("Failed to allocate storage for result data (%d cl_ints).\n", num_elements); free(resultData);
return -1; return 0;
}
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");
error = clEnqueueWriteBuffer(queue, buffer[0], CL_TRUE, 0, num_elements*sizeof(cl_int), srcData, 0, NULL, NULL);
test_error(error, "clEnqueueWriteBuffer failed");
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 = clEnqueueReadBuffer(queue, buffer[1], CL_TRUE, 0, num_elements*sizeof(cl_int), resultData, 0, NULL, NULL);
test_error(error, "clEnqueueReadBuffer failed");
for (i=0; i<num_elements; i++)
if (resultData[i] != srcData[i]*2) {
free(srcData);
free(resultData);
return -1;
}
error = clEnqueueReadBuffer(queue, buffer[2], CL_TRUE, 0, num_elements*sizeof(cl_int), resultData, 0, NULL, NULL);
test_error(error, "clEnqueueReadBuffer failed");
for (i=0; i<num_elements; i++)
if (resultData[i] != srcData[i]*4) {
free(srcData);
free(resultData);
return -1;
}
free(srcData);
free(resultData);
return 0;
} }
@@ -133,68 +148,75 @@ const char *include_kernel_code =
"}\n"; "}\n";
int test_preprocessor_include(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { REGISTER_TEST(preprocessor_include)
{
cl_int error;
clKernelWrapper kernel;
clProgramWrapper program;
clMemWrapper buffer[2];
cl_int *resultData;
int i;
cl_int error; char include_dir[4096] = { 0 };
clKernelWrapper kernel; char include_kernel[4096] = { 0 };
clProgramWrapper program;
clMemWrapper buffer[2];
cl_int *resultData;
int i;
char include_dir[4096] = {0}; char const *sep = get_dir_sep();
char include_kernel[4096] = {0}; char const *path = get_exe_dir();
char const * sep = get_dir_sep(); /* Build with the include directory defined */
char const * path = get_exe_dir(); sprintf(include_dir, "%s%sincludeTestDirectory%stestIncludeFile.h", path,
sep, sep);
sprintf(include_kernel, include_kernel_code, include_dir);
free((void *)sep);
free((void *)path);
/* Build with the include directory defined */ const char *test_kernel[] = { include_kernel, 0 };
sprintf(include_dir,"%s%sincludeTestDirectory%stestIncludeFile.h", path, sep, sep); error = create_single_kernel_helper(context, &program, &kernel, 1,
sprintf(include_kernel, include_kernel_code, include_dir); test_kernel, "include_test");
free( (void *) sep ); if (error) return -1;
free( (void *) path );
const char* test_kernel[] = { include_kernel, 0 }; buffer[0] = clCreateBuffer(context, CL_MEM_READ_WRITE,
error = create_single_kernel_helper(context, &program, &kernel, 1, test_kernel, "include_test"); num_elements * sizeof(cl_int), NULL, &error);
if (error) test_error(error, "clCreateBuffer failed");
return -1; buffer[1] = clCreateBuffer(context, CL_MEM_READ_WRITE,
num_elements * sizeof(cl_int), NULL, &error);
test_error(error, "clCreateBuffer failed");
buffer[0] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); resultData = (cl_int *)malloc(sizeof(cl_int) * num_elements);
test_error( error, "clCreateBuffer failed"); if (resultData == NULL)
buffer[1] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); {
test_error( error, "clCreateBuffer failed"); log_error("Failed to allocate storage for result data (%d cl_ints).\n",
num_elements);
resultData = (cl_int*)malloc(sizeof(cl_int)*num_elements); return -1;
if (resultData == NULL) {
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");
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 = clEnqueueReadBuffer(queue, buffer[1], CL_TRUE, 0, num_elements*sizeof(cl_int), resultData, 0, NULL, NULL);
test_error(error, "clEnqueueReadBuffer failed");
for (i=0; i<num_elements; i++)
if (resultData[i] != 12) {
free(resultData);
return -1;
} }
free(resultData); error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]);
return 0; test_error(error, "clSetKernelArg failed");
error = clSetKernelArg(kernel, 1, sizeof(buffer[1]), &buffer[1]);
test_error(error, "clSetKernelArg failed");
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 = clEnqueueReadBuffer(queue, buffer[1], CL_TRUE, 0,
num_elements * sizeof(cl_int), resultData, 0,
NULL, NULL);
test_error(error, "clEnqueueReadBuffer failed");
for (i = 0; i < num_elements; i++)
if (resultData[i] != 12)
{
free(resultData);
return -1;
}
free(resultData);
return 0;
} }
const char *line_error_kernel_code[] = { const char *line_error_kernel_code[] = {
"__kernel void line_error_test(__global int *dstA)\n" "__kernel void line_error_test(__global int *dstA)\n"
"{\n" "{\n"
@@ -206,59 +228,79 @@ const char *line_error_kernel_code[] = {
"}\n"}; "}\n"};
int test_preprocessor_line_error(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { REGISTER_TEST(preprocessor_line_error)
{
cl_int error, error2;
clKernelWrapper kernel;
clProgramWrapper program;
clMemWrapper buffer[2];
cl_int error, error2; char buildLog[1024 * 128];
clKernelWrapper kernel;
clProgramWrapper program;
clMemWrapper buffer[2];
char buildLog[ 1024 * 128 ]; log_info("test_preprocessor_line_error may report spurious ERRORS in the "
"conformance log.\n");
log_info("test_preprocessor_line_error may report spurious ERRORS in the conformance log.\n"); /* Create the program object from source */
program = clCreateProgramWithSource(context, 1, line_error_kernel_code,
NULL, &error);
test_error(error, "clCreateProgramWithSource failed");
/* Create the program object from source */ /* Compile the program */
program = clCreateProgramWithSource( context, 1, line_error_kernel_code, NULL, &error ); error2 = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
test_error(error, "clCreateProgramWithSource failed"); if (error2)
{
/* Compile the program */ log_info("Build error detected at clBuildProgram.");
error2 = clBuildProgram( program, 0, NULL, NULL, NULL, NULL ); }
if (error2) { else
log_info("Build error detected at clBuildProgram."); {
} else { log_info("Error not reported by clBuildProgram.\n");
log_info("Error not reported by clBuildProgram.\n");
}
cl_build_status status;
error = clGetProgramBuildInfo(program, deviceID, CL_PROGRAM_BUILD_STATUS, sizeof(status), &status, NULL);
test_error(error, "clGetProgramBuildInfo failed for CL_PROGRAM_BUILD_STATUS");
if (status != CL_BUILD_ERROR) {
log_error("Build status did not return CL_BUILD_ERROR for a program with #error defined.\n");
return -1;
} else if (status == CL_BUILD_ERROR || error2) {
error2 = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_LOG, sizeof( buildLog ), buildLog, NULL );
test_error( error2, "Unable to get program build log" );
log_info("Build failed as expected with #error in source:\n");
log_info( "Build log is: ------------\n" );
log_info( "%s\n", buildLog );
log_info( "Original source is: ------------\n" );
log_info( "%s", line_error_kernel_code[0] );
log_info( "\n----------\n" );
if (strstr(buildLog, "fictitious/file/name.c")) {
log_info("Found file name from #line param in log output.\n");
} else {
log_info("WARNING: Did not find file name from #line param in log output.\n");
} }
if (strstr(buildLog, "124")) { cl_build_status status;
log_info("Found line number from #line param in log output.\n"); error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS,
} else { sizeof(status), &status, NULL);
log_info("WARNING: Did not find line number from #line param in log output.\n"); test_error(error,
"clGetProgramBuildInfo failed for CL_PROGRAM_BUILD_STATUS");
if (status != CL_BUILD_ERROR)
{
log_error("Build status did not return CL_BUILD_ERROR for a program "
"with #error defined.\n");
return -1;
} }
else if (status == CL_BUILD_ERROR || error2)
{
error2 = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,
sizeof(buildLog), buildLog, NULL);
test_error(error2, "Unable to get program build log");
log_info("test_preprocessor_line_error PASSED.\n"); log_info("Build failed as expected with #error in source:\n");
log_info("Build log is: ------------\n");
log_info("%s\n", buildLog);
log_info("Original source is: ------------\n");
log_info("%s", line_error_kernel_code[0]);
log_info("\n----------\n");
if (strstr(buildLog, "fictitious/file/name.c"))
{
log_info("Found file name from #line param in log output.\n");
}
else
{
log_info("WARNING: Did not find file name from #line param in log "
"output.\n");
}
if (strstr(buildLog, "124"))
{
log_info("Found line number from #line param in log output.\n");
}
else
{
log_info("WARNING: Did not find line number from #line param in "
"log output.\n");
}
log_info("test_preprocessor_line_error PASSED.\n");
return 0; return 0;
} }
@@ -281,7 +323,6 @@ int test_preprocessor_line_error(cl_device_id deviceID, cl_context context, cl_c
} }
const char *pragma_kernel_code[] = { const char *pragma_kernel_code[] = {
"__kernel void pragma_test(__global int *dstA)\n" "__kernel void pragma_test(__global int *dstA)\n"
"{\n" "{\n"
@@ -294,47 +335,51 @@ const char *pragma_kernel_code[] = {
"}\n"}; "}\n"};
int test_preprocessor_pragma(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { REGISTER_TEST(preprocessor_pragma)
{
cl_int error;
clKernelWrapper kernel;
clProgramWrapper program;
clMemWrapper buffer[2];
cl_int *resultData;
int i;
cl_int error; error = create_single_kernel_helper(context, &program, &kernel, 1,
clKernelWrapper kernel; pragma_kernel_code, "pragma_test");
clProgramWrapper program; if (error) return -1;
clMemWrapper buffer[2];
cl_int *resultData;
int i;
error = create_single_kernel_helper(context, &program, &kernel, 1, pragma_kernel_code, "pragma_test"); buffer[0] = clCreateBuffer(context, CL_MEM_READ_WRITE,
if (error) num_elements * sizeof(cl_int), NULL, &error);
return -1; test_error(error, "clCreateBuffer failed");
buffer[0] = clCreateBuffer(context, CL_MEM_READ_WRITE, num_elements*sizeof(cl_int), NULL, &error); error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]);
test_error( error, "clCreateBuffer failed"); test_error(error, "clSetKernelArg failed");
error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]); size_t threads[3] = { (size_t)num_elements, 0, 0 };
test_error(error, "clSetKernelArg failed"); error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0,
NULL, NULL);
test_error(error, "clEnqueueNDRangeKernel failed");
size_t threads[3] = { (size_t)num_elements, 0, 0 }; resultData = (cl_int *)malloc(sizeof(cl_int) * num_elements);
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL); if (resultData == NULL)
test_error(error, "clEnqueueNDRangeKernel failed"); {
log_error("Failed to allocate storage for result data (%d cl_ints).\n",
resultData = (cl_int*)malloc(sizeof(cl_int)*num_elements); num_elements);
if (resultData == NULL) { return -1;
log_error("Failed to allocate storage for result data (%d cl_ints).\n", num_elements);
return -1;
}
error = clEnqueueReadBuffer(queue, buffer[0], CL_TRUE, 0, num_elements*sizeof(cl_int), resultData, 0, NULL, NULL);
test_error(error, "clEnqueueReadBuffer failed");
for (i=0; i<num_elements; i++)
if (resultData[i] != i) {
free(resultData);
return -1;
} }
free(resultData); error = clEnqueueReadBuffer(queue, buffer[0], CL_TRUE, 0,
return 0; num_elements * sizeof(cl_int), resultData, 0,
NULL, NULL);
test_error(error, "clEnqueueReadBuffer failed");
for (i = 0; i < num_elements; i++)
if (resultData[i] != i)
{
free(resultData);
return -1;
}
free(resultData);
return 0;
} }

View File

@@ -378,7 +378,7 @@ static void unload_platform_compiler(const cl_platform_id platform)
} }
/* Test calling the function with a valid platform */ /* Test calling the function with a valid platform */
int test_unload_valid(cl_device_id device, cl_context, cl_command_queue, int) REGISTER_TEST(unload_valid)
{ {
const cl_platform_id platform = device_platform(device); const cl_platform_id platform = device_platform(device);
const long int err = clUnloadPlatformCompiler(platform); const long int err = clUnloadPlatformCompiler(platform);
@@ -393,7 +393,8 @@ int test_unload_valid(cl_device_id device, cl_context, cl_command_queue, int)
} }
/* Test calling the function with invalid platform */ /* Test calling the function with invalid platform */
int test_unload_invalid(cl_device_id, cl_context, cl_command_queue, int) /* Disabling temporarily, see GitHub #977
REGISTER_TEST(unload_invalid)
{ {
const long int err = clUnloadPlatformCompiler(nullptr); const long int err = clUnloadPlatformCompiler(nullptr);
@@ -405,10 +406,10 @@ int test_unload_invalid(cl_device_id, cl_context, cl_command_queue, int)
return 0; return 0;
} }
*/
/* Test calling the function multiple times in a row */ /* Test calling the function multiple times in a row */
int test_unload_repeated(cl_device_id device, cl_context context, REGISTER_TEST(unload_repeated)
cl_command_queue, int)
{ {
check_compiler_available(device); check_compiler_available(device);
@@ -438,8 +439,7 @@ int test_unload_repeated(cl_device_id device, cl_context context,
} }
/* Test calling the function between compilation and linking of programs */ /* Test calling the function between compilation and linking of programs */
int test_unload_compile_unload_link(cl_device_id device, cl_context context, REGISTER_TEST(unload_compile_unload_link)
cl_command_queue, int)
{ {
check_compiler_available(device); check_compiler_available(device);
@@ -469,9 +469,7 @@ int test_unload_compile_unload_link(cl_device_id device, cl_context context,
} }
/* Test calling the function between program build and kernel creation */ /* Test calling the function between program build and kernel creation */
int test_unload_build_unload_create_kernel(cl_device_id device, REGISTER_TEST(unload_build_unload_create_kernel)
cl_context context, cl_command_queue,
int)
{ {
check_compiler_available(device); check_compiler_available(device);
@@ -501,8 +499,7 @@ int test_unload_build_unload_create_kernel(cl_device_id device,
/* Test linking together two programs that were built with a call to the unload /* Test linking together two programs that were built with a call to the unload
* function in between */ * function in between */
int test_unload_link_different(cl_device_id device, cl_context context, REGISTER_TEST(unload_link_different)
cl_command_queue, int)
{ {
check_compiler_available(device); check_compiler_available(device);
@@ -587,7 +584,7 @@ int test_unload_link_different(cl_device_id device, cl_context context,
return 1; return 1;
} }
const clCommandQueueWrapper queue = const clCommandQueueWrapper test_queue =
clCreateCommandQueue(context, device, 0, &err); clCreateCommandQueue(context, device, 0, &err);
if (CL_SUCCESS != err) if (CL_SUCCESS != err)
{ {
@@ -616,8 +613,8 @@ int test_unload_link_different(cl_device_id device, cl_context context,
} }
static const size_t work_size = 1; static const size_t work_size = 1;
err = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &work_size, nullptr, err = clEnqueueNDRangeKernel(test_queue, kernel, 1, nullptr, &work_size,
0, nullptr, nullptr); nullptr, 0, nullptr, nullptr);
if (CL_SUCCESS != err) if (CL_SUCCESS != err)
{ {
log_error("Test failure: clEnqueueNDRangeKernel() == %ld\n", log_error("Test failure: clEnqueueNDRangeKernel() == %ld\n",
@@ -625,8 +622,8 @@ int test_unload_link_different(cl_device_id device, cl_context context,
return 1; return 1;
} }
err = clEnqueueReadBuffer(queue, buffer, CL_BLOCKING, 0, sizeof(cl_uint), err = clEnqueueReadBuffer(test_queue, buffer, CL_BLOCKING, 0,
&value, 0, nullptr, nullptr); sizeof(cl_uint), &value, 0, nullptr, nullptr);
if (CL_SUCCESS != err) if (CL_SUCCESS != err)
{ {
log_error("Test failure: clEnqueueReadBuffer() == %ld\n", log_error("Test failure: clEnqueueReadBuffer() == %ld\n",
@@ -634,7 +631,7 @@ int test_unload_link_different(cl_device_id device, cl_context context,
return 1; return 1;
} }
err = clFinish(queue); err = clFinish(test_queue);
if (CL_SUCCESS != err) throw unload_test_failure("clFinish()", err); if (CL_SUCCESS != err) throw unload_test_failure("clFinish()", err);
if (42 != value) if (42 != value)
@@ -649,8 +646,7 @@ int test_unload_link_different(cl_device_id device, cl_context context,
/* Test calling the function in a thread while others threads are building /* Test calling the function in a thread while others threads are building
* programs */ * programs */
int test_unload_build_threaded(cl_device_id device, cl_context context, REGISTER_TEST(unload_build_threaded)
cl_command_queue, int)
{ {
using clock = std::chrono::steady_clock; using clock = std::chrono::steady_clock;
@@ -740,8 +736,7 @@ int test_unload_build_threaded(cl_device_id device, cl_context context,
} }
/* Test grabbing program build information after calling the unload function */ /* Test grabbing program build information after calling the unload function */
int test_unload_build_info(cl_device_id device, cl_context context, REGISTER_TEST(unload_build_info)
cl_command_queue, int)
{ {
check_compiler_available(device); check_compiler_available(device);
@@ -903,8 +898,7 @@ int test_unload_build_info(cl_device_id device, cl_context context,
/* Test calling the unload function between program building and fetching the /* Test calling the unload function between program building and fetching the
* program binaries */ * program binaries */
int test_unload_program_binaries(cl_device_id device, cl_context context, REGISTER_TEST(unload_program_binaries)
cl_command_queue, int)
{ {
check_compiler_available(device); check_compiler_available(device);