Simplify code by avoiding manual resource management.
This fixes use of an uninitialized `d` in the `free_mtdata` call, in
the case a `goto exit` was executed before initializing `d`.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
There is no particular reason to limit the domain of unsigned 32-bit
integers in the input, so use genrand_int32 directly.
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
Align `verify_data` with `checker_image_mem_host_read_only.hpp`, that
is, take an explicit pointer to compare against.
Add a missing (but unused) `float` parameter to
`KernelArgSampler::compare`.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Xcode 14 deprecated functions such as `sprintf` which is used in many
places. As an immediate fix for the pre-commit checks, disable
deprecated function warnings when building for macOS.
Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/1626
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* grab latest from upstream OpenCL
* Removed events for host to device data transfers
* grab latest from upstream OpenCL
* 1.) revert changes to CMakeLists.txt and run_batch script in hopes this will solve the CI issues for the PR.
2.) resolve the merge conflict in test_conversions.cpp
* 1.) resolve 2 additional merge conflicts
* 1.) resolve 1 additional merge conflicts
* locally this fails clang-format but CI version seems to require it.
* fix the warning.
* Remove now-unused event
Also, cut down a comment that is no longer accurate.
Co-authored-by: Joshua Luceno <joshualuceno@gmail.com>
Co-authored-by: Chip Davis <chip@holochip.com>
Co-authored-by: Chip Davis <cdavis5x@gmail.com>
* grab latest from upstream OpenCL
* Use clEnqueueFillBuffer rather than memset4 in all test files
* Cleanup leftover code from memset_pattern4
* Remove unnecessary map, unmap, writeBuffer from math_brute_force tests
* Remove extraneous build system change
* Appease clang-format
* Add option to perform buffer fills on the host
Co-authored-by: Taeten Prettyman <taeten.j@gmail.com>
Co-authored-by: taetenp <taet@holochip.com>
Co-authored-by: Chip Davis <chip@holochip.com>
* Added on-device reset for half
* run clang-format.
* test_half - Reset buffer with ushort rather than half type
* Half - update type in secondary reset kernel src
* Remove useless memset() calls.
* Add an option to still perform buffer resets on the host
* Check for program generation failure before attempting to create the kernel
* Don't exceed the range of a ushort when storing
* Appease clang-format
Co-authored-by: Joshua Luceno <joshualuceno@gmail.com>
Co-authored-by: taetenp <taet@holochip.com>
Co-authored-by: Chip Davis <chip@holochip.com>
print_hex_mem_dump was calling `sprintf` with source and destination
buffers overlapping, which is explicitly forbidden. Rewrite the
function to use C++ stringstreams instead.
This commit only affects the error path and does not change the
printed output. Error logs before and after this commit should not
differ.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
It only contains a pointer type definition for test functions that
really ought to be provided by testHarness.h.
Signed-off-by: Kévin Petit <kpet@free.fr>
Signed-off-by: Kévin Petit <kpet@free.fr>
Fail when an unhandled image format is encountered instead of
continuing validation with uninitialized variables.
Fixes a `-Wsometimes-uninitialized` warning for e.g. the `tolerance`
variable.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Simplify code by relying on RAII to free resources.
This commit only affects tests that use `BuildKernelInfo2`, which are
the single-threaded tests.
Original patch by Marco Antognini.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
`BufferAction::Setup` has an additional parameter `allocate` which
hides the virtual function `Action::Setup`. The additional parameter
was unused anyway, so remove it.
Fixes a -Woverloaded-virtual warning.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Replace repetitions of extensions_supported[num_of_supported_extensions]
with a single pointer variable.
Replace character-by-character comparisons with a new string_has_prefix
function.
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
Move functions in .h files to .cpp files where appropriate; align
prototypes and definitions; and remove functions that are not used.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* very basic test infrastructure
* move test to integer_ops
* added bitfield_reverse test
* added test for bitfield insert
* add a separate file for bitfield_extract
* cleaned up implementation and all tests are passing
* rename helper file so it can be used by other tests
* remove temporary hacks
* fix formatting
* address code review comments
* remove duplicated code after rebase
* fix formatting
a few naming changes for consistency
more changes for consistency
* fix copyright dates
* remove unused variable
So we get finer grain reporting and better parallelisation in the future.
Signed-off-by: Kévin Petit <kpet@free.fr>
Signed-off-by: Kévin Petit <kpet@free.fr>
Remove a misleading comment at the end. Improve comments in general,
and use `true`/`false` for `bool`s.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
It seems the intent was to use `.xyzw` vector component accessors in
the kernel whenever `vecSize` is 2, 3, or 4. The condition was wrong
(i.e., always true for any value of `vecSize`), causing it to always
create a kernel with numeric (`.s0123...`) vector component accessors.
The restriction on the use of `.xyzw` for 8 and 16-component vectors
has been lifted a while ago (see
https://github.com/KhronosGroup/OpenCL-Docs/issues/549) so we do not
need this check at all.
Also, fix the `vecSize` argument of two calls of `get_order_string`
when getting the order string for the "in" kernel argument. Pass
`inVecSize` in these cases, not `outVecSize`.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Simplify code by relying on RAII to free resources. Reduce code
duplication.
This commit only affects tests that use `BuildKernelInfo`, which are
the multi-threaded tests. Another patch will deal with the
single-threaded tests, i.e., those using `BuildKernelInfo2`.
Original patch by Marco Antognini.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
`std::exception` and `std::runtime_error` are polymorphic types and as
such they shouldn't be passed by value.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* Remove invalid assumption from sub-group tests
The sub-group dispatch tests were making the invalid assumption that
querying the local size (via `CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT`)
for a sub-group count obtained from a
`CL_KERNEL_SUB_GROUP_COUNT_FOR_ND_RANGE` with local size `{x, y, z}`
will result in the same local size i.e. that
`CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT` is the inverse of
`CL_KERNEL_SUB_GROUP_COUNT_FOR_ND_RANGE`. To take a trivial example
consider the case that there is only ever one sub-group per work
group(i.e. sub-group == work-group). Then regardless of the local size
passed to `CL_KERNEL_SUB_GROUP_COUNT_FOR_ND_RANGE` the sub-group count
will always be `1`, and `CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT` can
return any valid local size since all local sizes result in `1`
sub-group.
* Format surrounding changes
Conformance tests should not assume support for OpenCL 2.0, or specific
features. This patch removes uses of
`__opencl_c_program_scope_global_variables` for devices which do not
support it in the generic address space conformance tests. Additionally,
the `clCompileProgram` options have been updated to select between
`CL2.0` and `CL3.0` depending on which the device under test supports.
Co-authored-by: Amy Worthington <amy@codeplay.com>
The main source of warnings was the use of `%d` for printing a
templated type `T`, where `T` could be any cl_ scalar or vector type.
Introduce `print_expected_obtained`. It takes const references to
handle alignment of the cl_ types.
Define `operator<<` for all types used by the subgroup tests. Ideally
those would be template functions enabled by TypeManager data, but
that requires some more work on the TypeManager (which we'd ideally do
after more warnings have been enabled). So for now, define the
`operator<<` instances using preprocessor defines.
Also fix a few instances where the wrong format specifier was used for
`size_t` types.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* Deduplicate write_image
Merge writeimage,writeimage_int16,writeimage_fp32
as they share a lot of common code.
Signed-off-by: John Kesapides <john.kesapides@arm.com>
* Test for CL_MEM_WRITE_ONLY and CL_MEM_READ_WRITE.
Signed-off-by: John Kesapides <john.kesapides@arm.com>
* Rename test_flags to img_flags
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Signed-off-by: John Kesapides <john.kesapides@arm.com>
While testing an OpenCL driver with ThreadSanitizer enabled the
OpenCL-CTS suffers from thread leaks in conversions and bruteforce on
posix systems. This is because `pthread_join` is never called in
`ThreadPool_Exit` for the `pthread_t`s created by the thread pool.
Instead, the threads are only informed to stop waiting on the condition
variable which unblocks the worker thread but does not clean up after
itself.
```
ThreadPool: thread 1 exiting.
ThreadPool: thread 5 exiting.
ThreadPool: thread 4 exiting.
ThreadPool: thread 2 exiting.
ThreadPool: thread 7 exiting.
ThreadPool: thread 0 exiting.
ThreadPool: thread 3 exiting.
ThreadPool: thread 6 exiting.
Thread pool exited in a orderly fashion.
==================
WARNING: ThreadSanitizer: thread leak (pid=2292842)
Thread T9 (tid=2292855, finished) created by main thread at:
#0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x5ad75)
#1 ThreadPool_Init() <null> (test_conversions+0x35b2c)
#2 pthread_once ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1449 (libtsan.so.0+0x4057c)
#3 GetThreadCount() <null> (test_conversions+0x36262)
#4 DoTest(_cl_device_id*, Type, Type, SaturationMode, RoundingMode, _MTdata*) [clone .isra.0] <null> (test_conversions+0x10555)
#5 test_conversions(_cl_device_id*, _cl_context*, _cl_command_queue*, int) <null> (test_conversions+0x13226)
#6 callSingleTestFunction(test_definition, _cl_device_id*, int, int, unsigned long) <null> (test_conversions+0x2e66d)
#7 parseAndCallCommandLineTests(int, char const**, _cl_device_id*, int, test_definition*, int, unsigned long, int) <null> (test_conversions+0x2fb3a)
#8 runTestHarnessWithCheck(int, char const**, int, test_definition*, int, unsigned long, test_status (*)(_cl_device_id*)) <null> (test_conversions+0x349d8)
#9 main <null> (test_conversions+0xd725)
And 7 more similar thread leaks.
SUMMARY: ThreadSanitizer: thread leak (OpenCL-CTS/buildbin/conversions/test_conversions+0x35b2c) in ThreadPool_Init()
```
This patch adds global state to keep track of the `pthread_t`s created
by `pthread_create` in `ThreadPool_Init`. The list of `pthread_t`s is
then used by `ThreadPool_Exit` to call `pthread_join` to cleanup the
`pthread_t`s correctly.
A near identical example, and additional explanation, can be found on
[stackoverflow](https://stackoverflow.com/questions/72435574/thread-leak-detected-when-using-condition-variable-instead-of-join-with-pthrea).
On the Windows path, a similar change is not necessary because
`_beginthread` is used which automatically cleans up after itself when
the worker thread function returns.
Also use log_info instead of printf for skipped tests, for consistency.
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
`CMAKE_CXX_STANDARD` is already set in the top-level CMakeLists.txt
file, so there is no need to have it repeated for individual modules.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Merge readimage,readimage_int16,read_image_fp32,
readimage3d,readimage3d_int16,read_image3d_fp32
as they share a lot of common code.
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Merge fpmath_float,fpmath_float2,fpmath_float4
as they share a lot of common code.
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Fix a few instances where an incorrect number of arguments was
supplied when calling (v)log_error.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Use common functions to create the kernel source code for testing
1-argument and 2-argument math builtins. This reduces code duplication.
Use appropriate patterns to initialise variables to their full bit
widths. For example, `0xdead` was previously used to initialise 32-bit
integers, while now a larger number spanning all bytes is used.
Co-authored-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Co-authored-by: Marco Antognini <marco.antognini@arm.com>
Allow enabling/disabling building of the Vulkan interop tests via CMake
option without modifying the CMake. This matches the optionality of the
D3D10, D3D11, GL, and GLES interop tests.