Removes `using namespace std` and adds `std::` explicitly instead, which
is usually on calls to `min`.
This is generally best practice, and it also might be helpful when there
are the same function names in the std namespace and in the global
namespace (e.g. #1833).
All existing tests in `test_image_streams`, that are capable of testing
image formats using the `CL_UNORM_INT_2_101010_EXT` data type, do so.
Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
Fixes narrowing conversion build errors in test_common
Removing disable of narrowing errors in main CMakeLists.txt
and moving it down to specific test_conformance suite's
CMakeLists.txt where there are many more build errors revealed
from this fix.
Fixes a few simple issues under test_conformance in the process.
Contributes #787
Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
---------
Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
Fixes:
1. Multi import diff ctx subtest which acquires/releases external memory
via queue not associated with the context in which memory was imported.
2. Platform/Device info subtests to handle different platforms and
availability of the query.
glutInit double called in CTS CLGL test case code, which will lead
to an error:
freeglut (./test_gl): illegal glutInit() reinitialization attempt
root cause is in: test_conformance/gl/main.cpp:343
if (glEnv->Init(&argc, (char **)argv, CL_TRUE))
the glEnv->Init has already called in same file line:260, the function
glutInit in glEnv->Init can not be called twice, then a error will occur
although all the gl / CLGL cases are passed. Then in the full quick CTS
running it will appear:
(12-Jul 03:54:01) BEGIN OpenCL-GL Sharing :
PASSED sub-test.
PASSED 23 of 23 tests.
(12-Jul 04:01:48) FAILED OpenCL-GL Sharing : (467s, test 34/53)
Although all the gl/CLGL cases are passed, but this group test is judged
to failed.
This issue already been found in
https://github.com/KhronosGroup/OpenCL-CTS/pull/1885
And fixed partly by:
02471c8f56
But I found in setup_osx.cpp, the glutInit still has double init issue,
I add the same fix like previous fix,
can you please help to review?
Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>
Co-authored-by: Honglei Huang <Honglei1.Huang@amd.com>
Include `cmath` instead of `math.h` in C++ mode under MSVC, to avoid
build errors inside the header. Ideally we would not condition this
on `_MSC_VER`, but issue 1833 currently prevents doing so.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Basic explicit_s2v:
The verification step was always using round to even when converting a
float to half even for round to zero cores.
Commonfns degrees:
The verification step was only taking into account infinities and not
values that over/underflow. This resulted in an incorrect error
calculation. E.g:
double cpu_result = 175668.85998711039;
cl_half gpu_result = 31743; // this is 65504 when converting to float,
we overflowed.
float error = (cpu_result - gpu_result) * some_factor;
The fix adds the check if( (cl_half) reference == test ) before
calculating the error.
Some conformance tests use directly the size returned by the runtime
for max memory size to allocate buffers.
This doesn't leave enough memory for the system to run the tests.
Currently we don't escape subnormal values when generating image data.
In sampler read tests, we use `!=` to check the two values even when it
is floating-point data, which requires the two values are bitwise equal.
However, a sampler might flush subnormal values, causing the test case
to fail.
In this patch, when generating random image data, we escape subnormal
values.
* cl_copy_images
* cl_get_info
* cl_fill_image
* cl_read_write_image
* kernel_image_methods
* IMAGE1D_BUFFER cannot be created with (USE_|ALLOC_|COPY_)_HOST_PTR
* do not allow mipmap with 1D buffer
* adjust M to be within maximum_sizes and max_pixels
* remove unused variables
* make sure M will never be 0
* fix region[0] after refactoring removing mipmap
* fix formatting
* format with clang-format-11
* fix image1d_buffer creation with gEnablePitch
* add missing case in switch
* use align_malloc when CL version is at least 2.0
* use CL_DEVICE_NUMERIC_VERSION and align_free
* fix free of pitch buffer
* fix formatting
* fix formatting
* fix data->is_aligned
Add support for `CL_UNORM_INT_101010_2` in the `get_pixel_size` helper
function. This fixes the following tests:
* memInfo_image_from_buffer_positive
* image_from_buffer_alignment_negative
* imageInfo_image_from_buffer_positive
Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
* basic SPIR-V 1.3 testing support
* updated script to compile for more SPIR-V versions
* switch to general SPIR-V versions test
* update copyright text and fix license
* improve output while test is running
* check for higher SPIR-V versions first
* fix formatting
The source files for the spirv-new tests were using the older Khronos
license instead of the proper Apache license. Fixed the license in
all source files.
* Replace OBSOLETE_FORAMT with OBSOLETE_FORMAT
In imageHelpers.cpp and few other places in image tests, OBSOLETE_FORMAT is misspelled as OBSOLETE_FORAMT.
Fix misspelling by replcaing it with OBSOLETE_FORMAT.
Fixes#1769
* Remove code guarded by OBSOLETE_FORMAT
Remove code guarded by OBSOLETE_FORMAT
as suggested by review comments
Fixes#1769
* Fix formating issues for OBSOLETE_FORMAT changes
Fix formatting issues observed in files while removing
code guarded by OBSOLETE_FORMAT
Fixes#1769
* Some more formatting fixes
Some more formatting fixes to get CI clean
Fixes#1769
* Final Formating fixes
Final formatting fixes for #1769
* Added support for SYNC_FD and other handle types
* Fix consistency test
Deleted test cases that are no longer testable
according to the spec.
* Fix multi-import tests
-Delete obsolete code relating to offsets
-Propagate dedicated memory change
* Fix error handling
Some subtests did not fail on incorrect result.
Changes to macros to fail, so this does not occur
again.
* Delete invalid test cases
Test cases are not related to this extension.
* External memory test
Add support for any handle type supported by
the platform.
Change-Id: I6765fde5e7929988f49bfbf2df2f41d5263b6abc
* Update multi-import tests to use new semaphore types
* Fix formatting
* Addressed review comments. Deleted VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT_KMT as it appears to be redundant.
* Added cl_khr_fp16 support for test_explicit_s2v from basic (issue #142, basic)
* Cosmetic corrections
* cosmetic fix
* Added correction to distinguish signed and unsigned char types for ARM architecture tests
* Added missing pieces of convertion procedure to support half
* Corrected condition to verify if additional pragma is necessary (issue #142, basic)
* Add NaN check for half to float conversion
* check-format fixes
* Add NaN check for all float types
Use std::isnan for float/double types.
Change-Id: I005bddccaa3f8490ac59b2aa431ed315733ad143
* Fix Ubuntu build error with isnan macro definition
Change-Id: I671ed826a9631fbbc66d0aa9b674ab00124c7967
* Check format fixes
* NAN define not needed anymore
---------
Co-authored-by: Vasu Penugonda <vpenugon@qti.qualcomm.com>
Co-authored-by: Sreelakshmi Haridas <sharidas@quicinc.com>
The `CHECK_GL_ERROR` macro was lowercase before, which confused
clang-format and resulted in some odd indentations. Capitalize the
macro and run clang-format to fix the indentation.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
In preparation of re-enabling -Wformat globally, fix format string
warnings in test_common.
Printing a `size_t` requires the `%zu` specifier.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
The initialisation code is clearly meant to be run once but the volatile
flag did not guarantee that at all:
- Volatile does not mean atomic and loading the flag vs. other writes
was not safe.
- Multiple threads could have loaded 0 and performed the initialisation
resulting in write collisions.
Rely on std::call_once to provide the guarantee.
This issue was flagged by TSAN.
Signed-off-by: Kévin Petit <kpet@free.fr>
* Added cl_khr_fp16 extension support for commonfns test (issue #142, commonfns)
* Added missing header due to presubmit check
* Corrected radians/degrees ulp calculations + cosmetic fixes
* Corrected presubmit code format
* Corrections related to code review
* Moved string format helper to test_common in separate header
* Added clang format for last commit
* Corrections related to code review
* Modified mix verification procedure for half type to only report max error
* Removed redundant condition for logging mix verification
* Corrected generator limits for half tests
In preparation of re-enabling `-Wsign-compare` globally, avoid mixing
signed and unsigned integers in comparisons in test_common.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* Added half and double support for fpmath test from basic (issue #142, basic)
* Cosmetic corrections due to code review
* Removed unnecessary casting
* Added corrections due to code review
* Tuning range of input generation to avoid hitting infinity
* Moved string helpers procedures due to request from test_commonfns PR #1695
Names that begin with an underscore followed by an uppercase letter
are reserved for the C++ implementation.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This change introduces a new command-line parameter to enable
parallel execution by a specified number of worker threads. When
parallel execution is requested, tests are distributed across
the worker threads. This behaviour is disabled by default.
This does not currently work for all suites as some of them are
using global variables to configure tests. For the suites that
do not use global state, this change reduced the execution time
by up to 5x on an 8-core machine.
Signed-off-by: Kévin Petit <kpet@free.fr>
* Added support to test half floats with printf calls (issue #142, printf)
* Added corrections related to rounding and casting halfs (issue #142, printf)
* Reusing similar function (issue #142, printf)
* Corrected path without cl_khr_fp16 support (issue #142, printf)
* Cosmetic fix for order of vector tests (issue #142, printf)
* Added correction related to vendor test review (issue #142, printf)
In `os_helpers.cpp`, the preceding `if` already handles negative
values, so cast to unsigned.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* Don't recalculate image parameters repeatedly in `test_read_image()`
We've already done this in the loop. There's no need to recalculate
those parameters over and over again in `sample_image_pixel*()` and
`read_image_pixel*()`. This should save some work during the image
streams test.
This only affects the 3D tests for now, but my time profiles indicate
this is where we spend the most time anyway.
* Vectorize read_image_pixel_float() and sample_image_pixel_float() for SSE/AVX
This shortens the image streams test time from 45 minutes without it to
37 minutes. Unfortunately, most of the time is now spent waiting for
memory, particularly in the 3D tests, because the 3D image doesn't
neatly fit in the cache, especially in the linear sampling case, where
pixels from two 2D slices must be sampled. Software prefetching won't
help; it only helps when execution time is dominated by operations, but
this is dominated by memory access. Randomized offsets are likely a
factor, because they throw off the hardware prefetcher.
One possible further optimization is, in the linear sampling case, to
load two sampled pixels at once. This is easy to do using AVX, which
extends SSE with 256-bit vectors.
Obviously, this only applies to x86 CPUs with SSE2. The greatest
performance gains, however, are seen with SSE4.1. Most modern x86 CPus
have SSE4. Work is needed to support other CPUs' vector units--ARM
Advanced SIMD/NEON is probably the most important one. Another
possibility is arranging the code so that the compiler's
autovectorization will kick in and do what I did here manually.
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>
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.