Added corrections due to clean up harness helper functions for programs and kernels (#2626)

Related to #2597
This commit is contained in:
Marcin Hajder
2026-03-10 16:40:03 +01:00
committed by GitHub
parent c3d9c85743
commit a56e8ee92b
10 changed files with 44 additions and 77 deletions

View File

@@ -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.substr(0, MAX_LEN_FOR_KERNEL_LIST + 1);
kernelsList[kernelsList.size() - 1] = '.'; kernelsList[kernelsList.size() - 1] = '.';
kernelsList[kernelsList.size() - 1] = '.';
} }
oss << kernelsList; oss << kernelsList;
} }
@@ -678,17 +677,18 @@ static int create_single_kernel_helper_create_program_offline(
return CL_SUCCESS; return CL_SUCCESS;
} }
static int create_single_kernel_helper_create_program( int create_single_kernel_helper_create_program(cl_context context,
cl_context context, cl_device_id device, cl_program *outProgram, cl_program *outProgram,
unsigned int numKernelLines, const char **kernelProgram, unsigned int numKernelLines,
const char *buildOptions, CompilationMode compilationMode) const char **kernelProgram,
const char *buildOptions)
{ {
std::lock_guard<std::mutex> compiler_lock(gCompilerMutex); std::lock_guard<std::mutex> compiler_lock(gCompilerMutex);
std::string filePrefix = std::string filePrefix =
get_unique_filename_prefix(numKernelLines, kernelProgram, buildOptions); get_unique_filename_prefix(numKernelLines, kernelProgram, buildOptions);
bool shouldSaveToDisk = should_save_kernel_source_to_disk( bool shouldSaveToDisk = should_save_kernel_source_to_disk(
compilationMode, gCompilationCacheMode, gCompilationCachePath, gCompilationMode, gCompilationCacheMode, gCompilationCachePath,
filePrefix); filePrefix);
if (shouldSaveToDisk) if (shouldSaveToDisk)
@@ -701,7 +701,7 @@ static int create_single_kernel_helper_create_program(
return -1; return -1;
} }
} }
if (compilationMode == kOnline) if (gCompilationMode == kOnline)
{ {
int error = CL_SUCCESS; int error = CL_SUCCESS;
@@ -718,40 +718,9 @@ static int create_single_kernel_helper_create_program(
else else
{ {
return create_single_kernel_helper_create_program_offline( return create_single_kernel_helper_create_program_offline(
context, device, outProgram, numKernelLines, kernelProgram, context, nullptr, 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,
buildOptions, gCompilationMode); 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 // 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_image_format *list;
cl_uint count = 0; cl_uint count = 0;
cl_int err = clGetSupportedImageFormats(context, flags, image_type, 128, cl_int err =
NULL, &count); clGetSupportedImageFormats(context, flags, image_type, 0, NULL, &count);
if (count == 0) return 0; if (count == 0) return 0;
list = (cl_image_format *)malloc(count * sizeof(cl_image_format)); 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; 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 get_pixel_bytes(const cl_image_format *fmt)
{ {
size_t chanCount; size_t chanCount;

View File

@@ -487,10 +487,10 @@ compare_kernel_with_expected(cl_context context, cl_device_id device,
int failed_tests = 0; int failed_tests = 0;
clKernelWrapper kernel; clKernelWrapper kernel;
clProgramWrapper program; clProgramWrapper program;
cl_int err = create_single_kernel_helper_with_build_options( cl_int err = create_single_kernel_helper(context, &program, &kernel, 1,
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info", &kernel_src, "get_kernel_arg_info",
get_build_options(device).c_str()); 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) for (size_t i = 0; i < expected_args.size(); ++i)
{ {
KernelArgInfo actual; KernelArgInfo actual;
@@ -874,11 +874,10 @@ static int test_null_param(cl_context context, cl_device_id device,
{ {
clProgramWrapper program; clProgramWrapper program;
clKernelWrapper kernel; clKernelWrapper kernel;
cl_int err = create_single_kernel_helper_with_build_options( cl_int err = create_single_kernel_helper(context, &program, &kernel, 1,
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info", &kernel_src, "get_kernel_arg_info",
get_build_options(device).c_str()); get_build_options(device).c_str());
test_error_ret(err, "create_single_kernel_helper_with_build_options", test_error_ret(err, "create_single_kernel_helper", TEST_FAIL);
TEST_FAIL);
err = clGetKernelArgInfo(kernel, SINGLE_KERNEL_ARG_NUMBER, err = clGetKernelArgInfo(kernel, SINGLE_KERNEL_ARG_NUMBER,
CL_KERNEL_ARG_ADDRESS_QUALIFIER, 0, nullptr, 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]; char arg_return[sizeof(KERNEL_ARGUMENT_NAME) + 1];
clProgramWrapper program; clProgramWrapper program;
clKernelWrapper kernel; clKernelWrapper kernel;
cl_int err = create_single_kernel_helper_with_build_options( cl_int err = create_single_kernel_helper(context, &program, &kernel, 1,
context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info", &kernel_src, "get_kernel_arg_info",
get_build_options(device).c_str()); get_build_options(device).c_str());
test_error_ret(err, "create_single_kernel_helper_with_build_options", test_error_ret(err, "create_single_kernel_helper", TEST_FAIL);
TEST_FAIL);
err = err =
clGetKernelArgInfo(kernel, SINGLE_KERNEL_ARG_NUMBER, CL_KERNEL_ARG_NAME, clGetKernelArgInfo(kernel, SINGLE_KERNEL_ARG_NUMBER, CL_KERNEL_ARG_NAME,

View File

@@ -86,7 +86,8 @@ REGISTER_TEST(queue_hint)
clProgramWrapper program; clProgramWrapper program;
clKernelWrapper kernel; 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) if (err != 0)
{ {
return err; return err;

View File

@@ -103,11 +103,11 @@ REGISTER_TEST_VERSION(enqueued_local_size, Version(2, 0))
std::string cl_std = "-cl-std=CL"; std::string cl_std = "-cl-std=CL";
cl_std += (get_device_cl_version(device) == Version(3, 0)) ? "3.0" : "2.0"; 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, context, &program[0], &kernel[0], 1, &enqueued_local_size_1d_code,
"test_enqueued_local_size_1d", cl_std.c_str()); "test_enqueued_local_size_1d", cl_std.c_str());
test_error(err, "create_single_kernel_helper failed"); 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, context, &program[1], &kernel[1], 1, &enqueued_local_size_2d_code,
"test_enqueued_local_size_2d", cl_std.c_str()); "test_enqueued_local_size_2d", cl_std.c_str());
test_error(err, "create_single_kernel_helper failed"); test_error(err, "create_single_kernel_helper failed");

View File

@@ -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"; sizeof_kernel_code[0] = "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n";
} }
cl_int err = create_single_kernel_helper_with_build_options( cl_int err = create_single_kernel_helper(context, &p, &k, 4,
context, &p, &k, 4, sizeof_kernel_code, "test_sizeof", nullptr); sizeof_kernel_code, "test_sizeof");
test_error(err, "Failed to build kernel/program."); 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 ); m = clCreateBuffer( context, CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR, sizeof( cl_ulong ), size, &err );

View File

@@ -1245,9 +1245,8 @@ int CBasicTest<HostAtomicType, HostDataType>::ExecuteSingleTest(
programSource = PragmaHeader(deviceID) + ProgramHeader(numDestItems) programSource = PragmaHeader(deviceID) + ProgramHeader(numDestItems)
+ FunctionCode() + KernelCode(numDestItems); + FunctionCode() + KernelCode(numDestItems);
programLine = programSource.c_str(); programLine = programSource.c_str();
if (create_single_kernel_helper_with_build_options( if (create_single_kernel_helper(context, &program, &kernel, 1,
context, &program, &kernel, 1, &programLine, &programLine, "test_atomic_kernel"))
"test_atomic_kernel", gOldAPI ? "" : nullptr))
{ {
return -1; return -1;
} }

View File

@@ -42,8 +42,8 @@ int test_cxx_for_opencl(cl_device_id device, cl_context context,
execute(*p, x); execute(*p, x);
})"; })";
error = create_single_kernel_helper_with_build_options( error = create_single_kernel_helper(context, &program, &kernel1, 1,
context, &program, &kernel1, 1, &kernel_sstr, "k1", "-cl-std=CLC++"); &kernel_sstr, "k1", "-cl-std=CLC++");
test_error(error, "Failed to create k1 kernel"); test_error(error, "Failed to create k1 kernel");
kernel2 = clCreateKernel(program, "k2", &error); kernel2 = clCreateKernel(program, "k2", &error);

View File

@@ -336,9 +336,8 @@ int test_cl_image_write(cl_context context, cl_command_queue queue,
get_explicit_type_name(*outType), suffix, convert); get_explicit_type_name(*outType), suffix, convert);
programPtr = kernelSource; programPtr = kernelSource;
if (create_single_kernel_helper_with_build_options( if (create_single_kernel_helper(context, &program, &kernel, 1,
context, &program, &kernel, 1, (const char **)&programPtr, (const char **)&programPtr, "sample_test"))
"sample_test", ""))
{ {
return -1; return -1;
} }

View File

@@ -557,8 +557,9 @@ int TestNonUniformWorkGroup::prepareDevice () {
if (_testRange & Range::BARRIERS) if (_testRange & Range::BARRIERS)
buildOptions += " -D TESTBARRIERS"; buildOptions += " -D TESTBARRIERS";
err = create_single_kernel_helper_with_build_options (_context, &_program, &_testKernel, 1, err = create_single_kernel_helper(_context, &_program, &_testKernel, 1,
&KERNEL_FUNCTION, "testKernel", buildOptions.c_str()); &KERNEL_FUNCTION, "testKernel",
buildOptions.c_str());
if (err) if (err)
{ {
log_error("Error %d in line: %d of file %s\n", err, __LINE__, __FILE__); 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) if (testRange & Range::BARRIERS)
buildOptions += " -D TESTBARRIERS"; buildOptions += " -D TESTBARRIERS";
err = create_single_kernel_helper_with_build_options (_context, &program, &testKernel, 1, err = create_single_kernel_helper(_context, &program, &testKernel, 1,
&KERNEL_FUNCTION, "testKernel", buildOptions.c_str()); &KERNEL_FUNCTION, "testKernel",
buildOptions.c_str());
if (err) if (err)
{ {
log_error("Error %d in line: %d of file %s\n", err, __LINE__, __FILE__); log_error("Error %d in line: %d of file %s\n", err, __LINE__, __FILE__);

View File

@@ -63,8 +63,8 @@ REGISTER_TEST(pipe_info)
log_info( " CL_PIPE_MAX_PACKETS passed.\n" ); log_info( " CL_PIPE_MAX_PACKETS passed.\n" );
} }
err = create_single_kernel_helper_with_build_options( err = create_single_kernel_helper(context, &program, &kernel, 1,
context, &program, &kernel, 1, &pipe_kernel_code, "pipe_kernel", &pipe_kernel_code, "pipe_kernel",
"-cl-std=CL2.0 -cl-kernel-arg-info"); "-cl-std=CL2.0 -cl-kernel-arg-info");
test_error_fail(err, "Error creating program"); test_error_fail(err, "Error creating program");