Commit Graph

1009 Commits

Author SHA1 Message Date
Sven van Haastregt
487dbd292e relationals: Use stringstream in print_hex_mem_dump (#1597)
print_hex_mem_dump was calling `sprintf` with source and destination
buffers overlapping, which is explicitly forbidden.  Rewrite the
function to use C++ stringstreams instead.

This commit only affects the error path and does not change the
printed output.  Error logs before and after this commit should not
differ.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-01-20 15:11:31 +00:00
Kévin Petit
1eeb10296f Get rid of threadTesting.h (#1604)
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>
2023-01-14 15:18:27 +00:00
Sven van Haastregt
896f43615d basic: Return error on unhandled image format (#1613)
Fail when an unhandled image format is encountered instead of
continuing validation with uninitialized variables.

Fixes a `-Wsometimes-uninitialized` warning for e.g. the `tolerance`
variable.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-01-11 10:25:30 +00:00
Sven van Haastregt
4278d544dc [NFC] clang-format mem_host_flags (#1607)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-01-09 16:07:09 +00:00
Sven van Haastregt
8066e69b11 [NFC] clang-format mem_host_flags/checker_image_mem_host_write_only.hpp (#1600)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-12-20 13:46:47 +00:00
Sven van Haastregt
59a1198e5f [NFC] commonfns: Remove unused values arrays (#1595)
The arrays were assigned to, but the values were never used again.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-12-14 07:34:30 -08:00
Sven van Haastregt
884c736525 math_brute_force: Use clKernelWrapper in single-threaded tests (#1590)
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>
2022-12-13 09:53:56 -08:00
Sven van Haastregt
fb949f9256 events: Remove unused BufferAction::Setup parameter (#1586)
`BufferAction::Setup` has an additional parameter `allocate` which
hides the virtual function `Action::Setup`.  The additional parameter
was unused anyway, so remove it.

Fixes a -Woverloaded-virtual warning.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-12-13 09:53:11 -08:00
Sven van Haastregt
f48dd72da8 Fix -Wreorder warnings (#1583)
Initialize class members in the order they are declared.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-12-13 09:49:38 -08:00
Stuart Brady
a25b9c4948 Partial clean up of test_compiler_defines_for_extensions (#1577)
Replace repetitions of extensions_supported[num_of_supported_extensions]
with a single pointer variable.

Replace character-by-character comparisons with a new string_has_prefix
function.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-12-13 09:48:35 -08:00
Sven van Haastregt
3cadff7115 Fix unused-function warnings and enable -Wunused-function (#1576)
Move functions in .h files to .cpp files where appropriate; align
prototypes and definitions; and remove functions that are not used.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-12-13 09:47:48 -08:00
Ben Ashbaugh
58eb3d776d add tests for cl_khr_extended_bit_ops (#1232)
* very basic test infrastructure

* move test to integer_ops

* added bitfield_reverse test

* added test for bitfield insert

* add a separate file for bitfield_extract

* cleaned up implementation and all tests are passing

* rename helper file so it can be used by other tests

* remove temporary hacks

* fix formatting

* address code review comments

* remove duplicated code after rebase

* fix formatting

a few naming changes for consistency

more changes for consistency

* fix copyright dates

* remove unused variable
2022-12-13 09:46:42 -08:00
Kévin Petit
ed27a90775 samplerlessReads: split out 1D Buffer testing into a separate test (#1570)
So we get finer grain reporting and better parallelisation in the future.

Signed-off-by: Kévin Petit <kpet@free.fr>

Signed-off-by: Kévin Petit <kpet@free.fr>
2022-12-10 11:01:35 +00:00
Sven van Haastregt
73c6955068 [NFC] relationals: Tidy up get_order_string (#1591)
Remove a misleading comment at the end.  Improve comments in general,
and use `true`/`false` for `bool`s.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-12-08 12:08:56 +00:00
Sven van Haastregt
1c2c4581bd mem_host_flags: Fix WRITE_ONLY typo (#1585)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-12-01 09:30:54 -08:00
Sven van Haastregt
ab338569aa [NFC] clang-format mem_host_flags/mem_host_image.cpp (#1589)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-30 07:13:45 -08:00
Sven van Haastregt
0d24c6f69d relationals: Fix vector component accessor selection (#1567)
It seems the intent was to use `.xyzw` vector component accessors in
the kernel whenever `vecSize` is 2, 3, or 4.  The condition was wrong
(i.e., always true for any value of `vecSize`), causing it to always
create a kernel with numeric (`.s0123...`) vector component accessors.

The restriction on the use of `.xyzw` for 8 and 16-component vectors
has been lifted a while ago (see
https://github.com/KhronosGroup/OpenCL-Docs/issues/549) so we do not
need this check at all.

Also, fix the `vecSize` argument of two calls of `get_order_string`
when getting the order string for the "in" kernel argument.  Pass
`inVecSize` in these cases, not `outVecSize`.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-27 13:26:23 -08:00
Sven van Haastregt
6ecf824122 math_brute_force: Use clKernelWrapper in threaded tests (#1562)
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>
2022-11-27 13:25:32 -08:00
Sven van Haastregt
e9d2abf705 spir: Fix -Wcatch-value warnings (#1565)
`std::exception` and `std::runtime_error` are polymorphic types and as
such they shouldn't be passed by value.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-24 11:43:51 +00:00
Jack Frankland
c6bb15c289 Remove invalid assumptions from sub-group tests (#1504)
* Remove invalid assumption from sub-group tests

The sub-group dispatch tests were making the invalid assumption that
querying the local size (via `CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT`)
for a sub-group count obtained from a
`CL_KERNEL_SUB_GROUP_COUNT_FOR_ND_RANGE` with local size `{x, y, z}`
will result in the same local size i.e. that
`CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT` is the inverse of
`CL_KERNEL_SUB_GROUP_COUNT_FOR_ND_RANGE`. To take a trivial example
consider the case that there is only ever one sub-group per work
group(i.e. sub-group == work-group). Then regardless of the local size
passed to `CL_KERNEL_SUB_GROUP_COUNT_FOR_ND_RANGE` the sub-group count
will always be `1`, and `CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT` can
return any valid local size since all local sizes result in `1`
sub-group.

* Format surrounding changes
2022-11-23 13:19:35 -08:00
Callum Fare
9137cb66ed Test that cloned kernels can't be enqueued before all args are set (#1563) 2022-11-23 14:09:42 +00:00
Kenneth Benzie
def23dd6e6 Fix generic address space OpenCL 2.0 assumption (#1575)
Conformance tests should not assume support for OpenCL 2.0, or specific
features. This patch removes uses of
`__opencl_c_program_scope_global_variables` for devices which do not
support it in the generic address space conformance tests. Additionally,
the `clCompileProgram` options have been updated to select between
`CL2.0` and `CL3.0` depending on which the device under test supports.

Co-authored-by: Amy Worthington <amy@codeplay.com>
2022-11-23 14:08:30 +00:00
Sven van Haastregt
640f6e66c7 [NFC] workgroups: Remove unused array (#1572)
`value_range` was only used in an `NELEMS` expression; its values were
never read.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-23 14:04:31 +00:00
Marco Cattani
18dbf2f1c1 Added initial set of tests for the cl_khr_semaphore extension (#1428)
* Added initial set of tests for the cl_khr_semaphore extension

* Fixes to address first round of reviews for cl_khr_semaphore tests
v2022-11-15-03
2022-11-15 09:18:43 -08:00
Sven van Haastregt
fc4260bdae subgroups: Fix Wformat warnings (#1549)
The main source of warnings was the use of `%d` for printing a
templated type `T`, where `T` could be any cl_ scalar or vector type.

Introduce `print_expected_obtained`.  It takes const references to
handle alignment of the cl_ types.

Define `operator<<` for all types used by the subgroup tests.  Ideally
those would be template functions enabled by TypeManager data, but
that requires some more work on the TypeManager (which we'd ideally do
after more warnings have been enabled).  So for now, define the
`operator<<` instances using preprocessor defines.

Also fix a few instances where the wrong format specifier was used for
`size_t` types.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-15 09:12:31 -08:00
John Kesapides
2110e45cce Deduplicate write_image (#1536)
* Deduplicate write_image

Merge writeimage,writeimage_int16,writeimage_fp32
as they share a lot of common code.

Signed-off-by: John Kesapides <john.kesapides@arm.com>

* Test for CL_MEM_WRITE_ONLY and CL_MEM_READ_WRITE.

Signed-off-by: John Kesapides <john.kesapides@arm.com>

* Rename test_flags to img_flags

Signed-off-by: John Kesapides <john.kesapides@arm.com>

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2022-11-15 09:11:37 -08:00
Sven van Haastregt
524fcab7f3 [NFC] spir: Remove unused class member (#1568)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-10 14:23:47 +00:00
Kenneth Benzie
191fd0f9e5 Fix thread leaks in the thread pool (#1553)
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.
2022-11-08 09:32:45 -08:00
Stuart Brady
77049a3a0f Add missing newlines in log messages for image tests (#1564)
Also use log_info instead of printf for skipped tests, for consistency.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-11-08 09:28:30 -08:00
John Kesapides
aad303074c Fix image type on format check for test_readimage. (#1566)
Signed-off-by: John Kesapides <john.kesapides@arm.com>

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2022-11-08 11:09:10 -05:00
Stuart Brady
133834615e Improve logging of unknown extensions (#1556)
Add missing newlines, and log all unknown extensions instead of logging
only the first unknown extension found.
2022-11-04 11:26:19 -07:00
Sven van Haastregt
f29ebf0d59 [NFC] image_streams: Remove unused label (#1560)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-04 08:54:05 -07:00
Sven van Haastregt
a61fa63054 [NFC] cmake: Remove redundant CMAKE_CXX_STANDARD (#1558)
`CMAKE_CXX_STANDARD` is already set in the top-level CMakeLists.txt
file, so there is no need to have it repeated for individual modules.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-04 08:53:42 -07:00
John Kesapides
9794aaef04 Deduplicate test_basic read_image (#1535)
Merge readimage,readimage_int16,read_image_fp32,
readimage3d,readimage3d_int16,read_image3d_fp32
as they share a lot of common code.

Signed-off-by: John Kesapides <john.kesapides@arm.com>

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2022-11-01 13:26:09 -07:00
John Kesapides
bb54c435dc Deduplicate test_basic test_fpmath (#1534)
Merge fpmath_float,fpmath_float2,fpmath_float4
as they share a lot of common code.

Signed-off-by: John Kesapides <john.kesapides@arm.com>

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2022-11-01 13:10:14 -07:00
Sven van Haastregt
8bb69ef665 Fix -Wformat-extra-args warnings (#1533)
Fix a few instances where an incorrect number of arguments was
supplied when calling (v)log_error.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-11-01 13:09:48 -07:00
John Kesapides
fb1e8fcf9b Deduplicate test_basic arrayimagecopy (#1532)
Merge test_arrayimagecopy3d and test_arrayimagecopy
into a single test, as they share a lot of common code.
2022-11-01 13:09:12 -07:00
Sven van Haastregt
63274f97b7 math_brute_force: Factor out GetUnaryKernel and GetBinaryKernel (#1525)
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>
2022-11-01 13:08:36 -07:00
Grzegorz Wawiorko
44fe72c2b9 Fix vulkan test build issue on Intel compiler (#1464) 2022-11-01 13:05:37 -07:00
Kenneth Benzie
babed4c175 Make building the Vulkan interop tests optional (#1530)
Allow enabling/disabling building of the Vulkan interop tests via CMake
option without modifying the CMake. This matches the optionality of the
D3D10, D3D11, GL, and GLES interop tests.
v2022-10-27-00
2022-10-27 10:16:16 +01:00
John Kesapides
90a5183ec4 Use CTS type wrappers for test_enqueued_local_size (#1544)
Signed-off-by: John Kesapides <john.kesapides@arm.com>

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2022-10-14 09:55:10 +01:00
John Kesapides
5e116e7b0d Use CTS type wrappers for test_sizeof. (#1547)
Signed-off-by: John Kesapides <john.kesapides@arm.com>

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2022-10-14 09:53:33 +01:00
Sven van Haastregt
f6a963a583 harness: Fix -Wformat warnings (#1527)
The main sources of warnings were:

 * Printing of a `size_t` which requires the `%zu` specifier.

 * Printing of `cl_long`/`cl_ulong` which is now done using the
   `PRI*64` macros to ensure portability across 32 and 64-bit builds.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-10-13 10:02:40 +01:00
Sven van Haastregt
4b39b59469 [NFC] clang-format basic/test_progvar.cpp (#1528)
Manually reformat the `prog_src` variable which contains kernel code
and disable clang-format on it.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-10-13 10:01:53 +01:00
Sven van Haastregt
35cab9c85b pipes: Fix readwrite verification function for fp64 (#1522)
Use the appropriate function for verifying double precision values in
the `pipe_readwrite_double` test.

Change `verify_readwrite_double` to use `cl_long`, as `long long int`
could be wider than 64 bits which would cause out-of-bound reads.
This leaves no functional differences between
`verify_readwrite_double` and `verify_readwrite_long`.

Found by compiling with `-Wunused-function`, which flagged
`verify_readwrite_double` as unused.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-10-11 09:36:33 -07:00
Kévin Petit
9e0ce2ba80 Produce JSON results even when a suite's init function reports SKIP or FAIL (#1521)
Also tidy-up some surrounding code.

Signed-off-by: Kévin Petit <kpet@free.fr>

Signed-off-by: Kévin Petit <kpet@free.fr>
2022-10-11 09:35:36 -07:00
Grzegorz Wawiorko
f6e37b17d2 Fix image test image2d_from_buffer_positive (#1515) 2022-10-11 09:34:33 -07:00
niranjanjoshi121
d285ebe5be Fix memory oob problem in test conversions (#1513)
* Fix memory oob problem in test conversions

Allocate memory for argc arguments
instead of argc - 1.

* Fix formatting issue.
2022-10-11 09:32:47 -07:00
Sven van Haastregt
d9a938b698 Factor out GetTernaryKernel (#1511)
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>
v2022-10-05-00
2022-10-04 09:28:29 -07:00
Nikhil Joshi
07b055cd68 Cap CL_DEVICE_MAX_MEM_ALLOC_SIZE to SIZE_MAX (#1501)
* 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.

* Cap CL_DEVICE_MAX_MEM_ALLOC_SIZE to SIZE_MAX

Cap CL_DEVICE_MAX_MEM_ALLOC_SIZE to SIZE_MAX
when CL_DEVICE_GLOBAL_MEM_SIZE is capped with SIZE_MAX.
test_allocation caps the value of GLOBAL_MEM_SIZE to SIZE_MAX
if it exceeds the value of SIZE_MAX(value depends on platform bitness),
but doesn’t modify MAX_ALLOC_SIZE the same way.
Due to this MAX_ALLOC_SIZE becomes greater than GLOBAL_MEM_SIZE
and the test fails.

Modify MAX_MEM_ALLOC_SIZE as GLOBAL_MEM_SIZE when it exceeds SIZE_MAX

OpenCL-CTS #1022
2022-10-04 09:13:18 -07:00