In binary_float.cpp, copysign is special cased. All the reference
functions there take double arguments, except for reference_copysign
which takes float. This commit copies that approach to special case
copysign in binary_double.cpp as well: all the reference functions there
take long double arguments, but this commit changes reference_copysignl
to take double. The rationale for this in binary_float applies equally
to binary_double: conversions of NAN are not required to preserve its
sign bit. On architectures where conversion of NAN resets the sign bit,
copysign fp64 would return incorrect reference results.
When the math brute force test printed the platform version it always
printed information for the first platform in the system, which could
be different than the platform for the passed-in device. Fixed by
querying the platform from the passed-in device instead.
Fix the ULP error calculation for the `exp` and `exp2` builtins in
relaxed math mode for the full profile.
Previously, the `ulps` value kept being added to while verifying the
result buffer in a loop. `ulps` could even become a `NaN` when the
input argument being tested was a `NaN`.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* Fix enqueue_flags test to use correct barrier type.
Currently, enqueue_flags test uses CLK_LOCAL_MEM_FENCE.
Use CLK_GLOBAL_MEM_FENCE instead as all threads across work-groups
need to wait here.
* Add check for support for Read-Wrie images
Read-Write images have required OpenCL 2.x.
Read-Write image tests are already being skipped
for 1.x devices.
With OpenCL 3.0, read-write images being optional,
the tests should be run or skipped
depending on the implementation support.
Add a check to decide if Read-Write images are
supported or required to be supported depending
on OpenCL version and decide if the tests should
be run on skipped.
Fixes issue #894
* Fix formatting in case of Read-Write image checks.
Fix formatting in case of Read-write image checks.
Also, combine two ifs into one in case of
kerne_read_write tests
* Fix some more formatting for RW-image checks
Remove unnecessary spaces at various places.
Also, fix lengthy lines.
* Fix malloc-size calculation in test imagedim
unsigned char size is silently assumed to be 1
in imagedim test of test_basic.
Pass sizeof(type) in malloc size calculation.
Also, change loop variable from signed to unsigned.
Add checks for null pointer for malloced memory.
* Initial CTS for external sharing extensions
Initial set of tests for below extensions
with Vulkan as producer
1. cl_khr_external_memory
2. cl_khr_external_memory_win32
3. cl_khr_external_memory_opaque_fd
4. cl_khr_external_semaphore
5. cl_khr_external_semaphore_win32
6. cl_khr_external_semaphore_opaque_fd
* Updates to external sharing CTS
Updates to external sharing CTS
1. Fix some build issues to remove unnecessary, non-existent files
2. Add new tests for platform and device queries.
3. Some added checks for VK Support.
* Update CTS build script for Vulkan Headers
Update CTS build to clone Vulkan Headers
repo and pass it to CTS build
in preparation for external memory
and semaphore tests
* Fix Vulkan header path
Fix Vulkan header include path.
* Add Vulkan loader dependency
Vulkan loader is required to build
test_vulkan of OpenCL-CTS.
Clone and build Vulkan loader as prerequisite
to OpenCL-CTS.
* Fix Vulkan loader path in test_vulkan
Remove arch/os suffix in Vulkan loader path
to match vulkan loader repo build.
* Fix warnings around getHandle API.
Return type of getHandle is defined
differently based on win or linux builds.
Use appropriate guards when using API
at other places.
While at it remove duplicate definition
of ARRAY_SIZE.
* Use ARRAY_SIZE in harness.
Use already defined ARRAY_SIZE macro
from test_harness.
* Fix build issues for test_vulkan
Fix build issues for test_vulkan
1. Add cl_ext.h in common files
2. Replace cl_mem_properties_khr with cl_mem_properties
3. Replace cl_external_mem_handle_type_khr with
cl_external_memory_handle_type_khr
4. Type-cast malloc as required.
* Fix code formatting.
Fix code formatting to
get CTS CI builds clean.
* Fix formatting fixes part-2
Another set of formatting fixes.
* Fix code formatting part-3
Some more code formatting fixes.
* Fix code formatting issues part-4
More code formatting fixes.
* Formatting fixes part-5
Some more formatting fixes
* Fix formatting part-6
More formatting fixes continued.
* Code formatting fixes part-7
Code formatting fixes for image
* Code formatting fixes part-8
Fixes for platform and device query tests.
* Code formatting fixes part-9
More formatting fixes for vulkan_wrapper
* Code formatting fixes part-10
More fixes to wrapper header
* Code formatting fixes part-11
Formatting fixes for api_list
* Code formatting fixes part-12
Formatting fixes for api_list_map.
* Code formatting changes part-13
Code formatting changes for utility.
* Code formatting fixes part-15
Formatting fixes for wrapper.
* Misc Code formatting fixes
Some more misc code formatting fixes.
* Fix build breaks due to code formatting
Fix build issues arised with recent
code formatting issues.
* Fix presubmit script after merge
Fix presubmit script after merge conflicts.
* Fix Vulkan loader build in presubmit script.
Use cmake ninja and appropriate toolchain
for Vulkan loader dependency to fix
linking issue on arm/aarch64.
* Use static array sizes
Use static array sizes to fix
windows builds.
* Some left-out formatting fixes.
Fix remaining formatting issues.
* Fix harness header path
Fix harness header path
While at it, remove Misc and test pragma.
* Add/Fix license information
Add Khronos License info for test_vulkan.
Replace Apple license with Khronos
as applicable.
* Fix headers for Mac OSX builds.
Use appropriate headers for
Mac OSX builds
* Fix Mac OSX builds.
Use appropriate headers for
Mac OSX builds.
Also, fix some build issues
due to type-casting.
* Fix new code formatting issues
Fix new code formatting issues
with recent MacOS fixes.
* Add back missing case statement
Add back missing case statement
that was accidentally removed.
* Disable USE_GAS for Vulkan Loader build.
Disable USE_GAS for Vulkan Loader build
to fix aarch64 build.
* Fixes to OpenCL external sharing tests
Fix clReleaseSemaphore() API.
Fix copyright year.
Some other minor fixes.
* Improvements to OpenCL external sharing CTS
Use SPIR-V shaders instead of NV extension path
from GLSL to Vulkan shaders.
Fixes for lower end GPUs to use limited memory.
Update copy-right year at some more places.
* Fix new code formatting issues.
Fix code formatting issues with
recent changes for external sharing
tests.
* More formatting fixes.
More formatting fixes for recent
updates to external sharing tests.
* Final code formatting fixes.
Minor formatting fixes to get
format checks clean.
* Update extension list of test_compiler
Upate extension list of test_compiler
with missing external memory and semaphore
extensions
* Add ffp-contract=off Compilation flag for CTS build.
GCC defaults to using ffp-contract=fast even when fast math is disabled in the
case of GNU C
This creates precision issues when comparing the results with that of x86_64.
GNU options reference:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#
This fix is to disable floating-point expression contractions with
flag ffp-contract=off for math_brute_force tests
Fixes#1794
* Make fp-contract flag arch-independent, but compiler dependent
Use existing CMake constructs to add fp-contract flag
so that it automatically checks for compiler support.
Also, make this change arch-independent.
Fixes#1794
* Fix typo in earlier commit
Fix typo in earlier commit
Fixes#1794
* Remove duplicate addition of ffp-contract flag
ffp-contract flag is currently added via two macros
Retain add_cxx_flag_if_supported macro and remove
set_gnulike_module_compile_flags.
Fixes#1794
* Fix typo in earlier commit
Add closing " that was unintentionally removed in previous commit.
The suite's `main()` function already disables the FTZ mode prior to
invoking `runTestHarnessWithCheck` and restores the FP state
afterwards, so tests don't have to do so themselves.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Simplify code by returning directly instead of using goto statements.
Although intended as an NFC commit, this changes the behaviour when
verification fails: the output buffer is no longer unmapped. Although
not ideal, this aligns the behaviour of `macro_unary_float` to the
other math_brute_force tests.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Avoid a maybe-uninitialized warning by ensuring that `oldMode` is
always initialized to 0. There is no need to use `memset` for this,
as `FPU_mode_type` is either an `int` or an `int64_t`.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
The OpenCL specification states that the build log is only for
clBuildProgram, clCompileProgram or clLinkProgram. Calling it after
clCreateKernel should not give any additional information, so this is
effectively dead code. In case building failed, any logs would
already have been printed by create_single_kernel_helper.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
When generating the kernel code, consider the return type(s) and the
types of all parameters, instead of only the first parameter type.
This fixes a missing extension pragma for certain cases (such as
`nan`).
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Replace occurrences of `BuildKernelInfo2` with `BuildKernelInfo`.
This aligns the kernel creation code of the non-threaded tests to
the kernel creation code of the threaded tests.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* [NFC] Remove duplicate symbol declarations
Those are provided by testHarness.h.
Signed-off-by: Kévin Petit <kpet@free.fr>
* add missing include
---------
Signed-off-by: Kévin Petit <kpet@free.fr>
Simplify code by returning directly instead of using goto statements.
Although intended as an NFC commit, this changes the behaviour around
clFlush calls. Before this commit, failure of the third clFlush call
would print "clFlush 3 failed" and return the clFlush error code.
This behaviour is inconsistent with the other clFlush calls in
math_brute_force, which are not fatal. The lack of a `goto exit`
makes me suspect that this 3rd clFlush call was intended to be
non-fatal too. As such, this commit makes all clFlush calls non-fatal
by returning `CL_SUCCESS` even when the third clFlush call fails.
Original patch by Marco Antognini.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.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>
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>
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>
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>
Use a common function to create the kernel source code for testing
3-argument math builtins. This reduces code duplication. 1-argument
and 2-argument math kernel construction will be factored out in future
work.
Change the kernels to use preprocessor defines for argument types and
undef values, to make the CTS code easier to read.
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>
* math_brute_force: Fix -Wformat warnings
The main sources of warnings were:
* Printing of 64-bit types, which is now done using the `PRI*64`
macros from <cinttypes> to ensure portability across 32 and 64-bit
builds.
* Printing of `size_t` types that lacked a `z` length modifier.
* Printing of values with a `z` length modifier that weren't a
`size_t` type.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* [NFC] math_brute_force: clang-format after -Wformat changes
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Factor out a macro to set module-specific compilation flags for
GNU-like compilers. This simplifies setting compilation flags per
test.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
math_brute_force compiles cleanly with `-Wall` currently, so avoid
regressing from that state. Ideally we would enable `-Wall` in the
top-level CMakeLists.txt, but other tests do not compile cleanly with
`-Wall` yet.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Improve the design of the MTdataHolder wrapper:
* Make it a class instead of a struct with a private member, to make
it clearer that there is no direct access to the MTdata member.
* Make the 1-arg constructor `explicit` to avoid unintended
conversions.
* Forbid copy construction/assignment as MTdataHolder is never
initialised from an MTdataHolder object in the codebase.
* Define move construction/assignment as per the "rule of five".
Use the MTdataHolder class throughout math_brute_force, to simplify
code by avoiding manual resource management.
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>
* Fix "‘nadj’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]".
* Fix "specified bound 4096 equals destination size
[-Werror=stringop-truncation]".
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Remove unused variables throughout the code base and enable the
`-Wunused-variable` warning flag globally to prevent new unused
variable issues being introduced in the future.
This is mostly a non-functional change, with one exception:
- In `test_conformance/api/test_kernel_arg_info.cpp`, an error check
of the clGetDeviceInfo return value was added.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Commit 9666ca3c ("[NFC] Fix sign-compare warnings in math_brute_force
(#1467)", 2022-08-23) inadvertently changed the semantics of the if
condition. The `i > gEndTestNumber` comparison was relying on
`gEndTestNumber` being promoted to unsigned. When casting `i` to
`int32_t`, this promotion no longer happens and as a result any tests
given on the command line were being skipped.
Use an unsigned type for `gStartTestNumber` and `gEndTestNumber` to
eliminate the casts and any implicit conversions between signed and
unsigned types.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Simplify code by avoiding manual resource management.
This commit only modifies tests that use one queue per thread. The
other unmodified tests are single-threaded and use the global
`gQueue`.
Original patch by Marco Antognini.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Fixes a missing-field-initializers warning. The original intent was
most likely to initialize both fields (similar to other functions in
this file), but a `,` was missed.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Remove the `offset` field from both structures, because it was always
set to the global `gMinVectorSizeIndex`.
Improve documentation and rename some variables:
- `i` becomes `vectorSize`;
- `kernel_count` becomes `threadCount`.
Original patch by Marco Antognini.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Move the main `BuildKernelInfo` definition into `common.h` to reduce
code duplication.
Some tests (e.g. `i_unary_double.cpp`) use a different struct; rename
those structs to `BuildKernelInfo2` for now to avoid ambiguity.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Simplify code by avoiding manual resource management.
This allows removing clReleaseProgram from `MakeKernels` to reduce
behavioral differences between `MakeKernels` and `MakeKernel`.
Original patch by Marco Antognini.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* Fix math tests to allow ftz in relaxed mode.
In recent spec clarification, it is agreed that ftz is
a valid optimization in case of cl-fast-math-relaxed
and doesn't require cl-denorms-are-zero to be passed
explicitly to enforce ftz behavior for implementations
that already support this.
GitHub Spec Issue OpenCL-Docs#579
GitHub Spec Issue OpenCL-Docs#597
GitHub CTS Issue OpenCL-CTS#1267
* Avoid manual memory management
Prefer std::vector over malloc and free. This will allow removing goto
statements by leveraging RAII.
Use appropriate type (bool) to store overflow predicates and allocate
std::vector<bool> of appropriate sizes: before this change the
allocation was unnecessary bigger than required.
No longer attempt to catch "out of host memory" issues, given that in
such situation it is generally not possible to cleanly report an error.
Rely on std::bad_alloc exception to report such issues.
Introduce a new header for common code in the math_brute_force
component. It is currently complementary to utility.h and is expected to
hold cleaned up content extracted from future refactoring operations.
List all headers as source in CMake for better compatibility with IDEs.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Remove manual or unnecessary memset
In order to use non-POD types as fields of TestInfo, memset must be
replaced with a compatible zero-initialisation.
Remove an unnecessary memset in MakeKernels.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
A program having a type (such as ThreadInfo) defined differently in
multiple translation units exhibits undefined behaviour.
This commit fixes such issues in the math_brute_force component by
ensuring most types are local to their translation unit with the help of
anonymous namespaces. Later refactoring will be able to extract common
definitions to a single place.
This patch also removes unnecessary static and typedef keywords.
Otherwise, code is only moved around with no change.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Cleanup usage of static, extern and typedef
Remove static on functions defined headers, as it can result in
duplication in binaries.
Remove unnecessary extern keyword on a function declaration, as it is
the default behavior and can be puzzling when reading the code.
Remove the unused declaration of my_ilogb, which is never defined.
Remove unnecessary usage of typedef, as they are only increasing the
cognitive load of the code for no purpose.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Improve usage of inline and static in harness
Functions declared in header as static can trigger unused warnings when
(indirectly) included in translation units that do not use such
functions. Use inline instead, which also avoids duplicating symbols in
binaries.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Only nan() is tested by unary_u_float.cpp and unary_u_double.cpp.
Testing of half_sin, half_tan and half_cos is done in unary_float.cpp
and unary_double.cpp.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Fix heap-buffer-overflow reported by AddressSanitizer: ensure the
appropriate number of elements are allocated for the list of tests.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Builtin functions producing two results can have their worst error, for
each result, on different inputs. Report both inputs.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Make variables local to loops, with appropriate types. These variables
are not read after the loop without being reset first, so this patch
doesn't change behaviour.
These variables should now be used for one purpose only, making it
easier to reason about the code. This will make future refactoring
easier.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Remove CMake statements that have no effect in math_brute_force.
set_source_files_properties without a list of files has no effect.
When MODULE_NAME is FOO,
set_source_files_properties(${MODULE_NAME}_SOURCES ...) sets the
properties of "FOO_SOURCES", not of the files listed in the variable
named FOO_SOURCES.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
gWimpyBufferSize is never modified and is actually not used to modify
the number of tests -- gWimpyReductionFactor is used for that purpose by
some tests, but not all.
This patch removes this unnecessary global variable to simplify the
codebase, and reduce differences between tests.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Use one loop to read buffers from device, with the last read operation
blocking until complete.
This pattern cannot be elegantly refactored just yet, mainly for two
reasons:
- Some tests use goto statements to clean their resources.
- Some tests (not modified in this patch) only use blocking read
operations.
Once code is further unified, this pattern can be refactored into a
helper function.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>