* 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>
* Split math_brute_force files
Split each file into two: one covering float and the other covering
double. The goal is to make it possible to diff files to identify bugs
more easily, reduce differences between code for float and double, and
ultimately reduce code duplication in all math_brute_force.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Address clang-format issues
In be936303 (Remove dead code in math_brute_force (#1117), 2021-01-20)
the code was reformatted using git-clang-format, which apparently is less
reliable than clang-format itself when changes occur in large files.
With the previous split of large files, git-clang-format complains about
the format of code originating from binary_two_results_i.cpp.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
This issue was introduced in 8ad1088a (Reduce difference between files
in math_brute_force (#1138), 2021-02-10).
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Moves `if (!gSkipCorrectnessTesting)` in binary_i.cpp to follow
structure of binary.cpp, unary.cpp, macro_unary.cpp and
macro_binary.cpp.
Other non-semantic changes include adding/removing new lines and
updating comments.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
When creating sub-buffers in math_brute_force, the wrong variables were
checked for runtime errors. This patch fixes this and ensures the logs
are consistent.
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().
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Reduce differences between files
This will help reduce code duplication is future commits.
Some code is moved around, some variables are renamed and some
statements are slightly altered to reduce differences between files in
math_brute_force, yet the semantics remains the same.
The differences were identified using n-way diffs. Many differences
remain however.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
* Workaround clang-format limitation
Introduces some insignificant spaces to force clang-format to reduce the
indentation and reduce differences between files.
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Ensure the following forms of command lines are supported, as per usage
message (-h):
- math_brute_force [<name1> [<name2> ... [<nameN>]]]
- math_brute_force I [J]
Remove dead/unnecessary code.
Fix regression introduced in f337e0b6 ( Fix command-line function range
for bruteforce (#1127), 2021-01-29).
Signed-off-by: Marco Antognini <marco.antognini@arm.com>