mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
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:
@@ -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 <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[])
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -16,14 +16,34 @@
|
||||
#ifndef _testBase_h
|
||||
#define _testBase_h
|
||||
|
||||
#include "harness/compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.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
|
||||
struct SubDevicesScopeGuarded
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<cl_device_partition_property> 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 )
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
@@ -205,7 +205,7 @@ int feature_macro_verify_results(std::string test_macro_name,
|
||||
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,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
@@ -233,7 +233,7 @@ 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,
|
||||
static int test_feature_macro_atomic_order_seq_cst(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
@@ -262,7 +262,7 @@ 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,
|
||||
static int test_feature_macro_atomic_scope_device(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
@@ -289,9 +289,8 @@ 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,
|
||||
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;
|
||||
@@ -316,7 +315,7 @@ 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,
|
||||
static int test_feature_macro_3d_image_writes(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
@@ -343,7 +342,8 @@ 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,
|
||||
static int test_feature_macro_device_enqueue(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
{
|
||||
@@ -371,7 +371,7 @@ 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,
|
||||
static int test_feature_macro_generic_address_space(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
@@ -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,7 +450,7 @@ int test_feature_macro_program_scope_global_variables(
|
||||
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,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
@@ -476,7 +477,8 @@ 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,
|
||||
static int test_feature_macro_subgroups(cl_device_id deviceID,
|
||||
cl_context context,
|
||||
std::string test_macro_name,
|
||||
cl_bool& supported)
|
||||
{
|
||||
@@ -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,7 +727,7 @@ 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,
|
||||
static int test_consistency_c_features_list(cl_device_id deviceID,
|
||||
std::vector<std::string> vec_to_cmp)
|
||||
{
|
||||
log_info("\nComparison list of features: CL_DEVICE_OPENCL_C_FEATURES vs "
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -248,44 +248,55 @@ const char *pragma_unroll_kernels[] = {
|
||||
"}\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;
|
||||
|
||||
cl_int error;
|
||||
|
||||
//execute all kernels and check if the results are as expected
|
||||
for (size_t kernelIdx = 0; kernelIdx < KERNEL_NUM; ++kernelIdx) {
|
||||
// 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"))
|
||||
(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);
|
||||
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
|
||||
// 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);
|
||||
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);
|
||||
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",
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -37,10 +37,8 @@ const char *define_kernel_code[] = {
|
||||
"}\n"};
|
||||
|
||||
|
||||
|
||||
|
||||
int test_preprocessor_define_udef(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) {
|
||||
|
||||
REGISTER_TEST(preprocessor_define_udef)
|
||||
{
|
||||
cl_int error;
|
||||
clKernelWrapper kernel;
|
||||
clProgramWrapper program;
|
||||
@@ -49,32 +47,40 @@ int test_preprocessor_define_udef(cl_device_id deviceID, cl_context context, cl_
|
||||
int i;
|
||||
MTdata d;
|
||||
|
||||
error = create_single_kernel_helper(context, &program, &kernel, 1, define_kernel_code, "define_test");
|
||||
if (error)
|
||||
return -1;
|
||||
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");
|
||||
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);
|
||||
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;
|
||||
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) {
|
||||
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);
|
||||
log_error("Failed to allocate storage for result data (%d cl_ints).\n",
|
||||
num_elements);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -86,28 +92,37 @@ int test_preprocessor_define_udef(cl_device_id deviceID, cl_context context, cl_
|
||||
test_error(error, "clSetKernelArg failed");
|
||||
|
||||
|
||||
error = clEnqueueWriteBuffer(queue, buffer[0], CL_TRUE, 0, num_elements*sizeof(cl_int), srcData, 0, NULL, NULL);
|
||||
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);
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
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) {
|
||||
for (i = 0; i < num_elements; i++)
|
||||
if (resultData[i] != srcData[i] * 4)
|
||||
{
|
||||
free(srcData);
|
||||
free(resultData);
|
||||
return -1;
|
||||
@@ -133,8 +148,8 @@ const char *include_kernel_code =
|
||||
"}\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;
|
||||
@@ -142,31 +157,36 @@ int test_preprocessor_include(cl_device_id deviceID, cl_context context, cl_comm
|
||||
cl_int *resultData;
|
||||
int i;
|
||||
|
||||
char include_dir[4096] = {0};
|
||||
char include_kernel[4096] = {0};
|
||||
char include_dir[4096] = { 0 };
|
||||
char include_kernel[4096] = { 0 };
|
||||
|
||||
char const * sep = get_dir_sep();
|
||||
char const * path = get_exe_dir();
|
||||
char const *sep = get_dir_sep();
|
||||
char const *path = get_exe_dir();
|
||||
|
||||
/* Build with the include directory defined */
|
||||
sprintf(include_dir,"%s%sincludeTestDirectory%stestIncludeFile.h", path, sep, sep);
|
||||
sprintf(include_dir, "%s%sincludeTestDirectory%stestIncludeFile.h", path,
|
||||
sep, sep);
|
||||
sprintf(include_kernel, include_kernel_code, include_dir);
|
||||
free( (void *) sep );
|
||||
free( (void *) path );
|
||||
free((void *)sep);
|
||||
free((void *)path);
|
||||
|
||||
const char* test_kernel[] = { include_kernel, 0 };
|
||||
error = create_single_kernel_helper(context, &program, &kernel, 1, test_kernel, "include_test");
|
||||
if (error)
|
||||
return -1;
|
||||
const char *test_kernel[] = { include_kernel, 0 };
|
||||
error = create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
test_kernel, "include_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[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");
|
||||
|
||||
resultData = (cl_int*)malloc(sizeof(cl_int)*num_elements);
|
||||
if (resultData == NULL) {
|
||||
log_error("Failed to allocate storage for result data (%d cl_ints).\n", num_elements);
|
||||
resultData = (cl_int *)malloc(sizeof(cl_int) * num_elements);
|
||||
if (resultData == NULL)
|
||||
{
|
||||
log_error("Failed to allocate storage for result data (%d cl_ints).\n",
|
||||
num_elements);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -176,14 +196,18 @@ int test_preprocessor_include(cl_device_id deviceID, cl_context context, cl_comm
|
||||
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);
|
||||
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);
|
||||
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) {
|
||||
for (i = 0; i < num_elements; i++)
|
||||
if (resultData[i] != 12)
|
||||
{
|
||||
free(resultData);
|
||||
return -1;
|
||||
}
|
||||
@@ -193,8 +217,6 @@ int test_preprocessor_include(cl_device_id deviceID, cl_context context, cl_comm
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char *line_error_kernel_code[] = {
|
||||
"__kernel void line_error_test(__global int *dstA)\n"
|
||||
"{\n"
|
||||
@@ -206,56 +228,76 @@ const char *line_error_kernel_code[] = {
|
||||
"}\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];
|
||||
|
||||
char buildLog[ 1024 * 128 ];
|
||||
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 );
|
||||
program = clCreateProgramWithSource(context, 1, line_error_kernel_code,
|
||||
NULL, &error);
|
||||
test_error(error, "clCreateProgramWithSource failed");
|
||||
|
||||
/* Compile the program */
|
||||
error2 = clBuildProgram( program, 0, NULL, NULL, NULL, NULL );
|
||||
if (error2) {
|
||||
error2 = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
|
||||
if (error2)
|
||||
{
|
||||
log_info("Build error detected at clBuildProgram.");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
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");
|
||||
error = clGetProgramBuildInfo(program, device, 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" );
|
||||
}
|
||||
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("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" );
|
||||
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")) {
|
||||
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");
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("WARNING: Did not find file name from #line param in log "
|
||||
"output.\n");
|
||||
}
|
||||
|
||||
if (strstr(buildLog, "124")) {
|
||||
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");
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("WARNING: Did not find line number from #line param in "
|
||||
"log output.\n");
|
||||
}
|
||||
|
||||
log_info("test_preprocessor_line_error PASSED.\n");
|
||||
@@ -281,7 +323,6 @@ int test_preprocessor_line_error(cl_device_id deviceID, cl_context context, cl_c
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *pragma_kernel_code[] = {
|
||||
"__kernel void pragma_test(__global int *dstA)\n"
|
||||
"{\n"
|
||||
@@ -294,8 +335,8 @@ const char *pragma_kernel_code[] = {
|
||||
"}\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;
|
||||
@@ -303,31 +344,38 @@ int test_preprocessor_pragma(cl_device_id deviceID, cl_context context, cl_comma
|
||||
cl_int *resultData;
|
||||
int i;
|
||||
|
||||
error = create_single_kernel_helper(context, &program, &kernel, 1, pragma_kernel_code, "pragma_test");
|
||||
if (error)
|
||||
return -1;
|
||||
error = create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
pragma_kernel_code, "pragma_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[0] = clCreateBuffer(context, CL_MEM_READ_WRITE,
|
||||
num_elements * sizeof(cl_int), NULL, &error);
|
||||
test_error(error, "clCreateBuffer failed");
|
||||
|
||||
error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]);
|
||||
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);
|
||||
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0,
|
||||
NULL, NULL);
|
||||
test_error(error, "clEnqueueNDRangeKernel failed");
|
||||
|
||||
resultData = (cl_int*)malloc(sizeof(cl_int)*num_elements);
|
||||
if (resultData == NULL) {
|
||||
log_error("Failed to allocate storage for result data (%d cl_ints).\n", num_elements);
|
||||
resultData = (cl_int *)malloc(sizeof(cl_int) * num_elements);
|
||||
if (resultData == NULL)
|
||||
{
|
||||
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);
|
||||
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) {
|
||||
for (i = 0; i < num_elements; i++)
|
||||
if (resultData[i] != i)
|
||||
{
|
||||
free(resultData);
|
||||
return -1;
|
||||
}
|
||||
@@ -335,6 +383,3 @@ int test_preprocessor_pragma(cl_device_id deviceID, cl_context context, cl_comma
|
||||
free(resultData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ static void unload_platform_compiler(const cl_platform_id 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 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 */
|
||||
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);
|
||||
|
||||
@@ -405,10 +406,10 @@ int test_unload_invalid(cl_device_id, cl_context, cl_command_queue, int)
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Test calling the function multiple times in a row */
|
||||
int test_unload_repeated(cl_device_id device, cl_context context,
|
||||
cl_command_queue, int)
|
||||
REGISTER_TEST(unload_repeated)
|
||||
{
|
||||
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 */
|
||||
int test_unload_compile_unload_link(cl_device_id device, cl_context context,
|
||||
cl_command_queue, int)
|
||||
REGISTER_TEST(unload_compile_unload_link)
|
||||
{
|
||||
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 */
|
||||
int test_unload_build_unload_create_kernel(cl_device_id device,
|
||||
cl_context context, cl_command_queue,
|
||||
int)
|
||||
REGISTER_TEST(unload_build_unload_create_kernel)
|
||||
{
|
||||
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
|
||||
* function in between */
|
||||
int test_unload_link_different(cl_device_id device, cl_context context,
|
||||
cl_command_queue, int)
|
||||
REGISTER_TEST(unload_link_different)
|
||||
{
|
||||
check_compiler_available(device);
|
||||
|
||||
@@ -587,7 +584,7 @@ int test_unload_link_different(cl_device_id device, cl_context context,
|
||||
return 1;
|
||||
}
|
||||
|
||||
const clCommandQueueWrapper queue =
|
||||
const clCommandQueueWrapper test_queue =
|
||||
clCreateCommandQueue(context, device, 0, &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;
|
||||
err = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &work_size, nullptr,
|
||||
0, nullptr, nullptr);
|
||||
err = clEnqueueNDRangeKernel(test_queue, kernel, 1, nullptr, &work_size,
|
||||
nullptr, 0, nullptr, nullptr);
|
||||
if (CL_SUCCESS != err)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
err = clEnqueueReadBuffer(queue, buffer, CL_BLOCKING, 0, sizeof(cl_uint),
|
||||
&value, 0, nullptr, nullptr);
|
||||
err = clEnqueueReadBuffer(test_queue, buffer, CL_BLOCKING, 0,
|
||||
sizeof(cl_uint), &value, 0, nullptr, nullptr);
|
||||
if (CL_SUCCESS != err)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
err = clFinish(queue);
|
||||
err = clFinish(test_queue);
|
||||
if (CL_SUCCESS != err) throw unload_test_failure("clFinish()", err);
|
||||
|
||||
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
|
||||
* programs */
|
||||
int test_unload_build_threaded(cl_device_id device, cl_context context,
|
||||
cl_command_queue, int)
|
||||
REGISTER_TEST(unload_build_threaded)
|
||||
{
|
||||
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 */
|
||||
int test_unload_build_info(cl_device_id device, cl_context context,
|
||||
cl_command_queue, int)
|
||||
REGISTER_TEST(unload_build_info)
|
||||
{
|
||||
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
|
||||
* program binaries */
|
||||
int test_unload_program_binaries(cl_device_id device, cl_context context,
|
||||
cl_command_queue, int)
|
||||
REGISTER_TEST(unload_program_binaries)
|
||||
{
|
||||
check_compiler_available(device);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user