fixes#2145
As suggested by @svenvh reciprocal has different precision requirements
than divide. This PR introduces special path for reciprocal for
binar_float_operator to test reciprocal with relaxed math. If this PR
will get approvals, invalidate PR #2162
In the half-precision `fdim` test, the original code used `CL_HALF_RTE`
to convert the float result back to half, causing a mismatch in
computation results when the hardware uses RTZ. Some of the examples:
```
fdim(0x365f, 0xdc63) = fdim( 0.398193f, -280.75f) = 281.148193f (RTE=0x5c65, RTZ=0x5c64)
fdim(0xa4a3, 0xf0e9) = fdim(-0.018112f, 10056.0f) = 10055.981445f (RTE=0x70e9, RTZ=0x70e8)
fdim(0x1904, 0x9ab7) = fdim( 0.002449f, -0.003279f) = 0.005728f (RTE=0x1dde, RTZ=0x1ddd)
```
Fixed this by using the hardware's default rounding mode when converting
the result back to half.
- to be able to have deterministic results it is useful to have a
mechanism
to force the same count of workers
- this commit doesn't change the default settings but expands
functionality
Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
Currently Intel® C++ Compiler Classic (ICC) is supported to build
OpenCL-CTS on Windows. This compiler has been discontinued since the
second half of 2023. Instead, Intel recommends that users transition to
use the LLVM-based Intel® oneAPI DPC++/C++ Compiler (ICX).
This change is to enable users to build OpenCL-CTS with ICX on Windows.
Replace the occurrences of 0.0f == test' with 0.0f == HTF(test)'. The
types of 0.0f and test are not the same, so the equality comparison will
get undesired result when the test represents a -0.0h (i.e., test is
32768=0x8000). In this situation, 0.0f == test will be false, but 0.0f
== HTF(test) will be true.
Revise each if-statement to match the OpenCL s7.5.3 Item 4, specifically
modify to check that the result is subnormal instead of checking that it
is zero. "If the result of 3. is a sub-normal before rounding, the
result may be flushed to zero"
Co-authored-by: tnimburk <tnimburk@qti.qualcomm.com>
Comparing test (of type cl_half) with 0.0f is incorrect because cl_half
is a typedef of uint16_t (or unsigned short in c)
Co-authored-by: Tejswini Nimburkar <tnimburk@qti.qualcomm.com>
It was disabled because lack of reference implementation. However the
reference implementation exists. Then no reason to start testing these
functions.
All of these are already set in the top-level `CMakeLists.txt` nowadays,
so no need to repeat them in the test's own `CMakeLists.txt`.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
The various forms of `TestInfoBase` have many members in common, so
avoid duplicating the struct definition and move it to `common.h`.
Provide a description and initializer for every struct member, and drop
initializations done with `memset`.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This makes it literally impossible for drivers to constant fold the
IsTininessDetectedBeforeRounding kernel. Sure, drivers might have should
respect volatile here, but I'm not convinced this is actually required
by the spec in a very strict sense, because here there are no
side-effects possible in the first place.
And as far as I know, constant folding is allowed to give different
results than an actual GPU calculation would.
In any case, passing the constants via kernel arguments makes this
detection more reliable and one doesn't have to wonder why the fma test
is failing.
Side note: this was the last bug (known as of today) I had to fix in
order being able to make a CL CTS submission for Apple Silicon devices.
Skip the correctly rounded divide (divide_cr) and sqrt (sqrt_cr) tests
for fp16 and fp64.
The corresponding build option to enable correctly rounded divide and
sqrt is named `-cl-fp32-correctly-rounded-divide-sqrt` and the
description refers only to "single precision floating-point", so this
option should not apply to fp16 or fp64.
The specification states that fp16 and fp64 divide and sqrt must be
correctly rounded for the full profile, without needing any additional
build options. This is already tested by the regular divide and sqrt
tests. For the embedded profile the ULP requirement is non-zero, but
there is no build option to request a correctly rounded implementation
anyway.
Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1901 .
Relates to https://github.com/KhronosGroup/OpenCL-CTS/issues/1996 .
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
The math_brute_force test has a link-check-only mode to quickly test if
all math functions are present.
In link-check-only mode, most tests return immediately after kernel
compilation, but some tests also run the kernel and read back the result
data before returning. Running the kernels takes a lot more time,
defeating the purpose of the `-l` mode.
Break out at the start of the main `for` loops in link-check-only mode
instead of returning directly, so that each test can still log its
trailing message (in most cases just a `\n`).
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
The `skipTestingRelaxed` check suffers the following problems:
- The use of `skipTestingRelaxed` in the `if` seems reversed: when
skipping correctness testing using the `-l` command line option, this
variable causes correctness testing to be run for relaxed-mode `tan`
regardless.
- Accuracy testing should only be skipped for derived `tan`
implementations. Non-derived `tan` implementations must still be tested
for accuracy, so the condition for setting the `skipTestingRelaxed`
variable is incomplete.
- It is unclear why only `tan` is conditionalized here. There are other
functions such as `tanpi` for which one would expect identical
behaviour.
The actual skipping of accuracy checks for derived implementations
happens in `Test()`, so just remove `skipTestingRelaxed` as it does not
seem to add any value.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
clang-format has already been disabled here. Make the function list a
bit easier to read. Make the currently commented out functions stand out
better on a line of their own.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
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>