* 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>
* Make variables and functions local to translation unit
Make some global variables local to function, or remove them when
actually dead.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Address comments
Remove unused code.
Reduce scope of gDoubleCapabilities.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Remove code for runtime measurement
The GetTime() and associated functions are not fully implemented on
Linux. This functionality is assumed to be untested, or unused at best.
Reduce differences between tests by removing this unnecessary feature.
It can be (re-)implemented later, if desired, once the math_brute_force
component is in better shape.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Coalesce if-statements
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Keep else branch
Address comments.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
To reduce differences between tests, remove APPLE specific code from
unary tests as no other test have similar logic.
Ensure gMeasureTimes is consistently initialised regardless of operating
systems to ensure a consistent command line interface.
The remaining APPLE specific pieces of code relate either to include
paths, or to the implementation of PreventSleep(), ResumeSleep() and
GetTime(). Those are not removed in this commit.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Make signature of BuildKernel more consistent across tests: now only two
variants exist:
int BuildKernel(const char *name, int vectorSize, cl_kernel *k,
cl_program *p, bool relaxedMode)
or
int BuildKernel(const char *name/symbol, int vectorSize,
cl_uint kernel_count, cl_kernel *k, cl_program *p,
bool relaxedMode)
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Improve format.
The binary_operator tests are left untouched by this commit as they
require some non-automatic changes.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Code is moved to reduce the differences between tests for single- and
double-precision.
Improve consistency in double-literal.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Add assertion to prove isNextafter is true iff the builtin is nextafter()
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Fold functions for nextafter
There is no need to differentiate nextafter() from other binary builtin
functions when creating the vtbl entries.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Improve math_brute_force kernels by consistently using size_t to store
the result of get_global_id().
This change was missed in 5d7be40e (Remove undesired conversions from
size_t to int (#1153), 2021-02-11).
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Because specialValuesInt2Count < specialValuesIntCount (when correctly
computed), there was no out-of-bound access when running the tests. This
also means additional cases will be covered now that the typo is fixed.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>