Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ endif(USE_CL_EXPERIMENTAL)

option(SANITIZER_THREAD "Build with the thread sanitiser" OFF)
if (SANITIZER_THREAD)
add_compile_options(-fsanitize=thread)
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer)
add_link_options(-fsanitize=thread)
endif (SANITIZER_THREAD)

option(SANITIZER_ADDRESS "Build with the address sanitiser" OFF)
if (SANITIZER_ADDRESS)
add_compile_options(-fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
endif (SANITIZER_ADDRESS)

#-----------------------------------------------------------
# Default Configurable Test Set
#-----------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions test_common/harness/testHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#if !defined(_WIN32)
#include <sys/utsname.h>
#include <sys/time.h>
#include <unistd.h>
#endif

Expand Down Expand Up @@ -319,7 +320,13 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
/* How are we supposed to seed the random # generators? */
if (argc > 1 && strcmp(argv[argc - 1], "randomize") == 0)
{
#ifdef _WIN32
gRandomSeed = (cl_uint)time(NULL);
#else
struct timeval TV = { 0 };
gettimeofday(&TV, NULL);
gRandomSeed = TV.tv_usec;
#endif
log_info("Random seed: %u.\n", gRandomSeed);
gReSeed = 1;
argc--;
Expand Down Expand Up @@ -914,6 +921,7 @@ void callTestFunctions(test_definition testList[],
for (auto th : threads)
{
th->join();
delete th;
}
assert(gTestQueue.size() == 0);
}
Expand Down
2 changes: 2 additions & 0 deletions test_conformance/SVM/test_byte_granularity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ REGISTER_TEST(svm_byte_granularity)
for (cl_uint i = 0; i < num_devices; i++)
clSVMFree(context, error_counts[i]);

free(error_counts);

if (failed) return -1;
return 0;
}
19 changes: 14 additions & 5 deletions test_conformance/api/test_api_consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "harness/testHarness.h"
#include "harness/deviceInfo.h"


static const char* test_kernel = R"CLC(
__kernel void test(__global int* dst) {
dst[0] = 0;
Expand Down Expand Up @@ -940,14 +941,22 @@ REGISTER_TEST_VERSION(consistency_il_programs, Version(3, 0))
// clCreateProgramWithIL
// Returns CL_INVALID_OPERATION if no devices in context support
// Intermediate Language Programs.

// May return also CL_INVALID_VALUE if SPIR-V validity is checked
// before testing device support
cl_uint bogus = 0xDEADBEEF;
clProgramWrapper ilProgram =
clCreateProgramWithIL(context, &bogus, sizeof(bogus), &error);
test_failure_error(
error, CL_INVALID_OPERATION,
"Device does not support IL Programs but clCreateProgramWithIL did "
"not return CL_INVALID_OPERATION");

if (error != CL_INVALID_VALUE && error != CL_INVALID_OPERATION)
{
log_error("ERROR: %s! (Got %s, expected (%s) from %s:%d)\n",
"Device does not support IL Programs but"
"clCreateProgramWithIL did not return accepted value",
IGetErrorString(error),
"CL_INVALID_OPERATION or CL_INVALID_VALUE", __FILE__,
__LINE__);
return TEST_FAIL;
}

// clSetProgramSpecializationConstant
// Returns CL_INVALID_OPERATION if no devices associated with program
Expand Down
4 changes: 2 additions & 2 deletions test_conformance/api/test_api_min_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ REGISTER_TEST(min_max_read_image_args)
size_t maxParameterSize;
cl_event event;
cl_int event_status;
cl_float image_data[4 * 4];
cl_float image_data[4 * 4 * 4]; // 4 x 4 RGBA
float image_result = 0.0f;
float actual_image_result;
cl_uint minRequiredReadImages = gIsEmbedded ? 8 : 128;
Expand Down Expand Up @@ -1131,7 +1131,7 @@ REGISTER_TEST(min_max_image_buffer_size)
streams[1] =
create_image_1d(context, CL_MEM_READ_ONLY, &image_format_desc,
maxDimensionPixels, 0, NULL, streams[0], &error);
if ((streams[0] == NULL) || (error != CL_SUCCESS))
if ((streams[1] == NULL) || (error != CL_SUCCESS))
{
print_error(error,
"1D Image from buffer creation failed for maximum image "
Expand Down
19 changes: 12 additions & 7 deletions test_conformance/api/test_kernel_arg_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,33 +542,38 @@ size_t get_param_size(const std::string& arg_type, cl_device_id device,
}

size_t ret(0);
/* "signed" and "unsigned" type names are valid (int is implied) */
if (arg_type.find("signed") != std::string::npos)
Comment on lines +545 to +546
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this guaranteed to be valid? Neither signed nor unsigned (without the int) are listed in https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#built-in-scalar-data-types.

Copy link
Copy Markdown
Contributor Author

@franz franz Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, i didn't check the list of the builtin scalar data types; however, in the code of the test, there is "signed" and "unsigned" (both without int) in the std::vector returned from method generate_all_type_arguments(cl_device_id device) and then the code calls get_param_size on each element of that vector.

I don't remember exactly, but IIRC the problem was that the get_param_size returned 0 for both these "implied int" types, and as a result total_param_size was miscalculated by 8 bytes, which then triggered an error because the actual total size of arguments was over limit, when used with SPIR-V compilation mode. IIRC Clang doesn't really care about PoCL's argument-related limits, so it will accept larger actual arguments, but the SPIRV translation path isn't so forgiving. I could try to recreate the error & get more details if you'd like.

{
ret = sizeof(cl_int);
}
if (arg_type.find("char") != std::string::npos)
{
ret += sizeof(cl_char);
ret = sizeof(cl_char);
}
if (arg_type.find("short") != std::string::npos)
{
ret += sizeof(cl_short);
ret = sizeof(cl_short);
}
if (arg_type.find("half") != std::string::npos)
{
ret += sizeof(cl_half);
ret = sizeof(cl_half);
}
if (arg_type.find("int") != std::string::npos)
{
ret += sizeof(cl_int);
ret = sizeof(cl_int);
}
if (arg_type.find("long") != std::string::npos)
{
ret += sizeof(cl_long);
ret = sizeof(cl_long);
}
if (arg_type.find("float") != std::string::npos)
{
ret += sizeof(cl_float);
ret = sizeof(cl_float);
}
if (arg_type.find("double") != std::string::npos)
{
ret += sizeof(cl_double);
ret = sizeof(cl_double);
}
if (arg_type.back() == '2')
{
Expand Down
1 change: 1 addition & 0 deletions test_conformance/basic/test_image_multipass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ REGISTER_TEST(image_multipass_integer_coord)

}
free_mtdata(d); d = NULL;
free(expected_output);
expected_output = generate_expected_byte_image(input_data, num_input_streams, img_width, img_height, 4);
for ( i = 0; i < num_input_streams; i++)
{
Expand Down
1 change: 1 addition & 0 deletions test_conformance/buffers/test_buffer_migrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ REGISTER_TEST(buffer_migrate)
if (bufferA) free(bufferA);
if (bufferB) free(bufferB);
if (bufferC) free(bufferC);
free_mtdata(d);

return ((failed) ? -1 : 0);
}
1 change: 1 addition & 0 deletions test_conformance/buffers/test_image_migrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ REGISTER_TEST(image_migrate)
if (imageA) free(imageA);
if (imageB) free(imageB);
if (imageC) free(imageC);
free_mtdata(d);

return ((failed) ? -1 : 0);
}
1 change: 1 addition & 0 deletions test_conformance/contractions/contractions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ test_status InitCL( cl_device_id device )
// reference result computation (see DisableFTZ call above)
RestoreFPState(&oldMode);
}
free(bufSkip);
}

char c[1000];
Expand Down
6 changes: 6 additions & 0 deletions test_conformance/events/test_waitlists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ static int test_waitlist(cl_device_id device, cl_context context,
log_info("WARNING: Reference event(s) already completed before we "
"could execute test event! Possible that the reference event "
"blocked (implicitly passing)\n");
// necessary to execute these to avoid memleak with UnmapBufferAction
if (PRINT_OPS) log_info("\tExecuting action to test...\n");
error = actionToTest->Execute(queue, (multiple) ? 2 : 1, &events[0],
&events[2]);
test_error(error, "Unable to execute test event");

return 0;
}

Expand Down
8 changes: 3 additions & 5 deletions test_conformance/images/clFillImage/test_fill_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,9 @@ int test_fill_image_generic( cl_context context, cl_command_queue queue, image_d

// Unmap the image.
error = clEnqueueUnmapMemObject(queue, image, mapped, 0, NULL, NULL);
if (error != CL_SUCCESS)
{
log_error( "ERROR: Unable to unmap image after verify: %s\n", IGetErrorString( error ) );
return -1;
}
test_error(error, "ERROR: Unable to unmap image after verify");
error = clFinish(queue);
test_error(error, "clFinish() returned error");

imgHost.reset(0x0);
imgData.reset(0x0);
Expand Down
11 changes: 4 additions & 7 deletions test_conformance/math_brute_force/reference_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3356,13 +3356,10 @@ long double reference_rintl(long double x)
// mantissa can represent more than LDBL_MANT_DIG binary digits.
x = rintl(x);
#else
static long double magic[2] = { 0.0L, 0.0L };

if (0.0L == magic[0])
{
magic[0] = scalbnl(0.5L, LDBL_MANT_DIG);
magic[1] = scalbnl(-0.5L, LDBL_MANT_DIG);
}
const long double magic[2] = {
9223372036854775808.0L, // scalbnl(0.5L, LDBL_MANT_DIG)
-9223372036854775808.0L // scalbnl(-0.5L, LDBL_MANT_DIG)
};

if (reference_fabsl(x) < magic[0] && x != 0.0L)
{
Expand Down
11 changes: 8 additions & 3 deletions test_conformance/run_conformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ def run_tests(tests):
run_time = (time.time() - start_time)

# Move print the finish status
# TEST_SKIP = 2, TEST_SKIPPED_ITSELF = -100
if result == 0:
print("(" + get_time() + ") PASSED " + test_name.ljust(40) + ": (" + str(int(run_time)).rjust(3) + "s, test " + str(test_number).rjust(3) + os.sep + str(len(tests)) + ")", end='')
else if result == 2 or result == -100:
print("(" + get_time() + ") SKIPPED " + test_name.ljust(40) + ": (" + str(int(run_time)).rjust(3) + "s, test " + str(test_number).rjust(3) + os.sep + str(len(tests)) + ")", end='')
else:
print("(" + get_time() + ") FAILED " + test_name.ljust(40) + ": (" + str(int(run_time)).rjust(3) + "s, test " + str(test_number).rjust(3) + os.sep + str(len(tests)) + ")", end='')

Expand All @@ -265,13 +268,15 @@ def run_tests(tests):
log_file.flush()

print("")
if result != 0:
if result == 0:
log_file.write(" (" + get_time() + ") Test " + test_name + " passed in " + str(run_time) + "s\n")
else if result == 2 or result == -100:
log_file.write(" (" + get_time() + ") Test " + test_name + " skipped in " + str(run_time) + "s\n")
else:
log_file.write(" *******************************************************************************************\n")
log_file.write(" * (" + get_time() + ") Test " + test_name + " ==> FAILED: " + str(result) + "\n")
log_file.write(" *******************************************************************************************\n")
failures = failures + 1
else:
log_file.write(" (" + get_time() + ") Test " + test_name + " passed in " + str(run_time) + "s\n")

log_file.write(" ----------------------------------------------------------------------------------------\n")
log_file.write("\n")
Expand Down
Loading