mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Added corrections due to clean up harness helper functions for programs and kernels (#2626)
Related to #2597
This commit is contained in:
@@ -141,7 +141,6 @@ std::string get_kernel_name(const std::string &source)
|
||||
{
|
||||
kernelsList = kernelsList.substr(0, MAX_LEN_FOR_KERNEL_LIST + 1);
|
||||
kernelsList[kernelsList.size() - 1] = '.';
|
||||
kernelsList[kernelsList.size() - 1] = '.';
|
||||
}
|
||||
oss << kernelsList;
|
||||
}
|
||||
@@ -678,17 +677,18 @@ static int create_single_kernel_helper_create_program_offline(
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
static int create_single_kernel_helper_create_program(
|
||||
cl_context context, cl_device_id device, cl_program *outProgram,
|
||||
unsigned int numKernelLines, const char **kernelProgram,
|
||||
const char *buildOptions, CompilationMode compilationMode)
|
||||
int create_single_kernel_helper_create_program(cl_context context,
|
||||
cl_program *outProgram,
|
||||
unsigned int numKernelLines,
|
||||
const char **kernelProgram,
|
||||
const char *buildOptions)
|
||||
{
|
||||
std::lock_guard<std::mutex> compiler_lock(gCompilerMutex);
|
||||
|
||||
std::string filePrefix =
|
||||
get_unique_filename_prefix(numKernelLines, kernelProgram, buildOptions);
|
||||
bool shouldSaveToDisk = should_save_kernel_source_to_disk(
|
||||
compilationMode, gCompilationCacheMode, gCompilationCachePath,
|
||||
gCompilationMode, gCompilationCacheMode, gCompilationCachePath,
|
||||
filePrefix);
|
||||
|
||||
if (shouldSaveToDisk)
|
||||
@@ -701,7 +701,7 @@ static int create_single_kernel_helper_create_program(
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (compilationMode == kOnline)
|
||||
if (gCompilationMode == kOnline)
|
||||
{
|
||||
int error = CL_SUCCESS;
|
||||
|
||||
@@ -718,40 +718,9 @@ static int create_single_kernel_helper_create_program(
|
||||
else
|
||||
{
|
||||
return create_single_kernel_helper_create_program_offline(
|
||||
context, device, outProgram, numKernelLines, kernelProgram,
|
||||
buildOptions, compilationMode);
|
||||
}
|
||||
}
|
||||
|
||||
int create_single_kernel_helper_create_program(cl_context context,
|
||||
cl_program *outProgram,
|
||||
unsigned int numKernelLines,
|
||||
const char **kernelProgram,
|
||||
const char *buildOptions)
|
||||
{
|
||||
return create_single_kernel_helper_create_program(
|
||||
context, NULL, outProgram, numKernelLines, kernelProgram, buildOptions,
|
||||
gCompilationMode);
|
||||
}
|
||||
|
||||
int create_single_kernel_helper_create_program_for_device(
|
||||
cl_context context, cl_device_id device, cl_program *outProgram,
|
||||
unsigned int numKernelLines, const char **kernelProgram,
|
||||
const char *buildOptions)
|
||||
{
|
||||
return create_single_kernel_helper_create_program(
|
||||
context, device, outProgram, numKernelLines, kernelProgram,
|
||||
context, nullptr, outProgram, numKernelLines, kernelProgram,
|
||||
buildOptions, gCompilationMode);
|
||||
}
|
||||
|
||||
int create_single_kernel_helper_with_build_options(
|
||||
cl_context context, cl_program *outProgram, cl_kernel *outKernel,
|
||||
unsigned int numKernelLines, const char **kernelProgram,
|
||||
const char *kernelName, const char *buildOptions)
|
||||
{
|
||||
return create_single_kernel_helper(context, outProgram, outKernel,
|
||||
numKernelLines, kernelProgram,
|
||||
kernelName, buildOptions);
|
||||
}
|
||||
}
|
||||
|
||||
// Creates and builds OpenCL C/C++ program, and creates a kernel
|
||||
@@ -1239,8 +1208,8 @@ int is_image_format_supported(cl_context context, cl_mem_flags flags,
|
||||
{
|
||||
cl_image_format *list;
|
||||
cl_uint count = 0;
|
||||
cl_int err = clGetSupportedImageFormats(context, flags, image_type, 128,
|
||||
NULL, &count);
|
||||
cl_int err =
|
||||
clGetSupportedImageFormats(context, flags, image_type, 0, NULL, &count);
|
||||
if (count == 0) return 0;
|
||||
|
||||
list = (cl_image_format *)malloc(count * sizeof(cl_image_format));
|
||||
@@ -1276,7 +1245,6 @@ int is_image_format_supported(cl_context context, cl_mem_flags flags,
|
||||
return (i < count) ? 1 : 0;
|
||||
}
|
||||
|
||||
size_t get_pixel_bytes(const cl_image_format *fmt);
|
||||
size_t get_pixel_bytes(const cl_image_format *fmt)
|
||||
{
|
||||
size_t chanCount;
|
||||
|
||||
@@ -487,10 +487,10 @@ compare_kernel_with_expected(cl_context context, cl_device_id device,
|
||||
int failed_tests = 0;
|
||||
clKernelWrapper kernel;
|
||||
clProgramWrapper program;
|
||||
cl_int err = create_single_kernel_helper_with_build_options(
|
||||
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info",
|
||||
cl_int err = create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
&kernel_src, "get_kernel_arg_info",
|
||||
get_build_options(device).c_str());
|
||||
test_error(err, "create_single_kernel_helper_with_build_options");
|
||||
test_error(err, "create_single_kernel_helper");
|
||||
for (size_t i = 0; i < expected_args.size(); ++i)
|
||||
{
|
||||
KernelArgInfo actual;
|
||||
@@ -874,11 +874,10 @@ static int test_null_param(cl_context context, cl_device_id device,
|
||||
{
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
cl_int err = create_single_kernel_helper_with_build_options(
|
||||
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info",
|
||||
cl_int err = create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
&kernel_src, "get_kernel_arg_info",
|
||||
get_build_options(device).c_str());
|
||||
test_error_ret(err, "create_single_kernel_helper_with_build_options",
|
||||
TEST_FAIL);
|
||||
test_error_ret(err, "create_single_kernel_helper", TEST_FAIL);
|
||||
|
||||
err = clGetKernelArgInfo(kernel, SINGLE_KERNEL_ARG_NUMBER,
|
||||
CL_KERNEL_ARG_ADDRESS_QUALIFIER, 0, nullptr,
|
||||
@@ -916,12 +915,11 @@ static int test_arg_name_size(cl_context context, cl_device_id device,
|
||||
char arg_return[sizeof(KERNEL_ARGUMENT_NAME) + 1];
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
cl_int err = create_single_kernel_helper_with_build_options(
|
||||
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info",
|
||||
cl_int err = create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
&kernel_src, "get_kernel_arg_info",
|
||||
get_build_options(device).c_str());
|
||||
|
||||
test_error_ret(err, "create_single_kernel_helper_with_build_options",
|
||||
TEST_FAIL);
|
||||
test_error_ret(err, "create_single_kernel_helper", TEST_FAIL);
|
||||
|
||||
err =
|
||||
clGetKernelArgInfo(kernel, SINGLE_KERNEL_ARG_NUMBER, CL_KERNEL_ARG_NAME,
|
||||
|
||||
@@ -86,7 +86,8 @@ REGISTER_TEST(queue_hint)
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
|
||||
err = create_single_kernel_helper_with_build_options(context, &program, &kernel, 1, queue_hint_test_kernel, "vec_cpy", NULL);
|
||||
err = create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
queue_hint_test_kernel, "vec_cpy");
|
||||
if (err != 0)
|
||||
{
|
||||
return err;
|
||||
|
||||
@@ -103,11 +103,11 @@ REGISTER_TEST_VERSION(enqueued_local_size, Version(2, 0))
|
||||
|
||||
std::string cl_std = "-cl-std=CL";
|
||||
cl_std += (get_device_cl_version(device) == Version(3, 0)) ? "3.0" : "2.0";
|
||||
err = create_single_kernel_helper_with_build_options(
|
||||
err = create_single_kernel_helper(
|
||||
context, &program[0], &kernel[0], 1, &enqueued_local_size_1d_code,
|
||||
"test_enqueued_local_size_1d", cl_std.c_str());
|
||||
test_error(err, "create_single_kernel_helper failed");
|
||||
err = create_single_kernel_helper_with_build_options(
|
||||
err = create_single_kernel_helper(
|
||||
context, &program[1], &kernel[1], 1, &enqueued_local_size_2d_code,
|
||||
"test_enqueued_local_size_2d", cl_std.c_str());
|
||||
test_error(err, "create_single_kernel_helper failed");
|
||||
|
||||
@@ -50,8 +50,8 @@ cl_int get_type_size( cl_context context, cl_command_queue queue, const char *ty
|
||||
{
|
||||
sizeof_kernel_code[0] = "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n";
|
||||
}
|
||||
cl_int err = create_single_kernel_helper_with_build_options(
|
||||
context, &p, &k, 4, sizeof_kernel_code, "test_sizeof", nullptr);
|
||||
cl_int err = create_single_kernel_helper(context, &p, &k, 4,
|
||||
sizeof_kernel_code, "test_sizeof");
|
||||
test_error(err, "Failed to build kernel/program.");
|
||||
|
||||
m = clCreateBuffer( context, CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR, sizeof( cl_ulong ), size, &err );
|
||||
|
||||
@@ -1245,9 +1245,8 @@ int CBasicTest<HostAtomicType, HostDataType>::ExecuteSingleTest(
|
||||
programSource = PragmaHeader(deviceID) + ProgramHeader(numDestItems)
|
||||
+ FunctionCode() + KernelCode(numDestItems);
|
||||
programLine = programSource.c_str();
|
||||
if (create_single_kernel_helper_with_build_options(
|
||||
context, &program, &kernel, 1, &programLine,
|
||||
"test_atomic_kernel", gOldAPI ? "" : nullptr))
|
||||
if (create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
&programLine, "test_atomic_kernel"))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ int test_cxx_for_opencl(cl_device_id device, cl_context context,
|
||||
execute(*p, x);
|
||||
})";
|
||||
|
||||
error = create_single_kernel_helper_with_build_options(
|
||||
context, &program, &kernel1, 1, &kernel_sstr, "k1", "-cl-std=CLC++");
|
||||
error = create_single_kernel_helper(context, &program, &kernel1, 1,
|
||||
&kernel_sstr, "k1", "-cl-std=CLC++");
|
||||
test_error(error, "Failed to create k1 kernel");
|
||||
|
||||
kernel2 = clCreateKernel(program, "k2", &error);
|
||||
|
||||
@@ -336,9 +336,8 @@ int test_cl_image_write(cl_context context, cl_command_queue queue,
|
||||
get_explicit_type_name(*outType), suffix, convert);
|
||||
|
||||
programPtr = kernelSource;
|
||||
if (create_single_kernel_helper_with_build_options(
|
||||
context, &program, &kernel, 1, (const char **)&programPtr,
|
||||
"sample_test", ""))
|
||||
if (create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
(const char **)&programPtr, "sample_test"))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -557,8 +557,9 @@ int TestNonUniformWorkGroup::prepareDevice () {
|
||||
if (_testRange & Range::BARRIERS)
|
||||
buildOptions += " -D TESTBARRIERS";
|
||||
|
||||
err = create_single_kernel_helper_with_build_options (_context, &_program, &_testKernel, 1,
|
||||
&KERNEL_FUNCTION, "testKernel", buildOptions.c_str());
|
||||
err = create_single_kernel_helper(_context, &_program, &_testKernel, 1,
|
||||
&KERNEL_FUNCTION, "testKernel",
|
||||
buildOptions.c_str());
|
||||
if (err)
|
||||
{
|
||||
log_error("Error %d in line: %d of file %s\n", err, __LINE__, __FILE__);
|
||||
@@ -842,8 +843,9 @@ int SubTestExecutor::calculateWorkGroupSize(size_t &maxWgSize, int testRange) {
|
||||
if (testRange & Range::BARRIERS)
|
||||
buildOptions += " -D TESTBARRIERS";
|
||||
|
||||
err = create_single_kernel_helper_with_build_options (_context, &program, &testKernel, 1,
|
||||
&KERNEL_FUNCTION, "testKernel", buildOptions.c_str());
|
||||
err = create_single_kernel_helper(_context, &program, &testKernel, 1,
|
||||
&KERNEL_FUNCTION, "testKernel",
|
||||
buildOptions.c_str());
|
||||
if (err)
|
||||
{
|
||||
log_error("Error %d in line: %d of file %s\n", err, __LINE__, __FILE__);
|
||||
|
||||
@@ -63,8 +63,8 @@ REGISTER_TEST(pipe_info)
|
||||
log_info( " CL_PIPE_MAX_PACKETS passed.\n" );
|
||||
}
|
||||
|
||||
err = create_single_kernel_helper_with_build_options(
|
||||
context, &program, &kernel, 1, &pipe_kernel_code, "pipe_kernel",
|
||||
err = create_single_kernel_helper(context, &program, &kernel, 1,
|
||||
&pipe_kernel_code, "pipe_kernel",
|
||||
"-cl-std=CL2.0 -cl-kernel-arg-info");
|
||||
test_error_fail(err, "Error creating program");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user