Compare commits

...

769 commits

Author SHA1 Message Date
joshqti
e9d4078a0b cl_khr_external_memory_android_hardware_buffer test
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 5s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-aarch64 (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m2s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
Android AHardwareBuffer test.  Initial testing
for buffers and images.
2025-06-06 11:44:16 -07:00
Ahmed
f209922722
Add cl_khr_external_memory_android_hardware_buffer to the list of known compiler test extensions (#2407)
Fixes compiler_defines_for_extensions failure when the extension is
supported.
2025-06-03 14:38:39 -07:00
Sven van Haastregt
2d165eee74
conversions: remove timing functionality (#2394)
Remove the test timing functionality from the conversions test, because
it

 - is not advertised in the help,

- is not supported on all platforms, triggering warnings during the
build,

 - goes beyond the core purpose of the conformance test suite.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-05-30 23:50:17 +01:00
Marcin Hajder
f30a191978
Corrected procedure to collect proper size of image from VkImageCreateInfo (#2289)
Fixes #2155 according to issue description

Additional remark: The image size was previously calculated based on the
memory size, which seems unusual. Due to Vulkan's configuration
capabilities, the size of memory allocated for a specific texture may
differ from what would be expected based on the texture dimensions.
Thus, calculating the image dimensions back from the memory size of a
Vulkan texture can be challenging.
2025-05-27 10:17:14 -07:00
Ahmed Hesham
3ab4d8aab2
Test image formats of cl_ext_image_unsigned_10x6_12x4_14x2 (#2375)
This change add the following image formats to the supported image
formats:
1. CL_UNSIGNED_INT10X6_EXT
2. CL_UNSIGNED_INT12X4_EXT
3. CL_UNSIGNED_INT14X2_EXT
4. CL_UNORM_INT10X6_EXT
5. CL_UNORM_INT12X4_EXT
6. CL_UNORM_INT14X2_EXT

For reference, the specification for
`cl_ext_image_unsigned_10x6_12x4_14x2` can be found here:
https://github.com/KhronosGroup/OpenCL-Docs/pull/1352

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
Co-authored-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-05-27 08:57:34 -07:00
Marcin Hajder
dec5644112
Added support for cl_ext_float_atomics in c11_atomics store test along with atomic_half type (#2293)
Related to #2142, according to the work plan extended `CBasicTestStore`
with support for `atomic_half`.

Optimization remark: in tests related to `CBasicTestStore` kernel source
code is mostly composed with arguments following similar pattern:

`__kernel void test_atomic_kernel(uint threadCount, uint numDestItems,
__global int *finalDest, __global int *oldValues, volatile __local
atomic_int *destMemory)`

`oldValues` buffer is initialized with a host pointer, after kernel
execution it is read back to the host pointer but it is unused in
neither of the kernels I verified.
2025-05-27 08:51:36 -07:00
Kévin Petit
110799bb67
Add missing coverage to api::zero_sized_enqueue (#2378)
- Cases with a NULL global_work_size were not tested
- The specification states that zero-sized enqueues behave similarly to
marker commands. Test that events for NDRange kernel commands have the
correct CL_COMMAND_NDRANGE_KERNEL command type to guard against
implementations naively using a marker command.
- Tidy up the code a bit and add missing error checking.

Signed-off-by: Kévin Petit <kpet@free.fr>
2025-05-13 03:51:43 +01:00
Michael Rizkalla
b011fb26d9
Add test_spir installation target (#2359)
`test_spir` and its data are not installed correctly when building the
installation target.
This change makes sure both the binary and the test data are installed
correctly to `${CMAKE_INSTALL_BINDIR}/$<CONFIG>`.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-05-06 09:45:01 -07:00
Kévin Petit
455c7b0504
ci: move contents of presubmit.sh to workflow file (#2380)
Signed-off-by: Kévin Petit <kpet@free.fr>
2025-05-06 09:43:38 -07:00
AlexGalazin-IMG
d3b043a891
Update README after PR 2200 (#2381)
PR2200 made the presence of spirv-as and spirv-val mandatory.

Reflect this fact in the Readme and update the example build
instructions
2025-05-06 09:41:41 -07:00
Romaric Jodin
3f7889bdbd
Remove CL_DEVICE_HALF_FP_CONFIG when cl_khr_fp16 is not supported (#2354)
Specification does not require to return an error when querying
CL_DEVICE_HALF_FP_CONFIG and cl_khr_fp16 is not supported.

Fix #2339
2025-05-06 09:33:34 -07:00
Sven van Haastregt
9917ed2790
[NFC] math_brute_force: use getAllowedUlpError for double (#2351)
Call `getAllowedUlpError` to obtain the allowed ULP error for all of the
double type (fp64) tests. The aim is to standardise obtaining the
desired ULP requirement and pave the way for adding the Embedded Profile
ULP errors.

Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/867

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-05-06 09:32:31 -07:00
Marcin Hajder
8aa47754de
Added object comparability verification for CL_DEVICE_PLATFORM query (#2225)
Fixes #1485 according to work plan, point CL_DEVICE_PLATFORM
2025-05-06 08:40:18 -07:00
Kévin Petit
9fc0d23b4c
Define SubDevicesScopeGuarded in the harness and remove duplicate copies (#2379)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 1s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-aarch64 (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
Signed-off-by: Kévin Petit <kpet@free.fr>
2025-04-21 11:16:17 +01:00
Ahmed Hesham
90524879e4
Migrate extensions suites to the new test registration framework (#2334)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 2s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-aarch64 (push) Failing after 2s
Presubmit / Build ubuntu-22.04 android-arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
This covers:
* cl_ext_cxx_for_opencl
* cl_khr_command_buffer
* cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch
* cl_khr_dx9_media_sharing
* cl_khr_external_semaphore
* cl_khr_kernel_clock
* cl_khr_semaphore

Contributes to #2181.

---------

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-04-16 11:14:34 +01:00
gorazd-sumkovski-arm
33846e6673
Refactor external semaphore scaffolding (#2300)
Remove the `CREATE_OPENCL_SEMAPHORE` macro and use derived class
instantiations of the `clExternalSemaphore` class, rather than base
pointers to derived class objects.

Remove the default argument for `queryParamName` in
`check_external_semaphore_handle_type()`.

Move `check_external_semaphore_handle_type()` checks to constructors of
`clExternalImportableSemaphore` and `clExternalExportableSemaphore`,
rather than manually making the check before creating an external
semaphore.

---------

Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
Co-authored-by: Kévin Petit <kpet@free.fr>
Co-authored-by: Kevin Petit <kevin.petit@arm.com>
2025-04-16 09:11:38 +05:30
Sven van Haastregt
4ce3d8968a
conversions: use C++17 to avoid Wformat warnings (#2369)
Using C++17's `if constexpr` avoids Wformat warnings in this template
function, as it is now made explicit that the various format strings are
only used with appropriate types.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-04-15 18:28:47 +01:00
Kévin Petit
829e91663a
Stop using optimally-tiled images in external memory tests (#2349)
Support for optimally-tiled images and tiling inference in general is
implementation-defined. It should not be relied upon in the CTS.

Also build the code base as C++17 for std::optional. Many Khronos
projects are now using C++17 and the transition in the CTS is IMO
overdue.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2025-04-15 22:58:35 +05:30
Kévin Petit
e96edaef8b
Require C++17 (#2356)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-aarch64 (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
This enables many useful newer C++ features. C++17 is already required
by many components of the Khronos ecosystem.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2025-04-08 09:50:33 -07:00
Sven van Haastregt
0abec2f49a
spirv_new: remove invalid Aligned 0 decorations (#2360)
After https://github.com/KhronosGroup/SPIRV-Tools/pull/6027 spirv-val is
now rejecting `Aligned 0` Memory Operands. This causes the spirv_new
test binary to no longer build with a recent SPIRV-Tools version.

Mechanically remove all occurrences of `Aligned 0` in the SPIR-V
assembly files.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-04-08 17:49:00 +01:00
Grzegorz Wawiorko
051b82b7e9
SPIR-V tests for scalar printf - fix for Windows OS (#2358) 2025-04-04 08:52:05 -07:00
Grzegorz Wawiorko
42b4bca510
Fix test_printf - any nan format is allowed by OpenCL C spec (#2298)
OpenCL C says that printing nan is implementation-defined for
floating-point numbers -
https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#printf-format-string
2025-04-01 13:44:39 -07:00
Michael Rizkalla
5930d45fc6
Refactor clCopyImage and clFillImage tests (#2283)
This change mainly extends `clFillImage` and `clCopyImage` test function
to include memory flags to be used during creating the image instead of
hard-coding these values. The memory flags are also different parameters
for source and destination images in `clCopyImage` tests.

---------

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-04-01 09:53:37 -07:00
Sreelakshmi Haridas Maruthur
78bd3ddece
allocations: Scale number of work-items in relation to input size (#2336)
Make the number of work-items proportional to size of the allocation so
we launch more work-items and do less work per work-item as buffer sizes
go up with device capabilities.

To test:
test_allocations multiple 5 buffer
test_allocations single 5 buffer
2025-04-01 09:53:21 -07:00
Grzegorz Wawiorko
a429ce771e
Test printf - set more precisely printing floating point numbers (#2299)
We noticed such issue 
expected: ^(K{C, -30304.8, -22634.574219, 24476.882812, E4929EC2,
1467582223, 96vL.+
got: ^(K{C, -30304.8, -22634.574219, 24476.882813, E4929EC2, 1467582223,
96vL.+
The input value is 24476.882812 and cannot be precisely represented as a
single-floating point, so compilers are allowed to round it to the
nearest representable value. In this case, the closest representable
value to 24476.882812 is 24476.8828125, which rounds to 24476.882813.
Even some versions of MSVC prints that value as 24476.882813 and some
24476.882812 : https://godbolt.org/z/5GhEf8KPT
The proposal is to set precisely how many number should be displayed to
avoid rounding.
2025-04-01 09:52:19 -07:00
Marcin Hajder
4e00778b93
Modernization of semaphores_negative_create_invalid_device related to creating sub-devices (#2307)
Due to the improvements developed during work on #2237 with @bashbaug
2025-04-01 08:47:59 -07:00
Marcin Hajder
88953edf6c
Modernization of semaphores_negative_create_multi_device_property related to creating sub-devices (#2306)
Due to the improvements developed during work on #2237 with @bashbaug
2025-04-01 08:47:27 -07:00
Marcin Hajder
004bc4a82d
Cleanup corrections for get_program_info_mult_devices test (#2305) 2025-04-01 08:46:18 -07:00
Sven van Haastregt
b6924adfb2
basic: fix Wformat warnings (#2343)
Fix all `-Wformat` warnings in the basic test suite, and re-enable the
warning.

---------

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-03-25 09:45:18 -07:00
Marcin Hajder
1cbb548e27
Added support to run the CTS with Vulkan validation layers (#2246)
Fixes #2116 according to task description.

As approved 25Mar25
2025-03-25 08:43:28 -07:00
Marcin Hajder
81f33190e2
Added test to verify program queries after recompiling and relinking (#2272)
Fixes #2163 according to issue description

As approved 25Mar25
2025-03-25 08:41:04 -07:00
Michael Rizkalla
e36da9798e
Migrate integer_ops suite to the new test registration framework (#2332)
Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/2181.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-03-23 15:12:34 +00:00
Ahmed Hesham
a9507ce33f
Migrate images suite to the new test registration framework (#2328)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-23 15:02:29 +00:00
Michal Babej
36178cf6e3
add tests for cl_ext_buffer_device_address (#2192) 2025-03-19 14:08:17 -07:00
Ahmed Hesham
e88e5be93e
Migrate basic suite to the new test registration framework (#2316)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-18 17:32:58 +00:00
Ahmed Hesham
b39eff86c5
Migrate math_brute_force to the new test registration framework (#2327)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-18 17:25:14 +00:00
Ahmed Hesham
11db5e5d62
Migrate multiple_device_context suite to the new test registration framework (#2325)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-18 17:22:11 +00:00
Ahmed Hesham
e52f6a732b
Migrate conversions suite to the new test registration framework (#2322)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-18 17:15:28 +00:00
Michael Rizkalla
ac38405a62
Migrate geometrics suite to the new test registration framework (#2335)
Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/2181.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-03-18 17:13:35 +00:00
Michael Rizkalla
7cd13e1e93
Migrate generic_address_space suite to the new test registration framework (#2333)
Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/2181.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-03-18 17:11:43 +00:00
Ahmed Hesham
2131aff0e9
Migrate compiler suite to the new test registration framework (#2319)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-18 17:10:21 +00:00
Ahmed Hesham
d4c292ed46
Fix broken CI on MacOS (#2341)
LunarG has changed the SDK file hosted for MacOS v1.3.275.0 from a .zip
file to a .dmg file with the old hyperlink transparently redirecting to
the new one.

The script expects a .zip archive so it fails when it downloads a .dmg
file.

Bump the Vulkan SDK version to 1.4.309.0, which is the latest version
and is provided as a .zip archive.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-18 09:04:14 -07:00
Starla Huang
395648cfef
Use max work item size instead (#2294)
The test is using CL_DEVICE_MAX_WORK_GROUP_SIZE as first dimension of
local work size. But it can be bigger than the first dimension of
CL_DEVICE_MAX_WORK_ITEM_SIZEs which results in failure.

This patch corrects it to query and use the first dimension of
CL_DEVICE_MAX_WORK_ITEM_SIZES instead.

Signed-off-by: Xing Huang <xing.huang@arm.com>
2025-03-18 09:03:13 -07:00
Sven van Haastregt
b9301d1ae8
basic: fix -Wformat-security warnings (#2284)
Fix warnings such as:

test_vloadstore.cpp:330:49: error: format string is not a string literal
(potentially insecure)

There were no security issues here as the format string arguments do not
contain any conversion specifiers and are never written to. Make that
latter fact explicit to avoid the warnings.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-03-18 09:02:31 -07:00
Ahmed
d38b8b4ae8
Change relaxed exp exp2 embedded error to 4 + floor(fabs(2x)) (#2326)
Reflects the changes to the specification:
https://github.com/KhronosGroup/OpenCL-Docs/pull/1318

Relaxed embedded exp and exp2 ulps will be 4 + floor(fabs(2 * x)).

Reciprocal and divide are unchanged because the code already handles the
embedded profile case, see unary_float.c and binary_operator_float.c.

---------

Co-authored-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-03-18 08:55:27 -07:00
Kévin Petit
bb604702a5
Migrate workgroups suite to the new test registration framework (#2308)
Contributes to #2181

Signed-off-by: Kévin Petit <kpet@free.fr>
2025-03-11 22:00:38 +00:00
Ahmed Hesham
641ffeaa67
Migrate half suite to the new test registration framework (#2329)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-11 22:00:23 +00:00
Ahmed Hesham
ba95285a0e
Migrate contractions suite to the new test registration framework (#2321)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-11 21:58:52 +00:00
Ahmed Hesham
c4fa48db05
Migrate events suite to the new test registration framework (#2324)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-11 21:57:59 +00:00
Ahmed Hesham
bb331c2c92
Migrate device_execution suite to the new test registration framework (#2323)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-11 21:54:22 +00:00
Ahmed Hesham
671ea7b286
Migrate computeinfo suite to the new test registration framework (#2320)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-11 21:52:28 +00:00
Kévin Petit
13b82d1833
Migrate non_uniform_work_group suite to the new test registration framework (#2317)
Contributes to #2181

Signed-off-by: Kévin Petit <kpet@free.fr>
2025-03-11 21:48:14 +00:00
Kévin Petit
132ba21a3c
Migrate mem_host_flags suite to the new test registration framework (#2314)
Contributes to #2181

Signed-off-by: Kévin Petit <kpet@free.fr>
2025-03-11 21:47:58 +00:00
Kévin Petit
c4179d0f6a
Migrate thread_dimensions suite to the new test registration framework (#2309)
Contributes to #2181

Signed-off-by: Kévin Petit <kpet@free.fr>
2025-03-11 21:46:38 +00:00
Kévin Petit
3a275fe81b
Always enable beta extensions (#2330)
`CL_ENABLE_BETA_EXTENSIONS` was just introduced in
https://github.com/KhronosGroup/OpenCL-Headers/pull/276
to guard provisional and other experimental extensions. The CTS
currently assumes
all definitions are always present.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2025-03-11 11:40:29 -07:00
Kévin Petit
30f9a5eb21
Remove .gitattributes (#2310)
We don't use git lfs. We have no .7z files in the repo.

Signed-off-by: Kévin Petit <kpet@free.fr>
2025-03-10 22:16:21 -07:00
Ahmed Hesham
2d0fda0179
Migrate c11_atomics suite the new test registration framework (#2318)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-10 09:55:24 +00:00
Ahmed Hesham
fbeebac9d5
Migrate buffers suite to the new test registration framework (#2315)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-09 09:59:01 +00:00
Ahmed Hesham
3f7774b089
Migrate subgroups suite to the new test registration framework (#2313)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-09 09:53:47 +00:00
Ahmed Hesham
aed6c3a214
Migrate relationals suite to the new test registration framework (#2312)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-09 09:49:24 +00:00
Ahmed Hesham
6eb1aa1d0a
Migrate printf suite to the new test registration framework (#2311)
Contributes to #2181.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-09 09:44:59 +00:00
Ahmed Hesham
5b47d4b19f
Migrate pipes suite to the new test registration framework (#2302)
Contributes to #2181

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-03-09 09:42:10 +00:00
Ahmed Hesham
521d067083
Migrate device_partition suite to the new test registration framework (#2301)
Contributes to #2181
2025-03-08 22:37:04 +00:00
Romaric Jodin
11db332281
fix error message in work_item_functions_out_of_range (#2303)
The value printed in the error message is not the correct one (used in
the comparison statement)
2025-03-07 23:43:00 +00:00
Ben Ashbaugh
637deb0011
add missing Float16 capability (#2304)
A recent improvement to the SPIR-V validator added checks to ensure the
**Float16** capability is declared when directly operating on fp16
values, which identified issues in one of our SPIR-V test files. This PR
fixes the SPIR-V files to add the missing capability.
2025-03-07 10:08:58 -08:00
Ben Ashbaugh
6a36bd9d5c
add SPIR-V 1.6 testing for UniformDecoration decorations (#2254)
Adds a basic test for the SPIR-V 1.6 UniformDecoration decorations.
Specifically:

* Tests both the Uniform and UniformId decorations.
* Tests the decorations on constants, function parameters, and
variables.
2025-03-05 08:29:26 -08:00
Michael Rizkalla
9a5041a25b
Fix inconsistent variable name in REGISTER_TEST and REQUIRE_EXTENSION (#2296)
Both `REGISTER_TEST` and `REQUIRE_EXTENSION` expect cl_device_id
variable but the variable name is inconsistent which makes both macros
unusable together.

This change renames `deviceID` in `REQUIRE_EXTENSION` to `device` to be
consistent with `REGISTER_TEST`.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-03-04 16:53:50 -08:00
Sven van Haastregt
733cc78c39
spirv_new: ensure int64 printf test uses 64 bits (#2295)
The `extinst_printf_operands_scalar_int64` test could fail on 32-bit
platforms with `CL_INVALID_ARG_SIZE`, because the helper function was
not guaranteed to be instantiated using a 64-bit integer template type.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-03-04 16:53:25 -08:00
Sven van Haastregt
7feb93cdd7
math_brute_force: treat reciprocal as unary function (#2281)
Treat reciprocal as a unary function, instead of handling it through the
binary function testing mechanism and special-casing it there.

This addresses two shortcomings of the previous implementation:

- Testing took significantly longer as the entire input domain was
tested many times (e.g. fp16 reciprocal has only 2^16 possible input
values, but binary function testing iterates over 2^16 * 2^16 input
values).

- The reciprocal test kernel was identical to the divide kernel. Thus
the device compiler would see a regular divide operation instead of a
reciprocal operation and would be unlikely to emit a specialized
reciprocal sequence.

This reverts all of the changes in binary_operator*.cpp made by
bcfa1f7c2 ("Added corrections to re-enable reciprocal test in
math_brute_force suite for relaxed math mode (#2221)", 2025-02-04).

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-03-04 16:52:28 -08:00
Michael Rizkalla
5167d7202b
Fix signalling and waiting on semaphore from two queues (#2271)
`semaphores_ooo_ops_cross_queue` uses two OOO command queues to run the
test. In one queue, a semaphore is signalled and the semahpore is waited
on in the other queue.

The CL specification requires the application to synchronize the queues
if objects are shared.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-03-04 16:51:18 -08:00
Ahmed Hesham
5a65278613
Fix compilation failure caused by DMA heaps (#2292)
Project fails to build on systems with a kernel version older than 5.6.0
because of `-Wunused-function` combined with `-Werror`.

Expand the conditional compilation guard to include the offending code.
2025-02-27 07:30:08 -08:00
Marcin Hajder
a7c4d7f4c7
Added test to verify program queries after rebuilding (#2253)
Fixes #2163 according to issue description
2025-02-26 09:55:38 -08:00
Ahmed Hesham
9ba6f062d4
Add support for allocating DMA buffers (#2170)
This adds support for allocating DMA buffers on systems that support it,
i.e. Linux and Android.

On mainline Linux, starting version 5.6 (equivalent to Android 12),
there is a new kernel module framework available called [DMA-BUF
Heaps](https://github.com/torvalds/linux/blob/master/drivers/dma-buf/dma-heap.c).
The goal of this framework is to provide a standardised way for user
applications to allocate and share memory buffers between different
devices, subsystems, etc. The main feature of interest is that the
framework provides device-agnostic allocation; it abstracts away the
underlying hardware, and provides a single IOCTL,
`DMA_HEAP_IOCTL_ALLOC`. Mainline implementation provides two heaps that
act as character devices that can allocate DMA buffers; system, which
uses the buddy allocator, and cma, which uses the
[CMA](https://developer.toradex.com/software/linux-resources/linux-features/contiguous-memory-allocator-cma-linux/)
(Contiguous Memory Allocator). Both of these are [kernel configuration
options](https://github.com/torvalds/linux/blob/master/drivers/dma-buf/heaps/Kconfig)
that need to be enabled when building the Linux kernel. Generally, any
kernel module implementing this framework is made available under
/dev/dma_heaps/<heap_name>, e.g. /dev/dma_heaps/system.

The implementation currently only supports one type of DMA heaps;
`system`, the default device path for which is `/dev/dma_heap/system`.
The path can be overridden at runtime using an environment variable,
`OCL_CTS_DMA_HEAP_PATH_SYSTEM`, if needed. Extending this in the future
should be trivial (subject to platform support), by adding an entry to
the enum `dma_buf_heap_type`, and an appropriate default path and
overriding environment variable name.

The proposed implementation will conditionally compile if the conditions
are met (i.e. building for Linux or Android, using kernel headers >=
5.6.0), and will provide a compile-time warning otherwise, and return
`-1` as the DMA handle in runtime if not.

To demonstrate the functionality, a new test is added for the
`cl_khr_external_memory_dma_buf` extension. If the extension is
supported by the device, a DMA buffer will be allocated and used to
create a CL buffer, that is then used by a simple kernel.

This should provide a way forward for adding more tests that depend on
DMA buffers.

---------

Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
Co-authored-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
2025-02-26 09:51:22 -08:00
Sreelakshmi Haridas Maruthur
6419744d76
printf: Fix the format specifier for %A to add the decimal point (#2290) 2025-02-25 12:54:53 -08:00
Ahmed
803e665683
Correct reference for fma for RTZ devices for half (#2269)
The reference was always being calculated using round to nearest even
for fma when testing half precision.

Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/2224
2025-02-25 12:54:26 -08:00
Marcin Hajder
c84b712366
Added object comparability verification for program devices query (#2237)
Fixes #1485 according to work plan from issue description.
2025-02-25 08:48:05 -08:00
Marcin Hajder
a90a8194bc
Added object comparability verification for program devices query (#2237)
Fixes #1485 according to work plan from issue description.
2025-02-25 08:43:12 -08:00
Marcin Hajder
0ddfbbe673
Added object comparability verification for context devices query (#2176)
Fixes #1485 according to work plan, point `CL_CONTEXT_DEVICES`
2025-02-25 08:42:09 -08:00
Sreelakshmi Haridas Maruthur
32361e1d89
bruteforce: Check both input values for nan (#2270) 2025-02-18 20:51:36 -08:00
zzk0
bdd0eb0b7e
bugfix nan test for basic fpmath (#2268)
This PR fixes the validation logic for cases where the data type is not
half. Because the variable nan_test is always false, types like float
never trigger a validation failure.
2025-02-18 20:51:19 -08:00
Michael Rizkalla
6d3d199b42
Deduplicate create_image from Copy/Fill image tests (#2262)
1. Remove duplicate `create_image` code that is in both clFillImage and
clCopyImage test directories.
2. Unify how pitch buffer's memory is deallocated; The buffer can be
allocated with either `malloc` or `align_malloc` and the free function
is pre-set in `pitch_buffe_data`'s member variable `free_fn` and used
when the buffer is deallocated. With this, the change removes
`is_aligned` conditional variable that was used to select the
appropriate free function.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2025-02-18 20:50:43 -08:00
Romaric Jodin
84fd99da76
fix profiling execute_multipass (#2239)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 2s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 2s
Presubmit / Build ubuntu-22.04 android-aarch64 (push) Failing after 2s
Presubmit / Build ubuntu-22.04 android-arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
- fix clGetDeviceInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES) by using the proper
size

- clamp localThreads[2] as for localThreads[0] and localThreads[2]

- clamp all localThreads elements in regard of CL_MAX_WORK_GROUP_SIZE

- fix the size using to create/read the output buffer

Fix #2238
2025-02-18 20:49:12 -08:00
Sreelakshmi Haridas Maruthur
8c298b1c3b
printf: Fix printf 'mixed_format_random' (#2236)
%a or %A with printf on MSVC platforms have a default precision of 13,
which is in contrast to OpenCL C specification for printf which only
allows for exact digits required if precision is not specified.
2025-02-18 20:48:26 -08:00
Ahmed Hesham
485964d87c
Add CMake installation rules (#2184)
Add installation rules for all the binary targets.

Targets are installed under `<CMAKE_INSTALL_PREFIX>/bin/<CONFIG>` where
`<CONFIG>` is `CMAKE_BUILD_TYPE` for single-config generators, e.g. Unix
Makefiles and Ninja, or the build configuration for multi-config
generators, e.g. Ninja Multi-Config and Visual Studio.

This creates the target `install` on Unix and `INSTALL` on Windows.
2025-02-18 20:47:56 -08:00
Kévin Petit
9216c81855
Migrate test_vulkan to the new registration framework (#2278)
Signed-off-by: Kévin Petit <kpet@free.fr>
2025-02-19 00:24:03 +05:30
Kévin Petit
24597e0145
Report external sharing tests as skipped instead of failed when not supported (#2277)
Throwing an exception in the constructor for VulkanTestBase was always
reported as an error.

Signed-off-by: Kévin Petit <kpet@free.fr>
2025-02-19 00:22:44 +05:30
Sven van Haastregt
46dcf18a18
spirv_new: print build log in get_program_with_il (#2274)
Print the build log when building the program in `get_program_with_il`
fails, to make it easier to investigate spirv_new test failures.

Factor out a global helper function `OutputBuildLog` for printing the
build log for a single device.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-02-18 09:13:01 -08:00
Sven van Haastregt
ea934a7648
basic: fix size_t Wformat warnings (#2264)
Printing of a `size_t` requires the `%zu` specifier.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-02-18 09:11:32 -08:00
Ben Ashbaugh
9c5999bc1d
add SPIR-V 1.6 testing for Nontemporal Image Operand (#2249)
Adds a basic test for reading from and writing to an image with the
optional Nontemporal image operand.
2025-02-18 09:10:09 -08:00
Ben Ashbaugh
9b247c06be
fix several compile issues with Visual Studio toolchains (#2219)
Fixes several compile issues I am seeing for my version of Visual Studio
related to an ambiguous call to `fpclassify`, which is called by `isnan`
and other similar functions, specifically for the `cl_half` type:

```
19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(401,1): error C2668: 'fpclassify': ambiguous call to overloaded function
19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(298,31): message : could be 'int fpclassify(long double) throw()'
19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(293,31): message : or       'int fpclassify(double) throw()'
19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(288,31): message : or       'int fpclassify(float) throw()'
19>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h(401,1): message : while trying to match the argument list '(_Ty)'
```

Some of these issues seem like differences in compiler behavior, but at
least one appears to have identified a legitimate bug.

Specifically, this change:

* Removes the special-case checks for finite half numbers for commonfns,
since this is already handled by `UlpFn`. (test with: `test_commonfns
degrees radians`)
* Assigns to temporary variables to eliminate the ambiguous function
call for relationals. (test with: `test_relationals relational*`)
* Properly converts from half to float when checking for NaNs for
select. This is the one that seems like a legitimate bug. (test with:
`test_select select_half_ushort select_half_short`)
* Uses `std::enable_if` to disambiguate a function call for spirv_new.
(test with: `test_spirv_new decorate_saturated*`)

If it's helpful, my specific Visual Studio version is:

```
Microsoft Visual Studio Professional 2019
Version 16.11.20
VisualStudio.16.Release/16.11.20+32929.386
```

I also have the Windows Software Development Kit 10.0.19041.685
installed.
2025-02-18 09:09:17 -08:00
Sven van Haastregt
9f63decb9c
basic: add missing newline at end of error messages (#2275)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-02-13 07:24:51 -08:00
xinjin01
3618402c3a
Remove unsupported raw10/raw12 tests (#2232)
Images with a `CL_UNSIGNED_INT_RAW10_EXT` and
`CL_UNSIGNED_INT_RAW12_EXT` data type are unnormalised, so the
normalised tests with theses images are invalid and will be skipped.

Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
Signed-off-by: Xin Jin <xin.jin@arm.com>
Co-authored-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
2025-02-11 10:35:56 -08:00
Marcin Hajder
be130c9b1c
Removed vulkan sub-tests overlapping with semaphore negative tests (#2250)
Fixes #2153 according to issue description.
2025-02-11 10:34:29 -08:00
Ben Ashbaugh
a61feea656
adds SPIR-V tests for scalar printf operands (#2211)
Adds targeted SPIR-V tests for printf with scalar operands.  See:

* https://github.com/KhronosGroup/OpenCL-Docs/issues/1211
* https://github.com/KhronosGroup/OpenCL-Docs/pull/1236

The fp32 test is likely to be the most interesting, especially on
devices that support fp64, because printf with scalar fp32 operands is
not generated by default in this case with Clang and the SPIR-V LLVM
Translator.
2025-02-11 08:55:39 -08:00
Ahmed
0bfe516318
Add the half ulps values for embedded profile (#2265)
This change adds the half ulps values for embedded profile.


https://github.com/KhronosGroup/OpenCL-CTS/issues/1685
2025-02-11 08:54:47 -08:00
Ben Ashbaugh
d7cb6b006b
fix negative_create_command_buffer_not_supported_properties test (#2248)
fixes #2247 

* For the `negative_create_command_buffer_not_supported_properties`
test, the only property we can check for is simultaneous use. All other
properties are part of other extensions and hence will generate
`CL_INVALID_VALUE`, not `CL_INVALID_PROPERTY`.
* Checks whether the `cl_khr_command_buffer_multi_device` extension is
supported when using `CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR`, instead
of `device_side_enqueue_support`.
* If the `cl_khr_command_buffer_multi_device` extension is NOT supported
and the `CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR` command buffer creation
flag is used, the expected error code is `CL_INVALID_VALUE`, not
`CL_INVALID_PROPERTY`.
2025-02-11 08:52:53 -08:00
Sreelakshmi Haridas Maruthur
7188c4b29b
allocations: Make buffer kernel more efficient for multiple allocations (#2235)
- Fix malloc for 'access_string' and 'kernel_string'.
- Fix typo in 'number_of_work_itmes'.

Co-authored-by: Sreelakshmi Haridas Maruthur <sharidas@quicinc.com>
2025-02-11 08:49:34 -08:00
Ewan Crawford
044ec98f66
Command-buffer queue compatibility test update (#2230)
Update cl_khr_command_buffer tests to reflect changes from
https://github.com/KhronosGroup/OpenCL-Docs/pull/1292

* Moves negative test for
`CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR` from
command-buffer creation to enqueue.
* Moves negative test for
`CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR` from
command-buffer creation to enqueue.
* Introduces a negative test for `CL_INVALID_DEVICE` on command-buffer
enqueue for new error condition in spec. Although it requires a context
to be contain more than 1 device, which I'm not sure if possible in
current test framework.
* Introduces a new test that created a command-buffer using a queue
without the profiling property set, then enqueues the command-buffer to
a queue with the profiling property set.
* Introduces a new test that creates a command-buffer with an in-order
queue, enqueued on an out-of-order queue.
* Introduces a new test that creates a command-buffer with an
out-of-order queue, enqueued on an in-order queue.
2025-02-11 08:47:15 -08:00
Chuang-Yu Cheng
54afc2e7a5
printf: Fix floating-point rounding consistency for RTZ devices (#2202)
1. In vector test, prepare RTZ answer for RTZ rounding.

2. In mixed_format_random test, for a given float 'arg', the test
previously used 'arg' directly to generate ref_str:
   ```
     ref_str << str_sprintf(format, arg);
   ```

   This approach incorrectly assumes:
   ```
     (float) arg == to_fp(to_str(arg));
   ```

   However, this assumption fails under RTZ rounding. For example: 
   ```
     arg = 0xC642549C 
     to_str(arg) = -12437.152343f 
     to_fp_rtz(-12437.152343f) = 0xC642549B (-0X1.84A936P+13) 
     to_fp_rte(-12437.152343f) = 0xC642549C (-0X1.84A938P+13)
   ```

To address this, the reference result is now computed based on the
literal float string rather than the original 'arg' value.
2025-02-11 08:46:23 -08:00
Ahmed Hesham
ecd012737f
Generate the SPIR-V shaders automatically at build time (#2200)
Add custom commands and targets to automatically assemble and validate
the SPIR-V shaders used by the test.

Automatic assembly depends on finding `python3`, `spirv-as` and
`spirv-val`. `SPIRV_TOOLS_DIR` can be defined by the user during
configuration to provide an override path. Default behaviour assumes
that the binaries exist in `PATH`.

---------

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-02-11 08:43:37 -08:00
Sven van Haastregt
a8b32b2720
math_brute_force: remove LogBuildError (#2233)
`LogBuildError` was only ever called after `clSetKernelArg`, but setting
a kernel argument has no impact on the program build log. Printing of
the actual build log in case of a build failure is already handled via
`create_single_kernel_helper`.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-02-06 10:43:00 -08:00
Antonios Christidis
2031e21a58
Fix Build Warnings for AArch64 (#2242)
This commit links to issue (#2234).

When cross-compiling for AArch64, using gcc 13.3, you encounter three
warnings types that turn into errors:

- maybe-uninitialized
- stringop-truncation
- strict-aliasing

This commit fixes all the warnings found, in regards to the first two
rules. To resolve the warnigns due to strict-aliasing, I am editing the
CMake build system.

Signed-off-by: Antonios Christidis <a-christidis@ti.com>
2025-02-05 13:58:17 +01:00
Marcin Hajder
bcfa1f7c26
Added corrections to re-enable reciprocal test in math_brute_force suite for relaxed math mode (#2221)
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
2025-02-04 08:45:20 -08:00
Julia Jiang
cc9e61652f
Fix profiling execute_multipass failure with segmentation fault (#2256)
The buffer size input to the test function clEnqueueReadBuffer was
incorrect, which cause segmentation fault. And it didn't match the size
for the host allocation outptr
2025-02-03 13:46:52 +01:00
Chuang-Yu Cheng
5749818906
math_brute_force: fix fdim to use device's rounding when converting result back to half. (#2223)
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.
2025-01-28 12:33:00 -08:00
Ahmed Hesham
73dd3b9af8
Fix errors in test_vulkan (#2183)
This fixes three problems in `test_vulkan`:

1. One negative test is violating the OpenCL specification. A call to
`clEnqueue{Wait,Signal}SemaphoresKHR` with an invalid semaphore should
return `CL_INVALID_SEMAPHORE_KHR` and not `CL_INVALID_VALUE`.
>
[CL_INVALID_SEMAPHORE_KHR](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_INVALID_SEMAPHORE_KHR)
if any of the semaphore objects specified by sema_objects is not valid.

2. When populating the list of supported external memory handle types
for Vulkan, the types are unconditionally added to the list, without
checking if the device supports it or not, this fix is namely for
`VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD`.

3. If a device does not support an optional extension (that is required
for a test), the test should skip, not throw an exception and fail. A
test failure should be reserved for the cases where a device claims
support for an extension but then fails to execute the test correctly.

---------

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-01-28 10:08:24 -08:00
Marcin Hajder
c6cfb6800f
Added test to verify flush on clReleaseCommandQueue with multiple queues (#2134)
Fixes #2087 according to task description.
2025-01-28 08:53:40 -08:00
Sreelakshmi Haridas Maruthur
5b3518096c
bruteforce: Update ULP for half-precision divide to 1.0f (#2214)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 1s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 2s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 2s
Presubmit / Build ubuntu-22.04 android-aarch64 (push) Failing after 2s
Presubmit / Build ubuntu-22.04 android-arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m2s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
CTS test update to match proposed spec update
https://github.com/KhronosGroup/OpenCL-Docs/issues/1278
2025-01-21 09:44:47 -08:00
Marcin Hajder
98c3fe4f16
Added test for work-item functions with out-of-range arguments (#2099)
Fixes #2005 according to task description.
2025-01-21 08:39:28 -08:00
Ewan Crawford
2ff5cdaf7d
Command-buffer query for supported queue properties (#2101)
CTS test update to match OpenCL-Doc & OpenCL-Header PRs:
* https://github.com/KhronosGroup/OpenCL-Headers/pull/265
* https://github.com/KhronosGroup/OpenCL-Docs/pull/850

Tested with https://github.com/bashbaug/SimpleOpenCLSamples/pull/126
locally using a checkout of the linked OpenCL-Headers branch
2025-01-14 12:37:38 -08:00
joshqti
a7db9a49f9
vulkan: Choose where Shaders are generated (#2226)
- generate spv files into VULKAN_TEST_RESOURCES directory
- works with change that generates spv at build time

Co-authored-by: dcrawley <dcrawley@qti.qualcomm.com>
2025-01-14 10:12:02 -08:00
Kévin Petit
f6611ec912
Migrate commonfns suite to new test registration framework (#2197)
Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2025-01-14 09:11:31 -08:00
Sven van Haastregt
a2d6cadec1
relationals: fix -Wformat warnings (#2218)
Avoid a
```
  ‘%zu’ directive writing between 1 and 20 bytes into a region of size 16
```
warning by using `std::string` for `generate_shuffle_mask`.

As this fixes the last remaining Wformat warning in the relationals
suite, drop the local `-Wno-format` compiler option.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2025-01-14 09:08:32 -08:00
Ewan Crawford
bc5b0215ee
Fix derived command-buffer Skip() checks (#2217)
It was noticed during another PR review
https://github.com/KhronosGroup/OpenCL-CTS/pull/2207/files#r1903921283
that there
was a case where the return value of a `Skip()` check was ignored, this
is fixed in this PR.

I've also tracking down occurrences of derived class overriding the
`Skip()` test fixture method, but not calling the parents class `Skip()`
check inside of the method. I believe omitting this parent skip check
wasn't intentional, it's clearer to explicitly respect the parent
classes skip conditions, even if we've got away with not needing too due
to the way the derived class skip conditions have been defined.
2025-01-14 09:07:41 -08:00
Ewan Crawford
98d52d0d56
Check command-buffer extension version for equality (#2215)
As described in Issue
https://github.com/KhronosGroup/OpenCL-CTS/issues/2152 we currently
check the provisional extension version supported by a vendor is the
same or older than a test specified version. However, it was discussed
in the WG that this should be a check for equality to avoid hitting
issues when a implementation tests against an older version of the CTS
using a lower extension version, with API breaking changes having
occurred since.

The tests for the command-buffer family of extensions are the only
provisional KHR tests using this versioning check, so this PR updates
all those cases to equality.
2025-01-14 09:06:30 -08:00
Ben Ashbaugh
4fd42150bc
add testing for SPIR-V 1.5 (#2208)
fixes #2140 

Adds testing for SPIR-V 1.5 features:

* Adds a test for bitcasts between pointers and vectors of integers.
Note, SPIR-V 1.5 only supports bitcasts to vectors of two 32-bit
integers. Therefore, the SPIR-V 1.5 behavior will only be exercised on
devices with 64-bit pointers. The test will run on devices with 32-bit
pointers, but will instead bitcast to scalars.
* Adds a test for OpGroupNonUniformBroadcast with a dynamic index. Note,
this is not an exhaustive test, and only unsigned integer types are
tested, to avoid duplicating testing for cl_khr_subgroup_ballot.
2025-01-14 09:05:47 -08:00
Ewan Crawford
74cb5cd608
[NFC] Add .gitignore file (#2216)
Introduce a `.gitignore` file to the repository matching a build folder
`[Bb]uild/` pattern.
2025-01-09 20:55:37 -08:00
Marcin Hajder
d058dfdeef
Corrected test_vulkan to use specific platform/device from harness (#2154)
Fixes #1926 according to task description
2025-01-07 23:39:38 +05:30
Marcin Hajder
4c70fecad7
Moved sub-test external_semaphores_import_export_fd to test_external_semaphore executable (#2110)
Fixes #1989 according to task description. Moreover, fixes #1876 as
well.
2025-01-07 10:06:20 -08:00
Kévin Petit
6fc3870728
Delete read_array_half and write_array_half tests (#2212)
These tests are broken, have been disabled for the longest time, and
don't add significant value.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2025-01-07 10:00:12 -08:00
Karol Herbst
34feb6e008
svm: finish all queues in svm_pointer_passing (#2209)
The `svm_pointer_passing` test has unflushed buffer unmap commands
queued, which a runtime might process after the `clSVMFree` calls at the
end of the test (through implicit flushing when destroying the queues at
e.g. program exit handlers).

This is only an issue when running the test with multiple devices.

However I think this was caused by a simple typo given the `clFinish`
was simply in the wrong block.
2025-01-07 09:35:46 -08:00
Romaric Jodin
86e0c236a1
fix negative_create_command_buffer_device_does_not_support_out_of_ord… (#2207)
…er_queue

Test should be skipped if device does not support out of order queue or
if device supports out of order command buffer.

Fix #2204
2025-01-07 09:33:29 -08:00
Romaric Jodin
435db66a3a
fix negative_command_buffer_enqueue_with_different_context (#2206)
negative_command_buffer_enqueue_with_different_context does not need to
use CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE

Fix #2205
2025-01-07 09:32:36 -08:00
Ahmed Hesham
4486241540
Generate the Vulkan shaders at build time (#2199)
Use `add_custom_command` and `add_custom_target` instead of
`execute_process` so the generation of the Vulkan shader is done at
build time and not configuration time.

Use `configure_file` instead of string replacement.

Fixes #2179

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2025-01-07 09:30:27 -08:00
Kamil-Goras-Mobica
28da01788d
Removed checking for supporting half (#2175)
Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1982 according
to description
2025-01-07 09:29:28 -08:00
Sven van Haastregt
2ea4d165d5
cmake: remove global -Wno-format (#2195)
Move the global `-Wno-format` compiler option to the individual tests
that still trigger Wformat warnings. The majority of the tests now
compile cleanly with `-Wformat` enabled.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-12-24 14:49:31 +01:00
Ahmed Hesham
baed156699
Migrate the select suite to the new test registration framework (#2198)
Contirbutes to #2181

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-12-18 20:29:16 +00:00
Ahmed Hesham
794d332bab
Migrate API suite to the new test registration framework (#2196)
Contributes to #2181

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-12-18 17:29:08 +00:00
Ahmed Hesham
2316c6343f
Migrate allocations suite to the new test registration framework (#2191)
Contributes to #2181
2024-12-18 11:42:12 +00:00
Sven van Haastregt
9bb8a89bbd
semaphore: fix Wformat warning (#2194)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-aarch64 (push) Failing after 1s
Presubmit / Build ubuntu-22.04 android-arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
`i` is an `int`, so shouldn't use the `%zu` specifier for printing.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-12-17 23:41:36 +05:30
Katarzyna Cencelewska
e17e6eef7b
add option to bruteforce test to force count of worker threads (#2188)
- 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>
2024-12-17 09:58:03 -08:00
Kévin Petit
57a91b7ffe
[NFC] Migrate profiling suite to new registration framework (#2187)
Contributes to #2181

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2024-12-17 09:57:27 -08:00
Sven van Haastregt
7693ffe0a5
Fix more 32-bit Wformat warnings (#2185)
This fixes occurrences where the previous wrong specifier appears to
work in a typical 64-bit build, but causes a Wformat warning in 32-bit
builds.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-12-17 09:55:37 -08:00
Kévin Petit
be1278d5b2
Add utility macro to skip test when an extension is not supported (#2178)
Use in cl_khr_external_semaphore suite as an example.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2024-12-17 09:54:51 -08:00
Michael Rizkalla
09e4d03e46
Fix clCopyImage 1D buffer images tests with use_pitches flag (#2167)
This change fixes the following issues when running `clCopyImage` test
with `use_pitches` flag for 1D buffer images.

1. Query device CL version using `get_device_cl_version` rather than
using `CL_DEVICE_VERSION`. Previously, using `char` may not be enough to
store the return value.
2. Pass `host_ptr` to `clCreateBuffer` when creating the buffer for the
1D image. `host_ptr` may not be `nullptr` if use_pitches flag is used.
Also, `buffer_flags` will contain `CL_MEM_USE_HOST_PTR` which requires a
host pointer to be passed.
3. Conditionally use the `host_ptr` when calling `clCreateImage`, it
will not be used with 1D image buffer. This is made to align with the
spec, in which if `mem_flags` has `CL_MEM_USE_HOST_PTR` a host pointer
must be present, but if the memory flag is not present, host pointer
must be `nullptr`.
4. Use the correct free function `free` and `align_free` based on the
allocation function that was used.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2024-12-17 09:53:56 -08:00
John Kesapides
177be0969b
Extend clSetDefaultDeviceCommandQueue test coverage (#1551)
Fixes #23

Signed-off-by: Vikas Katariya <vikas.katariya@arm.com>

---------

Signed-off-by: Vikas Katariya <vikas.katariya@arm.com>
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Co-authored-by: Vikas Katariya <vikas.katariya@arm.com>
2024-12-17 09:53:35 -08:00
Kamil-Goras-Mobica
2df00c65a1
Added unique_ptrs and MTdataHolder to test_atomics.cpp (#2169)
Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1793 according
to description
2024-12-17 08:44:27 -08:00
Michael Rizkalla
e61da21cd6
Fix using incorrect free function in arrayimagecopy and imagearraycopy basic tests' unique_ptr (#2177)
This change addresses a free function mis-match issue where `delete` is
used to free memory allocated via `malloc` within `create_random_data`
and in the test function.

The change involves the following tests:
1. arrayimagecopy
2. arrayimagecopy3d
3. imagearraycopy
4. imagearraycopy3d

This should address #2173

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2024-12-17 09:30:48 +01:00
Ahmed Hesham
7d9ecaaf73
Migrate vectors suite to the new test registration framework (#2190)
Contributes to #2181
2024-12-13 16:47:01 +00:00
Ahmed Hesham
2fe382ec8a
Migrate atomics suite to the new test registration framework (#2189)
Contributes to #2181
2024-12-13 16:33:56 +00:00
Kévin Petit
5b7af4b36d
[NFC] Change the name of the default device provided by the new registration framework (#2186)
The code base uses a mix of 'device' and 'deviceID'. I suggest we
standardise on 'device' which is shorter and slightly more prevalent.

Contributes to #2181

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2024-12-12 13:24:04 -08:00
Sven van Haastregt
56d383b2e9
Fix more Wformat warnings related to size_t (#2166)
Printing of a `size_t` requires the `%zu` specifier.

This fixes occurrences where the previous wrong specifier appears to
work in a typical 64-bit build, but causes a Wformat warning in 32-bit
builds.

---------

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-12-10 09:13:58 -08:00
Ben Ashbaugh
d99b302f90
switch SVM tests to the new test registration framework (#2168)
Switches the SVM tests to the new test registration framework.

The first commit is the best to review and contains the actual changes.
The second commit purely has formatting changes.

Note that several of these changes were a bit more than mechanical
because many of the SVM tests create a new context vs. using the context
provided by the harness and passed to each test function. The previous
code named the context provided by the harness differently, and hence
could use the name "context" in each test function, but with the new
test registration framework this is no longer possible. Instead, I am
creating the new context using the name "contextWrapper" and then
assigning it to the "context" passed to the test function, which seems
like the best way to avoid using the wrong context unintentionally. I am
open to suggestions to do this differently.

I have verified that the same calls are made before and after these
changes, and specifically that there are no context leaks.
2024-12-03 14:51:23 -08:00
Ahmed Hesham
e361b387d9
Add Android to the CI build matrix (#2165)
Support building for Android on Arm and AArch64 platforms.

Modify the build matrix to add to new variations. Both variants
download, extract and setup the Android Native Development Kit (NDK) on
a Linux runner. Each variant specifies a `android_arch_abi`, which is
passed to CMake during configuration as its `CMAKE_ANDROID_ARCH_ABI`
option.

The CMake toolchain file provided by the NDK is used when building for
Android. The NDK version used is r27c, which is the latest Long-Term
Support (LTS) version. `ANDROID_PLATFORM` is intentionally not set, so
the NDK can default to the minimum supported version, which is 21. The
compiler (Clang) version used by this NDK is 18.0.3.

The NDK ships with its own sysroot, which has the Linux kernel headers
of version 6.8.0, or `LINUX_VERSION_CODE 395264`.

CMake
https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#id23
https://cmake.org/cmake/help/latest/variable/CMAKE_ANDROID_ARCH_ABI.html

NDK
https://developer.android.com/ndk/downloads
2024-12-03 08:56:46 -08:00
Sreelakshmi Haridas Maruthur
3bdd2f99b5
cl_fill_image: Use CL_DEVICE_VERSION instead of CL_DEVICE_NUMERIC_VER… (#2043)
…SION

CL_DEVICE_NUMERIC_VERSION is only available from OpenCL 3.0 Use
CL_DEVICE_VERSION instead.
2024-12-03 08:55:37 -08:00
Kévin Petit
0a1456d8f9
[RFC] Move logic for test registration to the test harness (#2151)
And use in device_timer suite.

Signed-off-by: Kévin Petit <kpet@free.fr>
2024-11-26 09:55:09 -08:00
Ahmed Hesham
df5e87bf97
Use the system package manager to install cross-compilers (#2158)
On Ubuntu, use the system's package manager, `apt`, to download and
install the cross-compilers for Arm and AArch64. This replaces
downloading the compilers as tarballs.

To ensure that the correct version of the compiler is used when calling
one without the version suffix, e.g. `aarch64-linux-gnu-gcc`, use
`update-alternatives`.

On Linux, the compilers for `x86_64`, `arm`, and `aarch64` will now
correctly use the filesystem root as their sysroots, i.e. `/usr/include`
will be used when searching for headers, instead of each compiler
providing its own.
2024-11-26 09:30:41 -08:00
Ahmed Hesham
5d85fb3e3b
Use cl_uint in some SPIR-V tests to avoid UB (#2159)
The following tests under `spirv_new`:
* `op_branch_conditional`
* `op_phi`
* `op_selection_merge`

were using randomly generated `cl_int` values, and storing the
difference between them as a `cl_int`. If one of the generated values is
negative and large enough, while the other is positive and large enough,
the difference then becomes a larger value that cannot be represented
using `cl_int`.

Switch the tests to use `cl_uint` instead, and update the relevant
spvasm{32,64} files to use `OpULessThan` instead of `OpSLessThan`.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-11-26 09:29:27 -08:00
gorazd-sumkovski-arm
96e3d7e669
Command buffer test adjustments (#2141)
Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
2024-11-26 09:26:04 -08:00
Sven van Haastregt
e360d2de5b
Fix various Wformat warnings (#2135)
test_copy_1D.cpp: num_mip_levels is a cl_uint, so don't cast and just
print using `%u`.

test_pipe_info.cpp: arg_type_qualifier is a 64-bit wide bitfield, so
print in hexadecimal format using the correct length modifier.

test_device_partition.cpp: it is not clear what the bit width of
`cl_device_partition_property` should be, so cast the operands to align
with the format specifiers.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-11-26 09:25:38 -08:00
Sreelakshmi Haridas Maruthur
d3b9520adc
printf: add fflush(stdout) at the end (#2103)
Some platforms (Windows in our case) seem to need this.
2024-11-26 09:25:01 -08:00
joshqti
1102e0bccf
Fix snorm (#2033)
When comparing scanlines for SNORM images, take into account that -1.0
can be exactly represented in two different ways.

---------

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
2024-11-26 09:24:35 -08:00
Kamil-Goras-Mobica
feca4c6354
Removed usage of half types in CTS gl tests (#2147)
see #1982
2024-11-26 08:39:42 -08:00
Ben Ashbaugh
e9a248f555
add SPIR-V 1.4 testing for OpCopyLogical (#2136)
This PR adds targeted testing for the SPIR-V 1.4 instruction
OpCopyLogical.
2024-11-25 07:35:50 -08:00
Sven van Haastregt
2358b46553
[NFC] kernelHelpers: remove unused macros and prototypes (#2156)
None of these are referenced anywhere in the code, so remove them.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-11-22 11:41:15 -08:00
Michael Rizkalla
918d561c6c
Refactor test copy from and to image to buffer (#2138)
This change refactors the following files:
1. test_imagearraycopy.cpp
2. test_arrayimagecopy.cpp

The purpose of refactoring is to allow passing different buffer and
image flags to the test function as well as passing customisable test
functions.

Signed-off-by: Michael Rizkalla <michael.rizkalla@arm.com>
2024-11-19 10:11:58 -08:00
Marcin Hajder
a9be3cc0e8
Added semaphore test to cover out-of-order operations synchronized with barrier (#2068)
Fixes #1979 according to task description.
2024-11-19 08:41:22 -08:00
joshqti
239159fd26
Re-enable simple_semaphore_2 (#2123)
Re-enable a disabled external semaphore test.
Delete obsolete subtests that remain in comments.
2024-11-12 10:10:07 -08:00
Kamil-Goras-Mobica
265cc18843
Corrected build under msvc compiler #1833 (#2121)
Fixes #1833 according to task description.
2024-11-12 08:55:57 -08:00
Ben Ashbaugh
b149060d52
add SPIR-V 1.4 testing for various miscellaneous additions (#2122)
This PR adds targeted testing for a few remaining miscellaneous SPIR-V
1.4 features:

* Variables in the Function storage class can have a NonWriteable
decoration.
* OpCopyMemorySized can have two optional memory operands.
* OpSelect can have composite operands that are not vectors.
2024-11-11 12:39:00 -08:00
Ahmed Hesham
10130a1261
Fix payload value query for external semaphores (#2127)
When creating a CL semaphore object from a Vulkan semaphore one, we
explicitly pass `-1` as the file descriptor value in the case of
`VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD`. According to the CL
specification:

>     The special value -1 for fd is treated like a valid sync file
>     descriptor referring to an object that has already signaled. The
>     import operation will succeed and the semaphore will have a
>     temporarily imported payload as if a valid file descriptor had
>     been provided.

The test currently checks that the semaphore payload is unsignalled,
unconditionally, which is incorrect.

Changed the test to check for the correct expected payload value.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-11-05 23:44:41 +05:30
joshqti
5d4b51b4f2
vulkan: Remove redundant negative testing (#2078)
- negative testing for semaphore functions is accomplished in semaphore
tests, as well as create image in the api test

Co-authored-by: dcrawley <dcrawley@qti.qualcomm.com>
2024-11-05 23:41:52 +05:30
saurabhnv
ef73a1d1ae
Import Vulkan resources via named NT handle (#1895)
Add coverage to import Vulkan resources (memory and semaphore) in
Windows via named NT handles.
If no name is given during resource creation, then use NT handles for
import.
If a name is given, have an option to either use that name or get the NT
handle and use that for import.
Resolves KhronosGroup/OpenCL-Docs#943
2024-11-05 10:09:07 -08:00
xinjin01
e211470035
Fix CTS mutable_dispatch memory leak (#2129)
Current class wrapper of the CTS test framework allows getting the
pointer of the private member object. This puts the object at risk of
losing its original value if the pointer gets reassigned, causing a
memory leak and potentially other problems.

This happens to the "clMemWrapper kernel" used by
mutable_command_work_groups tests, where the "clMemWrapper kernel" gets
initialised by the default basic setup function and then it gets
reassigned by the build_program_create_kernel_helper() helper function
through pointer.

This patch fixes this issue by updating mutable_command_work_groups
tests: instead of calling basic setup function and then initialise the
"clMemWrapper kernel" object again in the helper function, it now
overrides the basic setup function to make sure the "clMemWrapper
kernel" will be assigned only once.

Signed-off-by: Xin Jin <xin.jin@arm.com>
2024-11-05 08:53:55 -08:00
David Neto
040dc5f69e
kernel_image_methods: Fix size checks in 1Dbuffer case (#2106)
Image height is initialized to 0. But the size calculation should assume
a height of 1.
2024-11-05 08:53:27 -08:00
Qichao Gu
ccd455040a
Enable building OpenCL-CTS with Intel DPC++/C++ compiler ICX on Windows (#2088)
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.
2024-11-05 08:52:16 -08:00
Marcin Hajder
6563c9062c
Added test to verify required features coupling (#2115)
Fixes #1366 according to task description.
2024-11-05 08:38:45 -08:00
Ben Ashbaugh
c4119f07c1
add SPIR-V 1.4 testing for UserSemantic (#2053)
This PR adds targeted testing for more SPIR-V 1.4 features.
Specifically, this PR adds testing for OpDecorateString,
OpMemberDecorateString, and the UserSemantic decoration.
2024-10-31 07:12:30 -07:00
Ben Ashbaugh
d8228f0d72
remove using namespace std and use std namespace explicitly (#2125)
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).
2024-10-29 09:44:49 -07:00
Sven van Haastregt
8369028c92
cl_khr_semaphore: fix -Wformat warnings (#2124)
Add a `format` parameter to the macro, to be able to specify how to
print the expected and actual parameter values.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-10-29 09:43:30 -07:00
Harald van Dijk
7d3e1f0b82
Fix check for CL_DEVICE_HALF_FP_CONFIG. (#2108)
When cl_khr_fp16 is not supported, this property is not available.

Note that the spec is different for
CL_DEVICE_{PREFERRED,NATIVE}_VECTOR_WIDTH_HALF: those properties are
always available and return 0 if cl_khr_fp16 is not supported, so those
checks are left as is.
2024-10-29 09:41:16 -07:00
tomasz-platek
66fd9e4742
Fix for out of bounds access (#2105)
Rounding up the clusters_results size to avoid out of bounds access when
subgroup_size is not a multiple of cluster_size.
2024-10-29 09:39:42 -07:00
Sven van Haastregt
dd2454685b
[NFC] math_brute_force: use getAllowedUlpError for half (#2086)
Call `getAllowedUlpError` to obtain the allowed ULP error for all of the
half type (fp16) tests. The aim is to standardise obtaining the desired
ULP requirement and pave the way for adding the Embedded Profile ULP
errors.

Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/867
Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/1685

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-10-29 09:37:51 -07:00
Ben Ashbaugh
bc5f6cdfe8
add SPIR-V 1.4 testing for OpPtrEqual, OpPtrNotEqual, OpPtrDiff (#2054)
This PR adds targeted testing for the SPIR-V 1.4 instructions
OpPtrEqual, OpPtrNotEqual, and OpPtrDiff.
2024-10-29 09:36:26 -07:00
Kamil-Goras-Mobica
b1dfe8a640
Add testing for CL_KERNEL_LOCAL_MEM_SIZE #1235 (#2089)
#1235
2024-10-29 08:55:46 -07:00
Sven van Haastregt
6337d9be46
semaphore: fix mistyped "platform" in log messages (#2128)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-10-28 17:03:12 -07:00
joshqti
899cbf5cd2
vulkan: accept device selection (#2113)
- read CL_DEVICE_TYPE_ when specified like other conformance tests
- reject non-GPU device types

Co-authored-by: dcrawley <dcrawley@qti.qualcomm.com>
2024-10-22 22:44:57 +05:30
Sven van Haastregt
5b3bfeeca8
[NFC] relationals: fix -Wformat-security warnings (#2084)
Fix a "format string is not a string literal (potentially insecure)"
warning.

There is no security issue here as the format string argument is
constructed using a stringstream right before. Fix this occurrence
anyway to allow enabling the warning globally.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-10-22 18:00:38 +01:00
gorazd-sumkovski-arm
e678277c93
Add testing of CL_UNORM_INT_2_101010_EXT (#2112)
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>
2024-10-22 09:54:46 -07:00
Aharon Abramson
482a6bcff0
Some events are not released in test_mem_host_flags (#2104)
In test_mem_host_flags, some events are not released. In fact, they are
not used, so they can be removed altogether.
2024-10-22 09:52:31 -07:00
gorazd-sumkovski-arm
6a2c0b1cff
Fix bug in mutable_command_full_dispatch (#2082)
This test did not pass the `-cl-std=` flag when building the program. As
a result, for an OpenCL 3.0 device, the program will be "compiled using
the highest OpenCL C 1.x language version supported" by the device.
However this will force uniform work-group sizes which leads to a
`CL_INVALID_WORK_GROUP_SIZE` error.

To fix this, use the `create_single_kernel_helper()` helper function
which will automatically get the device version and pass that to
`-cl-std=` when building the program.

---------

Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
2024-10-22 09:51:46 -07:00
gorazd-sumkovski-arm
1a17853e75
Command buffer testing fixes (#2081)
Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
2024-10-22 09:50:20 -07:00
joshqti
5026b1be00
vulkan: Use image row pitch (#2077)
When importing a Vulkan external image, query and
pass OpenCL a row pitch if OpenCL is assuming linear for the imported
external handle type. Additionally fix a bug where OpenCL is being told
to create mipmapped images at all times.

---------

Co-authored-by: dcrawley <dcrawley@qti.qualcomm.com>
2024-10-22 09:48:41 -07:00
Ben Ashbaugh
ec6394488a
add SPIR-V 1.4 testing for no integer wrap decorations (#2041)
This PR adds targeted testing for SPIR-V 1.4 features. Specifically,
this PR adds testing for the NoSignedWrap and NoUnsignedWrap
decorations.

We can reuse large parts of the testing for the
`cl_khr_spirv_no_integer_wrap_decoration` extension to test the SPIR-V
1.4 feature.
2024-10-22 09:47:57 -07:00
Ben Ashbaugh
94257defea
add SPIR-V 1.4 testing for Image Operands and Loop Controls (#2034)
This PR adds targeted testing for SPIR-V 1.4 features. Specifically,
this PR adds testing for:

1. The new Image Operand for SignExtend and ZeroExtend.
2. The new Loop Controls MinIterations, MaxIterations,
IterationMultiple, PeelCount, and PartialCount.
2024-10-22 09:47:31 -07:00
Sven van Haastregt
d1fe1ec252
conversions: fix condition for adding -cl-denorms-are-zero (#2067)
Commit b6941b6c ("Add fp16 testing to conversions and bruteforce
(#1975)", 2024-06-18) introduced a behavioural change for non-half
tests. The `-cl-denorms-are-zero` option could be added for non-half
tests such as `char_rtn_float` even when `gForceFTZ` was `false`. Fix
the condition by also taking the input and output types into account.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-10-22 09:45:03 -07:00
xinjin01
63ce937aac
Fix bug in mutable_command_full_dispatch (#2118)
The test is missing clFinish after clEnqueueSVMUnmap. Add clFinish after
clEnqueueSVMUnmap.

Signed-off-by: Xin Jin <xin.jin@arm.com>
2024-10-17 07:39:38 -07:00
Ben Ashbaugh
c071db7637
fixes a narrowing warning (treated as an error) affecting some platforms (#2117)
Looks like https://github.com/KhronosGroup/OpenCL-CTS/pull/2063 has a
"narrowing" warning that is now treated as an error and is hence causing
CI builds to fail.

Applies the same fix as
https://github.com/KhronosGroup/OpenCL-CTS/pull/2107 to fix this
warning.
2024-10-16 09:18:59 +02:00
joshqti
115068e2c4
vulkan: Choose where Shaders are generated (#2114)
- generate shader files in VULKAN_TEST_RESOURCES directory
- allows for outside CMakeLists to specify arbitrary destination

Co-authored-by: dcrawley <dcrawley@qti.qualcomm.com>
2024-10-15 10:17:41 -07:00
joshqti
881635a187
vulkan: Propagate fix to multiImport diffCtx (#2075)
Vulkan descriptors are being programmed incorrectly, use fix from 1676
in other subtest

Co-authored-by: dcrawley <dcrawley@qti.qualcomm.com>
2024-10-15 10:09:56 -07:00
Qichao Gu
9f54727924
Fix integer overflow in 1D buffer image tests (#2092) 2024-10-15 10:01:36 -07:00
Marcin Hajder
2998463eb4
Added missing test cases for CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR queries (#2063)
According to comments from issue #1875

---------

Co-authored-by: Nikhil Joshi <nikhilj@nvidia.com>
2024-10-15 08:44:23 -07:00
Ahmed Hesham
1527c4e425
Fix warning now treated as error (#2107)
Following the re-enablement of narrowing warnings, this fixes a
compilation error when running the `ubuntu 22.04 arm` GitHub action.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-10-08 13:11:46 -07:00
Ewan Crawford
b64f429b4a
Add new extensions to conformance csv files (#2096)
The extension tests in `test_conformance/extensions` have not matching
entries in the `opencl_conformance_tests_*.csv` files. This means that
they are missed from conformance runs by vendors who use these files.

I've included the new extensions in the full and quick CSV files as they
don't have vast combinations of tests to run like bruteforce or
conversions.

I've put `cl_khr_dx9_media_sharing` in the
`test_conformance/opencl_conformance_tests_d3d.csv` CSV as like the
other tests there the test binary is conditional built only on a Windows
platform.

I've created a new `opencl_conformance_tests_vulkan.csv ` file for
testing the `cl_khr_external_semaphore` extension, as creation of the
binary is conditional on the Vulkan SDK being enabled environment. Any
other tests that require the Vulkan SDK in future can also be added
there.
2024-10-08 09:58:31 -07:00
Michal Babej
c40c8d56f6
a few fixes (thread safety & cl_khr_command_buffer UB) (#1840)
some fixes we've been carrying in our CTS fork:

* fix UB in `command_buffer_event_sync.cpp`: enqueue of two commands in
two separate queues, with both using the same buffer argument, and no
synchronization between the commands.
* fix UB in `command_buffer_test_barrier.cpp`: missing synchronization
between zeroing command and command-buffer using two separate queues
* make `test_thread_dimensions.cpp` thread-safe to avoid spurious
errors.
2024-10-08 09:55:21 -07:00
ellnor01
617e7cb233
Re-enabling narrowing errors (#1144)
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>
2024-10-08 09:54:32 -07:00
Sreelakshmi Haridas Maruthur
7d86714c10
bruteforce: Fix retry logic for cases with subnormals (#2091)
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>
2024-10-08 09:53:55 -07:00
Marcin Hajder
d339fd4356
Extended printf test to verify length sub-specifiers (#2083)
According to work plan for issue #1058
2024-10-08 08:38:18 -07:00
Jaroslaw Warchulski
9cf439488a
Fix printing in test_api_min_max (#2102)
before: Filling constant buffer with 553805440 cl_ints (-2079745536
bytes).
after: Filling constant buffer with 553805440 cl_ints (2215221760
bytes).
2024-10-03 11:58:28 +02:00
joshqti
7cadf60117
vulkan: Use Vulkan 1.1 (#2076)
Increase Vulkan version to 1.1, which is required to support
vkGetBufferMemoryRequirements2.
2024-10-01 22:26:57 +05:30
Sreelakshmi Haridas Maruthur
3a5502539c
bruteforce: Fix comparions of unsigned shorts with 0.0f (#2095)
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>
2024-10-01 09:27:42 -07:00
Michal Babej
2be73b2be1
fix generic_address_space, command_buffer_event_sync, test_compiler and images/test_1D_buffer (#2062)
fixes several issues:

* `generic_address_space` test: add check for program scope variables.
The test uses both generic AS and program-scope variables, however it
only checked the generic-AS presence in `clGetDeviceInfo`.
* `compiler/test_compiler_defines_for_extensions.cpp`: add
`cl_khr_command_buffer_multi_device` to the list of recognized
extensions
* `command_buffer_event_sync.cpp`: add delays for testing
`clSetEventCallback` - according to specification, these can be executed
asynchronously (in a separate thread) by the OpenCL implementation,
hence the event callback is not quaranteed to be called before
`clFinish()` returns. Existing test `events/test_callbacks.cpp` also
waits for callback with loops of usleep.
* `images/kernel_image_methods/test_1D_buffer.cpp`: fix allocation size
being too small for the 1D buffer backing the image

---------

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
2024-10-01 09:26:39 -07:00
Grzegorz Wawiorko
97cf4c7e25
Math bruteforce test - enable erf/erfc functions (#1289)
It was disabled because lack of reference implementation. However the
reference implementation exists. Then no reason to start testing these
functions.
2024-10-01 09:25:45 -07:00
ellnor01
7e859cc296
Queue profiling and Device timebase equality test (#1150)
Adds test to confirm that the timestamp returned from
clGetEventProfilingInfo for an event on a device and a device
timestamp queried from the same device are in the same timebase.

Fixes #753

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>

---------

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
2024-10-01 09:25:16 -07:00
Kamil-Goras-Mobica
bcd54787e7
Added fp16 and fp64 api consistency tests (#2058)
#1578
2024-10-01 08:51:37 -07:00
Marcin Hajder
0395a1efef
Correction for printing long type variables in 32-bit system (#2094)
Due to change request from #2037
2024-10-01 08:45:39 -07:00
John Kesapides
cd74e02643
Use CTS type wrappers for test_global_linear_id. (#1545)
Signed-off-by: John Kesapides <john.kesapides@arm.com>

---------

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2024-09-24 18:02:32 +01:00
saurabhnv
e865c1e8dd
Fix vulkan subtest for diffCtx and platform/device info (#2046)
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.
2024-09-24 08:55:01 -07:00
Ahmed Hesham
0c7fbc46e6
Fix 1D buffer image tests (#2073)
Buffer size needs to be greater than or equal the image row pitch which
was not the case.
2024-09-24 08:53:00 -07:00
Joerg
1cede6dc2b
Skip testing mipmaps if extension is not available (#2085)
'./test_image_streams test_mipmaps CL_FILTER_NEAREST' already skips many
tests, but doesn't do so for cl_ext_image_raw10_raw12, causing it to
fail.

Add a check similar to how it is done in the other tests already.

On a device which doesn't support mipmap'd access:
W/o fix
```
./test_image_streams test_mipmaps CL_FILTER_NEAREST
...
1Darray passed
2Darray...
-----------------------------------------------------
This device does not support cl_khr_mipmap_image.
Skipping mipmapped image test. 
-----------------------------------------------------

-----------------------------------------------------
This device does not support cl_khr_mipmap_image.
Skipping mipmapped image test. 
-----------------------------------------------------

2Darray passed
cl_image_requirements_size_ext_negative...
...
image_from_buffer_read_positive passed
cl_ext_image_raw10_raw12...
---- Supported 2D read formats for this device for cl_ext_image_raw10_raw12---- 
  CL_R    CL_UNSIGNED_INT_RAW10_EXT 0
  CL_R    CL_UNSIGNED_INT_RAW12_EXT 0
------------------------------------------- 
read_image (normalized float coords, uint results) *****************************
[CL_R    CL_UNSIGNED_INT_RAW10_EXT 1] - CL_FILTER_NEAREST - CL_ADDRESS_CLAMP_TO_EDGE - NORMALIZED
ERROR: clBuildProgram failed! (CL_BUILD_PROGRAM_FAILURE from <>/OpenCL-CTS/test_common/harness/kernelHelpers.cpp:844)
Build options:  -cl-std=CL3.0
Original source is: ------------
#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
__kernel void sample_kernel( read_only image2d_t input, sampler_t imageSampler, __global float *xOffsets, __global float *yOffsets, __global uint4 *results , float lod)
{
   int tidX = get_global_id(0), tidY = get_global_id(1);
   unsigned int lod_int = (unsigned int) lod;
   int width_lod = (get_image_width(input) >> lod_int) ?(get_image_width(input) >> lod_int):1 ;
   int offset = tidY*width_lod + tidX;
   float2 coords = (float2)( (float)( xOffsets[offset] ), (float)( yOffsets[offset] ) );
   results[offset] = read_imageui( input, imageSampler, coords , lod);
}Build not successful for device <>, status: CL_BUILD_ERROR
Build log for device <> is: ------------
<source>:1:26: warning: unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring
#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
                         ^

<source>:9:22: error: no matching function for call to 'read_imageui'
   results[offset] = read_imageui( input, imageSampler, coords , lod);
                     ^~~~~~~~~~~~

error: Compiler frontend failed (error code <unknown>)
```


With fix:
```
./test_image_streams test_mipmaps CL_FILTER_NEAREST
....
image_from_buffer_read_positive...
image_from_buffer_read_positive passed
cl_ext_image_raw10_raw12...
---- Supported 2D read formats for this device for cl_ext_image_raw10_raw12---- 
  CL_R    CL_UNSIGNED_INT_RAW10_EXT 0
  CL_R    CL_UNSIGNED_INT_RAW12_EXT 0
------------------------------------------- 
-----------------------------------------------------
This device does not support cl_khr_mipmap_image.
Skipping mipmapped image test. 
-----------------------------------------------------

cl_ext_image_raw10_raw12 passed
PASSED sub-test.
PASSED 18 of 18 tests.
```
2024-09-24 08:52:10 -07:00
Marcin Hajder
661a7b08ae
Added printf test for long type cases (#2037)
according to work plan for issue
https://github.com/KhronosGroup/OpenCL-CTS/issues/1058
2024-09-24 08:42:49 -07:00
Marcin Hajder
8c647c1cf4
Added new tests to verify negative results of clEnqueueSignalSemaphoresKHR (#2006)
According to work plan from issue
https://github.com/KhronosGroup/OpenCL-CTS/issues/1691
2024-09-24 08:41:45 -07:00
energystoryhhl
2d077cf12b
Add flag to track wether glut has been initialized (#2023)
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>
2024-09-20 14:34:10 +02:00
Sven van Haastregt
97045f85a1
[NFC] math_brute_force: remove warning options (#2061)
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>
2024-09-19 07:59:43 -07:00
Cui, Dele
9f88b0b229
Specify precision in the format flag for float4 hexadecimal output (#2064)
This will ensure consistent output on any conforming implementation.
Note that the specification does not define the output style when
precision is missing.

---------

Signed-off-by: Cui, Dele <dele.cui@intel.com>
2024-09-19 09:30:10 +02:00
Ben Ashbaugh
dd2117f5fc
fix a few array-based mutable command buffer issues (#2074)
fixes a few minor issues introduced by #1984.

edit: Tested with the updated command buffer emulation layer on a device
that supports out-of-order queues and SVM and all of the
`test_cl_khr_mutable_dispatch` tests pass.
2024-09-17 09:34:17 -07:00
Sven van Haastregt
c083a87b35
[NFC] math_brute_force: add type argument to getAllowedUlpError (#2017)
Add a type argument so that in the future we can request the ULP
requirement for fp16 and fp64 types through `getAllowedUlpError` too.

Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/867

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-09-16 08:48:04 -07:00
Aharon Abramson
a773a379d9
Update test_event_dependencies.cpp (#2049)
In test_event_enqueue_wait_for_events_run_test:
* Decrease TEST_COUNT to 10
* Add clFinish to queues
2024-09-16 08:46:54 -07:00
gorazd-sumkovski-arm
bcfd8f82cd
Extend testing of CL_UNORM_INT_101010_2 (#2031)
All existing tests in `test_image_streams`, that are capable of testing
image formats using the `CL_UNORM_INT_101010_2` data type, now do so.
2024-09-16 08:45:16 -07:00
Ben Ashbaugh
a395174037
compile Vulkan SPIR-V shaders in CMAKE_CURRENT_BINARY_DIR (#2055)
fixes #2040 

* Compiles the Vulkan SPIR-V files in a directory based off of
CMAKE_CURRENT_BINARY_DIR.
* Changes the search path for the Vulkan SPIR-V files to this directory
rather than a semi-arbitrary set of directories.
2024-09-16 14:28:03 +01:00
gorazd-sumkovski-arm
21b0a09ef0
Extend IGetErrorString() (#2080)
Add cases for `CL_INCOMPATIBLE_COMMAND_QUEUE_KHR`,
`CL_INVALID_COMMAND_BUFFER_KHR` and
`CL_INVALID_SYNC_POINT_WAIT_LIST_KHR`.

Signed-off-by: Gorazd Sumkovski <gorazd.sumkovski@arm.com>
2024-09-12 16:17:11 +02:00
Sven van Haastregt
c32a76786c
cl_khr_mutable_dispatch: fix -Wformat warnings (#2071)
Printing of a `size_t` requires the `%zu` specifier.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-09-06 15:48:19 -07:00
Ben Ashbaugh
b57f90eeab
Add properties parameter to all command-buffer commands (update) (#2072)
This is an update to #2050, with updates from the main branch.

---------

Co-authored-by: Ewan Crawford <ewan@codeplay.com>
2024-09-06 08:22:37 -07:00
Ewan Crawford
0bdc5d082f
Array based clUpdateMutableCommandsKHR changes (#1984)
CTS changes to reflect the spec changes merged in
https://github.com/KhronosGroup/OpenCL-Docs/pull/1045 and requires
header updates from
https://github.com/KhronosGroup/OpenCL-Headers/pull/245

Tested using OCK implementation from
https://github.com/codeplaysoftware/oneapi-construction-kit/pull/501
2024-09-06 07:36:17 -07:00
Sven van Haastregt
ce680690de
Fix Windows build with MSVC 19.41 (#2065)
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>
2024-09-06 12:26:55 +02:00
Sven van Haastregt
9116bb7acb
[NFC] math_brute_force: move TestInfoBase to common.h (#2059)
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>
2024-09-03 18:30:13 +01:00
Marcin Hajder
eb7a30ae42
Modernization of tests from test_semaphores.cpp to align with new SemaphoreTestBase infrastructure (#2029) 2024-09-03 22:53:22 +05:30
saurabhnv
7131f87974
Fix external semaphore test when exportability is not supported (#2045)
An implementation may not support exportable semaphore, subtests
available in cl_khr_external_semaphore assumes support for exportable
semaphore, resulting in failure on such implementation. Allow
implementations to use importable semaphore in such cases.
2024-09-03 10:18:39 -07:00
Sven van Haastregt
90f523ea57
api: fix -Wformat warnings (#2025)
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>
2024-09-02 12:02:28 +02:00
Haonan Yang
a7162188d6
[NFC] Use std::vector to store large size array. (#2060)
windows default stack size is 1M, BUFFER_SIZE is 2 * 1024 * 1024, use
array with BUFFER_SIZE elemets on stack can exceed available stack size
limits.
2024-08-29 14:45:40 +02:00
Sven van Haastregt
c0db608eac
printf: add missing vector length modifiers (#2044)
The length modifier is required with a vector specifier.

Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/2039

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-08-29 14:45:15 +02:00
Marcin Hajder
0a00a1f5b0
Added printf test for double type cases (#2022)
according to work plan for issue
https://github.com/KhronosGroup/OpenCL-CTS/issues/1058
2024-08-27 08:41:05 -07:00
Kamil-Goras-Mobica
6cbe8cae35
Added two tests not calling event calback upon error status (#2028)
#1900 
Tested on POCL, callback is not called.
2024-08-20 08:55:03 -07:00
Kamil-Goras-Mobica
746544af80
Strengthen testing of CL_DEVICE_TYPE query and use of CL_DEVICE_TYPE* (#1977)
Issue: #1930
2024-08-20 08:54:06 -07:00
joshqti
b8981f5fb8
[basic] Enable image format aware scanline comparison. (#2042)
Use format aware memory comparison instead of memcmp.
2024-08-13 09:54:09 -07:00
Ahmed
b4c3bf2af2
Fixes for basic explicit_s2v and commonfns degrees for cl_half (#2024)
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.
2024-08-13 09:52:07 -07:00
Marcin Hajder
aa49f3bb53
Added few missing format cases for zero and blank space padding (#2016)
according to work plan for issue #1058
2024-08-13 09:50:07 -07:00
Karol Herbst
21ee05ecaf
math_brute_force: stop relying on volatile for IsTininessDetectedBeforeRounding (#2038)
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.
2024-08-13 09:18:33 -07:00
niranjanjoshi121
a406b34091
Fix error return and TEST_PASS for negative SVM tests (#2027)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 2s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
Fix error return and TEST_PASS for negative SVM tests
Fix review comments from #1802 

Fixes #1964
2024-08-06 22:50:21 +05:30
Marcin Hajder
d1434ae5aa
Added new cl_khr_semaphore tests to verify clCreateSemaphoreWithPropertiesKHR negative results (#1962)
According to work plan from #1691, new clSemaphoreWrapper introduced to
avoid duplication of code
2024-08-06 22:48:45 +05:30
gorazd-sumkovski-arm
3c81548cba
Fix issues in test_external_semaphores_cross_queues_io2 (#2036)
1. Fix memory leak by making `context2` use the context wrapper.
2. Create two separate events to associate with the two calls to
`clEnqueueSignalSemaphoresKHR()`, as events cannot be reused.

Also delete the unused helper function
`semaphore_external_cross_queue_helper()` (which was a duplicate of
`external_semaphore_cross_queue_helper()` anyway).
2024-08-06 09:33:30 -07:00
arm-wk
f47354680f
Limit buffers sizes to leave some memory for the platform (#1172)
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.
2024-08-06 09:32:08 -07:00
ellnor01
995e46590e
Add clSetCommandQueueProperty test (#1182)
Add test to check that clSetCommandQueueProperty
successfully changes command queue properties.

Fixes #904

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
2024-08-06 09:31:01 -07:00
Sven van Haastregt
1a9d41867e
math_brute_force: only test correctly rounded divide/sqrt for fp32 (#1997)
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>
2024-08-06 09:29:08 -07:00
ellnor01
13848621f1
Unduplicate kernel_read_write image tests (read) (#1552)
The kernel_read_write tests have a lot of duplicate code. These are the
next steps to reducing the duplication, by using the functions in
test_common.cpp as common for 1D, 1D array and 2D array.

---------

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
Co-authored-by: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com>
2024-08-06 09:28:39 -07:00
Sven van Haastregt
5be093e0c8
math_brute_force: skip all enqueues in -l mode (#1993)
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>
2024-08-06 09:26:38 -07:00
banan328
8974d74db7
conversions: fix ZeroNanToIntCases from https://github.com/KhronosGroup/OpenCL-CTS/pull/1975 (#2030)
The handling of NaN values in the templated function was incorrect due
to improper initialization of the input data source. Specifically, the
function ZeroNanToIntCases used a global pointer gIn, which was not
correctly set or did not point to the same data as the local input
pointer s used in the non-templated implementation.

to solve the issue I updated the templated function ZeroNanToIntCases to
take an additional parameter for the input data source.
and then passed the correct input data (s) to the templated function
during its invocation.

Co-authored-by: Banan Ashkar <banan.ashkar@mobileye.com>
2024-08-06 09:21:55 -07:00
banan328
89a720d3f7
Added new tests for CL_MUTABLE_DISPATCH_ASSERT_NO_ADDITIONAL_WORK_GROUPS_KHR flag with mutable dispatch (#1991)
Added new tests for
CL_MUTABLE_DISPATCH_ASSERT_NO_ADDITIONAL_WORK_GROUPS_KHR with mutable
dispatch according to this test plan
https://github.com/KhronosGroup/OpenCL-CTS/issues/1897

Co-authored-by: Banan Ashkar <banan.ashkar@mobileye.com>
2024-08-06 09:19:49 -07:00
Marcin Hajder
19cb042985
Extended printf test to support more vector cases (#2019)
according to work plan for issue
https://github.com/KhronosGroup/OpenCL-CTS/issues/1058
2024-08-06 08:45:58 -07:00
Kévin Petit
284f7578e6
Remove outdated readme-spir-v-binaries.txt (#2026)
Completely outdated. Confuses people.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2024-07-29 09:07:21 +01:00
Sven van Haastregt
70884151c9
[NFC] Remove config.hpp (#2020)
The defines inside this header were not used anywhere.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-07-23 20:11:56 +01:00
David Neto
0be82dce5e
[printf] Test empty format string, and empty arg string (#2018)
Issue: #1058
2024-07-23 20:11:34 +01:00
David Neto
5b5e43e1fb
[printf]: input value should be exactly representable as 32-bit float (#2015)
Fixed: #2009
2024-07-18 14:08:43 -07:00
Ahmed Hesham
070052c890
Use sccache on all CI platforms (#2014)
MSVC on Windows was previously omitted from the list of CI platforms
that use sccache. Unify the CMAKE_CACHE_OPTIONS used for all CI
platforms.

In the case of a 100% cache hit, this cuts down the average checks time
from 8 minutes to 4 minutes, example:
https://github.com/ahesham-arm/OpenCL-CTS/actions/runs/9896449792
2024-07-16 09:54:24 -07:00
Sven van Haastregt
39fa6e6d1b
math_brute_force: remove spurious tan skip check (#1992)
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>
2024-07-16 09:53:18 -07:00
Sven van Haastregt
8558eb88d7
computeinfo: add CL_DEVICE_HALF_FP_CONFIG (#2001)
The computeinfo test already checks that the cl_khr_fp16 extension is
available before querying `CL_DEVICE_HALF_FP_CONFIG`, but never actually
made the `CL_DEVICE_HALF_FP_CONFIG` query.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-07-16 09:52:18 -07:00
Marcin Hajder
7b0f4ee861
Added new cl_khr_semaphore tests to verify clReleaseSemaphoreKHR/clRetainSemaphoreKHR negative results (#1976)
According to work plan from issue #1691

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
2024-07-16 20:38:28 +05:30
Sven van Haastregt
881560a0fe
printf: add missing cstdint include (#2011)
Since GCC 13 some headers are no longer included transitively through
C++ Standard Library headers.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-07-12 17:23:59 +02:00
Sven van Haastregt
6d60301d20
[NFC] math_brute_force: reformat function list manually (#2008)
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>
2024-07-11 17:25:02 +02:00
Ahmed Hesham
1858922dac
Use the --parallel build option in CI workflows (#2004)
Instead of selecting an arbitrary number for the number of parallel
build jobs, use CMake's `--parallel` option instead.

Option was introduced in version 3.12, GitHub runners currently use
CMake version 3.29.6 so this is supported.

Fixes #2003

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-07-09 09:59:28 -07:00
Ahmed Hesham
47546a5c4c
Drop linking Vulkan directly (#2000)
The `vulkan-wrapper` helper library's purpose is to eliminate the need
to link targets directly to Vulkan, and load it dynamically instead at
runtime, using `dlopen` and `LoadLibrary`.

Remove the direct linking of the Vulkan library from targets that link
to `vulkan-wrapper`.

Fixes #1999

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2024-07-09 09:57:39 -07:00
John Kesapides
dd029cab8f
Deduplicate test_imagedim (#1546)
Signed-off-by: John Kesapides <john.kesapides@arm.com>

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2024-07-09 09:56:42 -07:00
John Kesapides
cabdf6a5fc
Use CTS type wrappers for test_basic test_if. (#1540)
Signed-off-by: John Kesapides
[john.kesapides@arm.com](mailto:john.kesapides@arm.com)
2024-07-09 09:55:57 -07:00
John Kesapides
cb9b8db894
Deduplicate test_basic image_array_copy (#1538)
Merge image_array_copy, image_array_copy3d
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>
2024-07-09 09:55:16 -07:00
Marcin Hajder
8cd2b7d799
Extended printf test with new mixed format cases (#1988)
According to work plan from issue #1058

Added new case `TYPE_MIXED_FORMAT_RANDOM` which focus on three factors:

-data before conversion flags - this is randomly generated ascii string
-randomly generated conversion flags - integer or floating point, for
each flag specific argument is generated
-data after conversion flags - this is randomly generated ascii string

Moreover, due to fact in case of `TYPE_MIXED_FORMAT_RANDOM` test is
generated on the fly, logging of negative result was extended.
2024-07-09 08:47:31 -07:00
Marcin Hajder
c1af7c3301
Added new tests to verify negative results of clGetSemaphoreInfoKHR (#1981)
According to work plan from issue #1691
2024-07-09 08:46:37 -07:00
Sven van Haastregt
89cd9660be
computeinfo: fix memory leak (#2002)
Even on the common code path (i.e., no error paths taken),
test_computeinfo failed to release its allocated memory, preventing a
clean run with LeakSanitizer.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-07-08 13:34:39 +02:00
Julia Jiang
6b4d57d85c
Fix cts build error on mariner OS (#1872) 2024-07-02 09:40:42 -07:00
Ben Ashbaugh
38ae617ca4
add testing for OpExpectKHR with boolean sources (#1904)
Adds a missing test case for OpExpectKHR with boolean sources.
2024-07-02 09:39:33 -07:00
Sven van Haastregt
f775377e6a
image_streams: fix -Wformat warnings (#1948)
The main sources of warnings were:

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

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

* Calling log_error with a format string of `"%f %f %f %f"` but
specifying only three arguments.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-07-02 09:38:36 -07:00
Sven van Haastregt
2d8028668f
[NFC] api: remove duplicate and unused macros (#1949)
The removed macros were never used.

Use the more common `ARRAY_SIZE` macro instead of defining an identical
`NELEMS` macro.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-07-02 09:37:49 -07:00
Sven van Haastregt
269e8185f6
math_brute_force: update README.txt for half testing (#1985)
Half precision math functions are fully tested as of #1975.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-07-02 09:37:13 -07:00
Haonan Yang
07ddc66d8a
Fix typo for log. (#1995)
This aligns with unary_float.cpp.
2024-07-02 09:36:18 -07:00
Julia Jiang
02471c8f56
Fix build errors related with variable defined array length and gl te… (#1957)
…sts logged error
2024-07-02 09:34:53 -07:00
Michal Babej
769984b023
fix bugs in negative command_buffer tests (#1969)
- when calling command buffer APIs, test with `command_queue != NULL`
should return `CL_INVALID_VALUE` only if the device doesn't support
`cl_khr_command_buffer_multi_device` (added `Skip`)

- some tests enqueued commands with multiple invalid arguments, e.g.
`clCommandCopyImageToBufferKHR` with two images and invalid sync points.
AFAIK the order of argument checking is not defined, so implementation
can return any valid error value for such API calls, but the tests
assumed only one particular error would be returned. Fix the API calls
to be unambiguous.
2024-07-02 09:32:12 -07:00
Karol Herbst
89923f8004
Extend printf tests with more %% corner cases (#1986)
We've had a couple of bugs inside mesa/rusticl processing %% correctly.
I've added those cases locally to make sure all corner cases are
properly handled.
2024-07-02 09:30:03 -07:00
Chuang-Yu Cheng
1cd0266ca1
spirv_new: fix test_decorate to use the device's default rounding (#1987)
The verification code assumes the hardware uses CL_HALF_RTE, which
causes a mismatch computation results when the hardware uses RTZ. Fix to
use the hardware's default rounding mode.
2024-07-02 09:29:00 -07:00
Marcin Hajder
340b7c956a
Added new cl_khr_semaphore tests to verify clEnqueueWaitSemaphoresKHR negative results (#1965)
According to work plan from
https://github.com/KhronosGroup/OpenCL-CTS/issues/1691

After consultations with @bashbaug I skipped this case:

`CL_INVALID_VALUE if any of the semaphore objects specified by
sema_objects requires a semaphore payload and sema_payload_list is NULL`
2024-07-02 08:43:52 -07:00
Sven van Haastregt
fcbccab4d1
[NFC] math_brute_force: drop unneeded gotos (#1843)
Simplify code by returning directly instead of using goto statements.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-06-27 09:46:33 +02:00
Harald van Dijk
c7b682f12a
spirv_new: fix test_decorate. (#1980)
test_decorate was checking for half-precision NAN incorrectly, calling
cl_half_from_float where cl_half_to_float was intended, causing a wrong
expected result.

test_decorate was also printing the expected and actual results
reversed, printing "got -1, want 0", when our implementation already
returned 0.
2024-06-25 09:47:55 -07:00
paulfradgley
ac6931198d
Fixed incorrect usage of clGetDeviceIDs num_devices (#1952)
clGetDeviceIDs 'num_devices' output parameter is described as:
> num_devices returns the number of OpenCL devices available that match
device_type.

but the _test_events
out_of_order_event_waitlist_multi_queue_multi_device_ test expects that
after calling:
`clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 2, two_device_ids,
&number_returned);`

the content of number_returned needs to be 2, but it should be valid to
return a larger number.

---------

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
2024-06-25 09:46:49 -07:00
Kévin Petit
a281046e0e
Bump clang-format version to 14 (#1983)
Default version coming with Ubuntu 22.04 that the CI now uses.
2024-06-25 09:44:31 -07:00
Harald van Dijk
80a02cbd48
Disable implicit conversion of copysign arguments. (#1970)
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.
2024-06-25 09:42:58 -07:00
Pedro Olsen Ferreira
e2c7e901b8
Add special test for generic address space atomics (#1959)
The atomic operations are tested with generic pointers but in a way
where the compiler can infer the original pointer address space. This
commit adds tests specifically for the case where the compiler cannot
make inferences.
Test that the correct address is used with atomics when the address is
group variant and invariant.
2024-06-25 09:41:23 -07:00
Ewan Crawford
8e6c519354
Negative test for CL_INVALID_QUEUE_PROPERTIES (#1935)
Test that verifies `CL_INVALID_QUEUE_PROPERTIES` is returned from
`clCreateCommandQueue`, `clCreateCommandQueueWithProperties`, and
`clCreateCommandQueueWithPropertiesKHR` to match spec wording

> CL_INVALID_QUEUE_PROPERTIES if values specified in properties are
valid but are not supported by the device.
2024-06-25 09:40:32 -07:00
Sven van Haastregt
2b266434b7
cl_khr_kernel_clock: use create_single_kernel_helper (#1978)
`create_single_kernel_helper` invokes `clBuildProgram` and sets
`-cl-std` to the latest version supported by the context.

The vast majority of tests are using `create_single_kernel_helper`
instead of the `..._create_program` variant, so use the former for the
sake of consistency.

---------

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-06-18 09:44:40 -07:00
Sven van Haastregt
b6941b6c61
Add fp16 testing to conversions and bruteforce (#1975)
Merge the `fp16-staging` branch into `main`, adding fp16 (`half`)
testing to the conversions and math bruteforce tests.

---------

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
Signed-off-by: Guo, Yilong <yilong.guo@intel.com>
Signed-off-by: John Kesapides <john.kesapides@arm.com>
Co-authored-by: Marcin Hajder <marcin.hajder@gmail.com>
Co-authored-by: Ewan Crawford <ewan@codeplay.com>
Co-authored-by: Wawiorko, Grzegorz <grzegorz.wawiorko@intel.com>
Co-authored-by: Sreelakshmi Haridas Maruthur <sharidas@quicinc.com>
Co-authored-by: Harald van Dijk <harald@gigawatt.nl>
Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
Co-authored-by: Haonan Yang <haonan.yang@intel.com>
Co-authored-by: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com>
Co-authored-by: niranjanjoshi121 <43807392+niranjanjoshi121@users.noreply.github.com>
Co-authored-by: Wenwan Xing <wenwan.xing@intel.com>
Co-authored-by: Yilong Guo <yilong.guo@intel.com>
Co-authored-by: Romaric Jodin <89833130+rjodinchr@users.noreply.github.com>
Co-authored-by: joshqti <127994991+joshqti@users.noreply.github.com>
Co-authored-by: Pekka Jääskeläinen <pekka.jaaskelainen@tuni.fi>
Co-authored-by: imilenkovic00 <155085410+imilenkovic00@users.noreply.github.com>
Co-authored-by: John Kesapides <46718829+JohnKesapidesARM@users.noreply.github.com>
Co-authored-by: Aharon Abramson <aharon.abramson@mobileye.com>
2024-06-18 09:43:11 -07:00
Ahmed
b3c89ebde0
Fixes for Image_from_buffer_alignment_negative when alignments are 1 (#1971)
The Image_from_buffer_alignment_negative test creates images with
incorrect pitches by adding 1 and tests whether the image creation
fails.

Devices that return 1 for either of
CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT,
CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT or
CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT will successfully
create the image and therefore fail the test.

This change allows to skip the image creation in this case as the error
condition (pitch % pitch_alignment != 0) will not be triggered for these
devices.
2024-06-18 09:40:14 -07:00
Sreelakshmi Haridas Maruthur
c8f91c5ead
gl: enable cl_khr_fp16 for image write tests (#1974)
Co-authored-by: riteshv <riteshv@qti.qualcomm.com>
2024-06-18 09:30:34 -07:00
Marcin Hajder
582fea57dc
Extended printf test with new strings cases (#1951)
According to work plan from issue #1058

Corrections to general test:
-removed duplication of separate tests for each element of
`PrintfTestType` vector, instead `doTest` procedure would iterate over
vector related to specific `PrintfTestType` automaticaly
-fixed procedure to assemble kernel source so it can accept only one
parameter of the function ( eg. `printf("%%");` )
-incorporated important modifications from #1940 to avoid expected
conflicts
-warnings fixes, minor corrections, clang format

Extension for string testing:
-special symbols
-nested symbols
-all ascii characters 
-added new type of test `TYPE_FORMAT_STRING` to verify format string
only (according to request from the issue)
2024-06-18 08:44:18 -07:00
Kamil-Goras-Mobica
d379b58ab6
Added negative tests for clCommandCopy[Buffer, BufferRect, BufferToImage]KHR (#1941)
According to description
https://github.com/KhronosGroup/OpenCL-CTS/issues/1668
2024-06-11 08:42:29 -07:00
Marcin Hajder
806dd2fb61
Added new query for cl_khr_semaphore test to verify device handle list (#1942)
This PR addresses the first part of #1691 issue and #1875 issue.
2024-06-04 23:10:37 +05:30
Sven van Haastregt
a130f3d179
relationals: fix out of bounds accesses in shuffle test (#1961)
The values in `src` are indices into an array in `get_order_string()`.
Not initializing `src` resulted in out of bounds accesses there.

It seems that when the out of bounds accesses happened, the result of
`get_order_string()` was not actually used, so at least the test was not
using random data. Fix the issue as it prevents a clean run of this test
with e.g. AddressSanitizer.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-06-04 09:38:44 -07:00
Shilei Tian
556025ba14
Escape subnormal values (#1953)
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.
2024-05-30 15:19:00 -07:00
Sven van Haastregt
75be6a3125
cl_khr_kernel_clock: fix builtin function names (#1968)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
According to the
[specification](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#kernel-clock-functions),
the work_group and sub_group variants have an `_` in them.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-05-29 15:14:17 -07:00
Sven van Haastregt
1d3ad8d791
mem_host_flags: check returned pointer for NULL (#1924)
The specification states that `clEnqueueMapImage` and
`clEnqueueMapBuffer` should return NULL on error. Ensure this is
checked.

This testing gap was caught by a compiler warning about `dataPtr` being
written but not read. With this fix, there are no more
Wunused-but-set-variable warnings in this test, so reenable the warning.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-05-29 15:11:32 -07:00
saurabhnv
6807e165d7
Import OpenCL exported semaphore in Vulkan (#1898)
Except for SYNC_FD, current implementation doesn't import exported
OpenCL semaphore in Vulkan and ends up doing signal and wait on
essentially two unrelated semaphores (one created in OpenCL and one in
Vulkan).
Since OpenCL exports the semaphore, import that in Vulkan to perform
signal/wait on the same underlying payload.
2024-05-28 10:20:25 -07:00
pkaur19
1433ffe515
Vulkan interop coverage (#1887)
Added Code changes for 1D, 1DList, 3D, 3DList and test cases.
2024-05-28 10:14:01 -07:00
Kamil-Goras-Mobica
d53d7bc559
Added negative tests for clCommandFill[Buffer, Image]KHR (#1944)
According to description
https://github.com/KhronosGroup/OpenCL-CTS/issues/1668
2024-05-28 08:39:01 -07:00
Kamil-Goras-Mobica
d3e3bdabaa
Negative tests clCommandSvmMem[cpy, Fill]KHR (#1956)
According to description
https://github.com/KhronosGroup/OpenCL-CTS/issues/1668
2024-05-22 09:18:36 +01:00
Romaric Jodin
fe76832ec8
add missing header (#1966)
test_common/harness/integer_ops_test_info.h is using std::vector but is
not including the header.

This is breaking on Google internal CI.
2024-05-21 13:00:13 -07:00
Ahmed
cdf8d5e35e
Add cl_khr_kernel_clock tests (#1960)
Adds cl_khr_kernel_clock test.

Also fixes failure in the compiler defines for extension compiler
subtest when cl_khr_kernel_clock is supported.
2024-05-21 08:49:49 -07:00
Sreelakshmi Haridas Maruthur
5ce18c3f5a
basic: workaround MSVC compiler bug with post-increment operator (#1939)
Prevent the compiler from optimizing away initialization loops
2024-05-21 08:47:47 -07:00
Grzegorz Wawiorko
b377b8537b
test allocations: restore small number of work items in case of reduction (#1932) 2024-05-21 08:46:14 -07:00
joshqti
4fceb78b93
Add acquire/release (#1899)
Add acquire/release commands where appropriate. This is related to 1886.
2024-05-21 08:45:41 -07:00
John Kesapides
fb39357911
Raw10/12 CTS tests (#1830)
Add support for cl_ext_image_raw10_raw12 testing
on test_image_streams.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2024-05-21 08:44:28 -07:00
niranjanjoshi121
0353c0bdbe
Add negative test for test_svm size check (#1802)
Isuue #875 clarified that CL_INVALID_BUFFER_SIZE should be returned if
clCreateBuffer is passed a pointer returned by clSVMAlloc as its
host_ptr and the size of the buffer exceeds the size of the SVM
allocation.

Add a new negative test to ensure CL_INVALID_BUFFER_SIZE is returned
when the size of buffer exceeds the size of the SVM allocation.

Fixes #1701
2024-05-21 08:43:55 -07:00
Kamil-Goras-Mobica
9500c30492
Negative tests for commandCopyImage[ToBuffer]KHR (#1943)
According to description
https://github.com/KhronosGroup/OpenCL-CTS/issues/1668
2024-05-21 08:40:08 -07:00
Marcin Hajder
88a707dd13
Corrections for printf test with floating point limits arguments (#1940)
According to work plan from issue #1058
2024-05-21 08:38:04 -07:00
Kamil-Goras-Mobica
e6fec7417f
Added negative tests for clCommandBarrierWithWaitListKHR (#1937)
According to description
https://github.com/KhronosGroup/OpenCL-CTS/issues/1668
2024-05-14 08:43:23 -07:00
Kamil-Goras-Mobica
5093ce5be5
Added negative test commandNDRangeKernel (#1936)
According to description
https://github.com/KhronosGroup/OpenCL-CTS/issues/1668
2024-05-14 08:42:46 -07:00
Sreelakshmi Haridas Maruthur
aa70c06d8f
Fix build breakage introduced by #1911 (#1958) 2024-05-07 10:03:02 -07:00
Sven van Haastregt
46255db86f
compiler: fix memory leak (#1950)
The `test_compiler compiler_defines_for_extensions` test did not free
all `malloc`'ed memory.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-04-26 16:32:03 +02:00
Kamil-Goras-Mobica
4c085dec4a
Added negative tests for clEnqueueCommandBufferKHR (#1931)
* Added negative tests for clEnqueueCommandBufferKHR

* Added blocking the clEnqueueCommandBufferKHR call on a user event

* Added finalizing buffer before enqueuing
2024-04-21 23:45:33 -07:00
Kamil-Goras-Mobica
308fa6e78c
Added negative tests for clRetainCommandBufferKHR, clReleaseCommandBu… (#1928)
* Added negative tests for clRetainCommandBufferKHR, clReleaseCommandBufferKHR, clFinalizeCommandBufferKHR

* Added blocking the clEnqueueCommandBufferKHR call on a user event

* Changed cl_event to clEventWrapper
2024-04-19 14:01:38 -07:00
Sven van Haastregt
7dc9593d88
test_vulkan: don't throw from destructors (#1947)
Only report an error (and include the error code), but don't throw an
exception as that would call `terminate`.  Failure to release
resources is not fatal in other parts of the CTS.

This fixes `-Wterminate` warnings:

  warning: ‘throw’ will always call ‘terminate’ [-Wterminate]
  note: in C++11 destructors default to ‘noexcept’

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-04-16 10:11:08 -07:00
Pedro Olsen Ferreira
43237f74a8
Remove dead code (#1946)
This is 7-year old CMake code that never did anything because the
function invocation is missing the PROPERTIES keyword.
Adding the keyword results in build errors, so just drop the dead code
since everything seems to be working without it anyway.
2024-04-16 08:54:28 -07:00
Pedro Olsen Ferreira
a977e35e0b
Delete stale files (#1945)
These aren't included or built anywhere.
2024-04-16 08:53:59 -07:00
David Tobolik
61a220ff33
fix: move suggested_local_size to test_api (#1916) 2024-04-16 08:49:24 -07:00
Romaric Jodin
be8b56d949
Test IMAGE1D_BUFFER in more scenario (#1806)
* 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
2024-04-16 08:48:05 -07:00
Kamil-Goras-Mobica
7fa567c7a5
Corrections for negative tests for function CreateCommandBufferKHR (#1915) 2024-04-16 08:40:44 -07:00
Sven van Haastregt
1139f54bde
device_execution: fix -Wformat warnings (#1938)
Printing of a `size_t` requires the `%zu` specifier.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-04-15 13:37:07 +02:00
joshqti
48b987827e
Fix cross-context semaphore signals (#1886)
Multi-context test was not correctly
testing cross-context functionality.
Use semaphore import/export mechanism
to signal across contexts.
2024-04-09 08:59:49 -07:00
Kamil-Goras-Mobica
d0300d176f
Added negative tests for clGetCommandBufferInfoKHR (#1929)
* Added negative tests for clGetCommandBufferInfo

* Replaced param_value_size values from 0 to sizeof() - 1
2024-04-09 08:54:44 -07:00
Marcin Hajder
f2a30737b6
Corrections for mutable arguments tests (#1921)
* Corrections to mutable arguments tests

-added verification of device capabilities against mutable arguments
-corrected fail of 2 tests with Construction Kit
-general cleanup

* cleanup corrections

* restored relaxed version of mutable arguments tests

* corrections to strengthen the test around SVM arguments
2024-04-09 08:50:03 -07:00
Sven van Haastregt
5fe1cc01c0
spirv_new: fix -Wformat warnings (#1933)
`log_error` was invoked from a template function, but the format
specifiers weren't adjusted for the template parameter types.  Use a
stringstream for printing instead.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-04-05 12:28:20 +02:00
Ben Ashbaugh
27e47e9e87
fix the type used for bitfield_extract_signed (#1913)
We compute the reference values using unsigned types exclusively,
even when the input type is signed.  This fixes one place where
an signed type was inadvertently used.
2024-04-04 13:08:41 -07:00
Sven van Haastregt
48003e9d32
[NFC] subgroups: clarify bs128 to uint4 conversion (#1893)
There appears to have been some confusion over `uint_mask` during the
initial reviews of the subgroup tests.  Add a comment to clarify the
purpose of the mask.

Use a 32-bit all-ones mask (`0xffffffff`) instead of a 64-bit all-ones
mask to further clarify the intent, that is, don't delay discarding
the upper 32 bits until the assignment but mask them out immediately.

Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1203

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-04-04 15:12:10 +02:00
saurabhnv
7f1caf4aa9
Shader -> SPIR-V at CTS build time (#1849) (#1878)
* Shader -> SPIR-V at CTS build time (#1849)

Instead of relying on prebuilt checked-in SPIR-V files, compile
available shaders at CTS build time.

* Add dependency on glslc (available as part of VULKAN_SDK).
* Add optional build flag BUILD_GLSL_SHADERS, OFF by default.

* Remove pre-built SPIR-V files

* Compile Shader -> SPIR-V at CTS build time

* Use glslangValidator for shader -> spirv

* Add glslangValidator tool for shader -> spirv

* Refactor glslangValidator tool retrieval

* Address review comments

* Use add_subdirectory() instead of include()
* Use glslang instead of glslangValidator
* Update Github actions CI to install Vulkan SDK
2024-04-02 10:16:45 -07:00
Sven van Haastregt
83203db6e2
half: fix -Wformat warnings (#1927)
Avoid casting to `uint64_t` in some places; instead keep the types as
`size_t` and use the `%z` length modifier, or as
`uint32_t` and use the `%u` specifier.

For printing of 64-bit types, use the `PRI*64` macros from <cinttypes>
to ensure portability across 32 and 64-bit builds.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-03-27 14:46:27 +01:00
Marcin Hajder
96361171ed
Added test to cover iterative mutable argument update (#1925)
* Added test to cover iterative mutable argument update

According to issue description #1481

* cosmetic correction

* clang format fix

* Corrections due to code review
2024-03-26 08:39:18 -07:00
Marcin Hajder
349427e4aa
Added test to cover overwritten update of mutable parameters (#1922)
* Added test to cover overwritten update of mutable parameters

According to issue description #1481

* cosmetic corrections

* Corrections due to code review
2024-03-26 08:38:38 -07:00
Sven van Haastregt
049b719eea
relationals: fix -Wformat-truncation warning (#1918)
`inOrderStr` and `outOrderStr` are both written into `orderName`,
which may not fit as all three are the same size.  Decrease the sizes
of `inOrderStr` and `outOrderStr`.  The new sizes are still
sufficiently large to hold the result of `get_order_string`.

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>
2024-03-20 13:54:50 +01:00
Ahmed Hesham
0deddf2ce7
Fix failing image tests for CL_UNORM_INT_101010_2 (#1917)
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>
2024-03-20 11:30:36 +00:00
Marcin Hajder
da4a30d394
Added new test to cover multiple commands dispatch in one enqueued update (#1919)
* Added new test to cover multiple comands dispatch in one enqueued update

According to issue description #1481

* clang format correction

* Few minor corrections

* cosmetic corrections
2024-03-19 08:42:42 -07:00
Marcin Hajder
8f3ef0891d
Added new tests for simultaneous use with mutable dispatch (#1912)
* Added new tests for simultaneous use with mutable dispatch

-cross queue simultaneous use
-in-order queue with simultaneous use

According to issue description #1481

* Several corrections applied:

-reordered Skip conditions to check valid simultaneous_use_support flag
-removed unnecessary SetUpKernel call
-initialize kernel and memory buffers from BasicCommandBufferTest
instead BasicMutableCommandBufferTest

* Corrections for command buffer creation to request simultaneous property
2024-03-19 08:41:41 -07:00
Ben Ashbaugh
109c0a1ddd
configure depdendabot github actions version updates (#1923) 2024-03-19 07:10:19 -07:00
David Heidelberg
77293c83bd
musl-libc doesn't provide GNU version of strerror_r but uses BSD/XSI one (#1911)
* harness: correct include and sort

warning redirecting incorrect #include <sys/errno.h> to <errno.h>

Signed-off-by: David Heidelberg <david@ixit.cz>
2024-03-18 16:37:21 +01:00
Sven van Haastregt
4c318a1617
[CI] Upgrade to actions/checkout@v4 (#1920)
Node.js 16 actions are deprecated, so update to v4 which uses Node 20.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-03-18 10:38:35 +01:00
Sven van Haastregt
d8ad10d1ea
device_execution: fix CL_QUEUE_* in error messages (#1896)
When reporting errors from `clCreateCommandQueueWithProperties`,
report the correct property names.  In particular:

`CL_QUEUE_DEVICE` should be `CL_QUEUE_ON_DEVICE`.
`CL_QUEUE_DEFAULT` should be `CL_QUEUE_ON_DEVICE_DEFAULT`.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-03-12 09:36:02 -07:00
Marcin Hajder
ffb0265abd
Added command buffer test with all mutable parameters dispatch (#1905)
* Added command buffer with full mutable dispatch test

According to #1481 issue description, point 2.1

* Corrected the test to handle all available mutable properties

According to #1481 issue description, point 2.1
2024-03-12 09:33:57 -07:00
niranjanjoshi121
6530ae45b5
Add NULL CL_MEM_HOST_PTR check for all flag combinations (#1850)
* Add NULL CL_MEM_HOST_PTR check for clGetMemObjectInfo

The spec requires implementations return NULL for CL_MEM_HOST_PTR
when the flags passed at memory object creation time do not contain
CL_MEM_USE_HOST_PTR

CTS was not checking this. Add the same check.

Fixes #1752

* Add NULL CL_MEM_HOST_PTR check for all flag combinations

As part of suggestions to #1801, add NULL CL_MEM_HOST_PTR
check for all flag combinations.

Fixes #1752

* Fix formatting issues
2024-03-12 09:31:46 -07:00
BZZiv
90cefbb38e
Bug fix in test_async_copy_fence - wrong events usage (#1736) 2024-03-12 09:25:22 -07:00
Yilong Guo
a045f76eed
[subgroups][non_uniform_broadcast] Fix broadcasting index generation (#1680)
* [subgroups][non_uniform_broadcast] Fix broadcasting index generation

The subgroup size may not be greater than `NR_OF_ACTIVE_WORK_ITEMS`.
Broadcasting index needs to be reduced in that case.

Otherwise, if subgroup size == `NR_OF_ACTIVE_WORK_ITEMS` == 4, then we
will encounter "divide-by-zero" error when evaluating `bcast_index %
(n - NR_OF_ACTIVE_WORK_ITEMS)`.

* Revert "[subgroups][non_uniform_broadcast] Fix broadcasting index generation"

This reverts commit 9bbab539de6ee30676e3a4af1249ba91d0b6c5ed.

* [subgroups][non_uniform_broadcast] Fix broadcasting index generation

Dynamically activate half of the work items in the current subgroup
instead of hardcoding as `NR_OF_ACTIVE_WORK_ITEMS`.

* Apply suggestion
2024-03-12 09:25:06 -07:00
Sven van Haastregt
ee504ba861
spirv_new: avoid GLOB for sources in CMakeLists (#1907)
Using `GLOB` here breaks incremental builds when switching between
branches (e.g. when trying out a pull request).  The CMake
documentation discourages use of `GLOB` to collect a list of source
files, so list all source files explicitly.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-03-11 10:13:13 +01:00
Sven van Haastregt
1f0fa08c4f
vectors: fix -Wformat warnings (#1910)
Use the `z` length modifier for printing `size_t` types.

Also fix a typo in the error messages.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-03-08 08:08:41 -08:00
Harald van Dijk
6a60db558b
Fix uninitialised memory use. (#1909)
CL_DEVICE_MAX_WORK_GROUP_SIZE is specified to fill in a size_t. By
asking it to fill in an uninitialised cl_long, on platforms where size_t
is smaller than cl_long, the high bits of the cl_long remain
uninitialised.
2024-03-08 08:07:09 -08:00
rafaykhurram
26c89df31b
subgroups: Add missing algorithm header (#1906)
* Was causing a build error with GN
* fill_and_shuffle_safe_values() in subhelpers.cpp calls std::shuffle()
* std::shuffle is defined in <algorithm>
2024-03-07 13:34:16 +01:00
Sven van Haastregt
e0a31a03fc
Fix -Wformat warnings in various tests (#1868)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
All of these warnings stem from printing `size_t` types, which should
be done using the `z` length modifier.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-02-27 09:59:39 -08:00
Ben Ashbaugh
0052af2227
add tests for cl_khr_expect_assume (#1888)
* initial support for cl_khr_expect_assume

Tests expect with 64-bit SPIR-V binaries.

* add support for assume testing with 64-bit binaries

* add 32-bit SPIR-V files

* fix formatting

* address review comments
2024-02-27 09:57:52 -08:00
Aharon Abramson
d4f9d04b39
add support for custom devices (#1891)
enable the CTS to run on custom devices
2024-02-13 09:29:39 -08:00
Marcin Hajder
a4b5a30210
Added cl_khr_fp16 extension support for test_decorate from spirv_new (#1770)
* Added cl_khr_fp16 extension support for test_decorate from spirv_new, work in progres

* Complemented test_decorate saturation test to support cl_khr_fp16 extension (issue #142)

* Fixed clang format

* scope of modifications:

-changed naming convention of saturation .spvasm files related to
test_decorate of spirv_new
-restored float to char/uchar saturation tests
-few minor corrections

* fix ranges for half testing

* fix formating

* one more formatting fix

* remove unused function

* use isnan instead of std::isnan

isnan is currently implemented as a macro, not as a function, so
we can't use std::isnan.

* fix Clang warning about inexact conversion

---------

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
2024-02-13 09:22:32 -08:00
Sven van Haastregt
e1877465cb
[NFC] subgroups: remove unnecessary extern keywords (#1892)
In C and C++ all functions have external linkage by default.

Also remove the unused `gMTdata` and `test_pipe_functions`
declarations.

Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1137

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-02-09 07:56:39 -08:00
Ben Ashbaugh
a256e4ad05
add test for cl_khr_spirv_linkonce_odr (#1226)
* initial version of the test with placeholders for linkonce_odr linkage

* add OpExtension SPV_KHR_linkonce_odr extension

* add check for extension

* switch to actual LinkOnceODR linkage

* fix formatting

* add a test case to ensure a function with linkonce_odr is exported

* add back the extension check

* fix formatting

* undo compiler optimization and actually add the call to function a
2024-02-06 09:56:49 -08:00
John Kesapides
d394b0f274
Minor fixes in mutable dispatch tests. (#1829)
* Minor fixes in mutable dispatch tests.

* Fix size of newWrapper in MutableDispatchSVMArguments.
* Fix errnoneus clCommandNDRangeKernelKHR call.

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

* * Set the row_pitch for imageInfo in MutableDispatchImage1DArguments
and MutableDispatchImage2DArguments. The row_pitch is
used by get_image_size() to calculate the size of
the host pointers by generate_random_image_data.

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

---------

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2024-01-30 09:23:42 -08:00
imilenkovic00
ac7a14ece1
api tests fix: Use MTdataHolder in test_get_image_info (#1871) 2024-01-30 09:22:17 -08:00
Ben Ashbaugh
7dbf31e57f
fix the reported platform information for math brute force (#1884)
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.
2024-01-30 09:21:38 -08:00
Ben Ashbaugh
d5b7d10db7
add SPIR-V version testing (#1861)
* 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
2024-01-30 09:14:40 -08:00
Pekka Jääskeläinen
8bb89b165c
subgroups: fix for testing too large WG sizes (#1620)
It seemed to be a typo; the comment says that it
tries to fetch local size for a subgroup count with
above max WG size, but it just used the previous
subgroup count.

The test on purpose sets a SG count to be a larger
number than the max work-items in the work group.
Given the minimum SG size is 1 WI, it means that there
can be a maximum of maximum work-group size of SGs (of
1 WI of size). Thus, if we request a number of SGs that
exceeds the local size, the query should fail as expected.
2024-01-30 09:13:22 -08:00
joshqti
b5f030faa1
Updated semaphore tests to use clSemaphoreReImportSyncFdKHR. (#1854)
* Updated semaphore tests to use clSemaphoreReImportSyncFdKHR.

Additionally updated common semaphore code to handle spec updates
that restrict simultaneous importing/exporting of handles.

* Fix build issues on CI

* gcc build issues

* Make clReImportSemaphoreSyncFdKHR a required API
call if cl_khr_external_semaphore_sync_fd is present.

* Implement signal and wait for all semaphore types.
2024-01-23 23:39:14 +05:30
Sven van Haastregt
0bdd0fd2fa
compiler: fix grammar in error message (#1877)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-01-17 08:05:10 -08:00
Ben Ashbaugh
1260e7f5e0
fix the license header on the spirv-new tests (#1865)
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.
2024-01-16 09:58:34 -08:00
Ben Ashbaugh
0a32b5ca9d
fix macos builds by avoiding double compilation of function_list.cpp for test_spir (#1866)
* modernize CMakeLists for test_spir

* add the operating system release to the sccache key

* include the math brute force function list vs. building it twice
2024-01-16 09:54:53 -08:00
Romaric Jodin
7d3db1bd07
fix return code when readwrite image is not supported (#1873)
This function (do_test) starts by testing write and read individually.
Both of them can have errors.

When readwrite image is not supported, the function returns
TEST_SKIPPED_ITSELF potentially masking errors leading to the test
returning EXIT_SUCCESS even with errors along the way.
2024-01-16 09:52:08 -08:00
Yilong Guo
f924273cdd
Enable LARGEADDRESSAWARE for 32 bit compilation (#1858)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
* Enable LARGEADDRESSAWARE for 32 bit compilation

32-bit executables built with MSVC linker have only 2GB virtual memory
address space by default, which might not be sufficient for some tests.

Enable LARGEADDRESSAWARE linker flag for 32-bit targets to allow tests
to handle addresses larger than 2 gigabytes.

https://learn.microsoft.com/en-us/cpp/build/reference/largeaddressaware-handle-large-addresses?view=msvc-170

Signed-off-by: Guo, Yilong <yilong.guo@intel.com>

* Apply suggestion

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>

---------

Signed-off-by: Guo, Yilong <yilong.guo@intel.com>
Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
2024-01-09 09:51:59 -08:00
Sven van Haastregt
ebe8aa0fcc
math_brute_force: fix exp/exp2 rlx ULP calculation (#1848)
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>
2024-01-09 09:50:34 -08:00
Wenwan Xing
6606fc2e7b
Fix bug of conversion from long to double (#1847)
* Fix bug of conversion from long to double

It the input is long type, it should be load as long type, not ulong.

* update long2float
2024-01-09 09:48:56 -08:00
Sven van Haastregt
115bbb3ca2
[NFC] conversions: reenable Wunused-but-set-variable (#1845)
Remove an assigned-to but unused variable.

Reenable the Wunused-but-set-variable warning for the conversions
suite, as it now compiles cleanly with this warning enabled.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2024-01-09 09:47:04 -08:00
Grzegorz Wawiorko
05ba82ad9a
Enhancement: Thread dimensions user parameters (#1384)
* Fix format in the test scope

* Add user params to limit testing

Add parameters to reduce amount of testing.
Helpful for debugging or for machines with lower performance.

* Restore default value

* Print info only if testing params bigger than 0.
2024-01-09 09:43:36 -08:00
niranjanjoshi121
b041ec0a9a
Replace OBSOLETE_FORAMT with OBSOLETE_FORMAT (#1776)
* 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
2023-12-28 18:52:13 +00:00
Sven van Haastregt
b36b2d592c
integer_ops: fix -Wformat warnings (#1860)
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>
2023-12-20 17:57:35 +01:00
Sven van Haastregt
47d5d371cd
geometrics: fix Wsign-compare warnings (#1855)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-12-14 16:26:16 +01:00
Ahmed Hesham
344a88301d
Limit individual allocation size using the global memory size (#1835)
Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2023-12-12 09:44:56 -08:00
Sreelakshmi Haridas Maruthur
c8ebba8699
c11_atomics: Reduce the loopcounter for sequential consistency tests (#1853)
Reduce the loop from 1000000 to 500000 since the former value
makes the test run too long and cause system issues on certain
platforms
2023-12-12 09:38:14 -08:00
Sreelakshmi Haridas Maruthur
352e707836
thread_dimensions: Avoid combinations of very small LWS and very large GWS (#1856)
Modify the existing condition to include extremely small LWS like
1x1 on large GWS values
2023-12-12 09:35:18 -08:00
Haonan Yang
a73f2b38fb
Fix windows stack overflow. (#1839) 2023-12-12 09:33:09 -08:00
Sreelakshmi Haridas Maruthur
9a8fd1f667
allocations: Move results array from stack to heap (#1857)
* allocations: Fix stack overflow

* check format fixes
2023-12-12 09:32:45 -08:00
Kévin Petit
0fa6f236be
Increase the number of work items used by the allocations test (#1852)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 1s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
* Increase the number of work items used by the allocations test

The test uses a fixed number of work items to process very large
buffers and images. As devices support more and more memory, this
leads to an ever-increasing amount of work done in each work item.
This results in some implementations and devices hitting timeout
issues.

Furthermore, a greater number of work items can provide performance
benefits on some devices.

Long term, this test should be redesigned to scale the number
of threads dynamically as a function of the max allocation size.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>

* formatting and add parentheses

---------

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2023-12-05 17:09:22 +00:00
joshqti
f5bd92b83e
Semaphore types bug fixes revised (#1822)
* 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.
2023-11-29 16:02:59 +05:30
Kévin Petit
5815e2ce33
Reduce the Vulkan interop buffer kernel workgroup size to 128 (#1846)
Vulkan guarantees 128 is always supported.

Relates to #1828

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2023-11-23 19:06:50 +05:30
Ben Ashbaugh
eec46a087a
switch to the new memory and semaphore specific device handle lists (#1814)
* switch to the new memory and semaphore specific device handle lists

* remove support for older headers

* dummy commit
2023-11-14 11:28:09 -08:00
Ahmed Hesham
8b1a44f93f
Reduce the Vulkan interop buffer kernel workgroup size to 256 (#1828)
Using `local_size_x = 512` in the shader used in the Vulkan interop
tests fails on older hardware because this exceeds the maximum barrier
size limit.

Changed to 256, which is still a multiple of 32 and 64,
and is below the hardware limitations. The tests are not performance
tests anyways, so the performance penalty, if any, is acceptable.

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
2023-11-15 00:03:46 +05:30
StrahinjaStamenkovic
482126d611
subgroup_functions_ext: fix missing flag initialization (#1826) 2023-11-14 09:10:57 -08:00
Sven van Haastregt
ea6e536ed3
c11_atomics: align signedness of host types (#1816)
Some `HOST_` types were declared with signedness different from the
`HOST_ATOMIC_` counterparts, leading to sign-compare warnings when
comparing between types.  Fix by aligning the signedness.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-11-14 09:09:45 -08:00
Sven van Haastregt
f08b3f6aee
profiling: fix -Wformat warnings (#1838)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-11-09 10:27:44 +00:00
Aharon Abramson
be626ca1fa
add MIPS architecture (#1837) 2023-11-07 09:36:45 -08:00
Sven van Haastregt
42434d04d0
c11_atomics: fix uninitialized member accesses (#1819)
Initialize the `_memoryOrder` and `_memoryScope` members to avoid
`CBasicTestMemOrderScope::MaxHostThreads()` accessing uninitialized
data.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-11-07 09:32:16 -08:00
John Kesapides
115e999a38
Image2d_from_buffer_positive comparison fix (#1569)
Only check against 2D image types as per the spec.
Move some device checks out of the loop.
Only perform the checks when element_size is a power of two.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-11-07 09:31:18 -08:00
John Kesapides
7e4b59dfaa
Delete unused file test_float2int.cpp (#1831)
Remove left over file from (#1537)

https://github.com/KhronosGroup/OpenCL-CTS/pull/1537#issuecomment-1642088122

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-10-30 13:01:34 +00:00
Sreelakshmi Haridas Maruthur
40aaa2bcf2
conversions: Build fix for x86 toolchain (#1827) 2023-10-17 09:49:35 -07:00
Karol Herbst
c6dd6f2aa3
make atomic tests in prog var testing optional (#1799)
This is helpful for testing progvars on implementations not implementing
all the optional atomic features.
2023-10-17 09:40:44 -07:00
Marcin Hajder
72bb711646
Added cl_khr_fp16 extension support for test_explicit_s2v from basic (#1713)
* 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>
2023-10-17 09:38:36 -07:00
niranjanjoshi121
c73d6a341b
Add NULL CL_MEM_HOST_PTR check for clGetMemObjectInfo (#1801)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
The spec requires implementations return NULL for CL_MEM_HOST_PTR
when the flags passed at memory object creation time do not contain
CL_MEM_USE_HOST_PTR

CTS was not checking this. Add the same check.

Fixes #1752
2023-10-10 09:25:10 -07:00
Michal Babej
af2710355d
add tests for clCommandSVMMemcpyKHR & clCommandSVMMemfillKHR (#1821)
* add tests for clCommandSVMMemcpyKHR & clCommandSVMMemfillKHR

* Fix typo SVMMemfill -> SVMMemFill

* fix clCommandSVMMemFillKHR calls to match extension

* add Khronos license + minor fixes

* review fixes
2023-10-10 09:22:50 -07:00
Nikhil Joshi
a7c33f8dc4
Add ffp-contract=off Compilation flag for CTS build (#1824)
* 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.
2023-10-10 09:21:23 -07:00
Aharon Abramson
60fc7fc844
Update test_compile.cpp (#1812)
* Update test_compile.cpp

Prevent the error:
"variable 'temp' is uninitialized when used here"

Since one of the generated kernels starts with:

__kernel void sample_test(__global float *src, __global int *dst)
{
    float temp;
    int  tid = get_global_id(0);
    dst[tid] = dst[tid] + temp;

* Update test_compile.cpp

clang format

* Update test_compile.cpp

Change the "0.0" literal to "0.0f" for devices that don't support FP64.
2023-10-10 09:18:22 -07:00
Sven van Haastregt
e3c8de8eb6
math_brute_force: don't set/restore FTZ mode twice (#1808)
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>
2023-10-03 09:36:01 -07:00
niranjanjoshi121
1fe72877d7
Check that CL_DEVICE_COMPILER_AVAILABLE is CL_TRUE for FULL_PROFILE (#1804)
OpenCL FULL profile requires that online compiler be available.
OpenCL-CTS currently queries profile as well as online compiler
availability via device queries, but doesn't check for the consistency.

Check for consistency that if CL_DEVICE_PROFILE is "FULL_PROFILE"
(or technically is not "EMBEDDED_PROFILE") then CL_DEVICE_COMPILER_AVAILABLE
is CL_TRUE for that device.

Fixes #1763
2023-10-03 09:33:47 -07:00
John Kesapides
4984196bcb
Fix CopyImage verification for 1D/2D images (#1791)
The verification uses a common function with nested loops to verify
the result of the copy operation. The upper loop limits thirdDim and
SecondDim should be set according to the image type under test. Previously
for 1D/2D they were set from dstImageInfo->depth and dstImageInfo->height.
The issue is that the depth and height are set to 0 when unused. This
caused the verification loop to be skipped.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-10-03 09:30:46 -07:00
niranjanjoshi121
7f0c0aee05
Replace cl_queue_properties_khr with cl_command_queue_properties (#1768)
test_conformance/api/test_queue_properties.cpp uses a cl_queue_properties_khr value
to query CL_DEVICE_QUEUE_PROPERTIES, however this should be a cl_command_queue_properties
typed variable.

Fixes issue #1640
2023-10-03 09:29:20 -07:00
Steven Winston
43d6886810
rewrite test_select to run in a few seconds. (#1665)
* rewrite test_select to run in a few seconds.

* removing the threading; reverting to the original method.

* Merge from Master, remove all suggested changes and start with a simple change report on each change's cost savings:
 BEFORE:
        real    47m8.497s
        user    48m8.860s
        sys     0m14.952s
AFTER:
        real    17m53.383s
        user    18m53.342s
        sys     0m13.297s

initSrcBuffer generates the same random noise every iteration through the loop.  There is no change to the arguments, and the host data itself doesn't need to get rewritten.  Profiling realizes a 2 times speed accel from simply relying upon the buffer to remain randomized at the next loop iteration.

* BEFORE:
        real    17m53.383s
        user    18m53.342s
        sys     0m13.297s
AFTER:
real    12m26.035s
user    13m15.505s
sys     0m15.414s

rearrange a few things in the loops to allow for vectorized / interleaved loop traversal.  NB: not all loops are vectorizable obviously; but this addresses the worst offenders.  Also note, to enable compiler to generate vectorized and interleaved loop traversal build with -o3.

* address the CI format requirements.

* address the CI format requirements.

* address the CI format requirements.
2023-10-03 09:26:48 -07:00
Sven van Haastregt
f39685030f
gl: fix sometimes-uninitialized warning (#1815)
Bail out when hitting the default case, so that we don't attempt to
access the uninitialized `error` variable.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-10-02 08:11:55 -07:00
Sven van Haastregt
b143a990d9
select: fix -Wformat warnings (#1817)
* Printing of a `size_t` requires the `%z` specifier.

 * Printing of `cl_long`/`cl_ulong` 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>
2023-09-22 07:10:44 -07:00
Sreelakshmi Haridas Maruthur
7759c2669a
basic: fix more unused-but-set variables (#1811)
Some checks failed
Presubmit / Build ubuntu-22.04 gl (push) Failing after 1s
Presubmit / Build ubuntu-22.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-22.04 arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
2023-09-21 08:30:32 -07:00
Sven van Haastregt
aa953aaa51
[NFC] cmake: do not suppress -Wsign-compare globally (#1810)
Only disable `-Wsign-compare` for tests that do not compile cleanly
with this warning enabled.  Re-enable the warning for the other tests,
so that it can catch any new occurrences.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-09-20 15:48:25 +01:00
Sven van Haastregt
1c616238bc
test_common: Capitalize macro and clang-format (#1813)
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>
2023-09-20 10:19:13 +01:00
Sven van Haastregt
d20913b4e3
test_common: fix -Wformat warnings (#1771)
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>
2023-09-19 12:26:48 +01:00
Sven van Haastregt
d7f24a7986
Fix more -Wsign-compare warnings (#1779)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-09-14 11:00:30 +01:00
Sven van Haastregt
39cca992b8
math_brute_force: remove gotos in macro_unary_float (#1725)
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>
2023-09-06 13:32:19 +01:00
Ahmed
d20de8ddea
Command buffer wait_for_sec_queue_event subtest, call clFinish in the correct order. (#1758)
* Fix for Command buffer wait_for_sec_queue_event subtest, call clFinish in the correct order.

queue has a command that depends on a command that resides in queue_sec, calling clFinish(queue) before clFinish(queue_sec) causes the test to hang as the queue_sec command never got a chance to finish.

* Update PR change as per the suggestion.
2023-09-05 09:09:04 -07:00
Sreelakshmi Haridas Maruthur
15b54aa0bd
External memory updates (#1676)
* Vulkan: Fix descriptor sets

Use descriptor set arrays when programming
arrays for compute shader.

Change-Id: Idabab775a256a223660eb7a850e26f290453659e

* Vulkan: Fix queue propertyies

Transfer bit for queue family is not required
to be reported by the implementation, it is
implicit for compute.

Change-Id: I7424b00e25e35145433dd74b0b4dfe7eeeaf98c8

* Vulkan: Allow implementation to choose dedicated memory

Dedicated vs non-dedicated memory must be queried by
the app.  Implementations are not required to support
exportable non-dedicated memory.

Change-Id: Idbc46ace1be20f61d1b58b34756f6d79a7745911

* Fix formatting

Auto-generated formatting fix

* Fix bug in dedicated memory.

* Add check for if OpenCL assumes linear tiling

Change-Id: Idd2e24d9d69e1fbc3ccb4a279067533104185332

* Changed macro name to reflect spec

CL_DEVICE_EXTERNAL_MEMORY_IMPORT_ASSUME_LINEAR_HANDLE_TYPES_KHR to
CL_DEVICE_EXTERNAL_MEMORY_IMPORT_ASSUME_LINEAR_IMAGES_HANDLE_TYPES_KHR

Also changed some functions to not use the KHR variants.

---------

Co-authored-by: Joshua Kelly <joshkell@qti.qualcomm.com>
2023-09-05 09:04:38 -07:00
Vishal Patil
c511ac62b0
fix memory leak from argList and from wrong ordering of free and return statement (#1792) 2023-08-29 09:19:45 -07:00
John Kesapides
8fd55dc889
Fix minimum image size for cl_ext_image_requirements_info (#1790)
Some new extension formats require the width to be a multiple
of 4 or 2 (see cl_ext_image_raw10_raw12).
Change has not functional impact as the affected image is only used
for generic queries.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-08-29 09:18:11 -07:00
Ben Ashbaugh
bd548e63e6
fix a sporadic failure in the mutable_command_dimensions test (#1785) 2023-08-29 09:16:53 -07:00
Ewan Crawford
a3262eb4b6
[Command-buffer] Test finalizing empty command-buffer (#1782)
This patch adds two test cases related to command-buffer finalization:

1) That it is an error to finalize and already finalized command-buffer.
See https://github.com/KhronosGroup/OpenCL-Docs/pull/817

2) That it is not an error to create, finalize, and execute an empty
command-buffer. Closes issue #1781
2023-08-29 09:15:39 -07:00
Sven van Haastregt
c23631c690
subgroups: fix Wsign-compare warnings (#1778)
The subgroup and workgroup sizes reported by clGetKernelSubGroupInfo
and clGetKernelWorkGroupInfo are of type `size_t`.  Avoid changing the
values to an `int` type as they are propagated through the tests and
then compared against `size_t` again.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-08-29 09:14:23 -07:00
Sven van Haastregt
46fde8d051
atomics: fix memory leaks on error paths (#1732)
Before this change, `add_index_bin_test` would not release `cl_mem`
resources or `malloc`ed memory when encountering an error.  Fix by
using `clMemWrapper` and `std::unique_ptr` to automatically release
resources.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-08-29 09:13:03 -07:00
Kévin Petit
ddbb0de4b9
ci: use ubuntu-22.04 instead of 20.04 (#1795)
* ci: use ubuntu-22.04 instead of 20.04

Signed-off-by: Kevin Petit <kevin.petit@arm.com>

* bump clang-format version

Oldest supported by 22.04

* update check-format script

---------

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2023-08-22 18:13:22 +01:00
Kévin Petit
0702f2ecee
Make genrand_int32 thread safe (#1797)
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>
2023-08-19 11:15:17 +01:00
Ewan Crawford
df53e02a12
[command-buffer] Remove deleted enum (#1798)
The enum value `CL_COMMAND_BUFFER_STATE_INVALID_KHR` no longer exists:
* https://github.com/KhronosGroup/OpenCL-Headers/pull/235
* https://github.com/KhronosGroup/OpenCL-Docs/pull/885

Replace variable initialization using this enum with a value where
all the bits are set, requiring the runtime to write to it for the
test to pass.
2023-08-17 11:15:59 +01:00
Sven van Haastregt
ddf46ca9e8
math_brute_force: always initialize oldMode (#1796)
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>
2023-08-07 13:51:29 +01:00
Sreelakshmi Haridas Maruthur
aa23f345c3
Add testing for sync_fd (#1747)
Modify the external semaphore extension test
to use SYNC_FD, if available on the device.

Deleted tests that are not compatible with blocking
semaphores.
2023-08-01 11:03:00 -07:00
Sven van Haastregt
e29d0fd3a1
conversions: fix memory leak from excess gMTdata initialization (#1787)
`gMTdata` was initialized twice, but freed only once.

Drop the first initialization with a local seed, and initialize with
`gRandomSeed` instead.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-08-01 09:49:43 +01:00
John Kesapides
a01349c44e
Use CTS type wrappers for test_basic test_loop (#1541)
* Use CTS type wrappers for test_basic test_loop
* Move variable declaration to first use in verify_loop

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-07-27 14:00:03 +01:00
Sven van Haastregt
0460756f6e
basic/int2fp: fix missing include (#1789)
With GCC 13 some headers are no longer included transitively through
C++ Standard Library headers.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-07-23 09:36:23 +01:00
John Kesapides
25ce398037
Use CTS type wrappers for test_constant. (#1543)
Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-07-20 16:13:42 +01:00
John Kesapides
339c932c57
Use the CTS typewrappers in image_r8 (#1539)
Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-07-19 14:18:49 +01:00
John Kesapides
cd5c165946
Deduplicate test_barrier (#1542)
Merge test_barrier and test_wg_barrier.

Reformat using clang-format kernel source code.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-07-19 13:51:30 +01:00
Kévin Petit
3a1daafd5a
harness: add missing stdexcept header (#1783)
Required for std::runtime_error.

Signed-off-by: Kévin Petit <kpet@free.fr>
2023-07-19 13:47:18 +01:00
Sven van Haastregt
c3babfeebb
conversions: fix undefined behaviour from shift by 64 (#1788)
Avoid a shift by 64 on a `uint64_t`.  The value resulting from the
spurious shift was overwritten later, so just avoid the shift in that
case.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-07-19 09:48:59 +01:00
Nora
3c1f2814b8
add cl_khr_expect_assume to test_compiler_defines_for_extensions (#1735) 2023-07-18 16:07:17 -07:00
Sven van Haastregt
19bddc90e4 conversions: restore optimization workaround
The refactoring of the conversions test dropped the workaround added
by 59a12047a ("Fix for test_conversions failure with Clang build on
Linux #1057 (#1062)", 2021-05-11).

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-07-14 15:50:41 +01:00
Sven van Haastregt
b32d566bca conversions: fix undefined behaviour in DataInfoSpec
For conversion from integers to float, the DataInfoSpec constructor
tries to convert `CL_FLT_MAX` to an integer.  The float value cannot
be represented as an integer, which is undefined behaviour.

Fix by only doing this conversion when `InType` is a floating point
value.

While at it, use `static_cast` for the conversions.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-07-14 15:50:41 +01:00
Paweł Jastrzębski
6c841fbad8
Add image arguments tests for cl_khr_command_buffer_mutable_dispatch. (#1750)
* Add image arguments tests for cl_khr_command_buffer_mutable_dispatch.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add fixes for MutableDispatchImage1DArguments and MutableDispatchImage2DArguments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix constant magic number.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix condition for result check.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Changes made:
- Fix kernel parameters
- Fix indentation
- Add skip condition for CL_DEVICE_IMAGE_SUPPORT

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Change array data type.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Changes made:
- Fix skip conditions
- Fix kernel arguments update
- Change random generated values for dst_image

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Remove unneeded headers.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-07-11 13:52:16 -07:00
Paweł Jastrzębski
c69bc00b56
Add arguments tests for cl_khr_command_buffer_mutable_dispatch. (#1749)
* Add arguments tests for cl_khr_command_buffer_mutable_dispatch.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add clFinish and clEnqueueCommandBufferKHR to mutable dispatch global arguments test.

Applied review comments for mutable dispatch global arguments test:
- clFinish to ensure command-buffer has finished executing for calling clUpdateMutableCommandsKHR
- Add second clEnqueueCommandBufferKHR for the command-buffer again before calling clEnqueueReadBuffer so that the kernel runs with the new argument

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add clFinish and clEnqueueCommandBufferKHR to remaining mutable dispatch arguments test.

Applied review comments for remaining mutable dispatch arguments test:
- clFinish to ensure command-buffer has finished executing for calling clUpdateMutableCommandsKHR

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang format.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang format.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Recover proper MutableDispatchGlobalArguments test.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Recover proper MutableDispatchNullArguments test.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix constant magic number.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review changes.

Changes made:
- Remove unneeded headers
- Remove unneeded variable
- Remove unneeded skip condition
- Fix type int -> cl_int

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix tests definitions.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix compilation error.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang format.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang format.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang format.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang format.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-07-11 13:04:30 -07:00
Paweł Jastrzębski
ae1a712e3e
Add out of order tests for cl_khr_command_buffer_mutable_dispatch. (#1746)
* Add out of order tests for cl_khr_command_buffer_mutable_dispatch.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Replace CL_KERNEL_EXEC_INFO_SVM_PTRS with cl_mutable_dispatch_arg_khr command-buffer mutable buffer update.

CL_KERNEL_EXEC_INFO_SVM_PTRS limits the test to devices which support SVM.
Updating arg_list with a cl_mutable_dispatch_arg_khr struct is one of the
best supported, and also easiest to verify, configurations to change.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix skip condition.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review changes.

Changes made:
- Fix skip condition
- Add event
- Add memory verification

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-07-11 10:43:29 -07:00
Paweł Jastrzębski
64130824a8
Add global size tests for cl_khr_command_buffer_mutable_dispatch. (#1744)
* Add global size tests for cl_khr_command_buffer_mutable_dispatch.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add kernel with observable output.

We should check that's some observable output from the kernel
as a result of the change to global work size, not just that
clGetMutableCommandInfoKHR has been updated. For example,
getting every work-item to call get_global_size() inside of
the kernel and writing it to a buffer, then reading the buffer
after the command-buffer enqueue has finished and check it
matches what we expect.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Applied review comments for mutable dispatch global arguments test:
- clFinish to ensure command-buffer has finished executing for calling clUpdateMutableCommandsKHR
- Change variable and constant names for global size

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Changes made:
- Fix skip conditions
- Remove obsolete variable
- Replace a variable with a constant

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Changes made:
- Remove explicit base class call
- Fix condition check
- Fix constant magic number

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix constant magic number.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Remove uneeded comments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-07-11 09:41:43 -07:00
Paweł Jastrzębski
3b7fda2071
Add local size tests for cl_khr_command_buffer_mutable_dispatch. (#1745)
* Add local size tests for cl_khr_command_buffer_mutable_dispatch.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add kernel with observable output.

We should check that's some observable output from the kernel
as a result of the change to local work size, not just that
clGetMutableCommandInfoKHR has been updated. For example,
getting every work-item to call get_local_size() inside of
the kernel and writing it to a buffer, then reading the buffer
after the command-buffer enqueue has finished and check it
matches what we expect.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

    Applied review comments for mutable dispatch local size test:
    - clFinish to ensure command-buffer has finished executing for calling clUpdateMutableCommandsKHR
    - Change variable and constant names for local size

Applied review comments for mutable dispatch global arguments test:
- clFinish to ensure command-buffer has finished executing for calling clUpdateMutableCommandsKHR

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Changes made:
- Fix skip conditions
- Remove obsolete variable
- Replace a variable with a constant

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Remove explicit base class call.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix constant magic number.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Update global size and local size to meet the spec requirements.

Make sure work-groups number is not increased after update of command-buffer.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Remove uneeded includes.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-07-11 08:56:49 -07:00
Paweł Jastrzębski
1ab4b26821
Add tests for external sharing not dependant on semaphores. (#1648)
* Add tests for external sharing not dependant on semaphores.

Additional external sharing tests that use fences instead of semaphores.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang-format

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Apply changes for review.

Apply changes for review:
- Make VkFence + clFinish a synchronization option to existing tests
instead of creating a separate test that uses fence.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix build break.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix resource release conditions.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix fence usage.

Fixed following fence issues:
- Add missing link to command buffer
- Add fence reset before wait

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add Vulkan wrapper for fence.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Rework fence reset.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Change synchronisation mechanisms.

Changes made:
- wait for fence with clFinish
- queue submit with wait for fence

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Replace clFinish with vkWaitForFences.

Replaced clFinish with vkWaitForFences in Vulkan exectution context.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Replace remaining clFinish with vkWaitForFences.

Replaced remaining clFinish with vkWaitForFences in Vulkan exectution context.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments for synchoronisation simplification.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments for synchoronisation simplification for remaining tests.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix condition check.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-07-11 08:55:37 -07:00
Marcin Hajder
2686b9e2c1
Modernization of conversions test (#1719)
* Modernization of conversions test, preparation to handle cl_khr_fp16 extension

* Added missing virtual descructor

* Added corrections due to code review

* More separators removed

* Fixed clang format

* Added multiple corrections related to code review

* Corrected missing implicit test lost after modernization corrections

* Corrected single, selected test to limit number of unnecessary operations
2023-07-11 08:52:25 -07:00
Marcin Hajder
3a1388a2b4
Added cl_khr_fp16 extension support for test_vloadstore from basic (#1734)
* Added cl_khr_fp16 support for test_vloadstore from basic (issue #142, basic)

* Moved string helper procedures due to request from test_commonfns PR #1695

* restored original test sizes

* Corrected invalid initialization of reference buffer
2023-07-11 08:51:05 -07:00
Marcin Hajder
40b3eb3f7f
Added cl_khr_fp16 extension support for test_op_vector_extract from spirv_new (#1765)
* Added cl_khr_fp16 extension support for test_op_vector_extract from spirv_new (issue #142)

* Added missing condition to test available cl_khr_fp16 extension
2023-07-11 08:49:44 -07:00
Marcin Hajder
1e2d3522cf
Added cl_khr_fp16 extension support for test_op_vector_insert from spirv_new (#1766)
* Added cl_khr_fp16 extension support for test_op_vector_insert from spirv_new, work in progress.

* Added cl_khr_fp16 extension support for test_op_vector_insert from spirv_new (issue #142)
2023-07-11 08:48:41 -07:00
Sven van Haastregt
9e8430a6a6
[NFC] clang-format basic/test_enqueue_map.cpp (#1777)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-07-03 10:07:32 +01:00
Sven van Haastregt
9b0f78549a
workgroups: fix program/kernel object leak (#1775)
`create_single_kernel_helper` is called in a loop, overwriting the
objects contained in the wrapper classes.  The wrapper class is not
aware of this, as the overwriting happens through its `operator&`.

Move the wrapper objects into the loop, so that the contained objects
get released as soon as the program and kernel objects are no longer
needed.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-30 11:22:43 +01:00
Sven van Haastregt
845ec694bb
workgroups: fix -Wsign-compare warnings (#1774)
In preparation of re-enabling -Wsign-compare globally, fix some
instances of this warning.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-29 12:20:15 +01:00
Sven van Haastregt
729cd8b7a9
[NFC] device_execution: use raw string literals for block kernels (#1767)
Modernize by using raw string literals, which makes the kernel sources
easier to read/extract.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-28 09:34:07 +01:00
Ewan Crawford
75aca34e60
Test CL_COMMAND_BUFFER_CONTEXT_KHR (#1697)
Test coverage for spec PR https://github.com/KhronosGroup/OpenCL-Docs/pull/899
which introduces a new cl_khr_command_buffer query for the cl_context
2023-06-28 08:13:15 +01:00
Paweł Jastrzębski
56974a5858
Add global offset tests for cl_khr_command_buffer_mutable_dispatch. (#1743)
* Add global offset tests for cl_khr_command_buffer_mutable_dispatch.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add kernel with observable output.

We should check that there's some observable output from the kernel
as a result of the change to global work offset, not just that
clGetMutableCommandInfoKHR has been updated. E.g we could call
get_global_offset() inside of the kernel, write something to a
buffer based on that, and read the buffer after the command-buffer
enqueue has finished.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Applied review comments for mutable dispatch global offset test:
- clFinish to ensure command-buffer has finished executing for calling clUpdateMutableCommandsKHR
- Change variable and constant names for global offset
- Remove redundant return CL_SUCCESS

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Changes made:
- Fix skip conditions
- Remove obsolete variable
- Replace a variable with a constant

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Changes made:
- Remove explicit base class call
- Fix constant magic number

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix constant magic number.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang-format.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix condition for result check.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-06-27 08:54:14 -07:00
Paweł Jastrzębski
fee6d6bb66
Command buffer re-enqueue testing. (#1738)
* Command buffer re-enqueue testing.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Remove reenqueue tests and add reenqueue to existing tests.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add re-enqueue for copy and barrier tests.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix review comments.

Applied review comments for command buffer re-enqueue testing:
- Add second clEnqueueCommandBufferKHR for all tests
- Reinitialise memory before second enqueue of command buffers
- Add different patterns for second enqueue of command buffers

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix verification patterns for second enqueue tests.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Reinitialise output memory for second command buffer re-enqueue.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix cast for conversion from 'const cl_char' to 'const cl_uint.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix compilation error for MSVC.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Reinitialise in_mem and out_mem with zero.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix cast for conversion from 'const cl_int' to 'const cl_uint'.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-06-27 08:47:24 -07:00
Marcin Hajder
73ead9da04
Added cl_khr_fp16 extension support for test_op_negate from spirv_new (#1762)
* Added cl_khr_fp16 extension support for test_op_negate from spirv_new (issue #142)

* Added clang format fix
2023-06-27 08:43:44 -07:00
Marcin Hajder
43c244f01d
Added cl_khr_fp16 extension support for test vector_times_scalar from spirv_new (#1757)
* Added cl_khr_fp16 support for vector_times_scalar from spirv_new (issue #142, spirv_new)

* Logging correction
2023-06-27 08:42:56 -07:00
Marcin Hajder
2495eca9fa
Added cl_khr_fp16 extension support for test_commonfns (#1695)
* 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
2023-06-27 08:42:02 -07:00
Marcin Hajder
60f025a7da
Added cl_half support for test_select (#1617)
* Added cl_half support for test_select (issue #142, select)

* Added corrections due to code review + performance optimization + replaced C object with wrappers

* minor fix

* Corrected use of user event

* Removed unnecessary user event
2023-06-27 08:40:35 -07:00
Sven van Haastregt
2e88013b34
compiler: fix memory leak from unnecessary strdup (#1761)
The result of the `strdup` was never freed.  The string duplication
isn't necessary, so remove it.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-21 22:08:21 -07:00
Sven van Haastregt
50f9f06323
test_common: fix -Wsign-compare warnings (#1759)
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>
2023-06-21 15:19:21 +01:00
Marcin Hajder
df3ec8deec
Added cl_khr_fp16 extension support for test_int2fp from basic (#1742)
* Added cl_khr_fp16 and cl_khr_fp64 support for float2int and int2float tests from basic

* removed debug output

* Replaced procedure to generate random half values in specific range (issue #142, basic)

* Added cosmetic fixes due to code review comments

* Moved string helper procedures due to request for test_commonfns PR #1695
2023-06-20 08:44:45 -07:00
Marcin Hajder
0e229b8f01
Added cl_khr_fp16 extension support for test_fpmath from basic (#1718)
* 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
2023-06-20 08:42:57 -07:00
Sven van Haastregt
44b2578ac7
basic: fix unused-but-set variables (#1764)
Remove the unused `numItems` variable.

As this fixes all occurrences of this warning in test_basic, remove
the suppression flag.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-16 10:53:08 +01:00
Marcin Hajder
16a75dc0af
Added cl_khr_fp16 extension support for test_vector_creation from basic (#1728)
* Added cl_khr_fp16 extension support for vector_creation test from basic

* Added corrections related to vendor's review

* Added protection to avoid similar creation cases

* Added comment for recent correction

* cosmetics

* Corrected factor array to restore lost capacity of original test..

leaving only 16-sizes vector tests limited.
2023-06-13 08:41:39 -07:00
Marcin Hajder
095091bc57
Added cl_khr_fp16 extension support for test_vec_type_hint from basic (#1724)
* Added cl_khr_fp16 extension support for test_vec_type_hint from basic (issue #142, basic)

* Added correction to fix casting problem
2023-06-12 23:39:22 -07:00
Sven van Haastregt
475a37abbf
[NFC] Do not use reserved names for include guards (#1737)
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>
2023-06-09 11:25:20 +01:00
Sven van Haastregt
c8061ab21a
mem_host_flags: use size_t for element count (#1755)
More recent GCC versions (e.g. 12.2, 13.1) report that the argument to
`new[]` in the `Init` methods exceeds the maximum object size,
seemingly related to the negative range of the widened `int`.

Use an unsigned type to avoid the warning and propagate the signedness
change to other uses of the `num_elements` member.

Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1582

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-08 13:27:20 +01:00
Romaric Jodin
1011f8ea81
fix async strided test outputing error during verify (#1754)
This bug was introduced by
https://github.com/KhronosGroup/OpenCL-CTS/pull/1711

Ref google/clspv#1127
2023-06-07 15:53:12 +01:00
Sven van Haastregt
658a8b62fb
[CI] Build Vulkan loader with USE_GAS=ON (#1756)
https://github.com/KhronosGroup/Vulkan-Loader/pull/1212 broke builds
that set `USE_GAS=OFF`.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-07 15:07:25 +01:00
Sven van Haastregt
b843b3bd8c
relationals: fix missing includes (#1753)
With GCC 13 some headers are no longer included transitively through
C++ Standard Library headers.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-07 10:51:38 +01:00
Marcin Hajder
c467391680
Added support for cl_khr_fp16 extension in test_async_copy from basic (issue #142, basic) (#1707) 2023-06-06 08:46:56 -07:00
Sven van Haastregt
63a8cb6b9d
non_uniform_work_group: fix unused-but-set variables (#1733)
Remove the unused `nonRemainderGlobalSize` array.  Inspect the result
of the `clGetDeviceInfo` call.

As this fixes all occurrences of this warning, remove the suppression
flag from this test.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-05 11:45:25 +01:00
Sven van Haastregt
ce17549812
cmake: do not suppress -Wsometimes-uninitialized globally (#1741)
Fix an instance of this warning in mem_host_flags.

Only disable `-Wsometimes-uninitialized` for the SVM test, which does
not compile cleanly with this warning enabled.  Re-enable the warning
for the other tests, so that it can catch any new occurrences.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-06-02 10:57:10 +01:00
Sven van Haastregt
abd556f7a2
relationals: add missing virtual destructor (#1739)
`RelationalsFPTest` contains a vector of `RelTestBase` pointers to
`RelTestParams` instances, so the base class destructor should be
virtual to avoid undefined behaviour.

Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1731

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-05-31 10:02:54 +01:00
Chris Gearing
19f4fc3f3d
Make extended_async_copy tests type agnostic (#1619)
The latest version of the cl_khr_extended_async_copies extension uses
element size rather the element type as its base. The means it can be
called with arbitrary and in particular non power of 2 sizes, such as 3
or 13.

Update the test_async_copy2D and test_async_copy3D tests to make them
element size based rather than type based.

As well as this run all tests that can fit into the memory of the
target rather than presumed large elements cannot fit.

Make some addtional good practice changes in terms of const usage,
declaring variables where they are use, and usage of iterators.

The test coverage increases from 1224 cases to 1332 cases for the
test_async_copy2D and test_async_copy3D cases.

Ticket: #1579

Signed-off-by: Chris Gearing <chris.gearing@mobileye.com>
Co-authored-by: Chris Gearing <chris.gearing@mobileye.com>
2023-05-30 09:05:18 -07:00
Zhaoyu Zhang
38abfc7d24
select: using clEnqueueReadBuffer rather than clEnqueueMapBuffer (#1712)
* select: using clEnqueueReadBuffer rather than clEnqueueMapBuffer

* Update code to be compatible with clang-format

* update code again to be compatible with clang-format

* update code again to comply with clang-format

* updata code again to be compatible with clang-format

The clang-format tool is so weird, it's not even consistent between runs...
2023-05-30 08:54:32 -07:00
Marcin Hajder
b3c1401d48
Added cl_khr_fp16 extension support for test_async_strided_copy from basic (issue #142, basic) (#1711) 2023-05-30 08:52:27 -07:00
Marcin Hajder
c58ead9aea
Added cl_khr_fp16 extension support for test_astype from basic (#1706)
* Added support for cl_khr_fp16 extenstion in test_astype from basic (issue #142, basic)

* Added correction to iterate over vector of types

* Fixed case with both fp16 and fp64 supported

* Cosmetic corrections due to code review

* Cosmetic corrections due to code review
2023-05-30 08:52:06 -07:00
Sreelakshmi Haridas Maruthur
9692380505
Semaphore test: Use blocking semaphores (#1675)
Semaphore spec has been updated to reflect the fact that semaphores
will be in the appropriate - pending signal or pending wait - state
when returning from clEnqueueSignalSemaphore or
clEnqueueWaitSemaphore commands: KhronosGroup/OpenCL-Docs#882

Deleted the following tests to match the updated spec:

semaphores_order_1 - Test calls EnqueueWaitSemaphore before calling
EnqueueSignalSemaphore and expects this wait to succeed.
This behavior is not compatible with the recent
spec updates to semaphores.

semaphores_order_2 & semaphores_order_3 - Calling
clEnqueueSignalSemaphoresKHR with a dependency on a user event may
cause the implementation to block until the user event is complete.
This is unsafe usage of clEnqueueSignalSemaphoresKHR and may
lead to deadlock.

semaphores_invalid_command - This test checks for specific behavior
when waiting on a semaphore in an invalid state.
According to the spec, this is undefined behavior,
and therefore cannot be tested directly.

Co-authored-by: Joshua Kelly <joshkell@qti.qualcomm.com>
2023-05-30 08:49:31 -07:00
Marcin Hajder
4cb39b8c14
Added cl_khr_fp16 extension support for test_hiloeo from basic (#1721)
* Added cl_khr_fp16 support for hiloeo test from basic (issue #142, basic)

* Added correction due to compiler warrning

* Cosmetic correction
2023-05-30 08:48:09 -07:00
Paweł Jastrzębski
35b8db35c6
Add check for CL_COMMAND_BUFFER_STATE_EXECUTABLE_KHR after completion. (#1740)
* Add check for CL_COMMAND_BUFFER_STATE_EXECUTABLE_KHR after completion.

Added check for state CL_COMMAND_BUFFER_STATE_EXECUTABLE_KHR in state info tests.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add wait for event.

Wait for event to guarantee that a command-buffer has finished executing by this point.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add new event to wait for.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-05-30 08:43:58 -07:00
Marcin Hajder
4dece20f7d
Added cl_khr_fp16 extension support for test_vector_swizzle from basic (#1729)
* Added cl_khr_fp16 extension support for vector_swizzle from basic (issue #142, basic)

* Added code review related fix
2023-05-29 14:04:04 +01:00
John Kesapides
3e8898ffeb
Deduplicate test_basic int2float/float2int (#1537)
Merge int2float,float2int.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2023-05-24 16:55:25 +01:00
Sven van Haastregt
957e3b3985
Convert some if-else chains to switch statements (#1730)
All of these if-else chains compare against enums, which is better
done using switch statements.  This helps avoid some
`-Wsometimes-uninitialized` warnings of variables that are assigned
inside the switch.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-05-24 11:11:23 +01:00
Sven van Haastregt
4f62adf1ca
computeinfo: fix use of uninitialized config_size_ret (#1727)
The variable `config_size_ret` is only assigned to inside the `if`.
If the condition is false, we would read uninitialized data.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-05-23 09:43:25 +01:00
Sven van Haastregt
8f3027387a
Fix some Wformat size_t warnings (#1726)
Printing a `size_t` requires the `%zu` specifier.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-05-18 09:29:27 +01:00
Tuomas Lauttia
85c95297ac
Removed hardcoded -cl-std=CL2.0 build option from progvar tests (#1710)
Some checks failed
Presubmit / Build ubuntu-20.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-20.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-20.04 arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
* Removed hardcoded -cl-std=CL2.0 build option from progvar tests

Fixes issue #1380
https://github.com/KhronosGroup/OpenCL-CTS/issues/1380

These changes will query the device for the latest supported CL C
version instead of using a hardcoded value. The create_single_kernel_helper
function queries for the latest CL C version internally, so calls to
create_single_kernel_helper_with_build_options were replaced with calls
to create_single_kernel_helper instead.

* Fixed formatting
2023-05-16 08:46:28 -07:00
Marcin Hajder
32688a47b3
Complementation and modernization of commonfns tests (#1694)
* Unified common functions tests due to preparation for adding cl_khr_fp16 support

* Renamed base structure, few cosmetic corrections

* Added corrections due to code review

* Removed comment separators

* Added review related corrections
2023-05-16 08:44:42 -07:00
Juan Manuel Martinez Caamaño
0447b7a2c8
Avoid integer overflows when computing abs_diff (#1689)
After compiling OpenCL CTS with -fsanitize=undefined I stumbled upon
some signed integer overflows.

test_absdiff.cpp:103:24: runtime error: signed integer overflow:
  419625160 - -1937831252 cannot be represented in type 'int'
test_absdiff.cpp:101:28: runtime error: signed integer overflow:
  1277901399 - -1294103363 cannot be represented in type 'int'
test_absdiff.cpp:140:24: runtime error: signed integer overflow:
  8945130301981949496 - -2872789959208163723 cannot be represented in type
  'long int'
test_absdiff.cpp:138:29: runtime error: signed integer overflow:
  5488544718097069860 - -5558131619970145206 cannot be represented in type
  'long int'

The result from these operations was used to compare against the kernel result.

This patch replaces the abs_diff manual computations by a function that handles
the signed integer overflow case.
2023-05-16 08:44:15 -07:00
Marcin Hajder
f31b2f029c
Added cl_half support for test_relationals (#1623)
* Added cl_khr_fp16 support for test_relationals (issue #142, relationals)

* Added cl_khr_fp16 support for any and bitselect test cases (issue #142, relationals)

* correction related to automated travis build for macOS (issue #142, relationals)

* more corrections related to automated travis build for macOS (issue #142, relationals)

* Added few cosmetic corrections (issue #142, test_relationals)

* Added missing clang format

* Added corrections related to order of initialization

* Added corrections due to code review (issue #142, relationals)

* Correction for prev commit

* Added subnormals related condition for test verification (issue #142, relationals)

* Added indexing correction due to code review

* Replaced hardcoded iteration limit (issue #142, relationals)
2023-05-16 08:43:47 -07:00
Sven van Haastregt
1884042f5d
[NFC] cmake: do not suppress -Wunused-but-set-variable globally (#1723)
Only disable `-Wunused-but-set-variable` for tests that do not compile
cleanly with this warning enabled.  This re-enables the warning for
most other tests, so that it can catch any new occurrences.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-05-16 09:58:04 +01:00
Kévin Petit
06c0c99c2e
Enable clCopyImage suite to run in parallel (#1717)
Signed-off-by: Kévin Petit <kpet@free.fr>
2023-05-13 10:21:34 +01:00
Sven van Haastregt
b23268acf5
math_brute_force: don't get build log after clCreateKernel (#1722)
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>
2023-05-13 10:21:13 +01:00
Sven van Haastregt
d223e46f20
atomics: Remove unused variable in atomic_add_index_bin (#1709)
Remove a variable that was set when an OpenCL API call failed, but
never read again.  Instead, return immediately upon failure.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-05-11 14:12:09 +01:00
Sven van Haastregt
8272c83c6f
math_brute_force: consider all types for extension pragmas (#1705)
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>
2023-05-10 10:45:44 +01:00
Sven van Haastregt
20afedbd4a
[NFC] math_brute_force: remove unused MakeKernel function (#1714)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-05-04 16:18:35 +01:00
Banan-Askhar-Mobileye
caa656c268
fixing test events (#1678) 2023-05-03 09:16:21 +01:00
Kévin Petit
ff1369d94e
Add basic support to the harness for parallel test execution (#1687)
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>
2023-04-25 19:30:42 +01:00
paulfradgley
033aa195c5
Pass 'flag' variable through to clGetImageRequirementsInfoEXT (attempt 2) (#1700)
Rebase of my previous clGetImageRequirementsInfoEXT flag=0 fix PR: PR1632

Pass 'flag' variable through to clGetImageRequirementsInfoEXT:

Almost all of the image_from_buffer cl_ext_image_requirements_info tests pass '0' as the 'flags' to clGetImageRequirementsInfoEXT.
Passing '0' as the flags is valid according to the spec, but since the tests are calling clGetImageRequirementsInfoEXT in a loop over a list of flags it doesn't seem intended that all the tests pass '0'.

Fixed CL_MEM_KERNEL_READ_AND_WRITE flag override:

The mem_flags override for CL_MEM_KERNEL_READ_AND_WRITE was incorrectly affecting subsequent iterations of the image_format loop.
Fixed by using a separate variable inside the loop.
2023-04-25 09:17:22 -07:00
Sven van Haastregt
aa34b4b8c3
[NFC] Remove unused depth_lod variables (#1696)
Remove the remaining unused variables in the test harness.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-04-25 09:16:10 -07:00
Sven van Haastregt
b57445e56a
[NFC] README.md: fix typos (#1704)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-04-24 11:39:27 +01:00
Tuomas Lauttia
4f5af72088
Fixed use-after-free and class-memaccess errors when compiling with GCC 12.2.0 (#1702) 2023-04-21 10:09:55 +01:00
Ben Ashbaugh
5b87f53fe8
define CL_NO_EXTENSION_PROTOTYPES (#1325)
* define CL_NO_PROTOTYPES

When we switch to generated headers this will suppress declaration
of extension functions, so we can continue to declare function
pointers with the same name.

* switch to CL_NO_EXTENSION_PROTOTYPES

CL_NO_PROTOTYPES will omit declarations of core OpenCL APIs also.
2023-04-11 09:30:01 -07:00
Sven van Haastregt
9772516c3f
cmake: Enable -Wall for non-release builds (#1686)
Enable a larger set of compiler warnings globally for gcc/clang-like
compilers.  This should help catch issues early and result in better
code quality.  These warnings are primarily aimed at OpenCL-CTS
developers, so only enable them for non-release builds.

Ensure `-Wall` and `-Werror` are set before any `-Wno-...` options, as
the `-Wall`/`-Werror` flags undo `-Wno-...` for some compilers.

The code base does not compile cleanly with `-Wall` yet, so disable
some warnings.  Do this globally for now, to keep this patch small and
localized.

Silence `-Wunknown-pragmas` (instead of only making them non-fatal),
to avoid verbose warning logs.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-04-05 09:39:38 +01:00
Marcin Hajder
f0f887d07f
printf test cases for cl_khr_command_buffer extenstion (#1592)
* Added printf test case for cl_khr_command_buffer extenstion according to point 1.6 from:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Corrections related to macos and windows build

* Added missing header

* Added corrections related to code review of draft PR:

https://github.com/KhronosGroup/OpenCL-CTS/pull/1592

refers to issue #1369, p.1.6:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* minor fix for previous commit

* printf capability condition moved to ::Skip method (#1369, p.1.6):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Applied minor corrections related to code review (#1369, p.1.6):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added correction to replace string literals with sequence of characters printf arguments (issue #1369, printf)

* Added clang formatting.

* Added header related to android build (issue #1369, printf)

* Fixed memory leak

* Fixed memory leak in test_printf

* Added cosmetic fix for last commit
2023-04-04 08:12:05 +01:00
Sven van Haastregt
605228ae7f
[NFC] api: Fix sign-compare warnings (#1692)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-04-03 16:29:51 +01:00
Sven van Haastregt
a70fa56003
Fix some Wunused-but-set warnings (#1666)
To the best of my understanding, these occurrences of the
`-Wunused-but-set` warnings do not reveal any underlying issues, so we
can safely remove these variables.  There are more occurrences of this
warning in other places (not touched by this commit) that require
further analysis.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-03-30 09:34:00 +01:00
Sven van Haastregt
8e74722a0a
cmake: Fix -Wno- handling in add_cxx_flag_if_supported (#1656)
The `-Wno-...` compiler flags only result in a diagnostic if another
diagnostic is emitted.  When passing such flags to
`add_cxx_flag_if_supported` (and `check_cxx_compiler_flag`), the test
would always succeed.  For such cases, test the `-W...` flag instead
of the `-Wno-...` flag.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-03-29 11:10:27 +01:00
Ahmed
9afb918bf5
Disable vendor extension formats from image_from_buffer_fill_positive as the verification step is incorrect and can cause seg fault, e.g. for YUV images (#1657) 2023-03-28 09:16:15 -07:00
Ahmed
14f421e54b
Fix slice pitch for 1D array images on image_from_buffer_read_positive kernel_read_write images subtest (#1654) 2023-03-28 09:15:33 -07:00
Sreelakshmi Haridas Maruthur
868de6c15e
test_harness: Update test status upon api failure (#1615)
Co-authored-by: Vasu Penugonda <vpenugon@qti.qualcomm.com>
2023-03-28 09:14:47 -07:00
Marcin Hajder
20ab003053
Added cl_half support for test_printf (#1622)
* 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)
2023-03-28 08:57:03 -07:00
Marcin Hajder
f537c40abc
clGetCommandBufferInfoKHR test cases for cl_khr_command_buffer extension (#1611)
* Added initial commit for issue #1369, p.1.4

* Added support for clGetCommandBufferInfoKHR test cases (issue #1369, p.1.3)

* Added correction for CL_COMMAND_BUFFER_QUEUES_KHR query test (issue #1369, p.1.4)

* Added corrections related to changed orders of operations Skip/SetUp and code review (issue #1369, clGetCommandBufferInfoKHR)

* Added cosmetic correction related to printout messages (issue #1369, clGetCommandBufferInfoKHR)

* Corrected info_prop_array test to accept scenario without simultaneous use (issue #1369, p.1.4)

* Added protection test agains POCL unexpected values (issue #1369, p.1.4)

* Added corrections related to Ben's code review
2023-03-28 08:41:41 -07:00
Sven van Haastregt
8352966818
[NFC] Remove unused imagePtr variable (#1682)
This variable is shadowed by another variable further down.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-03-27 12:03:07 +01:00
Sven van Haastregt
c3d36bf9fb
[CI] Upgrade to actions/checkout@v3 (#1677)
Node.js 12 actions are deprecated, so update to v3 which uses Node 16.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-03-22 11:21:23 +00:00
Paweł Jastrzębski
3478f3d304
Add mutable dispatch tests. (#1651)
* Add mutable dispatch tests.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Mutable dispatch buffer tests redesigned to inherit from command buffer tests.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add remaining tests for clGetMutableCommandInfoKHR.

Added tests for missing queries:
* CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR
* CL_MUTABLE_DISPATCH_KERNEL_KHR
* CL_MUTABLE_DISPATCH_DIMENSIONS_KHR

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Minor code cleanup.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Introduce review changes.

Introduce changes requested in review:
- Remove bitwise chceck for CL_DEVICE_MUTABLE_DISPATCH_CAPABILITIES_KHR
- Add error check for clFinalizeCommandBufferKHR
- Add global_work_size to clCommandNDRangeKernelKHR for CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR
- Move BasicMutableCommandBufferTest to a separate header file
- Change name of file command_buffer_test_mutable_dispatch.cpp to mutable_command_info.cpp

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Set global_work_size on every use of clCommandNDRangeKernelKHR.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Apply changes for review.

- Add error check for init_extension_functions()
- Check mutable_capabilities for non-zero
- Replace clKernelWrapper with cl_kernel for CL_MUTABLE_DISPATCH_KERNEL_KHR test
- Replace clCommandBufferWrapper with cl_command_buffer_khr for CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR test
- Remove unneded test_command_buffer declarations
- Check type for CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR
- Remove retain() from operator= in clCommandBufferWrapper

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Apply changes for review.

Apply changes for review:
- Fix header guards
- Add copyright header
- Change checks for test_kernel, test_queue

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-03-21 09:12:34 -07:00
Paweł Jastrzębski
63b0f441f1
Add external semaphore tests. (#1645)
* Add external semaphore tests.

Added basic test to check the functionality of cl_ext_external_semaphore_test extension.
Tests rely on Vulkan API as the producer of the external semaphore functionality. The
Vulkan wrapper has been copied from the Vulkan CTS tests and minor changes have been
introduced. A separate copy of the Vulkan wrapper is for breaking any dependencies
between different CTS modules and thus make the build system simpler.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang-format

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Move vulkan wrapper to a separate library.

Vulkan wrapper is extracted as a separate module and can be used in different
CTS tests as a shared library.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Add cl_ext_external_samaphore tests based on cl_khr_semaphore tests.

Added cl_khr_semaphore adjusted to creating semaphores in Vulkan context
and importing them through export semaphore functionality in OpenCL
(cl_ext_external_samaphore).

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Cleanup.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix build issues.

* Add missing directories for build cl_ext_external_semaphore.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Set Vulkan lib directory.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Change extension directory name.

Changed extensions directory name from cl_ext_external_semaphore to cl_khr_external_semaphore.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Remove unneeded compile options.

Removed VK_USE_PLATFORM_WIN32_KHR option from cl_khr_external_semaphore
compilation arguments.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-03-21 09:06:15 -07:00
Sven van Haastregt
b7f2dd58e9
math_brute_force: Drop BuildKernelInfo2 (#1634)
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>
2023-03-20 09:44:25 +00:00
Kévin Petit
9755c7ac58
[NFC] Only assign gIsEmbedded in the test harness (#1672)
Signed-off-by: Kévin Petit <kpet@free.fr>
2023-03-16 12:15:51 +00:00
Kévin Petit
1f94b5748b
[NFC] Remove duplicate symbol declarations (#1671)
* [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>
2023-03-16 12:15:37 +00:00
Sven van Haastregt
9e0369b307
[NFC] Remove unused printMe variable (#1674)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-03-16 06:23:06 +00:00
Sven van Haastregt
9798a96a9f
[NFC] Fix some sign-compare warnings (#1670)
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>
2023-03-12 11:06:55 +00:00
paulfradgley
5297ecd673
Add compiler test external memory/semaphore extensions (#1662)
The OpenCL Headers have cl_khr_external_memory_dx, cl_khr_external_memory_dma_buf and cl_khr_external_semaphore_dx_fence as extension strings, but CTS Compiler fails if an implementation says that it supports them.
2023-03-07 09:54:15 -08:00
Paweł Jastrzębski
e882a3dc5e
Move semaphore tests from api to extensions (#1646)
* Move semaphore tests from api to extensions

Moved cl_khr_semaphore tests from core api tests to a separate
extension test as suggested in
https://github.com/KhronosGroup/OpenCL-CTS/issues/1588 .

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix clang-format

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Remove unneeded comment.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-03-07 09:00:16 -08:00
Marcin Hajder
0b44338eda
clSetKernelArg test cases for cl_khr_command_buffer extenstion (#1593)
* Initial commit for clSetKernelArg test case (issue #1369, p.1.7):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added simultaneous version of clSetKernelArg test, (#1369, p.1.7):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added/corrected comments (#1369, p.1.7)

* Corrected logic of conditions of command-buffer simultaneous use (#1369, p.1.7):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added missing comment for consistency with other command-buffer tests

* Cleanup related to code review (#1369, p.1.7):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added clang format correction

* Removed redundant code (issue #1369 clSetKernelArg)
2023-03-06 10:30:27 +00:00
Sven van Haastregt
712eb4f988
gl: Fix array size expression (#1610)
`sizes` is a pointer argument, so the expression does not compute the
presumably intended number of elements in `sizes`.

Fixes a `-Wsizeof-pointer-div` warning.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-03-03 13:29:29 +00:00
Marcin Hajder
33285facbe
Command buffer event sync (#1606)
* Added initial commit for event sync test cases (issue #1369, p.3.3)

* Added test cases for return event scenarios with and without out-of-order, work in progress (#1369, p.3.3)

* Added support for return event test cases for both regular and out-of-order command queue (#1369, p.3.3)

* Added user event test cases, cosmetic corrections (#1369, p.3.3)

* Added correction for windows build (#1369, p.3.3)

* Corrected proper testing of test fail/skip conditions (#1369, p.3.3)

* Added corrections related to PR review (#1369, p.3.3)

* Added correction related to change of order Skip/SetUp (issue #1369, event sync)

* Added clang format correction for previous commit

* Reordered initialization of attributes.
2023-03-03 08:20:46 +00:00
Sven van Haastregt
dc8ee495bd
[NFC] Fix -Wmissing-braces warnings (#1643)
The `cl_*` types need two levels of braces for initialization: the
outer braces for the union and the inner braces for the array.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-03-02 09:28:51 +00:00
victzhan
75db137822
Change order of print statement (#1631)
* Change order of print statement

* Made change for test_imagearraycopy3d.cpp as well

* Update test_imagearraycopy.cpp
2023-03-02 09:26:49 +00:00
Marcin Hajder
531e5e82f9
Out-of-order command-queue test cases for cl_khr_command_buffer (#1596)
* Initial commit for out-of-order test cases (#1369, p.2):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added support for simultaneous test of out-of-order command buffers and queues (#1369, p.2.1):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Cosmetic fixes (#1369, p.2):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Corrected two bugs related to simultaneous test (#1369, p.2.1):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added additional event to synchronize symultaneous passes, cosmetic fixes (#1369, p.2.1):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Cosmetic fix due to consistency concerns (#1369, p.2):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Fix for prev commit

* Added corrections related to changed order of Skip/SetUp methods (issue #1369, 2.0 out-of-order)

* Reverted formating of unrelated header

* Reverted formating of unrelated header, correction

* Reordered initialization of attributes.
2023-03-02 09:16:32 +00:00
Ben Ashbaugh
e71a7bce68
Revert "Image streams optimization (#1616)" (#1638)
This reverts commit b73c3149ad.
2023-02-28 09:06:34 -08:00
Nikhil Joshi
df3c4fae95
Enable test_vulkan by default in presubmit (#1655)
test_vulkan is disabled by default as part of
PR #1530.
Given the ongoing development to test_vulkan,
it is important to have this enabled in CI builds
to avoid breaking test builds.
Enable the test build as part of presubmit script.
2023-02-28 08:51:22 -08:00
Sven van Haastregt
2c9526f9a5
[NFC] Fix multi-line comment warnings (#1641)
Disabling of frem and fmod by b81b49e1 ("spirv: disable frem and fmod
tests for now (#1614)", 2023-02-07) introduced some new warnings about
multi-line `//` comments due to the trailing backslashes.  Fix these.

Also fix a typo.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-02-24 15:44:59 +00:00
Marcin Hajder
296a7a574d
Command buffer profiling (#1598)
* Added test cases for profiling command-buffers according to issue description #1369, p.3.2:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added cosmetic fixes (#1369, p.3.2)

* Corrected the path of initialization profiling event for simultaneous test (#1369, p.3.2):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* clang format fix

* Added correction related to macos build error (#1369, p.3.2)

* Applied corrections related to code review (#1369, p.3.2)

* Corrected query of queue properies (issue #1369, command buffer profiling)

* Reverted formating of unrelated header

* Added code review corrections for type consistency and fail condition (issue #1369, p.3.2)

* Reordered initialization of attributes.

* Reverted correct order of initialization.
2023-02-21 09:05:17 +00:00
Paweł Jastrzębski
fa2c1d2417
Add test for clGetEventInfo info queries. (#1647)
* Add test for clGetEventInfo info queries.

Test clGetEventInfo() info queries from event returned by command-buffer
enqueue for the single command-queue to command-buffer case:
* CL_EVENT_COMMAND_TYPE is CL_COMMAND_COMMAND_BUFFER_KHR
* CL_EVENT_COMMAND_QUEUE
* CL_EVENT_CONTEXT
* CL_EVENT_COMMAND_EXECUTION_STATUS
* CL_EVENT_REFERENCE_COUNT

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

* Fix return TEST_FAIL instead of -1.

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>

---------

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-02-20 16:19:11 +00:00
Sven van Haastregt
61ec521b1c
[NFC] Fix BasicCommandBufferTest initialization order (#1628)
The `command_buffer` member is initialized with `this`, and should
thus be initialized after all other members have been initialized, to
avoid any potential uninitialized data accesses by `command_buffer`'s
constructor.  This is currently not a problem, but would become a
problem when `command_buffer`'s constructor accesses the object
through its parameter.

Fixes a -Wreorder warning.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-02-20 11:39:18 +00:00
Paweł Jastrzębski
560d6eafbd
Added tests for 1.1 individual command entry-points. (#1594)
* Added tests for 1.1 individual command entry-points.

* Adding fixes pointed out in review: checks for CL_DEVICE_IMAGE_SUPPORT, remove redundant buffers, synchronisation issues, fixed clang-format, other minor issues.

* Fix compilation issues for Windows and macOS, fix clang-format.

* Fix compilation issue for Windows.

* Removed redundant blocking and event operations.

* Style fixes for test skip conditions.

* Fix clang format.

* Fixed function names, file names, comments and barrier test.

* Restored Individual command entry-points tests after merge with main.

* Fix clang format.

* Superficial fixes for review.
* Fix Skip() condition for barrier test
* Fix typos
* Fix new line

Signed-off-by: Paweł Jastrzębski <p.k.jastrzebski@gmail.com>
2023-02-20 08:36:34 +00:00
Karol Herbst
b81b49e10e
spirv: disable frem and fmod tests for now (#1614)
The OpenCL SPIR-V Environment Specification does not require the SPIR-V
opcodes `OpFMod` and `OpFRem` to match any OpenCL C semantics, so
implementations implementing those two instructions according to Vulkan
and/or OpenGL semantics will fail those tests without actually violating
any OpenCL specification.

We should keep those tests disabled until we figure out what the actual
precision requierement should be and update the test accordingly.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
2023-02-07 09:08:29 -08:00
Sven van Haastregt
1e5b5c96e2
math_brute_force: Remove unnecessary gotos (#1605)
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>
2023-02-07 09:01:07 -08:00
Paweł Jastrzębski
11782f7650
Fixed EnqueueAcquire and EnqueueRelease calls to be compliant with the spec. (#1629) 2023-02-07 08:58:48 -08:00
Chip Davis
b73c3149ad
Image streams optimization (#1616)
* 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.
2023-02-07 08:46:15 -08:00
Sven van Haastregt
f46cca0f8f
[NFC] clang-format gl (#1612)
Add some clang-format off/on comments to keep kernel code readable.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-02-06 15:09:04 +00:00
Sven van Haastregt
2318cedb21
select: Use MTdataHolder (#1609)
Simplify code by avoiding manual resource management.

This fixes use of an uninitialized `d` in the `free_mtdata` call, in
the case a `goto exit` was executed before initializing `d`.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-01-31 09:50:21 -08:00
Finlay
691a45d605
c11 atomic fence: relaxed requirements for an auxiliary atomic_store (#1603) 2023-01-31 09:47:47 -08:00
Stuart Brady
68fcb5904f
Avoid use of rand in test_rw_image_access_qualifier (#1322)
There is no particular reason to limit the domain of unsigned 32-bit
integers in the input, so use genrand_int32 directly.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2023-01-31 09:42:45 -08:00
Sven van Haastregt
2cc8e2e593
Fix -Woverloaded-virtual warnings (#1599)
Align `verify_data` with `checker_image_mem_host_read_only.hpp`, that
is, take an explicit pointer to compare against.

Add a missing (but unused) `float` parameter to
`KernelArgSampler::compare`.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-01-27 16:34:22 +00:00
Sven van Haastregt
9eec8f3352
Suppress -Wdeprecated-declarations for macOS (#1627)
Xcode 14 deprecated functions such as `sprintf` which is used in many
places.  As an immediate fix for the pre-commit checks, disable
deprecated function warnings when building for macOS.

Contributes to https://github.com/KhronosGroup/OpenCL-CTS/issues/1626

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2023-01-27 13:34:50 +00:00
Marcin Hajder
afdd8b0058
Command buffer queue substitution (#1584)
* Added queue substitution CTS test based on issue: https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added cosmetic correction to properties_queue_substitution test, work in progress:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added support for simultaneous queue substitution test (1.3.3), more cosmetic corrections added:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added initial rearrangement of source files due to more test cases to be implemented.

* Corrected test with queue properties out-of-order:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added alternative temporary path for simultenaous pass (USE_COMMAND_BUF_KENEL_ARG):

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* applied git clang-format "origin/main"

* Added corrections for out-of-order property scenario, couple cosmetic fixes:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Replaced cl_command_queue with clCommandQueueWrapper for additional command queue with properties:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Removed unnecessary flag, additional cleanup:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added narrowing correction due to windows build fail:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Test simiplified in order to use only substitute queue on both simultaneous buffers:

https://github.com/KhronosGroup/OpenCL-CTS/issues/1369

* Added limitation to use only CL_QUEUE_PROFILING_ENABLE property, replaced cl_command_queue with related wrapper (#1369, p.1.4)

* Corrections related to order of operations due to code review (issue #1369, p.1.3)

* Cosmetic fix for prev commit

* Cosmetic fix for prev commit #2
2023-01-24 09:44:16 -08:00
Steven Winston
ea49084976
Conversions (#1555)
* grab latest from upstream OpenCL

* Removed events for host to device data transfers

* grab latest from upstream OpenCL

* 1.) revert changes to CMakeLists.txt and run_batch script in hopes this will solve the CI issues for the PR.
2.) resolve the merge conflict in test_conversions.cpp

* 1.) resolve 2 additional merge conflicts

* 1.) resolve 1 additional merge conflicts

* locally this fails clang-format but CI version seems to require it.

* fix the warning.

* Remove now-unused event

Also, cut down a comment that is no longer accurate.

Co-authored-by: Joshua Luceno <joshualuceno@gmail.com>
Co-authored-by: Chip Davis <chip@holochip.com>
Co-authored-by: Chip Davis <cdavis5x@gmail.com>
2023-01-24 08:53:18 -08:00
Steven Winston
4759159a50
Enqueue fill buffer (#1561)
* 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>
2023-01-24 08:51:00 -08:00
Steven Winston
77e4fe5588
Half (#1554)
* Added on-device reset for half

* run clang-format.

* test_half - Reset buffer with ushort rather than half type

* Half - update type in secondary reset kernel src

* Remove useless memset() calls.

* Add an option to still perform buffer resets on the host

* Check for program generation failure before attempting to create the kernel

* Don't exceed the range of a ushort when storing

* Appease clang-format

Co-authored-by: Joshua Luceno <joshualuceno@gmail.com>
Co-authored-by: taetenp <taet@holochip.com>
Co-authored-by: Chip Davis <chip@holochip.com>
2023-01-24 08:48:53 -08:00
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)
Some checks failed
Presubmit / Build ubuntu-20.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-20.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-20.04 arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
* Added initial set of tests for the cl_khr_semaphore extension

* Fixes to address first round of reviews for cl_khr_semaphore tests
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)
Some checks failed
Presubmit / Build ubuntu-20.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-20.04 aarch64 debug (push) Failing after 1s
Presubmit / Build ubuntu-20.04 arm (push) Failing after 1s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
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.
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)
Some checks failed
Presubmit / Build ubuntu-20.04 gl (push) Failing after 2s
Presubmit / Build ubuntu-20.04 aarch64 debug (push) Failing after 0s
Presubmit / Build ubuntu-20.04 arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Presubmit / Build windows-latest (push) Has been cancelled
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>
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
Ben Ashbaugh
6659a1b6b8
remove implicit conversion to pointer to fix 32-bit compile (#1488)
* remove implicit conversion to pointer to fix 32-bit compile

* fix formatting
2022-10-04 09:02:25 -07:00
Nikhil Joshi
dbd33bc9cf
External sharing new updates (#1482)
* 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.
2022-10-04 09:00:03 -07:00
Sven van Haastregt
30cc3db4ec
atomics: Fix -Wformat warnings (#1519)
The main sources of warnings were:

 * Printing of `i` which is a `size_t` requiring the `%zu` specifier.

 * Printing of `cl_long` which is now done using the `PRId64` macro
   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-03 22:09:28 +01:00
Sven van Haastregt
18825769e5
pipes: Fix typos in skip messages (#1523)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-10-03 22:09:05 +01:00
Jack Frankland
28e76e532a
Add missing type declaration (#1520)
Add a missing type declaration to OpenCL C code strings in 2D async copy
tests.
2022-10-03 14:32:11 +01:00
victzhan
a3294d4c95
Add Python 3 support to run_conformance.py (#1470) 2022-10-03 14:26:43 +01:00
Sven van Haastregt
73f51ccff7
math_brute_force: Fix -Wformat warnings (#1518)
* 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>
2022-10-01 10:14:32 +01:00
Sven van Haastregt
c69f6eec47
[NFC] atomics: Remove set-but-unused "succeed" variables (#1517)
The "succeed" variables are never read and they don't seem to serve
any purpose that's not already provided by the "fail" variables.

In `add_index_bin_test` the "fail" variable is also set but unused,
but that may require an actual fix, so leaving that out of this
commit.

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

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-09-30 11:41:19 +01:00
Sven van Haastregt
9bf6486352
[NFC] clang-format test_atomics (#1516)
Add some clang-format off/on comments to keep lists and kernel code
readable.

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

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-09-27 09:32:23 -07:00
Sven van Haastregt
9b21e9f06b
[NFC] Avoid mixing signed and unsigned in subhelpers run (#1505)
Fix a `-Wsign-compare` warning in the `run()` function, which resulted
in many repeated warnings when compiling with `-Wall` due to the many
template instantiations.

Both `clGetKernelSubGroupInfo` queries return a `size_t`, so it is
unclear why the results of these queries were being cast to `int`.
The `dynsc` uses don't seem to work with negative values, so make the
field unsigned.

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

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-09-27 09:29:58 -07:00
Sreelakshmi Haridas Maruthur
30500fba06
SVM: Fix memory allocation size. (#1514)
* SVM: Fix memory allocation size.

9ad48998 generally made memory allocation and mapping consistent with a
size of size_t. Apply that fix to the final two allocations.

* check-format fixes

Co-authored-by: spauls <spauls@qti.qualcomm.com>
2022-09-27 09:28:57 -07:00
ellnor01
c014122742
Creating common functions for image/kernel_read_write read tests (#1141)
* Make InitFloatCoords suitable for all image types

Contributes #616

* Create common functions neutral for image types

Remove 3D specific code from common test_read_image so using
it for other image types is simpler in following patches

Contributes #616

* Removing unused code

Tidying commented out or unnecessary code

Contributes #616

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>

* Restoring 'lod' variable name

Contributes #616

* Default cases to handle unsupported image types

Contributes #616

* Resolving build issues

Contributes #616

* Fix formatting

Contributes #616

* Using TEST_FAIL as an error code.

Contributes #616

* Add static keyword, improve error handling

Contributes #616

* Fix build errors with least disruption

Contributes #616

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
2022-09-26 12:57:42 +01:00
Sven van Haastregt
2012c6cadd [NFC] Fix typo in clang-format directive (#1512)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-09-23 10:08:10 -07:00
Krzysztof Kosiński
180adef84c
Remove __DATE__ and __TIME__ usage (#1506)
These macros make the build non-deterministic.
2022-09-23 17:29:18 +01:00
Sven van Haastregt
92285f7c9d
cmake: Add set_gnulike_module_compile_flags (#1510)
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>
2022-09-22 13:17:55 -07:00
Nikhil Joshi
86d5ee5414
Update extension list of test_compiler (#1507)
* Update extension list of test_compiler

Upate extension list of test_compiler
with missing external memory and semaphore
extensions
2022-09-20 09:07:14 -07:00
Sven van Haastregt
75edf2a881
[NFC] Enable -Wall for math_brute_force (#1477)
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>
2022-09-20 08:55:51 -07:00
niranjanjoshi121
76bd9d3674
Fix memory oob problem in test half (#1489)
Allocate memory for argc arguments
instead of argc - 1.
2022-09-20 08:53:34 -07:00
Sven van Haastregt
8f9c1960ff
Improve MTdataHolder design and use it in math_brute_force (#1490)
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>
2022-09-20 08:52:22 -07:00
Sven van Haastregt
a87e686757
Fix more warnings in math_brute_force (#1502)
* 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>
2022-09-16 13:34:36 +01:00
Stuart Brady
7859a33182
Include release builds in GitHub Actions (#1486)
The "Ninja" CMake generator does not support multiple configurations,
i.e. it does not support use of the '--config' option when running
'cmake --build'.  As such, the default configuration (i.e. Debug)
was getting used for all builds.

Use the CMAKE_BUILD_TYPE variable instead, so that we do release
builds, but change one build (ubuntu-20.04 aarch64) to use Debug
as its build type, to keep some build coverage for asserts, etc.

For Vulkan-Loader and OpenCL-ICD-Loader, we do release builds
unconditionally, as we assume there is no need in the CI workflow
to actually run the binaries that are built, and therefore no need
for any additional debug info.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-09-13 18:22:52 +01:00
Kévin Petit
c0a10f4e12
Tests for cl-ext-image-from-buffer and cl-ext-image-requirements-info (#1438)
* Add CTS tests for cl_ext_image_requirements_info

Change-Id: I20c1c77ff5ba88eb475801bafba30ef9caf82601

* Add CTS tests for cl_ext_image_from_buffer

Change-Id: Ic30429d77a1317d0fea7d9ecc6d603267fa6602f

* Fixes for image_from_buffer and image_requirements extension

* Use CL_MEM_READ_WRITE flag when creating images that support CL_MEM_KERNEL_READ_AND_WRITE (#1447)

* format fixes

Change-Id: I04d69720730440cb61e64fed2cb5065b2ff8bf90

Co-authored-by: Oualid Khelifi <oualid.khelifi@arm.com>
Co-authored-by: oramirez <oramirez@qti.qualcomm.com>
Co-authored-by: Sreelakshmi Haridas Maruthur <sharidas@quicinc.com>
2022-09-13 09:58:24 -07:00
Sreelakshmi Haridas Maruthur
426097cf7c
gles: Limit variable definition to the same scope as usage (#1495)
Fix unused-variable errors by limiting variable definition to the
case that would use it
2022-09-13 09:50:25 -07:00
Stuart Brady
d42b3dcfb6
[NFC] Fix typo (enevt_type -> event_type) (#1498)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-09-13 17:49:09 +01:00
Sven van Haastregt
5d5bffba13
[NFC] Declare format tables as const (#1493)
Without const, these variables would be flagged up by
`-Wunused-variable`.

Drop `struct` from the declarations as that is not needed in C++.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-09-13 14:48:54 +01:00
Stuart Brady
1d74c85ff3
[NFC] Reformat code in events test (#1497)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-09-13 13:42:32 +01:00
niranjanjoshi121
d928ac059c
Use correct size for memory allocation in SVM test (#1496)
Memory is allocated for cl_int, but mapped as size_t.

Use size_t instead of cl_int during allocation and mapping for consistency.
2022-09-12 12:42:06 +01:00
Stuart Brady
00f21739e5
Minor cleanups for run_conformance.py (#1492)
Use the print function from futures for Python 3 compatibility,
remove an unreachable statement, remove unused imports, and add
a missing sys.exit call when opening the log file fails.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-09-12 11:49:13 +01:00
Sven van Haastregt
89c8d87963
[NFC] Fix unused variable warning in Release builds (#1494)
The condition inside the assert is dropped in Release builds, so
`num_printed` becomes unused.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-09-09 17:58:31 +01:00
Sven van Haastregt
6554c49018
[NFCI] Remove unused variables and enable -Wunused-variable (#1483)
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>
2022-09-08 12:54:36 +01:00
Stuart Brady
fec9d9a238
[NFC] Fix whitespace issues in run_conformance.py (#1491)
Fix whitespace issues and remove superfluous parens in the
run_conformance.py script.  This addresses 288 out of the 415
issues reported by pylint.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-09-07 17:28:29 +01:00
Ahmed
388944c01c
Minimum 2 non atomic variables per thread for the c11 atomic fence test for embedded profile devices. (#1452)
* Minimum 2 Non atomic variables per thread for an embedded profile device - https://github.com/KhronosGroup/OpenCL-CTS/issues/1274

* Formatting
2022-09-06 09:53:12 -07:00
Ewan Crawford
7caa4c4421
Update known extensions in compiler define test (#1480)
Add
[cl_khr_command_buffer_mutable_dispatch](https://github.com/KhronosGroup/OpenCL-Docs/pull/819),
[cl_khr_subgroup_rotate](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_subgroup_rotate),
and [cl_khr_extended_async_copies](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_extended_async_copies)
to the list of known extensions used in
`test_compiler_defines_for_extensions`
2022-09-01 15:13:01 -07:00
niranjanjoshi121
9ad4899862
Use size_t instead of cl_int (#1414)
* Use size_t instead of cl_int

Memory is allocated for cl_int,
but mapped as size_t.
Use size_t instead of cl_int during
allocation and mapping for consistency.

* Use size_t instead of cl_int

Memory is allocated for cl_int,
but mapped as size_t.
Use size_t instead of cl_int during
allocation and mapping for consistency.

* Use size_t instead of cl_int

Memory is allocated for cl_int,
but mapped as size_t.
Use size_t instead of cl_int during
allocation and mapping for consistency.

* Remove test_half changes.

Remove test_half changes from other fix
that got included in this commit.

* Final formatting fix.
2022-08-31 22:58:13 -07:00
Romaric Jodin
2dc2533130
fix test kernel attributes when api fcts are failing (#1449)
test_error returns the err given as the first argument. As the
run_test function returns a bool, we end up returning true (meaning
pass) when an api function fails.
Instead return explicitly false (meaning fail).
2022-08-31 22:56:10 -07:00
Sven van Haastregt
f94c135755
Use clMemWrapper in math_brute_force (#1476)
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>
2022-08-31 22:43:43 -07:00
Ewan Crawford
8f5a2f0ae8
Initial command-buffer extension tests (#1368)
* Initial command-buffer tests

Introduce some basic testing of the
[cl_khr_command_buffer](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_command_buffer)
extension. This is intended as a starting point from which we can iteratively build up tests
for the extension collaboratively.

* Move tests into derived classes

* Move tests from methods into derived classes implementing
  a `Run()` interface.
* Fix memory leak when command_buffer isn't freed when a test
  is skipped.
* Print correct error code for
  `CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR`
* Pass `nullptr` for queue parameter to command recording entry-points

* Define command-buffer type wrapper

Other OpenCL object have a wrapper to reference count their use
and free the wrapped object. The command-buffer object can't use
the generic type wrappers which are templated on the appropriate
release/retain function, as the release/retain functions are
queried at runtime.

Instead, define our own command-buffer wrapper class where a base
object is passed on construction which contains function pointers
to the release/retain functions that can be used in the wrapper.

* Use create_single_kernel_helper_create_program

Use `create_single_kernel_helper_create_program` rather than
hardcoding `clCreateProgramWithSource` to allow for other types
of program input.

Also fix bug using wrong enum for passing properties on command-buffer
creation, should be `CL_COMMAND_BUFFER_FLAGS_KHR`

* Add out-of-order command-buffer test

Introduce a basic test for checking sync-point use
with out-of-order command-buffers.

This also includes better checking of required queue properties.
2022-08-30 09:54:50 -07:00
stoneforestwhu
f4eb852b6d
support format CL_ABGR (#1474)
* support format CL_ABGR

add code to handle format CL_ABGR

* Update imageHelpers.h

* fix format
2022-08-30 09:47:15 -07:00
Sven van Haastregt
afe4ef8b8f
Fix test skipping in math_brute_force (#1475)
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>
2022-08-24 12:05:01 +01:00
Sven van Haastregt
c82dabd4bb
Use clCommandQueueWrapper in math_brute_force (#1463)
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>
2022-08-24 10:31:32 +01:00
Sven van Haastregt
9666ca3c70
[NFC] Fix sign-compare warnings in math_brute_force (#1467)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-08-23 18:02:33 +01:00
Sven van Haastregt
e52a97e4e9
[NFC] Use Unix-style line endings (#1468)
Use the same line ending style across all source files.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-08-23 17:57:05 +01:00
Sven van Haastregt
d647529fec
[NFC] Fix missing double_double.lo initializer (#1466)
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>
2022-08-16 14:42:33 +01:00
Sven van Haastregt
38639f229d
Fix test_select verification failure reporting (#1462)
When verification of the computed result fails, the test would still
report as "passed".  This is because `s_test_fail` is only written to
and never read.

Fix the immediate issue by returning a failure value and incrementing
`gFailCount` if any error was detected.  The error handling can be
improved further, but I'm leaving that out of the scope of this fix.

Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1445

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-08-04 15:05:10 +01:00
Stuart Brady
4ee8022230
Remove unused variables in subgroup tests (#1460)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-08-04 15:04:14 +01:00
Sven van Haastregt
c12bff46c6
Tidy up BuildKernelInfo (#1461)
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>
2022-08-04 15:03:52 +01:00
Matthias Diener
c44b5b6ae3
Fix indentation of test_waitlists.cpp (#1459)
* fix indentation of test_waitlists.cpp

Followup of #1458

* run formatter
2022-08-02 20:31:24 +01:00
Stuart Brady
cdf5a105fc
Fix misleading indentation and enable -Wmisleading-indentation (#1458)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-08-02 18:16:03 +01:00
Kévin Petit
bd03e17a56
Add missing external memory/sync extensions to list of known khr extensions (#1455)
Signed-off-by: Kévin Petit <kpet@free.fr>
2022-08-01 10:18:53 +01:00
Stuart Brady
017f514c21
Tidy up subgroup log messages (#1454)
Add missing newlines and improve wording of messages.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-08-01 10:18:36 +01:00
Sven van Haastregt
b06ccc6cd9
Share BuildKernelInfo struct definition (#1453)
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>
2022-07-29 18:22:18 +01:00
Sven van Haastregt
0a5a8f90c9
Use clProgramWrapper in math_brute_force (#1451)
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>
2022-07-28 13:33:16 +01:00
Sven van Haastregt
2cf24e63b7
Fix function name in error messages (#1450)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
2022-07-21 18:54:20 +01:00
Callum Fare
a37884fe44
Update cl_khr_extended_async_copies tests to the latest extension version (#1426)
* Update cl_khr_extended_async_copies tests to the latest version of the extension

Update the 2D and 3D extended async copies tests. Previously they were based on
an older provisional version of the extension.

Also update the variable names to only use 'stride' to refer to the actual
stride values. Previously the tests used 'stride' to refer to the end of one
line or plane and the start of the next. This is not the commonly understood
meaning.

* Address cl_khr_extended_async_copies PR feedback

* Remove unnecessary parenthesis in kernel code
* Make variables `const` and rearrange so that we can reuse
  variables, rather than repeating expressions.
* Add in missing vector size of 3 for 2D tests

* Use C++ String literals for kernel code

Rather than C strings use C++11 string literals to define the
kernel code in the extended async-copy tests. Doing this makes
the kernel code more readable.

Co-authored-by: Ewan Crawford <ewan@codeplay.com>
2022-07-19 17:43:36 +01:00
Nikhil Joshi
8d9d1f3e9d
Fix math tests to allow ftz in relaxed mode. (#1371)
* 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
2022-07-05 22:28:18 +05:30
Sven van Haastregt
e3e1786761
Fix newline in sample_image_pixel_float_offset log (#1446) 2022-07-01 15:38:42 +01:00
Stuart Brady
1c19a4cbdb
Add tests for cl_khr_subgroup_rotate (#1439)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-06-28 17:05:11 +01:00
Nikhil Joshi
0b7118186a
Initial CTS for external semaphore and memory extensions (#1390)
* 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.

* Update Copyright Year.

Update Copyright Year to 2022
for external memory sharing tests.

* Android specific fixes

Android specific fixes to
external sharing tests.
2022-06-21 21:51:47 +05:30
Wenju He
67ac6c8d2d
Fix test_half async_work_group_copy arguments (#1298) (#1299)
Workitems in the last workgroup calls async_work_group_copy with
different argument values depending on 'adjust'. According to spec,
this results in undefined values.
2022-06-14 08:51:39 -07:00
Ahmed
f1c051afb1
Added missing tests for integer_dot_product_input_4x8bit and integer_dot_product_input_4x8bit_packed on feature_macro compiler test. (#1432)
* Added integer_dot_product_input_4x8bit and integer_dot_product_input_4x8bit_packed tests to feature_macro_test

* clang formatting

* Now the test checks whether the array of optional features returned by clGetDeviceInfo contains the standard optional features we are testing.

* Update test_conformance/compiler/test_feature_macro.cpp

Added printing the missing standard feature it it is not found inside the optional features array returned by clGetDeviceInfo.

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
2022-06-14 08:48:59 -07:00
paulfradgley
c2aca7d8e6
Fix local memory out of bounds issue in atomic_fence (replaces PR #1285) (#1437)
* Fix local memory out of bounds in atomic_fence

In the error condition, the atomic_fence kernel can illegally access local memory addresses.

In this snippet, localValues is in the local address space and provided as a kernel argument. Its size is effectively get_local_size(0) * sizeof(int). The stores to localValues lead to OoB accesses.

  size_t myId = get_local_id(0);

  ...

  if(hisAtomicValue != hisValue)
  { // fail
    atomic_store(&destMemory[myId], myValue-1);
    hisId = (hisId+get_local_size(0)-1)%get_local_size(0);
    if(myValue+1 < 1)
      localValues[myId*1+myValue+1] = hisId;
    if(myValue+2 < 1)
      localValues[myId*1+myValue+2] = hisAtomicValue;
    if(myValue+3 < 1)
      localValues[myId*1+myValue+3] = hisValue;
  }

* Fix formatting

* Fix formatting again

* Formatting
2022-06-14 08:47:06 -07:00
jansol
7c65afc4e7
test_compiler_defines_for_extensions: fix overflow (#1430)
GCC 11.2.0 warns about a possible string overflow (when
num_not_supported_extensions+num_of_supported_extensions == 0)
since no space would be allocated for the terminating
null byte that string manipulation fns expect to find.

This unconditionally adds an extra byte to the allocation to silence
the warning and fix building with -Werror.
2022-06-07 08:55:43 -07:00
paulfradgley
3bf46004ef
Fixes incorrect slice pitch calculation in clCopyImage 1Darray (#1258)
The slice pitch/padding calculation assumed that the 'height' variable contained the pixel height of the image, which it doesn't for IMAGE1D_ARRAY.
Fixes #1257
2022-05-31 08:55:42 -07:00
Ewan Crawford
f32f1aeaa2
Add content to README (#1427)
Fill in the placeholder readme with some basic information on building and
running the project. Information on the conformance submission process and
contributing are also included.

Should help close a few issues referenced in
https://github.com/KhronosGroup/OpenCL-CTS/issues/1096

I don't think this is all the information we want, but is a starting point
from which we can progress. For example, adding the android build instructions
from https://github.com/KhronosGroup/OpenCL-CTS/pull/1021
2022-05-17 08:54:39 -07:00
Jeremy Kemp
d54954c7cf
Enable mipmap extension pragmas (#1349)
* Enable mipmap pragmas where appopriate.

* clang-format changes.
2022-05-17 08:52:40 -07:00
Jason Ekstrand
6e6249fb48
images: Stop checking gDeviceType != CL_DEVICE_TYPE_GPU (#1418)
* images: Stop checking gDeviceType != CL_DEVICE_TYPE_GPU

If the device type also advertises CL_DEVICE_TYPE_DEFAULT (which should
be valid), this causes it to be considered a CPU device and the tests
enforce different precision and rounding expectations.

* Fix clang-format

* Drop redundant NORM_OFFSET checks
2022-05-17 08:51:53 -07:00
Karol Herbst
5149de2277
api/kernel_arg_info: Check for read_write image support before testing it (#1420)
Code taken from api/test_min_image_formats.cpp
2022-05-17 08:51:10 -07:00
Kévin Petit
3662d17447
Update Github Actions CI and add Windows (#1413)
- Add one Windows build to Github Actions
- Remove Appveyor config
- Move a few build steps out of the script
- Use Ninja as the generator (makes for more readable logs)
- Add build cache (except on Windows where it seems to break)

Change-Id: Ida90ee1842af98aff86e5144ab7b9766480378c9
Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2022-04-29 10:42:27 -07:00
Jeremy Kemp
5d6ca3e9d1
Change memory order and scope for atomics that gate final results being stored. (#1377)
* Change memory order and scope for atomics that gate final results being stored.

memory_order_acq_rel with memory_scope_device is now used to guarantee that the correct memory consistency is observed before final results are stored.

Previously it was possible for kernels to be generated that all used relaxed memory ordering, which could lead to false-positive failures.

Fixes #1370

* Disable atomics tests with global, in-program atomics.

If the device does not support `memory_order_relaxed` or `memory_scope_device`, disable atomics tests that declare their atomics in-program with global memory.

There is now an implicit requirement to support `memory_order_relaxed` and `memory_scope_device` for these tests.

* Fix misplaced parentheses.

* Change memory scope for atomic fetch and load calls in kernel

Change the memory scope from memory_scope_work_group to
memory_scope_device so the ordering applies across all work items

Co-authored-by: Sreelakshmi Haridas <sharidas@quicinc.com>
2022-04-28 15:34:08 -07:00
Romaric Jodin
35c21a8e06
imageHelpers: add CL_UNORM_SHORT_{555, 565} in get_max_absolute_error (#1406)
* imageHelpers: add CL_UNORM_SHORT_{555, 565} in get_max_absolute_error

Working on a device supporting CL_UNORM_SHORT_565 image data type, I
noticed that the max absolute error authorized was not the right one
for such image data type.

Also because of normalization, there is always an absolute error
authorized whatever the filtering of the sampler.

Ref #1140

* put back if statement on filter_mode
2022-04-28 14:46:52 -07:00
Jason Ekstrand
13d1b01f65
test_basic/enqueue_map: Initialize all the data (#1417)
Some checks failed
Presubmit / Build ubuntu-20.04 (push) Failing after 5m3s
Presubmit / Build ubuntu-20.04 AArch64 (push) Failing after 3s
Presubmit / Build ubuntu-20.04 Arm (push) Failing after 3s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
2022-04-22 10:51:32 +01:00
Jim Lewis
03da14d6a9
Fix clang 10 build errors (#1387)
* Fix clang 10 build errors

Lossy casts due to inexact float representation of CL_INT_MAX

* Fix clang format

* Remove implicit-const-int-float-conversion flag
2022-04-19 09:57:15 -07:00
Grzegorz Wawiorko
d533472c27
Fix incorrect use image channel data type and filtering mode (#1375) 2022-04-19 17:55:03 +01:00
Stuart Brady
7a0e7e767a
Test all cluster sizes for cl_khr_subgroup_clustered_reduce (#1408)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-04-12 09:42:55 -07:00
Ben Ashbaugh
2fcdde96d2
refactor work group scan and reduction tests (#1401)
* updated reduce test

* switched all reduce tests to new framework

* switch over scans to new framework

* remove old files

* minor fixes

* add type type name to the kernel name

* fix Windows build and warnings

* address review comments
2022-04-04 13:19:30 -07:00
Stuart Brady
e121b9d1bf
Fix sub_group_ballot_find_msb/lsb tests (#1411)
As per the OpenCL Extension Specification § 38.6 Ballots:

   If no bits representing predicate values from all work items in
   the subgroup are set in the bitfield value then the return value
   is undefined.

The case with no bits set is still worth testing, as it does not result
in undefined behavior, but only an undefined return value.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-04-04 09:57:36 -07:00
Jason Tang
93f4f6a548
test_api_min_max.cpp: use size_t for get_global_id() value (#1410)
In some rare cases where get_global_id() is larger than 2G, the 32bit int type would convert the value into a negative integer.
2022-03-29 16:08:08 -07:00
Stuart Brady
c42cf518da
Improve cl_khr_subgroup_shuffle* test coverage (#1402)
Test cases where the index/mask/delta is greater than or equal to the
maximum subgroup size.  These are cases that return undefined results
but are not undefined behavior.

The index/mask/delta values now include values less than twice the
subgroup size, and 0xffffffff.

Testing for sub_group_shuffle_xor() already allowed inputs that were
greater or equal to the subgroup size for the last subgroup in a
workgroup, but did not properly account for this in the verification
function, potentially resulting in out of bounds accesses.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-03-29 11:39:06 -07:00
Stuart Brady
f6dbc5b9b5
Add cluster size handling in subgroup test helpers (#1394)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-03-22 09:21:09 -07:00
Sreelakshmi Haridas Maruthur
0f4dc3166c
conversions: Use volatile qualifier to prevent optimizations (#1399)
Use volatile to prevent clang optimizations, fix int2float
2022-03-17 13:27:24 -07:00
Ben Ashbaugh
bbc7ccfc58
add a prefix to OpenCL extension names (#1311)
* add a prefix to OpenCL extension names

* fix formatting
2022-03-02 18:34:06 +00:00
Jim Lewis
3c4a1a3ce6
Fix build error for linux with clang-8 (#1304)
-Wabsolute-value warning reported as error (long double truncated to
double)
2022-03-02 18:31:14 +00:00
Jack Frankland
ae217e8bd2
Check for non-uniform work-group support (#1383)
Only run sub-group tests with non-uniform work-groups on OpenCL 3.0 and
later if it is supported by the device.
2022-03-02 18:30:31 +00:00
Jeremy Kemp
e437acd908
Added simple test for CL_DEVICE_PRINTF_BUFFER_SIZE. (#1386)
* Added simple test for CL_DEVICE_PRINTF_BUFFER_SIZE.

* Clang format fix.
2022-03-02 18:28:12 +00:00
Alastair Murray
d36196b662
Update format script and drop Travis badge for branch rename (#1393)
`master` is now `main`, so update `check-format.sh` accordingly.

Also completely drop the Travis badge as we now use GitHub actions.  There is
no replacement badge as the current action is pre-submission, not
post-submission.
2022-03-02 18:27:52 +00:00
Stuart Brady
279803abab
Refactor kernel execution in subgroup tests (#1391)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-03-02 13:25:53 +00:00
Jim Lewis
2d93b122c3
Sync submission_details with conformance doc v26 (#1389)
Some checks failed
Presubmit / Build ubuntu-20.04 (push) Failing after 5m2s
Presubmit / Build ubuntu-20.04 AArch64 (push) Failing after 3s
Presubmit / Build ubuntu-20.04 Arm (push) Failing after 3s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
Add "Patches" field
2022-02-22 16:49:35 +00:00
Stuart Brady
6b14d408dc
Improve testing of kernel arg info in pipe_info test (#1326)
The test now checks that CL_KERNEL_ARG_INFO_NOT_AVAILABLE is returned
when calling clGetKernelArgInfo() with offline compilation modes.

The correct function name is printed if clGetKernelArgInfo() fails
when using online compilation (and not "clSetKernelArgInfo()").

When using online compilation, if the actual arg type is not as
expected, the actual arg type is now logged, and the return value
is now TEST_FAIL (-1) as per other failures (and not 1).

All other test pass/fail values used in the test now use TEST_PASS
and TEST_FAIL instead of 0 and -1 literals.

An unnecessary cast of pipe_kernel_code has been removed.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-02-09 22:24:33 -08:00
Stuart Brady
60471a5208
Improve testing of sub_group_ballot (#1382)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-01-28 09:15:44 +00:00
Stuart Brady
656886030b
Refactor divergence mask handling in subgroup tests (#1379)
This changes compilation of subgroup test kernels so that a separate
compilation is no longer performed for each divergence mask value.

The divergence mask is now passed as a kernel argument.

This also fixes all subgroup_functions_non_uniform_arithmetic testing
and the sub_group_elect and sub_group_any/all_equal subtests of the
subgroup_functions_non_uniform_vote test to use the correct order of
vector components for GPUs with a subgroup size greater than 64.

The conversion of divergence mask bitsets to uint4 vectors has been
corrected to match code comments in WorkGroupParams::load_masks()
in test_conformance/subgroups/subhelpers.h.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2022-01-19 14:17:54 +00:00
Sreelakshmi Haridas Maruthur
06415f8b79
Fix memory leaks (#1378)
* Fix memory leaks

Fixed memory leaks in: buffers, basic, and vectors

* Formatting fixes

Co-authored-by: oramirez <oramirez@qti.qualcomm.com>
2022-01-11 16:52:11 +00:00
Jim Lewis
51c6d97d2f
Fix test_api get_command_queue_info (#1324)
* Fix test_api get_command_queue_info

Decouple host and device out-of-order test enabling

* Rename property sets more generically

* Refactor to use std::vector to accumulate test permutations
2022-01-06 10:26:20 +00:00
Jim Lewis
f91daf3d06
Remove invalid negative_get_platform_info testcase (#1374)
* Remove invalid negative_get_platform_info testcase

* Implementations are only required to do null checks
* Fixes #1318

* Fix formatting
2022-01-06 10:23:07 +00:00
Grzegorz Wawiorko
b71c204794
test_subgroups - Set safe input values for half type and mul, add operations (#1346)
* Set safe input values for half type and mul, add operations

* Set safe values for all data types

* Typo fix

* Set constant seed for shuffle

* Change function name to more specific

* set_value takes an integer value, not a bit pattern
2022-01-05 08:08:52 -08:00
Sreelakshmi Haridas Maruthur
c2facedfa0
Remove dead threading code (#1339)
Remove unused code that hasn't been used for the last three years
and isn't included in makefiles.

Co-authored-by: oramirez <oramirez@qti.qualcomm.com>
2022-01-05 07:43:50 -08:00
Stuart Brady
1161d788dd
Refactor logging of subgroup test start/pass messages (#1361)
Note that this also corrects the start messages logged for the
sub_group_ballot_bit_count/find_msb/find_lsb tests.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-12-14 17:52:44 +00:00
Ewan Crawford
73d71b6a76
Add cl_khr_command_buffer to list of extensions (#1365)
cl_khr_command_buffer is now public as a provisional khr extension
which implementations may report.
2021-12-08 16:08:15 +00:00
Grzegorz Wawiorko
8ffecf27c2
Fix build, glext should not be used with GLEW (#1337)
* Fix build, glext should not be used with GLEW

* Remove additional define GL_GLEXT_PROTOTYPES

* Remove includes which already defined in setup.h
2021-12-08 16:07:42 +00:00
Grzegorz Wawiorko
e106be14f9
Test api min max - fix printing cl_ulong data type (#1212)
* test api - fix code formatting only

* Fix printing cl_ulong type to avoid overloading.

* Fix printing size_t data type

* Fix printing size_t data type - set unsinged

* Fix formatting for maxArgs (uint) and numberOfInts (size_t)
2021-12-04 09:55:17 -08:00
Stuart Brady
f8ec235d3c
Tidy up code to determine bit mask for ballot scans (#1363)
It seems more intuitive to set only the bits that are required, rather
than to set one more bit than is required, only to clear it again.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-12-02 15:27:30 +00:00
Stuart Brady
7625011b66
Remove unused inclusion of <cstdio> (#1362)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-11-26 15:30:23 +00:00
Grzegorz Wawiorko
6f50623ba8
Subgroups tests - sub_group_non_uniform_scan_exclusive function fixes (#1350)
* Fix - comparing results will never happen.

* No special action needed for one work item in the subgroup
2021-11-25 13:41:06 +00:00
BKoscielak
6dff4fdffa
Fix conversion data loss in test_api min_max_constant_args (#1355) 2021-11-25 13:40:19 +00:00
Stuart Brady
3eb0f50d85
Use maximum subgroup size in sub_group_ballot tests (#1344)
sub_group_ballot_bit_count() and sub_group_ballot_find_msb() mask
their input according to a subgroup size, which is assumed to be the
maximum subgroup size, and not the actual subgroup size excluding
non-existent work-items in the "remainder" subgroup.

Fix this as per the the clarification made to the OpenCL C specification
in revision 3.0.9 for issue KhronosGroup/OpenCL-Docs#626 by pull request
KhronosGroup/OpenCL-Docs#689.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-11-25 13:36:20 +00:00
James Price
c25709f396
Fix stack-use-after-scope crash in conversions (#1358)
The way that program sources were being constructed involved capturing
pointers to strings that were allocated on the stack, and then trying
to use them outside of that scope. This change uses a stringstream
defined in the outer scope to build the program instead.
2021-11-23 19:04:02 +00:00
marcat03
3cd906aa9b
Fix missing cl_khr_semaphore extensions in compiler tests (#1357)
* Added missing extensions related to cl_khr_semaphore

Signed-off-by: Marco Cattani <marco.cattani@arm.com>
2021-11-16 16:07:43 +00:00
Stuart Brady
1c6dbc23e7
Clean up logging in cl_khr_subgroup_ballot tests (#1351)
The tests were logging scalar results as vectors padded with zeroes for
no apparent benefit.  Fix this.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-11-16 14:03:06 +00:00
Stuart Brady
1116a71ba2
Improve error handling in subgroup tests (#1352)
* MPGCOMP-14761 Improve error handling in subgroup tests

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

* Add missing newline
2021-11-16 11:27:04 +00:00
Stuart Brady
e9cd9a446e
Remove excessive logging in subgroup tests (#1343)
This also adds some missing data type logging to the
subgroup_functions_non_uniform_vote tests.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-11-08 11:00:50 +00:00
Stuart Brady
410f46f49f
Add testing of sub_group_broadcast for (u)char and (u)short types (#1347)
Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-11-03 16:36:36 +00:00
Grzegorz Wawiorko
7147d072c7
Remove space character from extension name (#1336)
Some checks failed
Presubmit / Build ubuntu-20.04 (push) Failing after 5m4s
Presubmit / Build ubuntu-20.04 AArch64 (push) Failing after 3s
Presubmit / Build ubuntu-20.04 Arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
2021-10-04 14:42:44 +01:00
Grzegorz Wawiorko
92844bead1
Extended subgroups - use 128bit masks (#1215)
* Extended subgroups - use 128bit masks

* Refactoring to avoid kernels code duplication

* unification kernel names as test_ prefix +subgroups function name
* use string literals that improve readability
* use kernel templates that limit code duplication
* WorkGroupParams allows define default kernel - kernel template for multiple functions
* WorkGroupParams allows define  kernel for specific one subgroup function

Co-authored-by: Stuart Brady <stuart.brady@arm.com>
2021-10-01 11:28:37 +01:00
Kévin Petit
903f1bf65d
Report unsupported extended subgroup tests as skipped rather than passed (#1301)
* Report unsupported extended subgroup tests as skipped rather than passed

Also don't check the presence of extensions for each sub-test.

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

* address review comments
2021-09-30 13:33:18 +01:00
Kévin Petit
2b770c4f34
Update cl_khr_integer_dot_product tests for v2 (#1317)
* Update cl_khr_integer_dot_product tests for v2

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
Signed-off-by: Marco Cattani <marco.cattani@arm.com>
Change-Id: I97dbd820f1f32f6b377e47d0bf638f36bb91930a

* only query acceleration properties with v2+

Change-Id: I3f13a0cba7f1f686365b10adf81690e089cd3d74
2021-09-29 12:38:42 +01:00
Sreelakshmi Haridas Maruthur
4fb5deeec1
api: Enable cl_khr_fp16 when using half types in kernel (#1327) 2021-09-28 10:19:40 -07:00
Sreelakshmi Haridas Maruthur
ddca0f802b
gles: Fix double frees. (#1323)
* gles: Fix double frees.

Remove a few explicit frees in the redirect_buffers test which are
already handled by a wrapper.

* gles: Fix double frees

A recent update to the object wrapper classes (#1268) changed the
behavior of assigning to a wrapper, whereby the wrapped object is now
released upon assignment. A couple of tests were manually calling
clReleaseMemObject and then assigning `nullptr` to the wrapper,
resulting in the wrapper calling clReleaseMemObject on an object that
had already been destroyed.

Co-authored-by: spauls <spauls@qti.qualcomm.com>
2021-09-28 10:19:17 -07:00
Ben Ashbaugh
02bf24d2b1
remove min max macros (#1310)
* remove the MIN and MAX macros and use the std versions instead

* fix formatting

* fix Arm build

* remove additional MIN and MAX macros from compat.h
2021-09-13 13:25:32 +01:00
Jeremy Kemp
1f26e1d8ba
Fix memory model issue in atomic_flag. (#1283)
* Fix memory model issue in atomic_flag.

In atomic_flag sub-tests that modify local memory, compilers may re-order memory accesses between the local and global address spaces which can lead to incorrect test failures.

This commit ensures that both local and global memory operations are fenced to prevent this re-ordering from occurring.

Fixes #134.

* Clang format changes.

* Added missing global acquire which is necessary for the corresponding global release.

Thanks to @jlewis-austin for spotting.

* Clang format changes.

* Match the condition for applying acquire/release fences.
2021-09-07 12:47:44 +01:00
Senran (Stephen) Zhang
34e47322db
Limit workgroup size for atomics tests (#1197)
* Limit workgroup size for atomics tests

This avoids extremely large local buffer size and slow run

* Always limit workgroup size
2021-09-06 17:14:36 +01:00
James Price
0601c6f765
Add missing include for gRandomSeed (#1307) 2021-08-31 11:45:24 -07:00
Ben Ashbaugh
995c7dbfbb
suppress MSVC strdup warning (#1314) 2021-08-31 11:44:17 -07:00
Grzegorz Wawiorko
e27a97fbd8
Add cl_khr_integer_dot_product to known extensions in test compiler. (#1316) 2021-08-31 15:53:55 +01:00
Kévin Petit
7cfd3a6033
Report failures in simple_{read,write}_image_pitch tests (#1309) 2021-08-29 15:12:52 -07:00
Ben Ashbaugh
39fdb462be
define NOMINMAX in the CMakefile to fix std::min and std::max on MSVC (#1308) 2021-08-28 10:21:34 +01:00
Ben Ashbaugh
070f8c0c0e
add tests for cl_khr_integer_dot_product (#1276)
* cl_khr_integer_dot_product_tests

* remove emulated codepaths

* fix formatting

* address code review comments

* remove emulated codepaths again

* address one more review comment
2021-08-25 10:14:58 +01:00
Kévin Petit
6c3c7e5266
Remove unused definitions in CMakeLists.txt (#1302)
Signed-off-by: Kévin Petit <kpet@free.fr>
2021-08-19 12:15:47 +01:00
Kévin Petit
43e1397468
Fix kernel source for cl_khr_suggested_local_work_size (#1300)
Use ASCII '-' instead of unicode '–' as subtration operator.

Signed-off-by: Kévin Petit <kpet@free.fr>
2021-08-18 11:11:30 +01:00
Grzegorz Wawiorko
6da9c6b68f
Fix double free in c11_atomics tests for SVM allocations (#1286)
Some checks failed
Presubmit / Build ubuntu-20.04 (push) Failing after 5m3s
Presubmit / Build ubuntu-20.04 AArch64 (push) Failing after 3s
Presubmit / Build ubuntu-20.04 Arm (push) Failing after 2s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-latest (push) Has been cancelled
* Only Clang format changes

* Fix double free object for SVM allocations

* Fix double free - review fixes
2021-08-11 18:06:10 +01:00
Feng Zou
1aa930957a
Temporarily disable the test_kernel_attributes test case (#1297)
* Temporarily disable the test_kernel_attributes test case

Per OpenCL spec on CL_KERNEL_ATTRIBUTES, for kernels not created from OpenCL C
source and the clCreateProgramWithSource API call the string returned from this
query will be empty.
But in test_kernel_attributes test, it read from bc binary and expect to get
kernel attribute, which is not consistent with OpenCL spec.

* Fix clang format issue
2021-08-11 18:04:21 +01:00
Ben Ashbaugh
4759e5cae0
remove testing for scalar vloada_half (#1293) 2021-08-11 18:03:44 +01:00
kalchr01
cc0b46e457
Add tests for entrypoint cl_khr_suggested_local_work_size (#1264)
* Add tests for entrypoint cl_khr_suggested_local_work_size

Tests added within test_conformance/workgroups. The tests cover several
shapes (num dimensions) and sizes of global work size, kernels using
local memory (dynamic and static) and present/non-present global work
offset.

Signed-off-by: Kallia Chronaki <kallia.chronaki@arm.com>

* Fix in comparison for error checking

Signed-off-by: Kallia Chronaki <kallia.chronaki@arm.com>

* 'test_wg_suggested_local_work_size' fixes

* Refactoring of 'test_wg_suggested_local_work_size'

Modifications to reduce code duplication and minimize build time
2021-08-09 11:20:40 +01:00
Sreelakshmi Haridas Maruthur
79f692d8e5
subgroups: Fix setting cl_halfs and progress check. (#1278)
* subgroups: Fix setting cl_halfs and progress check.

cl_float testing uses set_value such that a generated cl_ulong of 1 is
stored as 1.0F in a logical sense. However, cl_half values aren't
intrinsic to C++ and generated cl_ulongs less than 1024 in particular
are interpreted bitwise as subnormals. The test fails on compute devices
lacking subnormal support. Perform the logical conversion to cl_half.

Fix independent forward progress check.

* subgroups_half: Address review comments

* subgroups_half: Formatting fixes required by check-format

* subgroups_half: Modified to query and use rounding mode supported by device

Co-authored-by: spauls <spauls@qti.qualcomm.com>
2021-07-21 08:51:29 +01:00
Grzegorz Wawiorko
12637114ac
Fix double release of object in test_api and test_gl (#1287)
* Fix clang format only

* Fix double release of objects
2021-07-21 08:50:22 +01:00
Ben Ashbaugh
b500da5fbc
add basic test for cl_khr_pci_bus_info (#1227)
* add basic test for cl_khr_pci_bus_info

* correctly use TEST_SKIPPED_ITSELF

Co-authored-by: Kévin Petit <kpet@free.fr>

* fix related usage of TEST_SKIPPED_ITSELF

Co-authored-by: Kévin Petit <kpet@free.fr>
2021-07-21 08:48:48 +01:00
BKoscielak
433974fd28
Fix check for image support in test_basic sizeof (#1269) 2021-07-13 17:15:33 +01:00
James Price
4a03bb79cb
Fix double-release of memory objects (#1277)
A recent update to the object wrapper classes (#1268) changed the
behavior of assigning to a wrapper, whereby the wrapped object is now
released upon assignment. A couple of tests were manually calling
clReleaseMemObject and then assigning `nullptr` to the wrapper,
resulting in the wrapper calling clReleaseMemObject on an object that
had already been destroyed.
2021-07-05 15:35:39 +01:00
Kévin Petit
236cd73fa1
Use macOS 10 in CI (#1282)
macOS jobs frequently fail. Since macos-11.0 support is considered experimental,
move to macos-10, using macos-latest so we automatically move to 11 when
stable.

See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2021-07-02 10:34:13 +01:00
Marco Antognini
69f0054001
Fix copy and move semantics of wrapper classes (#1268)
* Remove unnecessary code

These custom equality operators are not necessary because of the
conversion operators which already allow using the standard equality
operators between two pointers.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>

* Fix copy and move semantics of wrapper classes

Related to #465.

The Wrapper classes are rewritten to properly handle copy and move
semantics, while preserving the existing API and removing code
duplication.

Add error handling around clRelase* and clRetain*.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>

* Address build issue on 32-bit Windows

Include linkage in RetainReleaseType function type.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>
2021-06-17 14:05:05 +01:00
John Kesapides
80a4a833be
Minor fixes for CL_UNORM_SHORT_565, CL_UNORM_SHORT_555 (#1129)
Some checks failed
Presubmit / Build ubuntu-20.04 (push) Failing after 5m3s
Presubmit / Build ubuntu-20.04 AArch64 (push) Failing after 4s
Presubmit / Build ubuntu-20.04 Arm (push) Failing after 3s
Presubmit / Check code format (push) Failing after 5m1s
Presubmit / Build macos-11.0 (push) Has been cancelled
* Minor fixes for CL_UNORM_SHORT_565, CL_UNORM_SHORT_555

* Fix verification for undefined bit
* Relax current infinitely precision requirement for these formats
  and move check in common function.
* Add proper debug output.

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

* Minor Formating fix.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
2021-06-11 09:44:16 +01:00
Stuart Brady
277d029608
Run spirv-val for SPIR-V offline compilation (#1108)
The common --disable-spirv-validation option has been added to disable
this functionality.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-06-11 09:42:20 +01:00
Marco Antognini
76ace61314
Fix leaks in callSingleTestFunction (#1224)
The context and queue were not released when the test is not supported
in offline mode or the queue couldn't be created.

Inline test_missing_support_offline_cmpiler_ret macro, remove dead
parameter of check_functions_for_offline_compiler and slightly refactor
callSingleTestFunction to address leaks.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>
2021-06-09 11:08:08 +01:00
Marco Antognini
315998511a
Address data race in ThreadPool (#1265)
ThreadSanitizer detects some data race in ThreadPool. They stem from
inappropriate usage of volatile which are replaced with std::atomic
variables in this patch.

This patch focuses on data races identified while running the
math_brute_force component. For example, it doesn't fully remove usage
of ThreadPool_AtomicAdd from other components of the CTS. Furthermore,
thread leaks, most likely because threads are not joined, are not
addressed.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>
2021-05-27 09:06:13 +01:00
Grzegorz Wawiorko
bd3135dd01
Extend list of known extensions (#1262) 2021-05-27 09:05:27 +01:00
Stuart Brady
0876ea10be
Ignore padding bits in clCopyImage/clFillImage testing (#1184)
The CL_UNORM_SHORT_555 and CL_UNORM_INT_101010 formats contain padding
bits which need to be ignored in clCopyImage and clFillImage testing.

For clFillImage tests, padding was not ignored for the CL_UNORM_SHORT_555
format, and was ignored for CL_UNORM_INT_101010 by modifying actual and
reference data.  For clCopyImage tests, padding was not ignored, both for
CL_UNORM_SHORT_555 and for CL_UNORM_INT_101010.

Fix this by adding a new compare_scanlines() function, which is used for
both of these formats, and does not modify the actual or reference data.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
2021-05-24 16:59:03 +01:00
Marco Antognini
ed839ebf10
Avoid manual memory management (#1260)
* 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>
2021-05-24 16:34:54 +01:00
ouakheli
a08cacc673
Fix clang-format-9 install (#1261) 2021-05-24 11:31:37 +01:00
Marco Antognini
ba9312e4a2
Fix ODR violations in math_brute_force (#1255)
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>
2021-05-21 10:07:54 +01:00
James Price
ce1687a408
Add missing cstdint include (#1259) 2021-05-21 10:07:12 +01:00
Marco Antognini
01aa55029d
Update warning options (#1252)
Remove workaround for #783, this was fixed by #1237.

Remove workaround for overflow, #699 has been merged.

Disable errors from -Wimplicit-const-int-float-conversion, the issue is
covered by #1250.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>
2021-05-21 10:06:13 +01:00
Pierre Moreau
de49d59c8d
Allocations fixes (#1245)
* allocations: Run buffer non-blocking even without images

Testing buffer non-blocking should not be dependent on whether images
are supported by a device or not.

* allocations: Fix typos
2021-05-18 18:12:55 +01:00
Sreelakshmi Haridas Maruthur
6c8045911a
gles: Fix compile warnings. (#1070)
* gles: Fix compile warnings.

For 32 and 64-bit Visual Studio and the Android Q NDK.

* Fix formatting violations

Co-authored-by: spauls <spauls@qti.qualcomm.com>
2021-05-18 18:10:24 +01:00
Marco Antognini
17a0d09567
Cleanup usage of static, extern and typedef (#1256)
* 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>
2021-05-18 18:09:46 +01:00
Pierre Moreau
6572837994
buffers: Switch from enqueueing to enqueuing (#1246)
OpenCL-Docs has 45 occurrences of “enqueuing” but a single one of
“enqueueing”.
2021-05-14 09:44:51 +01:00
Kévin Petit
e7c5694cf5
Fix image pixel reference calculation for CL_{INTENSITY,LUMINANCE} formats (#1247)
As per 6.15.15.7, the first three components have to be set to the luminance
value and all components to the intensity value.

Signed-off-by: Kévin Petit <kpet@free.fr>
2021-05-14 09:44:38 +01:00
Marco Antognini
02c2a424f7
Remove unnecessary code from unary_u_*.cpp (#1237)
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>
2021-05-13 09:31:13 +01:00
Grzegorz Wawiorko
db939bbb20
Fix test_buffer - undefined behavior in case of CL_MEM_USE_HOST_PTR (#1210) 2021-05-13 09:22:50 +01:00
Chetan Mistry
71e2681414
Add Test for CL_KERNEL_ATTRIBUTES (#832) (#1055)
* Improve Functionality of Harness

In the harness we previously were able to determine whether or
not a device supports the half or double data types, but doing so
required unintuitive function calls and would need to be repeated
per test.
A new pair of functions have been added which clearly state
what they do, and makes it easier to determine whether or not
a device supports the types.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* Add Test for CL_KERNEL_ATTRIBUTES (#832)

This test generates dummy kernels which have any
permutation combining the following attributes:

    * vec_type_hint
    * work_group_size_hint
    * reqd_work_group_size

It then gets the attributes by using clGetKernelInfo
and validates that the attributes returned are correct.
By matching the attributes which were used to generate
the kernel are present in the returned string from
clGetKernelInfo.
This test has been implemented as part of the
test_conformance/api suite.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Remove Signed Vector Attribute Hints

As per comments, SPIR-V does not distinguish the signedness
of an argument. This change removes the "signed" types
to ensure that the test passes in all scenarios.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Add TODO for Signed Vector Hints

As the current version only tests for unsigned
vector types (uchar/uint/etc), add a TODO in the code
as a reference to future work to introduce signed vector
tests

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>
2021-05-13 09:20:45 +01:00
Chetan Mistry
a43d96de69
Redesign clGetKernelArgInfo (#522) (#1056)
* Improve Functionality of Harness

In the harness we previously were able to determine whether or
not a device supports the half or double data types, but doing so
required unintuitive function calls and would need to be repeated
per test.
A new pair of functions have been added which clearly state
what they do, and makes it easier to determine whether or not
a device supports the types.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* Remove Old GetKernelArgInfo Tests (#522)

In the API test suite we have 2 versions which test the
clGetKernelArgInfo API. As part of this ticket we are redesigning
the implementation of this test. This change removes all of
the old code and makes it so that the tests simply pass. A later
commit will add the redesigned test

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* Redesign GetKernelArgInfo (#522)

The previous test for this API consisted of 5K+ lines
of code which would define the test kernels and the
expected outputs from this API. This redesign
instead generates the kernels and expected outputs
leading to incresased maintanability and a significantly
reduce line-of-code count.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Address Review Comments

This commit does the following:
    1) Update the Copyright to 2021
    2) Fixes a typo in a comment
    3) Explicitly declares a vector variable
       (previously auto)
    4) Output subtest result after completion rather than
       all of them at the end

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Ensure Kernel Arguments do not exceed CL_DEVICE_MAX_PARAMETER_SIZE

As per upstream comments, this change ensures that the total
size of parameters passed into a kernel does not exceed the
limit specified by CL_DEVICE_MAX_PARAMETER_SIZE for the device
used.
Additionally this change replaces ASSERT_SUCCESS() with test_error()
as per upstream requests.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Address Image and Vector Failures

This change aligns vector 3 types to be sized 4.
Additionally it ensures that image arguments do not
have the address space qualifier specified because
they are by default in the __global space.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Ensure that the size of pipe arguments are correct

As mentioned in PR comments, the test previously assumed that
sizeof(char) == sizeof(pipe char). The Clang implementation
treats a pipe to take the same size as a pointer, which
is now reflected in the code.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Ensure that CL_DEVICE_MAX_PIPE_ARGS is not Exceeded

This commit refactors the code so that Pipes are handled
separately.
Additionally, it removes signed char and char signed as
scalar types to test and removes some redundent code
for modifiying the expected type when processing unsigned
scalar types.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Remove compatibility test from skip-list

There is a list of tests which should be skipped when
using an offline compiler. As get_kernel_arg_compatibility
has been removed, it should also be removed here.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>

* [SQUASH] Disable Pipe Tests

This change disables the Pipe tests for clGetKernelArgInfo
as pipe metadata is not accurately reported on clang
which leads to the pipe tests failing.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>
2021-05-13 09:18:12 +01:00
Kévin Petit
ad8ab3fe90
Remove OpenCL C++ tests (#1241)
* Remove OpenCL C++ tests

Agreed in the 2021/05/11 teleconference.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>

* fix CI
2021-05-13 09:13:03 +01:00
Pierre Moreau
d7f87492bd
testHarness: Print error string when clFinish fails (#1243) 2021-05-12 11:39:45 +01:00
Pierre Moreau
06f7661fdc
basic/async: Check for extension only once per test (#1242)
As the extension is vector size and type independent, we only need to
check for the extension once per test and not for every possible
combination of inputs, thereby drastically reducing the log output of
the test when the extension is not supported.
2021-05-12 11:39:17 +01:00
sravikumar3393
59a12047a8
Fix for test_conversions failure with Clang build on Linux #1057 (#1062)
* Avoid optimization by using volatile qualifier
    * Fix both uint2float and ulong2double
2021-05-11 18:17:48 +01:00
Marco Antognini
3dd6d4137d
Avoid manual memory management, fixes #975 (#1240)
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>
2021-05-11 18:06:16 +01:00
Marco Antognini
3dab3df48d
Report inputs for worst errors (#1231)
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>
2021-05-07 09:29:28 +01:00
Marco Antognini
5daca107ad
Remove dead variables and functions (#1238)
These were identified using Clang's -Wunused warning flag.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>
2021-05-07 09:28:38 +01:00
Marco Antognini
01497c402e
Reduce scope of variables (#1228)
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>
2021-04-28 09:30:51 +01:00
Marco Antognini
cba7a8a537
Remove dead CMake code (#1230)
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>
2021-04-28 09:30:25 +01:00
Chetan Mistry
edc36b5d53
Remove NULL Platform Check for Negative clGetPlatformInfo (#1222) (#1229)
Part of the negative CTS test for clGetPlatformInfo
incorrectly tested with a NULL platform. As this is a
special case it meant that the test was not correct.
This change removes the incorrect part of the test so that
it conforms with the OpenCL specification.

Signed-off-by: Chetankumar Mistry <chetan.mistry@arm.com>
2021-04-27 15:43:39 +01:00
Marco Antognini
b8d1ea9962
Fold constant global variable (#1217)
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>
2021-04-21 10:45:34 +01:00
Marco Antognini
7542ae2443
Fold code into loop (#1218)
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>
2021-04-20 17:10:29 +01:00
Marco Antognini
6683fa91a9
Use lambda to reduce amount of code (#1219)
Signed-off-by: Marco Antognini <marco.antognini@arm.com>
2021-04-20 17:10:06 +01:00
Marco Antognini
7286e06a94
Make variables and functions local to translation unit (#1216)
* 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>
2021-04-15 18:19:09 +01:00
1355 changed files with 116011 additions and 101777 deletions

View file

@ -1,54 +0,0 @@
os:
- Visual Studio 2017
shallow_clone: true
platform:
- Win32
- x64
configuration:
- Release
environment:
matrix:
- SETARCH: i686
- SETARCH: x86_64
matrix:
exclude:
- platform: Win32
SETARCH: x86_64
- platform: x64
SETARCH: i686
before_build:
# Setup environment:
- ps: $env:TOP = $env:APPVEYOR_BUILD_FOLDER
- ps: $env:TOP
- echo %TOP%
# Get the OpenCL Headers:
- git clone --depth=1 https://github.com/KhronosGroup/OpenCL-Headers OpenCL-Headers
# Get and build the OpenCL ICD Loader:
- git clone --depth=1 https://github.com/KhronosGroup/OpenCL-ICD-Loader.git
- ps: cd OpenCL-ICD-Loader
- ps: mkdir build
- ps: cd build
- cmake -A%PLATFORM% -DENABLE_OPENCL30_PROVISIONAL=1 -DOPENCL_ICD_LOADER_HEADERS_DIR=%TOP%/OpenCL-Headers/ ..
- cmake --build . --config %CONFIGURATION%
- ps: cd $env:TOP
# Get the libclcxx standard library:
- git clone --depth=1 https://github.com/KhronosGroup/libclcxx.git libclcxx
# Generate the CTS solution file:
- cmake -DCL_INCLUDE_DIR=%TOP%/OpenCL-Headers
-DCL_LIB_DIR=%TOP%/OpenCL-ICD-Loader/build
-DCL_LIBCLCXX_DIR=%TOP%/libclcxx
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=./bin
-DOPENCL_LIBRARIES="OpenCL"
-H. -Bbuild_win -A%PLATFORM%
-DD3D10_IS_SUPPORTED=ON -DD3D11_IS_SUPPORTED=ON -DARCH=%SETARCH%
build:
project: build_win\CLConform.sln
parallel: true
verbosity: normal

1
.gitattributes vendored
View file

@ -1 +0,0 @@
*.7z filter=lfs diff=lfs merge=lfs -text

10
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"

View file

@ -3,38 +3,180 @@ on: [push, pull_request]
jobs:
build:
name: Build ${{ matrix.os }} ${{ matrix.name }}
name: Build ${{ matrix.os }} ${{ matrix.arch }}${{ matrix.extra }}
runs-on: ${{ matrix.os }}
env:
JOB_ARCHITECTURE: ${{ matrix.arch }}
JOB_ENABLE_GL: ${{ matrix.gl }}
strategy:
fail-fast: false
matrix:
mainmatrix: [true]
os: [ubuntu-20.04, macos-11.0]
build-type: [Release]
gl: [0]
os: [ubuntu-22.04, macos-latest, windows-latest]
include:
- os: ubuntu-20.04
mainmatrix: true
- os: ubuntu-22.04
gl: 1
- os: ubuntu-20.04
mainmatrix: false
name: Arm
extra: " gl"
- os: ubuntu-22.04
arch: arm
- os: ubuntu-20.04
mainmatrix: false
name: AArch64
- os: ubuntu-22.04
arch: aarch64
build-type: Debug
extra: " debug"
- os: ubuntu-22.04
arch: android-arm
android_arch_abi: armeabi-v7a
- os: ubuntu-22.04
arch: android-aarch64
android_arch_abi: arm64-v8a
steps:
- uses: actions/checkout@v2
- name: Build
run: ./presubmit.sh
- uses: actions/checkout@v4
- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Install Arm and AArch64 compilers
if: ${{ matrix.arch == 'arm' || matrix.arch == 'aarch64' }}
run: |
sudo apt-get update
sudo apt-get install -y \
gcc-12-arm-linux-gnueabihf g++-12-arm-linux-gnueabihf \
gcc-12-aarch64-linux-gnu g++-12-aarch64-linux-gnu
sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-12 12
sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-12 12
sudo update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-12 12
sudo update-alternatives --install /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-12 12
- name: Setup OpenGL build dependencies
if: ${{ matrix.gl }}
run: |
sudo apt-get update
sudo apt-get -y install libglu1-mesa-dev freeglut3-dev mesa-common-dev libglew-dev
- name: Setup MSVC with Ninja
uses: ilammy/msvc-dev-cmd@v1
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
variant: sccache
key: ${{ matrix.os }}-${{ matrix.arch }}
- name: Fetch OpenCL Headers
shell: bash
run: |
git clone https://github.com/KhronosGroup/OpenCL-Headers.git
cd OpenCL-Headers
ln -s CL OpenCL # For OSX builds
cd ..
- name: Install Vulkan SDK
uses: humbletim/install-vulkan-sdk@main
with:
version: 1.4.309.0
cache: true
- name: Install Android NDK
if: ${{ matrix.arch == 'android-arm' || matrix.arch == 'android-aarch64' }}
run: |
wget https://dl.google.com/android/repository/android-ndk-r27c-linux.zip -O android-ndk.zip
unzip android-ndk.zip -d $HOME
export ANDROID_NDK=$HOME/android-ndk-r27c
echo "ANDROID_NDK=$ANDROID_NDK" >> $GITHUB_ENV
export ANDROID_ARCH_ABI=${{ matrix.android_arch_abi }}
echo "ANDROID_ARCH_ABI=$ANDROID_ARCH_ABI" >> $GITHUB_ENV
- name: Prepare CMake Toolchain file
shell: bash
run: |
if [[ '${{ matrix.arch }}' == android-* ]]; then
TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake
else
TOOLCHAIN_FILE='${{ github.workspace }}'/toolchain.cmake
touch ${TOOLCHAIN_FILE}
fi
TOOLCHAIN_PREFIX_arm=arm-linux-gnueabihf
TOOLCHAIN_PREFIX_aarch64=aarch64-linux-gnu
if [[ '${{ matrix.arch }}' != android-* ]]; then
if [[ '${{ matrix.arch }}' != "" && ${RUNNER_OS} != "Windows" ]]; then
TOOLCHAIN_PREFIX_VAR=TOOLCHAIN_PREFIX_${{ matrix.arch }}
TOOLCHAIN_PREFIX=${!TOOLCHAIN_PREFIX_VAR}
echo "SET(CMAKE_SYSTEM_NAME Linux)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_SYSTEM_PROCESSOR ${{ matrix.arch }})" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> ${TOOLCHAIN_FILE}
fi
fi
echo "TOOLCHAIN_FILE=${TOOLCHAIN_FILE}" >> $GITHUB_ENV
- name: Prepare Android CMake arguments
if: ${{ matrix.arch == 'android-arm' || matrix.arch == 'android-aarch64' }}
shell: bash
run: |
echo "CMAKE_CONFIG_ARGS_ANDROID=-DCMAKE_ANDROID_ARCH_ABI=${ANDROID_ARCH_ABI}" >> $GITHUB_ENV
- name: Fetch and build OpenCL ICD Loader
shell: bash
run: |
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git
cd OpenCL-ICD-Loader
mkdir build
cd build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DOPENCL_ICD_LOADER_HEADERS_DIR='${{ github.workspace }}'/OpenCL-Headers/ \
"${CMAKE_CONFIG_ARGS_ANDROID}"
cmake --build . --parallel
- name: Fetch Vulkan Headers
shell: bash
run: |
git clone https://github.com/KhronosGroup/Vulkan-Headers.git
- name: Fetch and build Vulkan Loader
if: ${{ matrix.arch != 'android-arm' && matrix.arch != 'android-aarch64' }}
shell: bash
run: |
git clone https://github.com/KhronosGroup/Vulkan-Loader.git
cd Vulkan-Loader
mkdir build
cd build
python3 ../scripts/update_deps.py
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DBUILD_WSI_XLIB_SUPPORT=OFF \
-DBUILD_WSI_XCB_SUPPORT=OFF \
-DBUILD_WSI_WAYLAND_SUPPORT=OFF \
-C helper.cmake ..
cmake --build . --parallel
- name: Configure and build
shell: bash
run: |
mkdir build
cd build
if [[ ${RUNNER_OS} == "Windows" ]]; then
CMAKE_OPENCL_LIBRARIES_OPTION="OpenCL"
else
CMAKE_OPENCL_LIBRARIES_OPTION="-lOpenCL"
if [[ '${{ matrix.arch }}' != android-* ]]; then
CMAKE_OPENCL_LIBRARIES_OPTION="${CMAKE_OPENCL_LIBRARIES_OPTION} -lpthread"
fi
fi
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DCMAKE_CACHE_OPTIONS="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache" \
-DCL_INCLUDE_DIR='${{ github.workspace }}'/OpenCL-Headers \
-DCL_LIB_DIR='${{ github.workspace }}'/OpenCL-ICD-Loader/build \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=./bin \
-DOPENCL_LIBRARIES="${CMAKE_OPENCL_LIBRARIES_OPTION}" \
-DUSE_CL_EXPERIMENTAL=ON \
-DGL_IS_SUPPORTED=${{ matrix.gl }} \
-DVULKAN_IS_SUPPORTED=ON \
-DVULKAN_INCLUDE_DIR='${{ github.workspace }}'/Vulkan-Headers/include/ \
-DVULKAN_LIB_DIR='${{ github.workspace }}'/Vulkan-Loader/build/loader/ \
"${CMAKE_CONFIG_ARGS_ANDROID}"
cmake --build . --parallel
formatcheck:
name: Check code format
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Install packages
run: sudo apt install -y clang-format
- uses: actions/checkout@v2
run: sudo apt install -y clang-format clang-format-14
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check code format

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# Build dir
[Bb]uild/

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.12.0)
set( CONFORMANCE_SUFFIX "" )
set(CLConform_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@ -7,15 +7,9 @@ project(CLConform${CONFORMANCE_SUFFIX})
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_BUILD_TYPE STREQUAL "release")
set (BUILD_FLAVOR "release")
else(CMAKE_BUILD_TYPE STREQUAL "release")
set (BUILD_FLAVOR "debug")
endif(CMAKE_BUILD_TYPE STREQUAL "release")
add_definitions(-DCL_TARGET_OPENCL_VERSION=300)
add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_2_APIS=1)
add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_1_APIS=1)
@ -23,20 +17,14 @@ add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_0_APIS=1)
add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_2_APIS=1)
add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS=1)
add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_0_APIS=1)
add_definitions(-DCL_NO_EXTENSION_PROTOTYPES)
add_definitions(-DCL_ENABLE_BETA_EXTENSIONS)
option(USE_CL_EXPERIMENTAL "Use Experimental definitions" OFF)
if(USE_CL_EXPERIMENTAL)
add_definitions(-DCL_EXPERIMENTAL)
endif(USE_CL_EXPERIMENTAL)
# Support both VS2008 and VS2012.
set(BUILD_DIR "$ENV{ADRENO_DRIVER}/build")
if(MSVC90)
set(VS_BUILD_DIR "${BUILD_DIR}/vs2008")
else(MSVC110)
set(VS_BUILD_DIR "${BUILD_DIR}/vs2012")
endif(MSVC90)
#-----------------------------------------------------------
# Default Configurable Test Set
#-----------------------------------------------------------
@ -44,6 +32,7 @@ option(D3D10_IS_SUPPORTED "Run DirectX 10 interop tests" OFF)
option(D3D11_IS_SUPPORTED "Run DirectX 11 interop tests" OFF)
option(GL_IS_SUPPORTED "Run OpenGL interop tests" OFF)
option(GLES_IS_SUPPORTED "Run OpenGL ES interop tests" OFF)
option(VULKAN_IS_SUPPORTED "Run Vulkan interop tests" OFF)
#-----------------------------------------------------------
@ -62,58 +51,13 @@ set(CONFORMANCE_SUFFIX "" )
#build driver as a dependency of the conformance tests, or other such CMake customization
include(CMakeVendor.txt OPTIONAL)
#-----------------------------------------------------------
# Development options for OpenCL C++ tests
#-----------------------------------------------------------
# Use OpenCL C kernels instead of OpenCL C++ kernels
option(CLPP_DEVELOPMENT_USE_OPENCLC_KERNELS "Use OpenCL C kernels in OpenCL C++ tests" OFF)
if(CLPP_DEVELOPMENT_USE_OPENCLC_KERNELS)
set(CLPP_DEVELOPMENT_OPTIONS ${CLPP_DEVELOPMENT_OPTIONS} -DCLPP_DEVELOPMENT_USE_OPENCLC_KERNELS)
endif(CLPP_DEVELOPMENT_USE_OPENCLC_KERNELS)
# Only check if OpenCL C++ kernels compile to SPIR-V
option(CLPP_DEVELOPMENT_ONLY_SPIRV_COMPILATION "Only check if OpenCL C++ kernels compile to SPIR-V" OFF)
if(CLPP_DEVELOPMENT_ONLY_SPIRV_COMPILATION)
if(CLPP_DEVELOPMENT_USE_OPENCLC_KERNELS)
message(FATAL_ERROR "Can't use OpenCL C kernels and compile to SPIR-V.")
endif(CLPP_DEVELOPMENT_USE_OPENCLC_KERNELS)
set(CLPP_DEVELOPMENT_OPTIONS ${CLPP_DEVELOPMENT_OPTIONS} -DCLPP_DEVELOPMENT_ONLY_SPIRV_COMPILATION)
endif(CLPP_DEVELOPMENT_ONLY_SPIRV_COMPILATION)
#
if(CLPP_DEVELOPMENT_OPTIONS)
add_definitions(-DCLPP_DEVELOPMENT_OPTIONS)
add_definitions(${CLPP_DEVELOPMENT_OPTIONS})
endif(CLPP_DEVELOPMENT_OPTIONS)
# Offline OpenCL C/C++ compiler provided by Khronos is the only supported
# offline compiler.
#
# Path to offline OpenCL C/C++ compiler provided by Khronos.
# See https://github.com/KhronosGroup/SPIR/ (spirv-1.1 branch or newer SPIR-V-ready
# branch should be used).
if(KHRONOS_OFFLINE_COMPILER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DKHRONOS_OFFLINE_COMPILER=${KHRONOS_OFFLINE_COMPILER}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKHRONOS_OFFLINE_COMPILER=${KHRONOS_OFFLINE_COMPILER}")
# Additional OpenCL C/C++ compiler option.
if(KHRONOS_OFFLINE_COMPILER_OPTIONS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DKHRONOS_OFFLINE_COMPILER_OPTIONS=${KHRONOS_OFFLINE_COMPILER_OPTIONS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKHRONOS_OFFLINE_COMPILER_OPTIONS=${KHRONOS_OFFLINE_COMPILER_OPTIONS}")
endif(KHRONOS_OFFLINE_COMPILER_OPTIONS)
else(KHRONOS_OFFLINE_COMPILER)
message(WARNING "KHRONOS_OFFLINE_COMPILER is not defined!")
message(WARNING "Running CL C++ tests will not be possible.")
endif(KHRONOS_OFFLINE_COMPILER)
# CL_LIBCLCXX_DIR - path to dir with OpenCL C++ STL (libclcxx)
# CL_INCLUDE_DIR - path to dir with OpenCL headers
# CL_LIBCLCXX_DIR - path to dir with OpenCL library
if(CL_INCLUDE_DIR AND CL_LIB_DIR AND CL_LIBCLCXX_DIR)
if(CL_INCLUDE_DIR AND CL_LIB_DIR)
link_directories(${CL_LIB_DIR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCL_LIBCLCXX_DIR=${CL_LIBCLCXX_DIR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCL_LIBCLCXX_DIR=${CL_LIBCLCXX_DIR}")
else(CL_INCLUDE_DIR AND CL_LIB_DIR AND CL_LIBCLCXX_DIR)
else(CL_INCLUDE_DIR AND CL_LIB_DIR)
message(STATUS "OpenCL hasn't been found!")
message(FATAL_ERROR "Either install OpenCL or pass -DCL_INCLUDE_DIR, -DCL_LIB_DIR and -DCL_LIBCLCXX_DIR")
endif(CL_INCLUDE_DIR AND CL_LIB_DIR AND CL_LIBCLCXX_DIR)
message(FATAL_ERROR "Either install OpenCL or pass -DCL_INCLUDE_DIR and -DCL_LIB_DIR")
endif(CL_INCLUDE_DIR AND CL_LIB_DIR)
# CLConform_GL_LIBRARIES_DIR - path to OpenGL libraries
if(GL_IS_SUPPORTED AND CLConform_GL_LIBRARIES_DIR)
@ -140,21 +84,31 @@ endif()
macro(add_cxx_flag_if_supported flag)
string(REGEX REPLACE "[-=+]" "" FLAG_NO_SIGNS ${flag})
check_cxx_compiler_flag(${flag} COMPILER_SUPPORTS_${FLAG_NO_SIGNS})
set(FLAG_TO_TEST ${flag})
if((${flag} MATCHES "^-Wno-") AND NOT (${flag} MATCHES "^-Wno-error="))
# -Wno-... only causes a diagnostic if another diagnostic is emitted.
# Change such flags into a -W... flag to test if the warning is known.
string(REGEX REPLACE "^-Wno-" "-W" FLAG_TO_TEST ${flag})
endif()
check_cxx_compiler_flag(${FLAG_TO_TEST} COMPILER_SUPPORTS_${FLAG_NO_SIGNS})
if(COMPILER_SUPPORTS_${FLAG_NO_SIGNS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
endif()
endmacro(add_cxx_flag_if_supported)
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
add_cxx_flag_if_supported(-Wno-narrowing)
add_cxx_flag_if_supported(-Wno-format)
add_cxx_flag_if_supported(-Wmisleading-indentation)
add_cxx_flag_if_supported(-Wunused-function)
add_cxx_flag_if_supported(-Wunused-variable)
add_cxx_flag_if_supported(-Werror)
if(NOT CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo|MinSizeRel")
# Enable more warnings if not doing a release build.
add_cxx_flag_if_supported(-Wall)
endif()
add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive
add_cxx_flag_if_supported(-Wno-error=absolute-value) # Issue 783
add_cxx_flag_if_supported(-Wno-error=unknown-pragmas) # Issue #785
add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785
add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784
add_cxx_flag_if_supported(-Wno-error=overflow) # Fixed by #699
add_cxx_flag_if_supported(-Wno-strict-aliasing) # Issue 2234
# -msse -mfpmath=sse to force gcc to use sse for float math,
# avoiding excess precision problems that cause tests like int2float
@ -172,14 +126,46 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE__")
endif()
# Set a module's COMPILE_FLAGS if using gcc or clang.
macro(set_gnulike_module_compile_flags flags)
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
SET_SOURCE_FILES_PROPERTIES(
${${MODULE_NAME}_SOURCES}
PROPERTIES
COMPILE_FLAGS ${flags}
)
endif()
endmacro(set_gnulike_module_compile_flags)
# Xcode 14.1 deprecated functions such as sprintf.
# Suppress such warnings for now, see Issue #1626
if(APPLE)
add_cxx_flag_if_supported(-Wno-deprecated-declarations)
endif(APPLE)
if(MSVC)
# Don't warn when using standard non-secure functions.
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
# Don't warn about using the portable "strdup" function.
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE)
# Fix std::min and std::max handling with windows.harness.
add_compile_definitions(NOMINMAX)
endif()
if( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qlong-double -Qpc80 /DWIN32 /D_WINDOWS /W3 /GR /EHsc -nologo -Od -D_CRT_NONSTDC_NO_WARNINGS -EHsc -Wall -Qdiag-disable:68,111,177,186,161,869,1028,2259,2553,181,239,265,1188 -fp:strict -fp:source")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qlong-double -Qpc80 /DWIN32 /D_WINDOWS /W3 /GR /EHsc -nologo -Od -D_CRT_NONSTDC_NO_WARNINGS -EHsc -Wall -Qdiag-disable:68,111,177,186,161,869,1028,2259,2553,181,239,265,1188 -fp:strict -fp:source")
set(Shared_Flags_Intel "-Qlong-double -Qpc80 /DWIN32 /D_WINDOWS /W3 /GR /EHsc -nologo -Od -D_CRT_NONSTDC_NO_WARNINGS -EHsc -Wall -fp:strict")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Shared_Flags_Intel}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${Shared_Flags_Intel}")
if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM"))
set(ICC_Extra_Flags "-Qdiag-disable:68,111,177,186,161,869,1028,2259,2553,181,239,265,1188 -fp:source")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ICC_Extra_Flags}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ICC_Extra_Flags}")
endif()
endif()
# To handle addresses larger than 2 gigabytes for 32bit targets
if(WIN32 AND ${CLConform_TARGET_ARCH} STREQUAL "x86")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
endif()
list(APPEND CLConform_LIBRARIES ${OPENCL_LIBRARIES})
@ -197,10 +183,6 @@ if(LINK_PTHREAD)
list(APPEND CLConform_LIBRARIES pthread)
endif()
if(DEFINED USE_GLES3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLES3")
endif()
if(APPLE)
find_library(corefoundation CoreFoundation)
find_library(iokit IOKit)
@ -214,38 +196,5 @@ include_directories(${CLConform_SOURCE_DIR}/test_common/harness
${CLConform_SOURCE_DIR}/test_common/gl
${CLConform_SOURCE_DIR}/test_common)
if(CMAKE_BUILD_TYPE STREQUAL "release")
set (BUILD_FLAVOR "release")
elseif (CMAKE_BUILD_TYPE STREQUAL "debug")
set (BUILD_FLAVOR "debug")
endif(CMAKE_BUILD_TYPE STREQUAL "release")
add_subdirectory(test_common)
add_subdirectory(test_conformance)
# Support both VS2008 and VS2012.
set (DLL_FILES "${VS_BUILD_DIR}/Debug/*.dll")
set (DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/")
if (WIN32)
set (COPY "echo")
add_custom_target(COPY_DLL${CONFORMANCE_SUFFIX} ALL
COMMAND ${COPY} "${DLL_FILES}" "${DST_DIR}"
COMMENT "Copying dll files.. ")
else (WIN32)
set (COPY cp)
add_custom_target(COPY_DLL${CONFORMANCE_SUFFIX})
endif(WIN32)
set_property(TARGET COPY_DLL${CONFORMANCE_SUFFIX} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}")
if(WIN32)
add_custom_target( COPY_FILES${CONFORMANCE_SUFFIX} ALL
COMMAND ${COPY} ${DLL_FILES} ${DST_DIR}
COMMENT "Copying other files to output folder..." )
else(WIN32)
add_custom_target( COPY_FILES${CONFORMANCE_SUFFIX} )
endif(WIN32)
set_property(TARGET COPY_FILES${CONFORMANCE_SUFFIX} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}")

130
README.md
View file

@ -1,2 +1,128 @@
# OpenCL-CTS [![Build Status](https://api.travis-ci.org/KhronosGroup/OpenCL-CTS.svg?branch=master)](https://travis-ci.org/KhronosGroup/OpenCL-CTS/branches)
The OpenCL Conformance Tests
# OpenCL Conformance Test Suite (CTS)
This is the OpenCL CTS for all versions of the Khronos
[OpenCL](https://www.khronos.org/opencl/) standard.
## Building the CTS
The CTS supports Linux, Windows, macOS, and Android platforms. In particular,
GitHub Actions CI builds against Ubuntu 20.04, Windows-latest, and
macos-latest.
Compiling the CTS requires the following CMake configuration options to be set:
* `CL_INCLUDE_DIR` Points to the unified
[OpenCL-Headers](https://github.com/KhronosGroup/OpenCL-Headers).
* `CL_LIB_DIR` Directory containing the OpenCL library to build against.
* `SPIRV_TOOLS_DIR` Directory containing the `spirv-as` and `spirv-val` binaries
to be used in the CTS build process. Alternatively, the location to these binaries
can be provided via the `PATH` variable.
* `OPENCL_LIBRARIES` Name of the OpenCL library to link.
It is advised that the [OpenCL ICD-Loader](https://github.com/KhronosGroup/OpenCL-ICD-Loader)
is used as the OpenCL library to build against. Where `CL_LIB_DIR` points to a
build of the ICD loader and `OPENCL_LIBRARIES` is "OpenCL".
### Example Build
Steps on a Linux platform to clone dependencies from GitHub sources, configure
a build, and compile.
```sh
git clone https://github.com/KhronosGroup/OpenCL-CTS.git
git clone https://github.com/KhronosGroup/OpenCL-Headers.git
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git
git clone https://github.com/KhronosGroup/SPIRV-Tools.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git SPIRV-Tools/external/spirv-headers
git clone https://github.com/google/effcee.git SPIRV-Tools/external/effcee
git clone https://github.com/google/re2.git SPIRV-Tools/external/re2
mkdir OpenCL-ICD-Loader/build
cmake -S OpenCL-ICD-Loader -B OpenCL-ICD-Loader/build \
-DOPENCL_ICD_LOADER_HEADERS_DIR=$PWD/OpenCL-Headers
cmake --build ./OpenCL-ICD-Loader/build --config Release
mkdir SPIRV-Tools/build
cmake -S SPIRV-Tools -B SPIRV-Tools/build -DSPIRV_SKIP_TESTS=ON
cmake --build SPIRV-Tools/build --config Release
mkdir OpenCL-CTS/build
cmake -S OpenCL-CTS -B OpenCL-CTS/build \
-DCL_INCLUDE_DIR=$PWD/OpenCL-Headers \
-DCL_LIB_DIR=$PWD/OpenCL-ICD-Loader/build \
-DSPIRV_TOOLS_DIR=$PWD/SPIRV-Tools/build/tools/ \
-DOPENCL_LIBRARIES=OpenCL
cmake --build OpenCL-CTS/build --config Release
```
## Running the CTS
A build of the CTS contains multiple executables representing the directories in
the `test_conformance` folder. Each of these executables contains sub-tests, and
possibly smaller granularities of testing within the sub-tests.
See the `--help` output on each executable for the list of sub-tests available,
as well as other options for configuring execution.
If the OpenCL library built against is the ICD Loader, and the vendor library to
be tested is not registered in the
[default ICD Loader location](https://github.com/KhronosGroup/OpenCL-ICD-Loader#registering-icds)
then the [OCL_ICD_FILENAMES](https://github.com/KhronosGroup/OpenCL-ICD-Loader#table-of-debug-environment-variables)
environment variable will need to be set for the ICD Loader to detect the OpenCL
library to use at runtime. For example, to run the basic tests on a Linux
platform:
```sh
OCL_ICD_FILENAMES=/path/to/vendor_lib.so ./test_basic
```
### Offline Compilation
Testing OpenCL drivers which do not have a runtime compiler can be done by using
additional command line arguments provided by the test harness for tests which
require compilation, these are:
* `--compilation-mode` Selects if OpenCL-C source code should be compiled using
an external tool before being passed on to the OpenCL driver in that form for
testing. Online is the default mode, but also accepts the values `spir-v`, and
`binary`.
* `--compilation-cache-mode` Controls how the compiled OpenCL-C source code
should be cached on disk.
* `--compilation-cache-path` Accepts a path to a directory where the compiled
binary cache should be stored on disk.
* `--compilation-program` Accepts a path to an executable (default:
cl_offline_compiler) invoked by the test harness to perform offline
compilation of OpenCL-C source code. This executable must match the
[interface description](test_common/harness/cl_offline_compiler-interface.txt).
## Generating a Conformance Report
The Khronos [Conformance Process Document](https://members.khronos.org/document/dl/911)
details the steps required for a conformance submission.
In this repository [opencl_conformance_tests_full.csv](test_conformance/opencl_conformance_tests_full.csv)
defines the full list of tests which must be run for conformance. The output log
of which must be included alongside a filled in
[submission details template](test_conformance/submission_details_template.txt).
Utility script [run_conformance.py](test_conformance/run_conformance.py) can be
used to help generating the submission log, although it is not required.
Git [tags](https://github.com/KhronosGroup/OpenCL-CTS/tags) are used to define
the version of the repository conformance submissions are made against.
## Contributing
Contributions are welcome to the project from Khronos members and non-members
alike via GitHub Pull Requests (PR). Alternatively, if you've found a bug or have
a question please file an issue in the GitHub project. First time contributors
will be required to sign the Khronos Contributor License Agreement (CLA) before
their PR can be merged.
PRs to the repository are required to be `clang-format` clean to pass CI.
Developers can either use the `git-clang-format` tool locally to verify this
before contributing, or update their PR based on the diff provided by a failing
CI job.

View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Arg used to specify non-'origin/master' comparison branch
ORIGIN_BRANCH=${1:-"origin/master"}
CLANG_BINARY=${2:-"`which clang-format-9`"}
# Arg used to specify non-'origin/main' comparison branch
ORIGIN_BRANCH=${1:-"origin/main"}
CLANG_BINARY=${2:-"`which clang-format-14`"}
# Run git-clang-format to check for violations
CLANG_FORMAT_OUTPUT=$(git-clang-format --diff $ORIGIN_BRANCH --extensions c,cpp,h,hpp --binary $CLANG_BINARY)

View file

@ -1,76 +0,0 @@
#!/usr/bin/env bash
set -e
export TOP=$(pwd)
TOOLCHAIN_URL_arm="https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz"
TOOLCHAIN_URL_aarch64="https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz"
TOOLCHAIN_PREFIX_arm=arm-linux-gnueabihf
TOOLCHAIN_PREFIX_aarch64=aarch64-linux-gnu
TOOLCHAIN_FILE=${TOP}/toolchain.cmake
touch ${TOOLCHAIN_FILE}
BUILD_OPENGL_TEST="OFF"
# Prepare toolchain if needed
if [[ ${JOB_ARCHITECTURE} != "" ]]; then
TOOLCHAIN_URL_VAR=TOOLCHAIN_URL_${JOB_ARCHITECTURE}
TOOLCHAIN_URL=${!TOOLCHAIN_URL_VAR}
wget ${TOOLCHAIN_URL}
TOOLCHAIN_ARCHIVE=${TOOLCHAIN_URL##*/}
tar xf ${TOOLCHAIN_ARCHIVE}
TOOLCHAIN_DIR=${TOP}/${TOOLCHAIN_ARCHIVE%.tar.xz}
export PATH=${TOOLCHAIN_DIR}/bin:${PATH}
TOOLCHAIN_PREFIX_VAR=TOOLCHAIN_PREFIX_${JOB_ARCHITECTURE}
TOOLCHAIN_PREFIX=${!TOOLCHAIN_PREFIX_VAR}
echo "SET(CMAKE_SYSTEM_NAME Linux)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_SYSTEM_PROCESSOR ${JOB_ARCHITECTURE})" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> ${TOOLCHAIN_FILE}
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> ${TOOLCHAIN_FILE}
fi
if [[ ( ${JOB_ARCHITECTURE} == "" && ${JOB_ENABLE_GL} == "1" ) ]]; then
BUILD_OPENGL_TEST="ON"
sudo apt-get update
sudo apt-get -y install libglu1-mesa-dev freeglut3-dev mesa-common-dev libglew-dev
fi
# Prepare headers
git clone https://github.com/KhronosGroup/OpenCL-Headers.git
cd OpenCL-Headers
ln -s CL OpenCL # For OSX builds
cd ..
# Get and build loader
git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git
cd ${TOP}/OpenCL-ICD-Loader
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} -DOPENCL_ICD_LOADER_HEADERS_DIR=${TOP}/OpenCL-Headers/ ..
make
# Get libclcxx
cd ${TOP}
git clone https://github.com/KhronosGroup/libclcxx.git
# Build CTS
ls -l
mkdir build
cd build
cmake -DCL_INCLUDE_DIR=${TOP}/OpenCL-Headers \
-DCL_LIB_DIR=${TOP}/OpenCL-ICD-Loader/build \
-DCL_LIBCLCXX_DIR=${TOP}/libclcxx \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=./bin \
-DOPENCL_LIBRARIES="-lOpenCL -lpthread" \
-DUSE_CL_EXPERIMENTAL=ON \
-DGL_IS_SUPPORTED=${BUILD_OPENGL_TEST} \
..
make -j2

View file

@ -1,41 +0,0 @@
To run the conformance tests you need SPIR-V binaries.
If you are using a conformance package then the binaries are included in the
package. If you are using conformance tests from gitlab repositories then the
binaries need to be picked up from Khronos SVN URL mentioned below:
https://cvs.khronos.org/svn/repos/OpenCL/trunk/Khronos/spirv/spirv10_2015.11.25.zip
Alternatively you can check out and build all of the below repositories.
1. SPIRV-LLVM
LLVM with support for SPIR-V (required by clang compiler)
Repository: https://gitlab.khronos.org/opencl/SPIRV-LLVM
Branch: spec_constants
Notes: spirv-3.6.1 is a main branch with support for OpenCL C++ kernel language,
spec_constants is based on it, but it adds support for specialization constants.
2. Clang
Clang with support for OpenCL C++ kernel language
Repository: https://gitlab.khronos.org/opencl/clang
Branch: spec_constants
Notes: spirv-1.1 is a main branch with support for OpenCL C++ kernel language,
spec_constants is based on it, but it adds support for specialization constants.
3. libclcxx
OpenCL C++ Standard Library
Repository: https://gitlab.khronos.org/opencl/libclcxx
Branch: lit_tests_cl22
Notes: lit_tests_cl22 branch includes both LIT tests and changes introduced in
spec_constants branch, that is, implementation of Specialization Constants Library.
4. OpenCL 2.2 headers
OpenCL 2.2 headers
Repository: https://gitlab.khronos.org/opencl/headers
Branch: opencl22
5. OpenCL ICD (with 2.2 support)
OpenCL ICD
Repository: https://gitlab.khronos.org/opencl/icd
Branch: dev_cl22

View file

@ -1,6 +1,6 @@
set(HARNESS_SOURCES
harness/threadTesting.cpp
harness/alloc.cpp
harness/typeWrappers.cpp
harness/mt19937.cpp
harness/conversions.cpp
@ -22,4 +22,3 @@ set(HARNESS_SOURCES
)
add_library(harness STATIC ${HARNESS_SOURCES})

View file

@ -1,38 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef TEST_COMMON_AUTOTEST_AUTOTEST_HPP
#define TEST_COMMON_AUTOTEST_AUTOTEST_HPP
#include "test_suite.hpp"
#define STR_JOIN( X, Y ) STR_DO_JOIN( X, Y )
#define STR_DO_JOIN( X, Y ) STR_DO_JOIN_2(X,Y)
#define STR_DO_JOIN_2( X, Y ) X##Y
// How to use AUTO_TEST_CASE macro:
//
// AUTO_TEST_CASE(<test_case_name>)(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems)
// {
// (test case code...)
// }
//
#define AUTO_TEST_CASE(name) \
struct name { static int run_test(cl_device_id, cl_context, cl_command_queue, int); }; \
static autotest::detail::test_case_registration STR_JOIN(name, STR_JOIN(_registration, __LINE__)) (#name, name::run_test); \
int name::run_test
#endif //TEST_COMMON_AUTOTEST_AUTOTEST_HPP

View file

@ -1,61 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef TEST_COMMON_AUTOTEST_TEST_SUITE_HPP
#define TEST_COMMON_AUTOTEST_TEST_SUITE_HPP
#include <vector>
#include <string>
namespace autotest {
struct test_suite {
test_suite(const std::string& name)
: name(name)
{
}
void add(const test_definition& td)
{
test_defs.push_back(td);
}
// List of test definitions
std::vector<test_definition> test_defs;
// Test suite name
const std::string name;
static test_suite& global_test_suite()
{
static test_suite global_test_suite("global");
return global_test_suite;
}
};
namespace detail {
struct test_case_registration
{
test_case_registration(const std::string& name, const basefn ptr)
{
::autotest::test_suite::global_test_suite().add(test_definition({ptr, strdup(name.c_str())}));
}
};
} // end detail namespace
} // end autotest namespace
#endif // TEST_COMMON_AUTOTEST_TEST_SUITE_HPP

View file

@ -1,41 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef TEST_COMMON_CONFIG_HPP
#define TEST_COMMON_CONFIG_HPP
// Enable development options for OpenCL C++ tests (test_conformance/clpp)
// #define DEVELOPMENT
#if defined(CLPP_DEVELOPMENT_OPTIONS) && !defined(DEVELOPMENT)
#define DEVELOPMENT
#endif
#ifdef DEVELOPMENT
// If defined OpenCL C++ tests only checks if OpenCL C++ kernels compiles correctly
// #define ONLY_SPIRV_COMPILATION
#if defined(CLPP_DEVELOPMENT_ONLY_SPIRV_COMPILATION) && !defined(ONLY_SPIRV_COMPILATION)
#define ONLY_SPIRV_COMPILATION
#endif
#ifndef ONLY_SPIRV_COMPILATION
// If defined OpenCL C++ tests are run using OpenCL C kernels
// #define USE_OPENCLC_KERNELS
#if defined(CLPP_DEVELOPMENT_USE_OPENCLC_KERNELS) && !defined(USE_OPENCLC_KERNELS)
#define USE_OPENCLC_KERNELS
#endif
#endif
#endif
#endif // TEST_COMMON_CONFIG_HPP

View file

@ -966,12 +966,13 @@ void reorder_verification_buffer(GLenum glFormat, GLenum glType, char* buffer, s
#ifdef GL_VERSION_3_2
#define check_gl_error() \
{ \
GLenum errnom = GL_NO_ERROR;\
if ((errnom = glGetError()) != GL_NO_ERROR)\
log_error("GL Error: 0x%04X at %s:%d\n", errnom, __FILE__, __LINE__);\
}
#define CHECK_GL_ERROR() \
{ \
GLenum errnom = GL_NO_ERROR; \
if ((errnom = glGetError()) != GL_NO_ERROR) \
log_error("GL Error: 0x%04X at %s:%d\n", errnom, __FILE__, \
__LINE__); \
}
const char *get_gl_vector_type( GLenum internalformat )
{
@ -1045,10 +1046,12 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
// Check if the renderer supports enough samples
GLint max_samples = get_gl_max_samples(target, internalFormat);
check_gl_error()
CHECK_GL_ERROR()
if (max_samples < (GLint)samples)
log_error("GL error: requested samples (%d) exceeds renderer max samples (%d)\n", samples, max_samples);
log_error("GL error: requested samples (%zu) exceeds renderer max "
"samples (%d)\n",
samples, max_samples);
// Setup the GLSL program
const GLchar *vertex_source =
@ -1075,36 +1078,36 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
glShaderWrapper vertex_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex_shader, 1, &vertex_source, NULL);
glCompileShader(vertex_shader);
check_gl_error()
CHECK_GL_ERROR()
glShaderWrapper fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment_shader, 1, &fragment_source, NULL);
glCompileShader(fragment_shader);
check_gl_error()
CHECK_GL_ERROR()
GLuint prog = glCreateProgram();
glAttachShader(prog, vertex_shader);
glAttachShader(prog, fragment_shader);
check_gl_error()
CHECK_GL_ERROR()
glBindAttribLocation(prog, 0, "att0");
glLinkProgram(prog);
check_gl_error()
CHECK_GL_ERROR()
// Setup the FBO and texture
glFramebufferWrapper fbo;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
check_gl_error()
CHECK_GL_ERROR()
glViewport(0, 0, width, height);
check_gl_error()
CHECK_GL_ERROR()
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, internalFormat, width, height, fixedSampleLocations);
check_gl_error()
CHECK_GL_ERROR()
GLint attachment;
switch (internalFormat) {
@ -1122,7 +1125,7 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
}
glFramebufferTexture(GL_FRAMEBUFFER, attachment, tex, 0);
check_gl_error()
CHECK_GL_ERROR()
GLint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status == GL_FRAMEBUFFER_UNSUPPORTED) {
@ -1142,22 +1145,24 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
// Check if the framebuffer supports enough samples
GLint fbo_samples = 0;
glGetIntegerv(GL_SAMPLES, &fbo_samples);
check_gl_error();
CHECK_GL_ERROR();
if (fbo_samples < (GLint)samples)
log_error("GL Error: requested samples (%d) exceeds FBO capability (%d)\n", samples, fbo_samples);
log_error(
"GL Error: requested samples (%zu) exceeds FBO capability (%d)\n",
samples, fbo_samples);
glUseProgram(prog);
check_gl_error()
CHECK_GL_ERROR()
if (attachment != GL_DEPTH_ATTACHMENT && attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
glDisable(GL_DEPTH_TEST);
check_gl_error()
CHECK_GL_ERROR()
}
else {
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
check_gl_error()
CHECK_GL_ERROR()
}
// Setup the VBO for rendering a quad
@ -1172,14 +1177,14 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STREAM_DRAW);
check_gl_error()
CHECK_GL_ERROR()
glVertexArraysWrapper vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*2, 0);
check_gl_error()
CHECK_GL_ERROR()
//clearing color and depth buffer
glClearColor(0, 0, 0, 0);
@ -1223,13 +1228,13 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
color += color_delta;
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
check_gl_error();
CHECK_GL_ERROR();
glFlush();
}
glDisable(GL_SAMPLE_MASK);
check_gl_error();
CHECK_GL_ERROR();
*outTextureID = tex;
@ -1306,7 +1311,9 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
GLint max_samples = get_gl_max_samples(target, internalFormat);
if (max_samples < (GLint)samples)
log_error("GL error: requested samples (%d) exceeds renderer max samples (%d)\n", samples, max_samples);
log_error("GL error: requested samples (%zu) exceeds renderer max "
"samples (%d)\n",
samples, max_samples);
// Setup the GLSL program
const GLchar *vertex_source =
@ -1333,36 +1340,36 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
glShaderWrapper vertex_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex_shader, 1, &vertex_source, NULL);
glCompileShader(vertex_shader);
check_gl_error()
CHECK_GL_ERROR()
glShaderWrapper fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment_shader, 1, &fragment_source, NULL);
glCompileShader(fragment_shader);
check_gl_error()
CHECK_GL_ERROR()
glProgramWrapper prog = glCreateProgram();
glAttachShader(prog, vertex_shader);
glAttachShader(prog, fragment_shader);
check_gl_error()
CHECK_GL_ERROR()
glBindAttribLocation(prog, 0, "att0");
glLinkProgram(prog);
check_gl_error()
CHECK_GL_ERROR()
// Setup the FBO and texture
glFramebufferWrapper fbo;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
check_gl_error()
CHECK_GL_ERROR()
glViewport(0, 0, width, height);
check_gl_error()
CHECK_GL_ERROR()
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex);
glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, samples, internalFormat, width, height, total_layers, fixedSampleLocations);
check_gl_error()
CHECK_GL_ERROR()
GLint attachment;
switch (internalFormat) {
@ -1381,16 +1388,15 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
//calculating colors
double color_delta = 1.0 / (total_layers * samples);
double color = color_delta;
if (attachment != GL_DEPTH_ATTACHMENT && attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
glDisable(GL_DEPTH_TEST);
check_gl_error()
CHECK_GL_ERROR()
}
else {
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
check_gl_error()
CHECK_GL_ERROR()
}
// Setup the VBO for rendering a quad
@ -1405,18 +1411,18 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STREAM_DRAW);
check_gl_error()
CHECK_GL_ERROR()
glVertexArraysWrapper vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*2, 0);
check_gl_error()
CHECK_GL_ERROR()
for (size_t l=0; l!=total_layers; ++l) {
glFramebufferTextureLayer(GL_FRAMEBUFFER, attachment, tex, 0, l);
check_gl_error()
CHECK_GL_ERROR()
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status == GL_FRAMEBUFFER_UNSUPPORTED) {
@ -1436,13 +1442,15 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
// Check if the framebuffer supports enough samples
GLint fbo_samples = 0;
glGetIntegerv(GL_SAMPLES, &fbo_samples);
check_gl_error();
CHECK_GL_ERROR();
if (fbo_samples < (GLint)samples)
log_error("GL Error: requested samples (%d) exceeds FBO capability (%d)\n", samples, fbo_samples);
log_error(
"GL Error: requested samples (%zu) exceeds FBO capability (%d)\n",
samples, fbo_samples);
glUseProgram(prog);
check_gl_error()
CHECK_GL_ERROR()
//clearing color and depth buffer
glClearColor(0, 0, 0, 0);
@ -1483,13 +1491,13 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
glUniform1f(glGetUniformLocation(prog, "depthVal"), val);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
check_gl_error();
CHECK_GL_ERROR();
glFlush();
}
glDisable(GL_SAMPLE_MASK);
check_gl_error();
CHECK_GL_ERROR();
}
*outTextureID = tex;
@ -1716,7 +1724,7 @@ void * CreateGLRenderbuffer( GLsizei width, GLsizei height,
// Reverse and reorder to validate since in the
// kernel the read_imagef() call always returns RGBA
cl_uchar *p = (cl_uchar *)buffer;
for( size_t i = 0; i < (size_t)width * height; i++ )
for (GLsizei i = 0; i < width * height; i++)
{
cl_uchar uc0 = p[i * 4 + 0];
cl_uchar uc1 = p[i * 4 + 1];
@ -1734,7 +1742,7 @@ void * CreateGLRenderbuffer( GLsizei width, GLsizei height,
// Reverse and reorder to validate since in the
// kernel the read_imagef() call always returns RGBA
cl_uchar *p = (cl_uchar *)buffer;
for( size_t i = 0; i < width * height; i++ )
for (GLsizei i = 0; i < width * height; i++)
{
cl_uchar uc0 = p[i * 4 + 0];
cl_uchar uc1 = p[i * 4 + 1];

View file

@ -34,7 +34,6 @@
#include "harness/errorHelpers.h"
#include "harness/kernelHelpers.h"
#include "harness/threadTesting.h"
#include "harness/typeWrappers.h"
#include "harness/conversions.h"
#include "harness/mt19937.h"

View file

@ -19,21 +19,28 @@
class OSXGLEnvironment : public GLEnvironment
{
public:
OSXGLEnvironment()
{
mCGLContext = NULL;
}
private:
bool mIsGlutInit;
public:
OSXGLEnvironment()
{
mCGLContext = NULL;
mIsGlutInit = false;
}
virtual int Init( int *argc, char **argv, int use_opengl_32 )
{
if (!use_opengl_32) {
// Create a GLUT window to render into
glutInit( argc, argv );
glutInitWindowSize( 512, 512 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow( "OpenCL <-> OpenGL Test" );
if (!mIsGlutInit)
{
// Create a GLUT window to render into
glutInit(argc, argv);
glutInitWindowSize(512, 512);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("OpenCL <-> OpenGL Test");
mIsGlutInit = true;
}
}
else {

View file

@ -13,14 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#define GL_GLEXT_PROTOTYPES
#include "setup.h"
#include "testBase.h"
#include "harness/errorHelpers.h"
#include <GL/gl.h>
#include <GL/glut.h>
#include <CL/cl_ext.h>
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(

View file

@ -13,16 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#define GL_GLEXT_PROTOTYPES
#include "setup.h"
#include "testBase.h"
#include "harness/errorHelpers.h"
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include <GL/freeglut.h>
#include <GL/glx.h>
#include <CL/cl_ext.h>
@ -31,20 +26,26 @@ class X11GLEnvironment : public GLEnvironment
private:
cl_device_id m_devices[64];
cl_uint m_device_count;
bool m_glut_init;
public:
X11GLEnvironment()
{
m_device_count = 0;
m_glut_init = false;
}
virtual int Init( int *argc, char **argv, int use_opencl_32 )
{
// Create a GLUT window to render into
glutInit( argc, argv );
glutInitWindowSize( 512, 512 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow( "OpenCL <-> OpenGL Test" );
glewInit();
if (!m_glut_init)
{
glutInit(argc, argv);
glutInitWindowSize(512, 512);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("OpenCL <-> OpenGL Test");
glewInit();
m_glut_init = true;
}
return 0;
}
@ -90,10 +91,17 @@ public:
}
for (int i=0; i<(int)num_of_devices; i++) {
if (!is_extension_available(devices[i], "cl_khr_gl_sharing ")) {
log_info("Device %d of %d does not support required extension cl_khr_gl_sharing.\n", i+1, num_of_devices);
} else {
log_info("Device %d of %d supports required extension cl_khr_gl_sharing.\n", i+1, num_of_devices);
if (!is_extension_available(devices[i], "cl_khr_gl_sharing"))
{
log_info("Device %d of %d does not support required extension "
"cl_khr_gl_sharing.\n",
i + 1, num_of_devices);
}
else
{
log_info("Device %d of %d supports required extension "
"cl_khr_gl_sharing.\n",
i + 1, num_of_devices);
found_valid_device = 1;
m_devices[m_device_count++] = devices[i];
}

View file

@ -22,7 +22,7 @@
{GLint __error = glGetError(); if(__error) {log_error( "GL ERROR: %s!\n", gluErrorString( err ));}}
#if defined(__linux__) || defined(GL_ES_VERSION_2_0)
// On linux we dont link to GLU library to avoid comaptibility issues with
// On linux we don't link to GLU library to avoid compatibility issues with
// libstdc++
// FIXME: Implement this
const GLubyte* gluErrorString (GLenum error)
@ -271,8 +271,6 @@ void * ReadGLTexture( GLenum glTarget, GLuint glTexture,
// Read results from the GL texture
glBindTexture(get_base_gl_target(glTarget), glTexture);
GLint realWidth, realHeight;
GLint realInternalFormat;
GLenum readBackFormat = GL_RGBA;
GLenum readBackType = glType;
glFramebufferWrapper glFramebuffer;
@ -301,7 +299,7 @@ void * ReadGLTexture( GLenum glTarget, GLuint glTexture,
GetGLFormatName(readBackFormat),
GetGLTypeName(readBackType));
DumpGLBuffer(readBackType, realWidth, realHeight, (void*)outBuffer);
DumpGLBuffer(readBackType, outWidth, outHeight, (void *)outBuffer);
#endif

View file

@ -30,15 +30,13 @@
#if !defined (__APPLE__)
#include <CL/cl.h>
#include "gl_headers.h"
#include <CL/cl_gl.h>
#else
#include "gl_headers.h"
#include <CL/cl_half.h>
#endif
#include "gl_headers.h"
#include "harness/errorHelpers.h"
#include "harness/kernelHelpers.h"
#include "harness/threadTesting.h"
#include "harness/typeWrappers.h"
#include "harness/conversions.h"
#include "harness/mt19937.h"

View file

@ -22,6 +22,9 @@
#if defined(__APPLE__) || defined(__linux__) || defined(_WIN32)
// or any other POSIX system
#include <atomic>
#include <vector>
#if defined(_WIN32)
#include <windows.h>
#if defined(_MSC_VER)
@ -30,9 +33,9 @@
#include "mingw_compat.h"
#include <process.h>
#else // !_WIN32
#include <errno.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/errno.h>
#ifdef __linux__
#include <sched.h>
#endif
@ -56,6 +59,12 @@ CRITICAL_SECTION gAtomicLock;
pthread_mutex_t gAtomicLock;
#endif
#if !defined(_WIN32)
// Keep track of pthread_t's created in ThreadPool_Init() so they can be joined
// in ThreadPool_Exit() and avoid thread leaks.
static std::vector<pthread_t> pthreads;
#endif
// Atomic add operator with mem barrier. Mem barrier needed to protect state
// modified by the worker functions.
cl_int ThreadPool_AtomicAdd(volatile cl_int *a, cl_int b)
@ -241,7 +250,7 @@ pthread_cond_t cond_var;
// Condition variable state. How many iterations on the function left to run,
// set to CL_INT_MAX to cause worker threads to exit. Note: this value might
// go negative.
volatile cl_int gRunCount = 0;
std::atomic<cl_int> gRunCount{ 0 };
// State that only changes when the threadpool is not working.
volatile TPFuncPtr gFunc_ptr = NULL;
@ -261,19 +270,20 @@ pthread_cond_t caller_cond_var;
// # of threads intended to be running. Running threads will decrement this
// as they discover they've run out of work to do.
volatile cl_int gRunning = 0;
std::atomic<cl_int> gRunning{ 0 };
// The total number of threads launched.
volatile cl_int gThreadCount = 0;
std::atomic<cl_int> gThreadCount{ 0 };
#ifdef _WIN32
void ThreadPool_WorkerFunc(void *p)
#else
void *ThreadPool_WorkerFunc(void *p)
#endif
{
cl_uint threadID = ThreadPool_AtomicAdd((volatile cl_int *)p, 1);
cl_int item = ThreadPool_AtomicAdd(&gRunCount, -1);
// log_info( "ThreadPool_WorkerFunc start: gRunning = %d\n", gRunning );
auto &tid = *static_cast<std::atomic<cl_uint> *>(p);
cl_uint threadID = tid++;
cl_int item = gRunCount--;
while (MAX_COUNT > item)
{
@ -282,8 +292,6 @@ void *ThreadPool_WorkerFunc(void *p)
// check for more work to do
if (0 >= item)
{
// log_info("Thread %d has run out of work.\n", threadID);
// No work to do. Attempt to block waiting for work
#if defined(_WIN32)
EnterCriticalSection(cond_lock);
@ -298,9 +306,7 @@ void *ThreadPool_WorkerFunc(void *p)
}
#endif // !_WIN32
cl_int remaining = ThreadPool_AtomicAdd(&gRunning, -1);
// log_info("ThreadPool_WorkerFunc: gRunning = %d\n",
// remaining - 1);
cl_int remaining = gRunning--;
if (1 == remaining)
{ // last thread out signal the main thread to wake up
#if defined(_WIN32)
@ -350,7 +356,7 @@ void *ThreadPool_WorkerFunc(void *p)
#endif // !_WIN32
// try again to get a valid item id
item = ThreadPool_AtomicAdd(&gRunCount, -1);
item = gRunCount--;
if (MAX_COUNT <= item) // exit if we are done
{
#if defined(_WIN32)
@ -362,8 +368,7 @@ void *ThreadPool_WorkerFunc(void *p)
}
}
ThreadPool_AtomicAdd(&gRunning, 1);
// log_info("Thread %d has found work.\n", threadID);
gRunning++;
#if defined(_WIN32)
LeaveCriticalSection(cond_lock);
@ -447,12 +452,12 @@ void *ThreadPool_WorkerFunc(void *p)
}
// get the next item
item = ThreadPool_AtomicAdd(&gRunCount, -1);
item = gRunCount--;
}
exit:
log_info("ThreadPool: thread %d exiting.\n", threadID);
ThreadPool_AtomicAdd(&gThreadCount, -1);
gThreadCount--;
#if !defined(_WIN32)
return NULL;
#endif
@ -487,7 +492,7 @@ void ThreadPool_Init(void)
{
cl_int i;
int err;
volatile cl_uint threadID = 0;
std::atomic<cl_uint> threadID{ 0 };
// Check for manual override of multithreading code. We add this for better
// debuggability.
@ -523,7 +528,7 @@ void ThreadPool_Init(void)
{
// Count the number of bits in ProcessorMask (number of
// logical cores)
ULONG mask = ptr->ProcessorMask;
ULONG_PTR mask = ptr->ProcessorMask;
while (mask)
{
++gThreadCount;
@ -624,7 +629,7 @@ void ThreadPool_Init(void)
}
#endif // !_WIN32
gRunning = gThreadCount;
gRunning = gThreadCount.load();
// init threads
for (i = 0; i < gThreadCount; i++)
{
@ -644,6 +649,9 @@ void ThreadPool_Init(void)
gThreadCount = i;
break;
}
#if !defined(_WIN32)
pthreads.push_back(tid);
#endif // !_WIN32
}
atexit(ThreadPool_Exit);
@ -688,7 +696,6 @@ static BOOL CALLBACK _ThreadPool_Init(_PINIT_ONCE InitOnce, PVOID Parameter,
void ThreadPool_Exit(void)
{
int err, count;
gRunCount = CL_INT_MAX;
#if defined(__GNUC__)
@ -702,13 +709,13 @@ void ThreadPool_Exit(void)
#endif
// spin waiting for threads to die
for (count = 0; 0 != gThreadCount && count < 1000; count++)
for (int count = 0; 0 != gThreadCount && count < 1000; count++)
{
#if defined(_WIN32)
_WakeAllConditionVariable(cond_var);
Sleep(1);
#else // !_WIN32
if ((err = pthread_cond_broadcast(&cond_var)))
if (int err = pthread_cond_broadcast(&cond_var))
{
log_error("Error %d from pthread_cond_broadcast. Unable to wake up "
"work threads. ThreadPool_Exit failed.\n",
@ -722,9 +729,22 @@ void ThreadPool_Exit(void)
if (gThreadCount)
log_error("Error: Thread pool timed out after 1 second with %d threads "
"still active.\n",
gThreadCount);
gThreadCount.load());
else
{
#if !defined(_WIN32)
for (pthread_t pthread : pthreads)
{
if (int err = pthread_join(pthread, nullptr))
{
log_error("Error from %d from pthread_join. Unable to join "
"work threads. ThreadPool_Exit failed.\n",
err);
}
}
#endif
log_info("Thread pool exited in a orderly fashion.\n");
}
}
@ -738,7 +758,9 @@ void ThreadPool_Exit(void)
// all available then it would make more sense to use those features.
cl_int ThreadPool_Do(TPFuncPtr func_ptr, cl_uint count, void *userInfo)
{
#ifndef _WIN32
cl_int newErr;
#endif
cl_int err = 0;
// Lazily set up our threads
#if defined(_MSC_VER) && (_WIN32_WINNT >= 0x600)
@ -913,7 +935,9 @@ cl_int ThreadPool_Do(TPFuncPtr func_ptr, cl_uint count, void *userInfo)
err = jobError;
#ifndef _WIN32
exit:
#endif
// exit critical region
#if defined(_WIN32)
LeaveCriticalSection(gThreadPoolLock);

View file

@ -0,0 +1,121 @@
//
// Copyright (c) 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "alloc.h"
#include "errorHelpers.h"
#include "testHarness.h"
#if defined(linux) || defined(__linux__) || defined(__ANDROID__)
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
#include <linux/dma-heap.h>
struct dma_buf_heap_helper_t
{
dma_buf_heap_type heap_type;
const char* env_var = nullptr;
const char* default_path = nullptr;
constexpr dma_buf_heap_helper_t(dma_buf_heap_type heap_type,
const char* env_var,
const char* default_path)
: heap_type(heap_type), env_var(env_var), default_path(default_path)
{}
};
constexpr dma_buf_heap_helper_t DMA_BUF_HEAP_TABLE[] = {
{ dma_buf_heap_type::SYSTEM, "OCL_CTS_DMA_HEAP_PATH_SYSTEM",
"/dev/dma_heap/system" },
};
static dma_buf_heap_helper_t lookup_dma_heap(dma_buf_heap_type heap_type)
{
for (const auto& entry : DMA_BUF_HEAP_TABLE)
{
if (heap_type == entry.heap_type)
{
return entry;
}
}
assert(false
&& "DMA heap type does not have an entry in DMA_BUF_HEAP_TABLE");
return DMA_BUF_HEAP_TABLE[0];
}
#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
constexpr int DMA_HEAP_FLAGS = O_RDWR | O_CLOEXEC;
const auto entry = lookup_dma_heap(heap_type);
const auto override_path = getenv(entry.env_var);
const auto dma_heap_path =
(override_path == nullptr) ? entry.default_path : override_path;
const int dma_heap_fd = open(dma_heap_path, DMA_HEAP_FLAGS);
if (dma_heap_fd == -1)
{
log_error(
"Opening the DMA heap device: %s failed with error: %d (%s)\n",
dma_heap_path, errno, strerror(errno));
return TEST_SKIPPED_ITSELF;
}
dma_heap_allocation_data dma_heap_data = { 0 };
dma_heap_data.len = size;
dma_heap_data.fd_flags = O_RDWR | O_CLOEXEC;
int result = ioctl(dma_heap_fd, DMA_HEAP_IOCTL_ALLOC, &dma_heap_data);
if (result != 0)
{
log_error("DMA heap allocation IOCTL call failed, error: %d\n", result);
close(dma_heap_fd);
return -1;
}
result = close(dma_heap_fd);
if (result == -1)
{
log_info("Failed to close the DMA heap device: %s\n", dma_heap_path);
}
return dma_heap_data.fd;
#else
return TEST_SKIPPED_ITSELF;
#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
}
#else
int allocate_dma_buf(uint64_t size, dma_buf_heap_type heap_type)
{
log_error(
"OS doesn't have DMA buffer heaps (only Linux and Android do).\n");
return TEST_SKIPPED_ITSELF;
}
#endif // defined(linux) || defined(__linux__) || defined(__ANDROID__)

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2020 The Khronos Group Inc.
// Copyright (c) 2020 - 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -24,12 +24,17 @@
#include <stdlib.h>
#endif
#endif
#include <stdint.h>
#if defined(__MINGW32__)
#include "mingw_compat.h"
#endif
static void* align_malloc(size_t size, size_t alignment)
#if defined(_WIN32)
#include <cstdlib>
#endif
inline void* align_malloc(size_t size, size_t alignment)
{
#if defined(_WIN32) && defined(_MSC_VER)
return _aligned_malloc(size, alignment);
@ -53,7 +58,7 @@ static void* align_malloc(size_t size, size_t alignment)
#endif
}
static void align_free(void* ptr)
inline void align_free(void* ptr)
{
#if defined(_WIN32) && defined(_MSC_VER)
_aligned_free(ptr);
@ -66,4 +71,36 @@ static void align_free(void* ptr)
#endif
}
enum class dma_buf_heap_type
{
SYSTEM
};
/**
* @brief Allocate a DMA buffer.
*
* On systems that support it, use the DMA buffer heaps to allocate a DMA buffer
* of the requested size, using the requested heap type. The heap type defaults
* to using the system heap if no type is specified.
*
* A heap type will use a default path if one exists, and can be overriden using
* an environment variable for each type, as follows:
*
* SYSTEM:
* * Default path: /dev/dma_heap/system
* * Environment variable: OCL_CTS_DMA_HEAP_PATH_SYSTEM
*
* DMA buffer heaps require a minimum Linux kernel version 5.6. A compile-time
* warning is issued on older systems, as well as an error message at runtime.
*
* @param size [in] The requested buffer size in bytes.
* @param heap_type [in,opt] The heap type to use for the allocation.
*
* @retrun A file descriptor representing the allocated DMA buffer on success,
* -1 otherwise. Failure to open the DMA device returns TEST_SKIPPED_ITSELF so
* it can be handled separately to other failures.
*/
int allocate_dma_buf(uint64_t size,
dma_buf_heap_type heap_type = dma_buf_heap_type::SYSTEM);
#endif // #ifndef HARNESS_ALLOC_H_

View file

@ -13,18 +13,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef _COMPAT_H_
#define _COMPAT_H_
#ifndef COMPAT_H_
#define COMPAT_H_
#if defined(_WIN32) && defined(_MSC_VER)
#include <Windows.h>
#endif
#else
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
#endif
//
@ -116,6 +116,15 @@ int feclearexcept(int excepts);
#include <math.h>
#endif
#ifdef __cplusplus
#include <cmath>
extern "C" {
using std::isfinite;
using std::isinf;
using std::isnan;
}
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288
#endif
@ -138,18 +147,6 @@ extern "C" {
#define INFINITY (FLT_MAX + FLT_MAX)
#endif
#ifndef isfinite
#define isfinite(x) _finite(x)
#endif
#ifndef isnan
#define isnan(x) ((x) != (x))
#endif
#ifndef isinf
#define isinf(_x) ((_x) == INFINITY || (_x) == -INFINITY)
#endif
#if _MSC_VER < 1900 && !defined(__INTEL_COMPILER)
double rint(double x);
@ -309,13 +306,6 @@ EXTERN_C int __builtin_clz(unsigned int pattern);
#endif
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
/*-----------------------------------------------------------------------------
WARNING: DO NOT USE THESE MACROS:
@ -405,4 +395,4 @@ EXTERN_C int __builtin_clz(unsigned int pattern);
#define sleep(sec) Sleep((sec)*1000)
#endif
#endif // _COMPAT_H_
#endif // COMPAT_H_

View file

@ -14,12 +14,15 @@
// limitations under the License.
//
#include "conversions.h"
#include <cinttypes>
#include <limits.h>
#include <time.h>
#include <assert.h>
#include "mt19937.h"
#include "compat.h"
#include <CL/cl_half.h>
#if defined(__SSE__) || defined(_MSC_VER)
#include <xmmintrin.h>
#endif
@ -50,10 +53,10 @@ void print_type_to_string(ExplicitType type, void *data, char *string)
case kInt: sprintf(string, "%d", *((cl_int *)data)); return;
case kUInt:
case kUnsignedInt: sprintf(string, "%u", *((cl_uint *)data)); return;
case kLong: sprintf(string, "%lld", *((cl_long *)data)); return;
case kLong: sprintf(string, "%" PRId64 "", *((cl_long *)data)); return;
case kULong:
case kUnsignedLong:
sprintf(string, "%llu", *((cl_ulong *)data));
sprintf(string, "%" PRIu64 "", *((cl_ulong *)data));
return;
case kFloat: sprintf(string, "%f", *((cl_float *)data)); return;
case kHalf: sprintf(string, "half"); return;
@ -181,8 +184,8 @@ static ULong sUpperLimits[kNumExplicitTypes] = {
0xffffffffLL,
0xffffffffLL,
0x7fffffffffffffffLL,
0xffffffffffffffffLL,
0xffffffffffffffffLL,
0xffffffffffffffffULL,
0xffffffffffffffffULL,
0,
0
}; // Last two values aren't stored here
@ -260,6 +263,12 @@ static Long sLowerLimits[kNumExplicitTypes] = {
} \
break;
#define TO_HALF_CASE(inType, halfRoundingMode) \
case kHalf: \
halfPtr = (cl_half *)outRaw; \
*halfPtr = \
cl_half_from_float((float)(*inType##Ptr), halfRoundingMode); \
break;
#define TO_FLOAT_CASE(inType) \
case kFloat: \
floatPtr = (float *)outRaw; \
@ -280,6 +289,59 @@ static Long sLowerLimits[kNumExplicitTypes] = {
*outType##Ptr = (outType)lrintf_clamped(*floatPtr); \
break;
#define HALF_ROUND_CASE(outEnum, outType, rounding, sat) \
case outEnum: { \
outType##Ptr = (outType *)outRaw; \
/* Get the tens digit */ \
float fltEq = (Long)cl_half_to_float(*halfPtr); \
Long wholeValue = (Long)fltEq; \
float largeRemainder = (fltEq - (float)wholeValue) * 10.f; \
/* What do we do based on that? */ \
if (rounding == kRoundToEven) \
{ \
if (wholeValue & 1LL) /*between 1 and 1.99 */ \
wholeValue += 1LL; /* round up to even */ \
} \
else if (rounding == kRoundToZero) \
{ \
/* Nothing to do, round-to-zero is what C casting does */ \
} \
else if (rounding == kRoundToPosInf) \
{ \
/* Only positive numbers are wrong */ \
if (largeRemainder != 0.f && wholeValue >= 0) wholeValue++; \
} \
else if (rounding == kRoundToNegInf) \
{ \
/* Only negative numbers are off */ \
if (largeRemainder != 0.f && wholeValue < 0) wholeValue--; \
} \
else \
{ /* Default is round-to-nearest */ \
wholeValue = (Long)lrintf_clamped(fltEq); \
} \
/* Now apply saturation rules */ \
if (sat) \
{ \
if ((sLowerLimits[outEnum] < 0 \
&& wholeValue > (Long)sUpperLimits[outEnum]) \
|| (sLowerLimits[outEnum] == 0 \
&& (ULong)wholeValue > sUpperLimits[outEnum])) \
*outType##Ptr = (outType)sUpperLimits[outEnum]; \
else if (wholeValue < sLowerLimits[outEnum]) \
*outType##Ptr = (outType)sLowerLimits[outEnum]; \
else \
*outType##Ptr = (outType)wholeValue; \
} \
else \
{ \
*outType##Ptr = (outType)( \
wholeValue \
& (0xffffffffffffffffLL >> (64 - (sizeof(outType) * 8)))); \
} \
} \
break;
#define FLOAT_ROUND_CASE(outEnum, outType, rounding, sat) \
case outEnum: { \
outType##Ptr = (outType *)outRaw; \
@ -385,16 +447,18 @@ static Long sLowerLimits[kNumExplicitTypes] = {
break;
typedef unsigned char uchar;
typedef signed char schar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
bool saturate, RoundingType roundType,
cl_half_rounding_mode halfRoundingMode,
ExplicitType outType)
{
bool *boolPtr;
char *charPtr;
schar *scharPtr;
uchar *ucharPtr;
short *shortPtr;
ushort *ushortPtr;
@ -402,6 +466,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
uint *uintPtr;
Long *LongPtr;
ULong *ULongPtr;
cl_half *halfPtr;
float *floatPtr;
double *doublePtr;
@ -432,6 +497,11 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
get_explicit_type_size(outType));
break;
case kHalf:
halfPtr = (cl_half *)outRaw;
*halfPtr =
(*boolPtr) ? cl_half_from_float(-1.f, CL_HALF_RTE) : 0;
break;
case kFloat:
floatPtr = (float *)outRaw;
*floatPtr = (*boolPtr) ? -1.f : 0.f;
@ -448,29 +518,30 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
break;
case kChar:
charPtr = (char *)inRaw;
scharPtr = (schar *)inRaw;
switch (outType)
{
BOOL_CASE(char)
BOOL_CASE(schar)
case kChar:
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(char, kUChar, uchar, saturate)
SIMPLE_CAST_CASE(char, kUnsignedChar, uchar)
SIMPLE_CAST_CASE(char, kShort, short)
SIMPLE_CAST_CASE(char, kUShort, ushort)
SIMPLE_CAST_CASE(char, kUnsignedShort, ushort)
SIMPLE_CAST_CASE(char, kInt, int)
SIMPLE_CAST_CASE(char, kUInt, uint)
SIMPLE_CAST_CASE(char, kUnsignedInt, uint)
SIMPLE_CAST_CASE(char, kLong, Long)
SIMPLE_CAST_CASE(char, kULong, ULong)
SIMPLE_CAST_CASE(char, kUnsignedLong, ULong)
DOWN_CAST_CASE(schar, kUChar, uchar, saturate)
SIMPLE_CAST_CASE(schar, kUnsignedChar, uchar)
SIMPLE_CAST_CASE(schar, kShort, short)
SIMPLE_CAST_CASE(schar, kUShort, ushort)
SIMPLE_CAST_CASE(schar, kUnsignedShort, ushort)
SIMPLE_CAST_CASE(schar, kInt, int)
SIMPLE_CAST_CASE(schar, kUInt, uint)
SIMPLE_CAST_CASE(schar, kUnsignedInt, uint)
SIMPLE_CAST_CASE(schar, kLong, Long)
SIMPLE_CAST_CASE(schar, kULong, ULong)
SIMPLE_CAST_CASE(schar, kUnsignedLong, ULong)
TO_FLOAT_CASE(char)
TO_DOUBLE_CASE(char)
TO_HALF_CASE(schar, halfRoundingMode)
TO_FLOAT_CASE(schar)
TO_DOUBLE_CASE(schar)
default:
log_error("ERROR: Invalid type given to "
@ -490,7 +561,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(uchar, kChar, char, saturate)
DOWN_CAST_CASE(uchar, kChar, schar, saturate)
SIMPLE_CAST_CASE(uchar, kShort, short)
SIMPLE_CAST_CASE(uchar, kUShort, ushort)
SIMPLE_CAST_CASE(uchar, kUnsignedShort, ushort)
@ -501,6 +572,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(uchar, kULong, ULong)
SIMPLE_CAST_CASE(uchar, kUnsignedLong, ULong)
TO_HALF_CASE(uchar, halfRoundingMode)
TO_FLOAT_CASE(uchar)
TO_DOUBLE_CASE(uchar)
@ -522,7 +594,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(uchar, kChar, char, saturate)
DOWN_CAST_CASE(uchar, kChar, schar, saturate)
SIMPLE_CAST_CASE(uchar, kShort, short)
SIMPLE_CAST_CASE(uchar, kUShort, ushort)
SIMPLE_CAST_CASE(uchar, kUnsignedShort, ushort)
@ -533,6 +605,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(uchar, kULong, ULong)
SIMPLE_CAST_CASE(uchar, kUnsignedLong, ULong)
TO_HALF_CASE(uchar, halfRoundingMode)
TO_FLOAT_CASE(uchar)
TO_DOUBLE_CASE(uchar)
@ -553,7 +626,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(short, kChar, char, saturate)
DOWN_CAST_CASE(short, kChar, schar, saturate)
DOWN_CAST_CASE(short, kUChar, uchar, saturate)
DOWN_CAST_CASE(short, kUnsignedChar, uchar, saturate)
DOWN_CAST_CASE(short, kUShort, ushort, saturate)
@ -565,6 +638,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(short, kULong, ULong)
SIMPLE_CAST_CASE(short, kUnsignedLong, ULong)
TO_HALF_CASE(short, halfRoundingMode)
TO_FLOAT_CASE(short)
TO_DOUBLE_CASE(short)
@ -586,7 +660,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(ushort, kChar, char, saturate)
DOWN_CAST_CASE(ushort, kChar, schar, saturate)
DOWN_CAST_CASE(ushort, kUChar, uchar, saturate)
DOWN_CAST_CASE(ushort, kUnsignedChar, uchar, saturate)
DOWN_CAST_CASE(ushort, kShort, short, saturate)
@ -597,6 +671,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(ushort, kULong, ULong)
SIMPLE_CAST_CASE(ushort, kUnsignedLong, ULong)
TO_HALF_CASE(ushort, halfRoundingMode)
TO_FLOAT_CASE(ushort)
TO_DOUBLE_CASE(ushort)
@ -618,7 +693,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(ushort, kChar, char, saturate)
DOWN_CAST_CASE(ushort, kChar, schar, saturate)
DOWN_CAST_CASE(ushort, kUChar, uchar, saturate)
DOWN_CAST_CASE(ushort, kUnsignedChar, uchar, saturate)
DOWN_CAST_CASE(ushort, kShort, short, saturate)
@ -629,6 +704,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(ushort, kULong, ULong)
SIMPLE_CAST_CASE(ushort, kUnsignedLong, ULong)
TO_HALF_CASE(ushort, halfRoundingMode)
TO_FLOAT_CASE(ushort)
TO_DOUBLE_CASE(ushort)
@ -649,7 +725,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(int, kChar, char, saturate)
DOWN_CAST_CASE(int, kChar, schar, saturate)
DOWN_CAST_CASE(int, kUChar, uchar, saturate)
DOWN_CAST_CASE(int, kUnsignedChar, uchar, saturate)
DOWN_CAST_CASE(int, kShort, short, saturate)
@ -661,6 +737,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(int, kULong, ULong)
SIMPLE_CAST_CASE(int, kUnsignedLong, ULong)
TO_HALF_CASE(int, halfRoundingMode)
TO_FLOAT_CASE(int)
TO_DOUBLE_CASE(int)
@ -682,7 +759,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(uint, kChar, char, saturate)
DOWN_CAST_CASE(uint, kChar, schar, saturate)
DOWN_CAST_CASE(uint, kUChar, uchar, saturate)
DOWN_CAST_CASE(uint, kUnsignedChar, uchar, saturate)
DOWN_CAST_CASE(uint, kShort, short, saturate)
@ -693,6 +770,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(uint, kULong, ULong)
SIMPLE_CAST_CASE(uint, kUnsignedLong, ULong)
TO_HALF_CASE(uint, halfRoundingMode)
TO_FLOAT_CASE(uint)
TO_DOUBLE_CASE(uint)
@ -714,7 +792,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(uint, kChar, char, saturate)
DOWN_CAST_CASE(uint, kChar, schar, saturate)
DOWN_CAST_CASE(uint, kUChar, uchar, saturate)
DOWN_CAST_CASE(uint, kUnsignedChar, uchar, saturate)
DOWN_CAST_CASE(uint, kShort, short, saturate)
@ -725,6 +803,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
SIMPLE_CAST_CASE(uint, kULong, ULong)
SIMPLE_CAST_CASE(uint, kUnsignedLong, ULong)
TO_HALF_CASE(uint, halfRoundingMode)
TO_FLOAT_CASE(uint)
TO_DOUBLE_CASE(uint)
@ -745,7 +824,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
DOWN_CAST_CASE(Long, kChar, char, saturate)
DOWN_CAST_CASE(Long, kChar, schar, saturate)
DOWN_CAST_CASE(Long, kUChar, uchar, saturate)
DOWN_CAST_CASE(Long, kUnsignedChar, uchar, saturate)
DOWN_CAST_CASE(Long, kShort, short, saturate)
@ -757,6 +836,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
DOWN_CAST_CASE(Long, kULong, ULong, saturate)
DOWN_CAST_CASE(Long, kUnsignedLong, ULong, saturate)
TO_HALF_CASE(Long, halfRoundingMode)
TO_FLOAT_CASE(Long)
TO_DOUBLE_CASE(Long)
@ -778,7 +858,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
U_DOWN_CAST_CASE(ULong, kChar, char, saturate)
U_DOWN_CAST_CASE(ULong, kChar, schar, saturate)
U_DOWN_CAST_CASE(ULong, kUChar, uchar, saturate)
U_DOWN_CAST_CASE(ULong, kUnsignedChar, uchar, saturate)
U_DOWN_CAST_CASE(ULong, kShort, short, saturate)
@ -789,6 +869,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
U_DOWN_CAST_CASE(ULong, kUnsignedInt, uint, saturate)
U_DOWN_CAST_CASE(ULong, kLong, Long, saturate)
TO_HALF_CASE(ULong, halfRoundingMode)
TO_FLOAT_CASE(ULong)
TO_DOUBLE_CASE(ULong)
@ -810,7 +891,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
U_DOWN_CAST_CASE(ULong, kChar, char, saturate)
U_DOWN_CAST_CASE(ULong, kChar, schar, saturate)
U_DOWN_CAST_CASE(ULong, kUChar, uchar, saturate)
U_DOWN_CAST_CASE(ULong, kUnsignedChar, uchar, saturate)
U_DOWN_CAST_CASE(ULong, kShort, short, saturate)
@ -821,6 +902,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
U_DOWN_CAST_CASE(ULong, kUnsignedInt, uint, saturate)
U_DOWN_CAST_CASE(ULong, kLong, Long, saturate)
TO_HALF_CASE(ULong, halfRoundingMode)
TO_FLOAT_CASE(ULong)
TO_DOUBLE_CASE(ULong)
@ -831,13 +913,52 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
}
break;
case kHalf:
halfPtr = (cl_half *)inRaw;
switch (outType)
{
BOOL_CASE(half)
HALF_ROUND_CASE(kChar, schar, roundType, saturate)
HALF_ROUND_CASE(kUChar, uchar, roundType, saturate)
HALF_ROUND_CASE(kUnsignedChar, uchar, roundType, saturate)
HALF_ROUND_CASE(kShort, short, roundType, saturate)
HALF_ROUND_CASE(kUShort, ushort, roundType, saturate)
HALF_ROUND_CASE(kUnsignedShort, ushort, roundType, saturate)
HALF_ROUND_CASE(kInt, int, roundType, saturate)
HALF_ROUND_CASE(kUInt, uint, roundType, saturate)
HALF_ROUND_CASE(kUnsignedInt, uint, roundType, saturate)
HALF_ROUND_CASE(kLong, Long, roundType, saturate)
HALF_ROUND_CASE(kULong, ULong, roundType, saturate)
HALF_ROUND_CASE(kUnsignedLong, ULong, roundType, saturate)
case kHalf:
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
case kFloat:
floatPtr = (float *)outRaw;
*floatPtr = cl_half_to_float(*halfPtr);
break;
case kDouble:
doublePtr = (double *)outRaw;
*doublePtr = cl_half_to_float(*halfPtr);
break;
default:
log_error("ERROR: Invalid type given to "
"convert_explicit_value!!\n");
break;
}
break;
case kFloat:
floatPtr = (float *)inRaw;
switch (outType)
{
BOOL_CASE(float)
FLOAT_ROUND_CASE(kChar, char, roundType, saturate)
FLOAT_ROUND_CASE(kChar, schar, roundType, saturate)
FLOAT_ROUND_CASE(kUChar, uchar, roundType, saturate)
FLOAT_ROUND_CASE(kUnsignedChar, uchar, roundType, saturate)
FLOAT_ROUND_CASE(kShort, short, roundType, saturate)
@ -850,6 +971,8 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
FLOAT_ROUND_CASE(kULong, ULong, roundType, saturate)
FLOAT_ROUND_CASE(kUnsignedLong, ULong, roundType, saturate)
TO_HALF_CASE(float, halfRoundingMode)
case kFloat:
memcpy(outRaw, inRaw, get_explicit_type_size(inType));
break;
@ -869,7 +992,7 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
{
BOOL_CASE(double)
DOUBLE_ROUND_CASE(kChar, char, roundType, saturate)
DOUBLE_ROUND_CASE(kChar, schar, roundType, saturate)
DOUBLE_ROUND_CASE(kUChar, uchar, roundType, saturate)
DOUBLE_ROUND_CASE(kUnsignedChar, uchar, roundType, saturate)
DOUBLE_ROUND_CASE(kShort, short, roundType, saturate)
@ -882,6 +1005,8 @@ void convert_explicit_value(void *inRaw, void *outRaw, ExplicitType inType,
DOUBLE_ROUND_CASE(kULong, ULong, roundType, saturate)
DOUBLE_ROUND_CASE(kUnsignedLong, ULong, roundType, saturate)
TO_HALF_CASE(double, halfRoundingMode)
TO_FLOAT_CASE(double);
case kDouble:

View file

@ -25,6 +25,8 @@
#include <string.h>
#include <sys/types.h>
#include <CL/cl_half.h>
/* Note: the next three all have to match in size and order!! */
enum ExplicitTypes
@ -71,6 +73,7 @@ extern const char *get_explicit_type_name(ExplicitType type);
extern void convert_explicit_value(void *inRaw, void *outRaw,
ExplicitType inType, bool saturate,
RoundingType roundType,
cl_half_rounding_mode halfRoundingMode,
ExplicitType outType);
extern void generate_random_data(ExplicitType type, size_t count, MTdata d,

View file

@ -1,22 +1,21 @@
/******************************************************************
Copyright (c) 2016 The Khronos Group Inc.
All Rights Reserved. This code is protected by copyright laws and
contains material proprietary to the Khronos Group, Inc.
This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed
in whole or in part to third parties, and may not be reproduced, republished,
distributed, transmitted, displayed, broadcast or otherwise exploited in any
manner without the express prior written permission of Khronos Group.
//
// Copyright (c) 2016-2023 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
The receipt or possession of this code does not convey any rights to
reproduce, disclose, or distribute its contents, or to
manufacture, use, or sell anything that it may describe, in whole
or in part other than under the terms of the Khronos Adopters
Agreement or Khronos Conformance Test Source License Agreement as
executed between Khronos and the recipient.
******************************************************************/
#ifndef _CRC32_H_
#define _CRC32_H_
#ifndef CRC32_H_
#define CRC32_H_
#include <stdint.h>
#include <stddef.h>

View file

@ -63,6 +63,40 @@ int is_extension_available(cl_device_id device, const char *extensionName)
return false;
}
cl_version get_extension_version(cl_device_id device, const char *extensionName)
{
cl_int err;
size_t size;
err = clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS_WITH_VERSION, 0, nullptr,
&size);
if (err != CL_SUCCESS)
{
throw std::runtime_error("clGetDeviceInfo(CL_DEVICE_EXTENSIONS_WITH_"
"VERSION) failed to return size\n");
}
std::vector<cl_name_version> extensions(size / sizeof(cl_name_version));
err = clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS_WITH_VERSION, size,
extensions.data(), &size);
if (err != CL_SUCCESS)
{
throw std::runtime_error("clGetDeviceInfo(CL_DEVICE_EXTENSIONS_WITH_"
"VERSION) failed to return value\n");
}
for (auto &ext : extensions)
{
if (!strcmp(extensionName, ext.name))
{
return ext.version;
}
}
throw std::runtime_error("Extension " + std::string(extensionName)
+ " not supported by device!");
}
/* Returns a string containing the supported extensions list for a device. */
std::string get_device_extensions_string(cl_device_id device)
{
@ -86,3 +120,54 @@ std::string get_device_name(cl_device_id device)
{
return get_device_info_string(device, CL_DEVICE_NAME);
}
size_t get_max_param_size(cl_device_id device)
{
size_t ret(0);
if (clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(ret), &ret,
nullptr)
!= CL_SUCCESS)
{
throw std::runtime_error("clGetDeviceInfo failed\n");
}
return ret;
}
static cl_ulong get_device_info_max_size(cl_device_id device,
cl_device_info info,
unsigned int divisor)
{
cl_ulong max_size;
if (divisor == 0)
{
throw std::runtime_error("Allocation divisor should not be 0\n");
}
if (clGetDeviceInfo(device, info, sizeof(max_size), &max_size, NULL)
!= CL_SUCCESS)
{
throw std::runtime_error("clGetDeviceInfo failed\n");
}
return max_size / divisor;
}
cl_ulong get_device_info_max_mem_alloc_size(cl_device_id device,
unsigned int divisor)
{
return get_device_info_max_size(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
divisor);
}
cl_ulong get_device_info_global_mem_size(cl_device_id device,
unsigned int divisor)
{
return get_device_info_max_size(device, CL_DEVICE_GLOBAL_MEM_SIZE, divisor);
}
cl_ulong get_device_info_max_constant_buffer_size(cl_device_id device,
unsigned int divisor)
{
return get_device_info_max_size(device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,
divisor);
}

View file

@ -16,9 +16,6 @@
#ifndef _deviceInfo_h
#define _deviceInfo_h
// Configuration
#include "../config.hpp"
#include <string>
#include <CL/opencl.h>
@ -31,6 +28,11 @@ std::string get_device_info_string(cl_device_id device,
/* Determines if an extension is supported by a device. */
int is_extension_available(cl_device_id device, const char *extensionName);
/* Returns the version of the extension the device supports or throws an
* exception if the extension is not supported by the device. */
cl_version get_extension_version(cl_device_id device,
const char *extensionName);
/* Returns a string containing the supported extensions list for a device. */
std::string get_device_extensions_string(cl_device_id device);
@ -42,4 +44,20 @@ std::string get_device_version_string(cl_device_id device);
/* Returns a string containing the device name. */
std::string get_device_name(cl_device_id device);
// Returns the maximum size in bytes for Kernel Parameters
size_t get_max_param_size(cl_device_id device);
/* We need to use a portion of available alloc size,
* divide it to leave some memory for the platform. */
#define MAX_DEVICE_MEMORY_SIZE_DIVISOR (2)
/* Get max allocation size. */
cl_ulong get_device_info_max_mem_alloc_size(cl_device_id device,
unsigned int divisor = 1);
cl_ulong get_device_info_global_mem_size(cl_device_id device,
unsigned int divisor = 1);
cl_ulong get_device_info_max_constant_buffer_size(cl_device_id device,
unsigned int divisor = 1);
#endif // _deviceInfo_h

View file

@ -18,9 +18,12 @@
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include "errorHelpers.h"
#include "parseParameters.h"
#include "testHarness.h"
#include <CL/cl_half.h>
@ -102,6 +105,13 @@ const char *IGetErrorString(int clErrorCode)
case CL_INVALID_SPEC_ID: return "CL_INVALID_SPEC_ID";
case CL_MAX_SIZE_RESTRICTION_EXCEEDED:
return "CL_MAX_SIZE_RESTRICTION_EXCEEDED";
case CL_INCOMPATIBLE_COMMAND_QUEUE_KHR:
return "CL_INCOMPATIBLE_COMMAND_QUEUE_KHR";
case CL_INVALID_SYNC_POINT_WAIT_LIST_KHR:
return "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR";
case CL_INVALID_COMMAND_BUFFER_KHR:
return "CL_INVALID_COMMAND_BUFFER_KHR";
case CL_INVALID_SEMAPHORE_KHR: return "CL_INVALID_SEMAPHORE_KHR";
default: return "(unknown)";
}
}
@ -187,6 +197,8 @@ const char *GetChannelTypeName(cl_channel_type type)
case CL_UNORM_SHORT_565: return "CL_UNORM_SHORT_565";
case CL_UNORM_SHORT_555: return "CL_UNORM_SHORT_555";
case CL_UNORM_INT_101010: return "CL_UNORM_INT_101010";
case CL_UNORM_INT_101010_2: return "CL_UNORM_INT_101010_2";
case CL_UNORM_INT_2_101010_EXT: return "CL_UNORM_INT_2_101010_EXT";
case CL_SIGNED_INT8: return "CL_SIGNED_INT8";
case CL_SIGNED_INT16: return "CL_SIGNED_INT16";
case CL_SIGNED_INT32: return "CL_SIGNED_INT32";
@ -199,6 +211,14 @@ const char *GetChannelTypeName(cl_channel_type type)
case CL_SFIXED14_APPLE: return "CL_SFIXED14_APPLE";
#endif
case CL_UNORM_INT24: return "CL_UNORM_INT24";
case CL_UNSIGNED_INT_RAW10_EXT: return "CL_UNSIGNED_INT_RAW10_EXT";
case CL_UNSIGNED_INT_RAW12_EXT: return "CL_UNSIGNED_INT_RAW12_EXT";
case CL_UNSIGNED_INT10X6_EXT: return "CL_UNSIGNED_INT10X6_EXT";
case CL_UNSIGNED_INT12X4_EXT: return "CL_UNSIGNED_INT12X4_EXT";
case CL_UNSIGNED_INT14X2_EXT: return "CL_UNSIGNED_INT14X2_EXT";
case CL_UNORM_INT10X6_EXT: return "CL_UNORM_INT10X6_EXT";
case CL_UNORM_INT12X4_EXT: return "CL_UNORM_INT12X4_EXT";
case CL_UNORM_INT14X2_EXT: return "CL_UNORM_INT14X2_EXT";
default: return NULL;
}
}
@ -215,6 +235,8 @@ int IsChannelTypeSupported(cl_channel_type type)
case CL_UNORM_SHORT_565:
case CL_UNORM_SHORT_555:
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2:
case CL_UNORM_INT_2_101010_EXT:
case CL_SIGNED_INT8:
case CL_SIGNED_INT16:
case CL_SIGNED_INT32:
@ -222,10 +244,16 @@ int IsChannelTypeSupported(cl_channel_type type)
case CL_UNSIGNED_INT16:
case CL_UNSIGNED_INT32:
case CL_HALF_FLOAT:
case CL_FLOAT: return 1;
case CL_FLOAT:
#ifdef CL_SFIXED14_APPLE
case CL_SFIXED14_APPLE: return 1;
case CL_SFIXED14_APPLE:
#endif
case CL_UNSIGNED_INT10X6_EXT:
case CL_UNSIGNED_INT12X4_EXT:
case CL_UNSIGNED_INT14X2_EXT:
case CL_UNORM_INT10X6_EXT:
case CL_UNORM_INT12X4_EXT:
case CL_UNORM_INT14X2_EXT: return 1;
default: return 0;
}
}
@ -300,10 +328,6 @@ const char *GetQueuePropertyName(cl_command_queue_properties property)
}
}
#ifndef MAX
#define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#endif
#if defined(_MSC_VER)
#define scalbnf(_a, _i) ldexpf(_a, _i)
#define scalbn(_a, _i) ldexp(_a, _i)
@ -356,7 +380,7 @@ static float Ulp_Error_Half_Float(float test, double reference)
// The unbiased exponent of the ulp unit place
int ulp_exp =
HALF_MANT_DIG - 1 - MAX(ilogb(reference), HALF_MIN_EXP - 1);
HALF_MANT_DIG - 1 - std::max(ilogb(reference), HALF_MIN_EXP - 1);
// Scale the exponent of the error
return (float)scalbn(testVal - reference, ulp_exp);
@ -364,13 +388,13 @@ static float Ulp_Error_Half_Float(float test, double reference)
// reference is a normal power of two or a zero
int ulp_exp =
HALF_MANT_DIG - 1 - MAX(ilogb(reference) - 1, HALF_MIN_EXP - 1);
HALF_MANT_DIG - 1 - std::max(ilogb(reference) - 1, HALF_MIN_EXP - 1);
// Scale the exponent of the error
return (float)scalbn(testVal - reference, ulp_exp);
}
float Ulp_Error_Half(cl_half test, float reference)
float Ulp_Error_Half(cl_half test, double reference)
{
return Ulp_Error_Half_Float(cl_half_to_float(test), reference);
}
@ -436,7 +460,8 @@ float Ulp_Error(float test, double reference)
return 0.0f; // if we are expecting a NaN, any NaN is fine
// The unbiased exponent of the ulp unit place
int ulp_exp = FLT_MANT_DIG - 1 - MAX(ilogb(reference), FLT_MIN_EXP - 1);
int ulp_exp =
FLT_MANT_DIG - 1 - std::max(ilogb(reference), FLT_MIN_EXP - 1);
// Scale the exponent of the error
return (float)scalbn(testVal - reference, ulp_exp);
@ -444,7 +469,8 @@ float Ulp_Error(float test, double reference)
// reference is a normal power of two or a zero
// The unbiased exponent of the ulp unit place
int ulp_exp = FLT_MANT_DIG - 1 - MAX(ilogb(reference) - 1, FLT_MIN_EXP - 1);
int ulp_exp =
FLT_MANT_DIG - 1 - std::max(ilogb(reference) - 1, FLT_MIN_EXP - 1);
// Scale the exponent of the error
return (float)scalbn(testVal - reference, ulp_exp);
@ -512,7 +538,7 @@ float Ulp_Error_Double(double test, long double reference)
// The unbiased exponent of the ulp unit place
int ulp_exp =
DBL_MANT_DIG - 1 - MAX(ilogbl(reference), DBL_MIN_EXP - 1);
DBL_MANT_DIG - 1 - std::max(ilogbl(reference), DBL_MIN_EXP - 1);
// Scale the exponent of the error
float result = (float)scalbnl(testVal - reference, ulp_exp);
@ -528,7 +554,7 @@ float Ulp_Error_Double(double test, long double reference)
// reference is a normal power of two or a zero
// The unbiased exponent of the ulp unit place
int ulp_exp =
DBL_MANT_DIG - 1 - MAX(ilogbl(reference) - 1, DBL_MIN_EXP - 1);
DBL_MANT_DIG - 1 - std::max(ilogbl(reference) - 1, DBL_MIN_EXP - 1);
// Scale the exponent of the error
float result = (float)scalbnl(testVal - reference, ulp_exp);
@ -541,6 +567,39 @@ float Ulp_Error_Double(double test, long double reference)
return result;
}
cl_int OutputBuildLog(cl_program program, const cl_device_id device)
{
size_t size_ret;
// Get the build status
cl_build_status build_status;
cl_int error =
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS,
sizeof(build_status), &build_status, &size_ret);
test_error(error, "Unable to query build status");
// If the build failed then print the status, obtain the build log and
// print it.
if (build_status != CL_BUILD_SUCCESS)
{
log_error("ERROR: CL_PROGRAM_BUILD_STATUS=%d\n", (int)build_status);
error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0,
nullptr, &size_ret);
test_error(error, "Unable to query build log size");
char *build_log = (char *)malloc(size_ret);
error = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,
size_ret, build_log, &size_ret);
test_error(error, "Unable to query build log");
log_error("ERROR: CL_PROGRAM_BUILD_LOG:\n%s\n", build_log);
free(build_log);
}
return CL_SUCCESS;
}
cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
cl_device_id *device_list)
{
@ -564,7 +623,7 @@ cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL,
&size_ret);
test_error(error, "Unable to query context's device size");
num_devices = size_ret / sizeof(cl_device_id);
num_devices = static_cast<cl_uint>(size_ret / sizeof(cl_device_id));
device_list = (cl_device_id *)malloc(size_ret);
if (device_list == NULL)
{
@ -580,33 +639,8 @@ cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
unsigned int i;
for (i = 0; i < num_devices; i++)
{
// Get the build status
cl_build_status build_status;
error = clGetProgramBuildInfo(
program, device_list[i], CL_PROGRAM_BUILD_STATUS,
sizeof(build_status), &build_status, &size_ret);
test_error(error, "Unable to query build status");
// If the build failed then log the status, and allocate the build
// log, log it and free it
if (build_status != CL_BUILD_SUCCESS)
{
log_error("ERROR: CL_PROGRAM_BUILD_STATUS=%d\n",
(int)build_status);
error = clGetProgramBuildInfo(program, device_list[i],
CL_PROGRAM_BUILD_LOG, 0, NULL,
&size_ret);
test_error(error, "Unable to query build log size");
char *build_log = (char *)malloc(size_ret);
error = clGetProgramBuildInfo(program, device_list[i],
CL_PROGRAM_BUILD_LOG, size_ret,
build_log, &size_ret);
test_error(error, "Unable to query build log");
log_error("ERROR: CL_PROGRAM_BUILD_LOG:\n%s\n", build_log);
free(build_log);
}
error = OutputBuildLog(program, device_list[i]);
test_error(error, "OutputBuildLog failed");
}
// Was the number of devices given
@ -623,7 +657,6 @@ cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
const char *subtests_to_skip_with_offline_compiler[] = {
"get_kernel_arg_info",
"get_kernel_arg_info_compatibility",
"binary_create",
"load_program_source",
"load_multistring_source",
@ -691,21 +724,19 @@ const char *subtests_to_skip_with_offline_compiler[] = {
"library_function"
};
int check_functions_for_offline_compiler(const char *subtestname,
cl_device_id device)
bool check_functions_for_offline_compiler(const char *subtestname)
{
if (gCompilationMode != kOnline)
{
int nNotRequiredWithOfflineCompiler =
sizeof(subtests_to_skip_with_offline_compiler) / sizeof(char *);
size_t i;
for (i = 0; i < nNotRequiredWithOfflineCompiler; ++i)
size_t nNotRequiredWithOfflineCompiler =
ARRAY_SIZE(subtests_to_skip_with_offline_compiler);
for (size_t i = 0; i < nNotRequiredWithOfflineCompiler; ++i)
{
if (!strcmp(subtestname, subtests_to_skip_with_offline_compiler[i]))
{
return 1;
return false;
}
}
}
return 0;
return true;
}

View file

@ -56,17 +56,28 @@ static int vlog_win32(const char *format, ...);
#define vlog printf
#endif
#define ct_assert(b) ct_assert_i(b, __LINE__)
#define ct_assert_i(b, line) ct_assert_ii(b, line)
#define ct_assert_ii(b, line) \
int _compile_time_assertion_on_line_##line[b ? 1 : -1];
#define test_fail(msg, ...) \
{ \
log_error(msg, ##__VA_ARGS__); \
return TEST_FAIL; \
}
#define test_fail_and_cleanup(errRet, cleanup, msg, ...) \
{ \
log_error(msg, ##__VA_ARGS__); \
errRet = TEST_FAIL; \
goto cleanup; \
}
#define test_error_and_cleanup(errCode, cleanup, msg, ...) \
{ \
auto errCodeResult = errCode; \
if (errCodeResult != CL_SUCCESS) \
{ \
print_error(errCodeResult, msg); \
goto cleanup; \
} \
}
#define test_error(errCode, msg) test_error_ret(errCode, msg, errCode)
#define test_error_fail(errCode, msg) test_error_ret(errCode, msg, TEST_FAIL)
#define test_error_ret(errCode, msg, retValue) \
{ \
auto errCodeResult = errCode; \
@ -97,21 +108,6 @@ static int vlog_win32(const char *format, ...);
"the device version! (from %s:%d)\n", \
msg, __FILE__, __LINE__);
#define test_missing_support_offline_cmpiler(errCode, msg) \
test_missing_support_offline_cmpiler_ret(errCode, msg, errCode)
// this macro should always return CL_SUCCESS, but print the skip message on
// test not supported with offline compiler
#define test_missing_support_offline_cmpiler_ret(errCode, msg, retValue) \
{ \
if (errCode != CL_SUCCESS) \
{ \
log_info("INFO: Subtest %s tests is not supported in offline " \
"compiler execution path! (from %s:%d)\n", \
msg, __FILE__, __LINE__); \
return TEST_SKIP; \
} \
}
// expected error code vs. what we got
#define test_failure_error(errCode, expectedErrCode, msg) \
test_failure_error_ret(errCode, expectedErrCode, msg, \
@ -172,9 +168,24 @@ static int vlog_win32(const char *format, ...);
} \
} while (0)
#define test_assert_event_status(comparison_operator, event) \
do \
{ \
cl_int status; \
cl_int err = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS, \
sizeof(status), &status, nullptr); \
test_error(err, "Could not get " #event " info"); \
test_assert_error(status comparison_operator CL_COMPLETE, \
"Unexpected status for " #event); \
} while (false)
#define test_assert_event_inprogress(event) test_assert_event_status(>, event)
#define test_assert_event_terminated(event) test_assert_event_status(<, event)
#define test_assert_event_complete(event) test_assert_event_status(==, event)
extern const char *IGetErrorString(int clErrorCode);
extern float Ulp_Error_Half(cl_half test, float reference);
extern float Ulp_Error_Half(cl_half test, double reference);
extern float Ulp_Error(float test, double reference);
extern float Ulp_Error_Double(double test, long double reference);
@ -186,8 +197,8 @@ extern const char *GetAddressModeName(cl_addressing_mode mode);
extern const char *GetQueuePropertyName(cl_command_queue_properties properties);
extern const char *GetDeviceTypeName(cl_device_type type);
int check_functions_for_offline_compiler(const char *subtestname,
cl_device_id device);
bool check_functions_for_offline_compiler(const char *subtestname);
cl_int OutputBuildLog(cl_program program, const cl_device_id device);
cl_int OutputBuildLogs(cl_program program, cl_uint num_devices,
cl_device_id *device_list);

View file

@ -0,0 +1,36 @@
//
// Copyright (c) 2022 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef _extensionHelpers_h
#define _extensionHelpers_h
// Load a specific function that is part of an OpenCL extension
#define GET_PFN(device, fn_name) \
fn_name##_fn fn_name = reinterpret_cast<fn_name##_fn>( \
clGetExtensionFunctionAddressForPlatform( \
getPlatformFromDevice(device), #fn_name)); \
do \
{ \
if (!fn_name) \
{ \
log_error( \
"ERROR: Failed to get function pointer for %s at %s:%d\n", \
#fn_name, __FILE__, __LINE__); \
return TEST_FAIL; \
} \
} while (false)
#endif // _extensionHelpers_h

View file

@ -16,6 +16,8 @@
#ifndef _fpcontrol_h
#define _fpcontrol_h
#include <cstdint>
// In order to get tests for correctly rounded operations (e.g. multiply) to
// work properly we need to be able to set the reference hardware to FTZ mode if
// the device hardware is running in that mode. We have explored all other
@ -30,16 +32,22 @@
// that rounding mode.
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__linux__) \
|| defined(__MINGW32__)
#ifdef _MSC_VER
typedef int FPU_mode_type;
#else
typedef int64_t FPU_mode_type;
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) \
|| defined(__MINGW32__)
#include <xmmintrin.h>
#elif defined(__PPC__)
#include <fpu_control.h>
extern __thread fpu_control_t fpu_control;
#elif defined(__mips__)
#include "mips/m32c1.h"
#endif
// Set the reference hardware floating point unit to FTZ mode
static inline void ForceFTZ(FPU_mode_type *mode)
inline void ForceFTZ(FPU_mode_type *mode)
{
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) \
|| defined(__MINGW32__)
@ -55,17 +63,19 @@ static inline void ForceFTZ(FPU_mode_type *mode)
__asm__ volatile("fmxr fpscr, %0" ::"r"(fpscr | (1U << 24)));
// Add 64 bit support
#elif defined(__aarch64__)
unsigned fpscr;
uint64_t fpscr;
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr | (1U << 24)));
#elif defined(__mips__)
fpa_bissr(FPA_CSR_FS);
#else
#error ForceFTZ needs an implentation
#endif
}
// Disable the denorm flush to zero
static inline void DisableFTZ(FPU_mode_type *mode)
inline void DisableFTZ(FPU_mode_type *mode)
{
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) \
|| defined(__MINGW32__)
@ -81,17 +91,19 @@ static inline void DisableFTZ(FPU_mode_type *mode)
__asm__ volatile("fmxr fpscr, %0" ::"r"(fpscr & ~(1U << 24)));
// Add 64 bit support
#elif defined(__aarch64__)
unsigned fpscr;
uint64_t fpscr;
__asm__ volatile("mrs %0, fpcr" : "=r"(fpscr));
*mode = fpscr;
__asm__ volatile("msr fpcr, %0" ::"r"(fpscr & ~(1U << 24)));
#elif defined(__mips__)
fpa_bicsr(FPA_CSR_FS);
#else
#error DisableFTZ needs an implentation
#endif
}
// Restore the reference hardware to floating point state indicated by *mode
static inline void RestoreFPState(FPU_mode_type *mode)
inline void RestoreFPState(FPU_mode_type *mode)
{
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) \
|| defined(__MINGW32__)
@ -103,6 +115,8 @@ static inline void RestoreFPState(FPU_mode_type *mode)
// Add 64 bit support
#elif defined(__aarch64__)
__asm__ volatile("msr fpcr, %0" ::"r"(*mode));
#elif defined(__mips__)
// Mips runs by default with DAZ=1 FTZ=1
#else
#error RestoreFPState needs an implementation
#endif

File diff suppressed because it is too large Load diff

View file

@ -63,7 +63,7 @@ typedef struct
bool normalized_coords;
} image_sampler_data;
int round_to_even(float v);
cl_int round_to_even(float v);
#define NORMALIZE(v, max) (v < 0 ? 0 : (v > 1.f ? max : round_to_even(v * max)))
#define NORMALIZE_UNROUNDED(v, max) (v < 0 ? 0 : (v > 1.f ? max : v * max))
@ -126,6 +126,7 @@ typedef struct
const cl_image_format *format;
cl_mem buffer;
cl_mem_object_type type;
cl_mem_flags mem_flags;
cl_uint num_mip_levels;
} image_descriptor;
@ -139,6 +140,9 @@ void print_first_pixel_difference_error(size_t where, const char *sourcePixel,
image_descriptor *imageInfo, size_t y,
size_t thirdDim);
size_t compare_scanlines(const image_descriptor *imageInfo, const char *aPtr,
const char *bPtr);
void get_max_sizes(size_t *numberOfSizes, const int maxNumberOfSizes,
size_t sizes[][3], size_t maxWidth, size_t maxHeight,
size_t maxDepth, size_t maxArraySize,
@ -188,6 +192,42 @@ cl_uint compute_max_mip_levels(size_t width, size_t height, size_t depth);
cl_ulong compute_mipmapped_image_size(image_descriptor imageInfo);
size_t compute_mip_level_offset(image_descriptor *imageInfo, size_t lod);
constexpr size_t RAW10_EXT_CLUMP_SIZE = 5;
constexpr size_t RAW10_EXT_CLUMP_NUM_PIXELS = 4;
constexpr size_t RAW12_EXT_CLUMP_SIZE = 3;
constexpr size_t RAW12_EXT_CLUMP_NUM_PIXELS = 2;
inline bool is_width_compatible(image_descriptor imageInfo)
{
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW10_EXT
&& (imageInfo.width % RAW10_EXT_CLUMP_NUM_PIXELS) != 0)
{
return false;
}
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW12_EXT
&& (imageInfo.width % RAW12_EXT_CLUMP_NUM_PIXELS) != 0)
{
return false;
}
return true;
}
inline size_t calculate_row_pitch(image_descriptor imageInfo, size_t pixelSize)
{
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW10_EXT)
{
return (imageInfo.width * RAW10_EXT_CLUMP_SIZE)
/ RAW10_EXT_CLUMP_NUM_PIXELS;
}
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW12_EXT)
{
return (imageInfo.width * RAW12_EXT_CLUMP_SIZE)
/ RAW12_EXT_CLUMP_NUM_PIXELS;
}
return imageInfo.width * pixelSize;
}
template <class T>
void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
int y, int z, T *outData, int lod)
@ -252,10 +292,24 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
// Advance to the right spot
char *ptr = (char *)imageData;
size_t pixelSize = get_pixel_size(format);
ptr += z * slice_pitch_lod + y * row_pitch_lod + x * pixelSize;
switch (format->image_channel_data_type)
{
case CL_UNSIGNED_INT_RAW10_EXT: {
ptr += z * slice_pitch_lod + y * row_pitch_lod
+ (x / RAW10_EXT_CLUMP_NUM_PIXELS) * RAW10_EXT_CLUMP_SIZE;
break;
}
case CL_UNSIGNED_INT_RAW12_EXT: {
ptr += z * slice_pitch_lod + y * row_pitch_lod
+ (x / RAW12_EXT_CLUMP_NUM_PIXELS) * RAW12_EXT_CLUMP_SIZE;
break;
}
default: {
size_t pixelSize = get_pixel_size(format);
ptr += z * slice_pitch_lod + y * row_pitch_lod + x * pixelSize;
break;
}
}
// OpenCL only supports reading floats from certain formats
switch (format->image_channel_data_type)
{
@ -344,48 +398,6 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
break;
}
#ifdef OBSOLETE_FORMAT
case CL_UNORM_SHORT_565_REV: {
unsigned short *dPtr = (unsigned short *)ptr;
tempData[2] = (T)(dPtr[0] >> 11);
tempData[1] = (T)((dPtr[0] >> 5) & 63);
tempData[0] = (T)(dPtr[0] & 31);
break;
}
case CL_UNORM_SHORT_555_REV: {
unsigned short *dPtr = (unsigned short *)ptr;
tempData[2] = (T)((dPtr[0] >> 10) & 31);
tempData[1] = (T)((dPtr[0] >> 5) & 31);
tempData[0] = (T)(dPtr[0] & 31);
break;
}
case CL_UNORM_INT_8888: {
unsigned int *dPtr = (unsigned int *)ptr;
tempData[3] = (T)(dPtr[0] >> 24);
tempData[2] = (T)((dPtr[0] >> 16) & 0xff);
tempData[1] = (T)((dPtr[0] >> 8) & 0xff);
tempData[0] = (T)(dPtr[0] & 0xff);
break;
}
case CL_UNORM_INT_8888_REV: {
unsigned int *dPtr = (unsigned int *)ptr;
tempData[0] = (T)(dPtr[0] >> 24);
tempData[1] = (T)((dPtr[0] >> 16) & 0xff);
tempData[2] = (T)((dPtr[0] >> 8) & 0xff);
tempData[3] = (T)(dPtr[0] & 0xff);
break;
}
case CL_UNORM_INT_101010_REV: {
unsigned int *dPtr = (unsigned int *)ptr;
tempData[2] = (T)((dPtr[0] >> 20) & 0x3ff);
tempData[1] = (T)((dPtr[0] >> 10) & 0x3ff);
tempData[0] = (T)(dPtr[0] & 0x3ff);
break;
}
#endif
case CL_UNORM_SHORT_555: {
cl_ushort *dPtr = (cl_ushort *)ptr;
tempData[0] = (T)((dPtr[0] >> 10) & 31);
@ -416,6 +428,47 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
break;
}
#endif
case CL_UNSIGNED_INT_RAW10_EXT: {
cl_uchar *dPtr = (cl_uchar *)ptr;
i = x % RAW10_EXT_CLUMP_NUM_PIXELS;
uint8_t bit_index = i << 1;
uint16_t hi_val = dPtr[i] << 2;
uint16_t lo_val = (dPtr[4] & (0x3 << bit_index)) >> bit_index;
tempData[0] = (T)(hi_val | lo_val);
break;
}
case CL_UNSIGNED_INT_RAW12_EXT: {
cl_uchar *dPtr = (cl_uchar *)ptr;
i = x % RAW12_EXT_CLUMP_NUM_PIXELS;
uint8_t bit_index = i << 2;
uint16_t hi_val = dPtr[i] << 4;
uint16_t lo_val = (dPtr[2] & (0xF << bit_index)) >> bit_index;
tempData[0] = (T)(hi_val | lo_val);
break;
}
case CL_UNSIGNED_INT10X6_EXT: {
cl_short *dPtr = (cl_short *)ptr;
const size_t channelCount = get_format_channel_count(format);
for (i = 0; i < channelCount; i++)
tempData[i] = (dPtr[i] >> 6) & 0x3ff;
break;
}
case CL_UNSIGNED_INT12X4_EXT: {
cl_short *dPtr = (cl_short *)ptr;
const size_t channelCount = get_format_channel_count(format);
for (i = 0; i < channelCount; i++)
tempData[i] = (dPtr[i] >> 4) & 0xfff;
break;
}
case CL_UNSIGNED_INT14X2_EXT: {
cl_short *dPtr = (cl_short *)ptr;
const size_t channelCount = get_format_channel_count(format);
for (i = 0; i < channelCount; i++)
tempData[i] = (dPtr[i] >> 2) & 0x3fff;
break;
}
}
@ -479,6 +532,13 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
outData[2] = tempData[3];
outData[3] = tempData[0];
}
else if (format->image_channel_order == CL_ABGR)
{
outData[0] = tempData[3];
outData[1] = tempData[2];
outData[2] = tempData[1];
outData[3] = tempData[0];
}
else if ((format->image_channel_order == CL_BGRA)
|| (format->image_channel_order == CL_sBGRA))
{
@ -489,12 +549,14 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
}
else if (format->image_channel_order == CL_INTENSITY)
{
outData[0] = tempData[0];
outData[1] = tempData[0];
outData[2] = tempData[0];
outData[3] = tempData[0];
}
else if (format->image_channel_order == CL_LUMINANCE)
{
outData[0] = tempData[0];
outData[1] = tempData[0];
outData[2] = tempData[0];
}

View file

@ -0,0 +1,94 @@
//
// Copyright (c) 2021 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef INTEGER_OPS_TEST_INFO_H
#define INTEGER_OPS_TEST_INFO_H
#include "conversions.h"
#include "testHarness.h"
#include <vector>
// TODO: expand usage to other tests.
template <typename T> struct TestInfo
{
};
template <> struct TestInfo<cl_char>
{
static const ExplicitType explicitType = kChar;
static constexpr const char* deviceTypeName = "char";
static constexpr const char* deviceTypeNameSigned = "char";
static constexpr const char* deviceTypeNameUnsigned = "uchar";
};
template <> struct TestInfo<cl_uchar>
{
static const ExplicitType explicitType = kUChar;
static constexpr const char* deviceTypeName = "uchar";
static constexpr const char* deviceTypeNameSigned = "char";
static constexpr const char* deviceTypeNameUnsigned = "uchar";
};
template <> struct TestInfo<cl_short>
{
static const ExplicitType explicitType = kShort;
static constexpr const char* deviceTypeName = "short";
static constexpr const char* deviceTypeNameSigned = "short";
static constexpr const char* deviceTypeNameUnsigned = "ushort";
};
template <> struct TestInfo<cl_ushort>
{
static const ExplicitType explicitType = kUShort;
static constexpr const char* deviceTypeName = "ushort";
static constexpr const char* deviceTypeNameSigned = "short";
static constexpr const char* deviceTypeNameUnsigned = "ushort";
};
template <> struct TestInfo<cl_int>
{
static const ExplicitType explicitType = kInt;
static constexpr const char* deviceTypeName = "int";
static constexpr const char* deviceTypeNameSigned = "int";
static constexpr const char* deviceTypeNameUnsigned = "uint";
};
template <> struct TestInfo<cl_uint>
{
static const ExplicitType explicitType = kUInt;
static constexpr const char* deviceTypeName = "uint";
static constexpr const char* deviceTypeNameSigned = "int";
static constexpr const char* deviceTypeNameUnsigned = "uint";
};
template <> struct TestInfo<cl_long>
{
static const ExplicitType explicitType = kLong;
static constexpr const char* deviceTypeName = "long";
static constexpr const char* deviceTypeNameSigned = "long";
static constexpr const char* deviceTypeNameUnsigned = "ulong";
};
template <> struct TestInfo<cl_ulong>
{
static const ExplicitType explicitType = kULong;
static constexpr const char* deviceTypeName = "ulong";
static constexpr const char* deviceTypeNameSigned = "long";
static constexpr const char* deviceTypeNameUnsigned = "ulong";
};
template <typename T>
static void fill_vector_with_random_data(std::vector<T>& v)
{
MTdataHolder d(gRandomSeed);
generate_random_data(TestInfo<T>::explicitType, v.size(), d, v.data());
}
#endif /* INTEGER_OPS_TEST_INFO_H */

View file

@ -312,57 +312,6 @@ get_compilation_mode_str(const CompilationMode compilationMode)
}
}
#ifdef KHRONOS_OFFLINE_COMPILER
static std::string
get_khronos_compiler_command(const cl_uint device_address_space_size,
const bool openclCXX, const std::string &bOptions,
const std::string &sourceFilename,
const std::string &outputFilename)
{
// Set compiler options
// Emit SPIR-V
std::string compilerOptions = " -cc1 -emit-spirv";
// <triple>: for 32 bit SPIR-V use spir-unknown-unknown, for 64 bit SPIR-V
// use spir64-unknown-unknown.
if (device_address_space_size == 32)
{
compilerOptions += " -triple=spir-unknown-unknown";
}
else
{
compilerOptions += " -triple=spir64-unknown-unknown";
}
// Set OpenCL C++ flag required by SPIR-V-ready clang (compiler provided by
// Khronos)
if (openclCXX)
{
compilerOptions = compilerOptions + " -cl-std=c++";
}
// Set correct includes
if (openclCXX)
{
compilerOptions += " -I ";
compilerOptions += STRINGIFY_VALUE(CL_LIBCLCXX_DIR);
}
else
{
compilerOptions += " -include opencl.h";
}
#ifdef KHRONOS_OFFLINE_COMPILER_OPTIONS
compilerOptions += STRINGIFY_VALUE(KHRONOS_OFFLINE_COMPILER_OPTIONS);
#endif
// Add build options passed to this function
compilerOptions += " " + bOptions;
compilerOptions += " " + sourceFilename + " -o " + outputFilename;
std::string runString =
STRINGIFY_VALUE(KHRONOS_OFFLINE_COMPILER) + compilerOptions;
return runString;
}
#endif // KHRONOS_OFFLINE_COMPILER
static cl_int get_cl_device_info_str(const cl_device_id device,
const cl_uint device_address_space_size,
const CompilationMode compilationMode,
@ -476,49 +425,27 @@ static int invoke_offline_compiler(const cl_device_id device,
const CompilationMode compilationMode,
const std::string &bOptions,
const std::string &sourceFilename,
const std::string &outputFilename,
const bool openclCXX)
const std::string &outputFilename)
{
std::string runString;
if (openclCXX)
std::string clDeviceInfoFilename;
// See cl_offline_compiler-interface.txt for a description of the
// format of the CL device information file generated below, and
// the internal command line interface for invoking the offline
// compiler.
cl_int err = write_cl_device_info(device, device_address_space_size,
compilationMode, clDeviceInfoFilename);
if (err != CL_SUCCESS)
{
#ifndef KHRONOS_OFFLINE_COMPILER
log_error("CL C++ compilation is not possible: "
"KHRONOS_OFFLINE_COMPILER was not defined.\n");
return CL_INVALID_OPERATION;
#else
if (compilationMode != kSpir_v)
{
log_error("Compilation mode must be SPIR-V for Khronos compiler");
return -1;
}
runString = get_khronos_compiler_command(
device_address_space_size, openclCXX, bOptions, sourceFilename,
outputFilename);
#endif
log_error("Failed writing CL device info file\n");
return err;
}
else
{
std::string clDeviceInfoFilename;
// See cl_offline_compiler-interface.txt for a description of the
// format of the CL device information file generated below, and
// the internal command line interface for invoking the offline
// compiler.
cl_int err =
write_cl_device_info(device, device_address_space_size,
compilationMode, clDeviceInfoFilename);
if (err != CL_SUCCESS)
{
log_error("Failed writing CL device info file\n");
return err;
}
runString = get_offline_compilation_command(
device_address_space_size, compilationMode, bOptions,
sourceFilename, outputFilename, clDeviceInfoFilename);
}
runString = get_offline_compilation_command(
device_address_space_size, compilationMode, bOptions, sourceFilename,
outputFilename, clDeviceInfoFilename);
// execute script
log_info("Executing command: %s\n", runString.c_str());
@ -577,9 +504,8 @@ static cl_int get_device_address_bits(const cl_device_id device,
static int get_offline_compiler_output(
std::ifstream &ifs, const cl_device_id device, cl_uint deviceAddrSpaceSize,
const bool openclCXX, const CompilationMode compilationMode,
const std::string &bOptions, const std::string &kernelPath,
const std::string &kernelNamePrefix)
const CompilationMode compilationMode, const std::string &bOptions,
const std::string &kernelPath, const std::string &kernelNamePrefix)
{
std::string sourceFilename =
get_cl_source_filename_with_path(kernelPath, kernelNamePrefix);
@ -599,12 +525,12 @@ static int get_offline_compiler_output(
}
else
{
int error = invoke_offline_compiler(
device, deviceAddrSpaceSize, compilationMode, bOptions,
sourceFilename, outputFilename, openclCXX);
int error = invoke_offline_compiler(device, deviceAddrSpaceSize,
compilationMode, bOptions,
sourceFilename, outputFilename);
if (error != CL_SUCCESS) return error;
// read output file
// open output file for reading
ifs.open(outputFilename.c_str(), std::ios::binary);
if (!ifs.good())
{
@ -614,14 +540,33 @@ static int get_offline_compiler_output(
}
}
}
if (compilationMode == kSpir_v && !gDisableSPIRVValidation)
{
std::string runString = gSPIRVValidator + " " + outputFilename;
int returnCode = system(runString.c_str());
if (returnCode == -1)
{
log_error("Error: failed to invoke SPIR-V validator\n");
return CL_COMPILE_PROGRAM_FAILURE;
}
else if (returnCode != 0)
{
log_error(
"Failed to validate SPIR-V file %s: system() returned 0x%x\n",
outputFilename.c_str(), returnCode);
return CL_COMPILE_PROGRAM_FAILURE;
}
}
return CL_SUCCESS;
}
static int create_single_kernel_helper_create_program_offline(
cl_context context, cl_device_id device, cl_program *outProgram,
unsigned int numKernelLines, const char *const *kernelProgram,
const char *buildOptions, const bool openclCXX,
CompilationMode compilationMode)
const char *buildOptions, CompilationMode compilationMode)
{
if (kCacheModeDumpCl == gCompilationCacheMode)
{
@ -649,24 +594,12 @@ static int create_single_kernel_helper_create_program_offline(
std::ifstream ifs;
error = get_offline_compiler_output(ifs, device, device_address_space_size,
openclCXX, compilationMode, bOptions,
compilationMode, bOptions,
gCompilationCachePath, kernelName);
if (error != CL_SUCCESS) return error;
// -----------------------------------------------------------------------------------
// ------------- ONLY FOR OPENCL 22 CONFORMANCE TEST 22 DEVELOPMENT
// ------------------
// -----------------------------------------------------------------------------------
// Only OpenCL C++ to SPIR-V compilation
#if defined(DEVELOPMENT) && defined(ONLY_SPIRV_COMPILATION)
if (openclCXX)
{
return CL_SUCCESS;
}
#endif
ifs.seekg(0, ifs.end);
int length = ifs.tellg();
size_t length = static_cast<size_t>(ifs.tellg());
ifs.seekg(0, ifs.beg);
// treat modifiedProgram as input for clCreateProgramWithBinary
@ -748,8 +681,7 @@ static int create_single_kernel_helper_create_program_offline(
static int create_single_kernel_helper_create_program(
cl_context context, cl_device_id device, cl_program *outProgram,
unsigned int numKernelLines, const char **kernelProgram,
const char *buildOptions, const bool openclCXX,
CompilationMode compilationMode)
const char *buildOptions, CompilationMode compilationMode)
{
std::lock_guard<std::mutex> compiler_lock(gCompilerMutex);
@ -787,37 +719,39 @@ static int create_single_kernel_helper_create_program(
{
return create_single_kernel_helper_create_program_offline(
context, device, outProgram, numKernelLines, kernelProgram,
buildOptions, openclCXX, compilationMode);
buildOptions, compilationMode);
}
}
int create_single_kernel_helper_create_program(
cl_context context, cl_program *outProgram, unsigned int numKernelLines,
const char **kernelProgram, const char *buildOptions, const bool openclCXX)
int create_single_kernel_helper_create_program(cl_context context,
cl_program *outProgram,
unsigned int numKernelLines,
const char **kernelProgram,
const char *buildOptions)
{
return create_single_kernel_helper_create_program(
context, NULL, outProgram, numKernelLines, kernelProgram, buildOptions,
openclCXX, gCompilationMode);
gCompilationMode);
}
int create_single_kernel_helper_create_program_for_device(
cl_context context, cl_device_id device, cl_program *outProgram,
unsigned int numKernelLines, const char **kernelProgram,
const char *buildOptions, const bool openclCXX)
const char *buildOptions)
{
return create_single_kernel_helper_create_program(
context, device, outProgram, numKernelLines, kernelProgram,
buildOptions, openclCXX, gCompilationMode);
buildOptions, gCompilationMode);
}
int create_single_kernel_helper_with_build_options(
cl_context context, cl_program *outProgram, cl_kernel *outKernel,
unsigned int numKernelLines, const char **kernelProgram,
const char *kernelName, const char *buildOptions, const bool openclCXX)
const char *kernelName, const char *buildOptions)
{
return create_single_kernel_helper(context, outProgram, outKernel,
numKernelLines, kernelProgram,
kernelName, buildOptions, openclCXX);
kernelName, buildOptions);
}
// Creates and builds OpenCL C/C++ program, and creates a kernel
@ -826,7 +760,7 @@ int create_single_kernel_helper(cl_context context, cl_program *outProgram,
unsigned int numKernelLines,
const char **kernelProgram,
const char *kernelName,
const char *buildOptions, const bool openclCXX)
const char *buildOptions)
{
// For the logic that automatically adds -cl-std it is much cleaner if the
// build options have RAII. This buffer will store the potentially updated
@ -865,51 +799,14 @@ int create_single_kernel_helper(cl_context context, cl_program *outProgram,
build_options_internal += cl_std;
buildOptions = build_options_internal.c_str();
}
int error;
// Create OpenCL C++ program
if (openclCXX)
int error = create_single_kernel_helper_create_program(
context, outProgram, numKernelLines, kernelProgram, buildOptions);
if (error != CL_SUCCESS)
{
// -----------------------------------------------------------------------------------
// ------------- ONLY FOR OPENCL 22 CONFORMANCE TEST 22 DEVELOPMENT
// ------------------
// -----------------------------------------------------------------------------------
// Only OpenCL C++ to SPIR-V compilation
#if defined(DEVELOPMENT) && defined(ONLY_SPIRV_COMPILATION)
// Save global variable
bool tempgCompilationCacheMode = gCompilationCacheMode;
// Force OpenCL C++ -> SPIR-V compilation on every run
gCompilationCacheMode = kCacheModeOverwrite;
#endif
error = create_openclcpp_program(context, outProgram, numKernelLines,
kernelProgram, buildOptions);
if (error != CL_SUCCESS)
{
log_error("Create program failed: %d, line: %d\n", error, __LINE__);
return error;
}
// -----------------------------------------------------------------------------------
// ------------- ONLY FOR OPENCL 22 CONFORMANCE TEST 22 DEVELOPMENT
// ------------------
// -----------------------------------------------------------------------------------
#if defined(DEVELOPMENT) && defined(ONLY_SPIRV_COMPILATION)
// Restore global variables
gCompilationCacheMode = tempgCompilationCacheMode;
log_info("WARNING: KERNEL %s WAS ONLY COMPILED TO SPIR-V\n",
kernelName);
log_error("Create program failed: %d, line: %d\n", error, __LINE__);
return error;
#endif
}
// Create OpenCL C program
else
{
error = create_single_kernel_helper_create_program(
context, outProgram, numKernelLines, kernelProgram, buildOptions);
if (error != CL_SUCCESS)
{
log_error("Create program failed: %d, line: %d\n", error, __LINE__);
return error;
}
}
// Remove offline-compiler-only build options
std::string newBuildOptions;
if (buildOptions != NULL)
@ -930,18 +827,6 @@ int create_single_kernel_helper(cl_context context, cl_program *outProgram,
kernelName, newBuildOptions.c_str());
}
// Creates OpenCL C++ program
int create_openclcpp_program(cl_context context, cl_program *outProgram,
unsigned int numKernelLines,
const char **kernelProgram,
const char *buildOptions)
{
// Create program
return create_single_kernel_helper_create_program(
context, NULL, outProgram, numKernelLines, kernelProgram, buildOptions,
true, kSpir_v);
}
// Builds OpenCL C/C++ program and creates
int build_program_create_kernel_helper(
cl_context context, cl_program *outProgram, cl_kernel *outKernel,
@ -1361,7 +1246,7 @@ int is_image_format_supported(cl_context context, cl_mem_flags flags,
list = (cl_image_format *)malloc(count * sizeof(cl_image_format));
if (NULL == list)
{
log_error("Error: unable to allocate %ld byte buffer for image format "
log_error("Error: unable to allocate %zu byte buffer for image format "
"list at %s:%d (err = %d)\n",
count * sizeof(cl_image_format), __FILE__, __LINE__, err);
return 0;
@ -1434,13 +1319,21 @@ size_t get_pixel_bytes(const cl_image_format *fmt)
case CL_UNORM_SHORT_565:
case CL_UNORM_SHORT_555: return 2;
case CL_UNORM_INT_101010: return 4;
case CL_UNORM_INT_101010:
case CL_UNORM_INT_101010_2:
case CL_UNORM_INT_2_101010_EXT: return 4;
case CL_SNORM_INT8:
case CL_UNORM_INT8:
case CL_SIGNED_INT8:
case CL_UNSIGNED_INT8: return chanCount;
case CL_UNSIGNED_INT10X6_EXT:
case CL_UNSIGNED_INT12X4_EXT:
case CL_UNSIGNED_INT14X2_EXT:
case CL_UNORM_INT10X6_EXT:
case CL_UNORM_INT12X4_EXT:
case CL_UNORM_INT14X2_EXT:
case CL_SNORM_INT16:
case CL_UNORM_INT16:
case CL_HALF_FLOAT:
@ -1626,22 +1519,30 @@ size_t get_min_alignment(cl_context context)
return align_size;
}
cl_device_fp_config get_default_rounding_mode(cl_device_id device)
cl_device_fp_config get_default_rounding_mode(const cl_device_id device,
const cl_uint param)
{
char profileStr[128] = "";
cl_device_fp_config single = 0;
int error = clGetDeviceInfo(device, CL_DEVICE_SINGLE_FP_CONFIG,
sizeof(single), &single, NULL);
cl_device_fp_config config = 0;
int error = clGetDeviceInfo(device, param, sizeof(config), &config, NULL);
if (error)
test_error_ret(error, "Unable to get device CL_DEVICE_SINGLE_FP_CONFIG",
0);
{
std::string config_name = "CL_DEVICE_SINGLE_FP_CONFIG";
if (param == CL_DEVICE_HALF_FP_CONFIG)
config_name = "CL_DEVICE_HALF_FP_CONFIG";
else if (param == CL_DEVICE_DOUBLE_FP_CONFIG)
config_name = "CL_DEVICE_DOUBLE_FP_CONFIG";
std::string message =
std::string("Unable to get device ") + config_name;
test_error_ret(error, message.c_str(), 0);
}
if (single & CL_FP_ROUND_TO_NEAREST) return CL_FP_ROUND_TO_NEAREST;
if (config & CL_FP_ROUND_TO_NEAREST) return CL_FP_ROUND_TO_NEAREST;
if (0 == (single & CL_FP_ROUND_TO_ZERO))
if (0 == (config & CL_FP_ROUND_TO_ZERO))
test_error_ret(-1,
"FAILURE: device must support either "
"CL_DEVICE_SINGLE_FP_CONFIG or CL_FP_ROUND_TO_NEAREST",
"CL_FP_ROUND_TO_ZERO or CL_FP_ROUND_TO_NEAREST",
0);
// Make sure we are an embedded device before allowing a pass
@ -1730,7 +1631,7 @@ Version get_device_cl_c_version(cl_device_id device)
&opencl_c_version_size_in_bytes);
test_error_ret(error,
"clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_VERSION\n",
(Version{ -1, 0 }));
(Version{ 0, 0 }));
std::string opencl_c_version(opencl_c_version_size_in_bytes, '\0');
error =
@ -1739,13 +1640,13 @@ Version get_device_cl_c_version(cl_device_id device)
test_error_ret(error,
"clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_VERSION\n",
(Version{ -1, 0 }));
(Version{ 0, 0 }));
// Scrape out the major, minor pair from the string.
auto major = opencl_c_version[opencl_c_version.find('.') - 1];
auto minor = opencl_c_version[opencl_c_version.find('.') + 1];
return Version{ major - '0', minor - '0' };
return Version{ (cl_uint)(major - '0'), (cl_uint)(minor - '0') };
}
Version get_device_latest_cl_c_version(cl_device_id device)
@ -1763,7 +1664,7 @@ Version get_device_latest_cl_c_version(cl_device_id device)
&opencl_c_all_versions_size_in_bytes);
test_error_ret(
error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_ALL_VERSIONS",
(Version{ -1, 0 }));
(Version{ 0, 0 }));
std::vector<cl_name_version> name_versions(
opencl_c_all_versions_size_in_bytes / sizeof(cl_name_version));
error = clGetDeviceInfo(device, CL_DEVICE_OPENCL_C_ALL_VERSIONS,
@ -1771,13 +1672,15 @@ Version get_device_latest_cl_c_version(cl_device_id device)
name_versions.data(), nullptr);
test_error_ret(
error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_ALL_VERSIONS",
(Version{ -1, 0 }));
(Version{ 0, 0 }));
Version max_supported_cl_c_version{};
for (const auto &name_version : name_versions)
{
Version current_version{ CL_VERSION_MAJOR(name_version.version),
CL_VERSION_MINOR(name_version.version) };
Version current_version{
static_cast<cl_uint>(CL_VERSION_MAJOR(name_version.version)),
static_cast<cl_uint>(CL_VERSION_MINOR(name_version.version))
};
max_supported_cl_c_version =
(current_version > max_supported_cl_c_version)
? current_version
@ -1797,7 +1700,7 @@ Version get_max_OpenCL_C_for_context(cl_context context)
auto error = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, nullptr,
&devices_size_in_bytes);
test_error_ret(error, "clGetDeviceInfo failed for CL_CONTEXT_DEVICES",
(Version{ -1, 0 }));
(Version{ 0, 0 }));
std::vector<cl_device_id> devices(devices_size_in_bytes
/ sizeof(cl_device_id));
error = clGetContextInfo(context, CL_CONTEXT_DEVICES, devices_size_in_bytes,
@ -1822,7 +1725,7 @@ Version get_max_OpenCL_C_for_context(cl_context context)
else
{
current_version =
(std::min)(device_version, current_version);
std::min(device_version, current_version);
}
});
return current_version;
@ -1860,8 +1763,10 @@ bool device_supports_cl_c_version(cl_device_id device, Version version)
for (const auto &name_version : name_versions)
{
Version current_version{ CL_VERSION_MAJOR(name_version.version),
CL_VERSION_MINOR(name_version.version) };
Version current_version{
static_cast<cl_uint>(CL_VERSION_MAJOR(name_version.version)),
static_cast<cl_uint>(CL_VERSION_MINOR(name_version.version))
};
if (current_version == version)
{
return true;
@ -1891,3 +1796,26 @@ bool poll_until(unsigned timeout_ms, unsigned interval_ms,
return ret;
}
bool device_supports_double(cl_device_id device)
{
if (is_extension_available(device, "cl_khr_fp64"))
{
return true;
}
else
{
cl_device_fp_config double_fp_config;
cl_int err = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG,
sizeof(double_fp_config),
&double_fp_config, nullptr);
test_error(err,
"clGetDeviceInfo for CL_DEVICE_DOUBLE_FP_CONFIG failed");
return double_fp_config != 0;
}
}
bool device_supports_half(cl_device_id device)
{
return is_extension_available(device, "cl_khr_fp16");
}

View file

@ -16,9 +16,6 @@
#ifndef _kernelHelpers_h
#define _kernelHelpers_h
// Configuration
#include "../config.hpp"
#include "compat.h"
#include "testHarness.h"
@ -42,21 +39,6 @@
#include <functional>
/*
* The below code is intended to be used at the top of kernels that appear
* inline in files to set line and file info for the kernel:
*
* const char *source = {
* INIT_OPENCL_DEBUG_INFO
* "__kernel void foo( int x )\n"
* "{\n"
* " ...\n"
* "}\n"
* };
*/
#define INIT_OPENCL_DEBUG_INFO SET_OPENCL_LINE_INFO(__LINE__, __FILE__)
#define SET_OPENCL_LINE_INFO(_line, _file) \
"#line " STRINGIFY(_line) " " STRINGIFY(_file) "\n"
#ifndef STRINGIFY_VALUE
#define STRINGIFY_VALUE(_x) STRINGIFY(_x)
#endif
@ -72,31 +54,21 @@ extern int
create_single_kernel_helper(cl_context context, cl_program *outProgram,
cl_kernel *outKernel, unsigned int numKernelLines,
const char **kernelProgram, const char *kernelName,
const char *buildOptions = NULL,
const bool openclCXX = false);
const char *buildOptions = NULL);
extern int create_single_kernel_helper_with_build_options(
cl_context context, cl_program *outProgram, cl_kernel *outKernel,
unsigned int numKernelLines, const char **kernelProgram,
const char *kernelName, const char *buildOptions,
const bool openclCXX = false);
const char *kernelName, const char *buildOptions);
extern int create_single_kernel_helper_create_program(
cl_context context, cl_program *outProgram, unsigned int numKernelLines,
const char **kernelProgram, const char *buildOptions = NULL,
const bool openclCXX = false);
const char **kernelProgram, const char *buildOptions = NULL);
extern int create_single_kernel_helper_create_program_for_device(
cl_context context, cl_device_id device, cl_program *outProgram,
unsigned int numKernelLines, const char **kernelProgram,
const char *buildOptions = NULL, const bool openclCXX = false);
/* Creates OpenCL C++ program. This one must be used for creating OpenCL C++
* program. */
extern int create_openclcpp_program(cl_context context, cl_program *outProgram,
unsigned int numKernelLines,
const char **kernelProgram,
const char *buildOptions = NULL);
const char *buildOptions = NULL);
/* Builds program (outProgram) and creates one kernel */
int build_program_create_kernel_helper(
@ -162,7 +134,9 @@ size_t get_min_alignment(cl_context context);
/* Helper to obtain the default rounding mode for single precision computation.
* (Double is always CL_FP_ROUND_TO_NEAREST.) Returns 0 on error. */
cl_device_fp_config get_default_rounding_mode(cl_device_id device);
cl_device_fp_config
get_default_rounding_mode(const cl_device_id device,
const cl_uint param = CL_DEVICE_SINGLE_FP_CONFIG);
#define PASSIVE_REQUIRE_IMAGE_SUPPORT(device) \
if (checkForImageSupport(device)) \
@ -181,7 +155,7 @@ cl_device_fp_config get_default_rounding_mode(cl_device_id device);
}
#define PASSIVE_REQUIRE_FP16_SUPPORT(device) \
if (!is_extension_available(device, "cl_khr_fp16")) \
if (!device_supports_half(device)) \
{ \
log_info( \
"\n\tNote: device does not support fp16. Skipping test...\n"); \
@ -211,4 +185,10 @@ bool device_supports_cl_c_version(cl_device_id device, Version version);
bool poll_until(unsigned timeout_ms, unsigned interval_ms,
std::function<bool()> fn);
// Checks whether the device supports double data types
bool device_supports_double(cl_device_id device);
// Checks whether the device supports half data types
bool device_supports_half(cl_device_id device);
#endif // _kernelHelpers_h

View file

@ -714,6 +714,11 @@ int32_t float2int(float fx)
return u.i;
}
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#if !__has_builtin(__builtin_clz)
#if !defined(_WIN64)
/** Returns the number of leading 0-bits in x,
starting at the most significant bit position.
@ -778,6 +783,7 @@ int __builtin_clz(unsigned int pattern)
}
#endif // !defined(_WIN64)
#endif // !__has_builtin(__builtin_clz)
#include <intrin.h>
#include <emmintrin.h>

View file

@ -51,6 +51,7 @@
#include "harness/alloc.h"
#ifdef __SSE2__
#include <mutex>
#include <emmintrin.h>
#endif
@ -107,7 +108,7 @@ cl_uint genrand_int32(MTdata d)
/* mag01[x] = x * MATRIX_A for x=0,1 */
static const cl_uint mag01[2] = { 0x0UL, MATRIX_A };
#ifdef __SSE2__
static volatile int init = 0;
static std::once_flag init_flag;
static union {
__m128i v;
cl_uint s[4];
@ -123,8 +124,7 @@ cl_uint genrand_int32(MTdata d)
int kk;
#ifdef __SSE2__
if (0 == init)
{
auto init_fn = []() {
upper_mask.s[0] = upper_mask.s[1] = upper_mask.s[2] =
upper_mask.s[3] = UPPER_MASK;
lower_mask.s[0] = lower_mask.s[1] = lower_mask.s[2] =
@ -134,8 +134,8 @@ cl_uint genrand_int32(MTdata d)
MATRIX_A;
c0.s[0] = c0.s[1] = c0.s[2] = c0.s[3] = (cl_uint)0x9d2c5680UL;
c1.s[0] = c1.s[1] = c1.s[2] = c1.s[3] = (cl_uint)0xefc60000UL;
init = 1;
}
};
std::call_once(init_flag, init_fn);
#endif
kk = 0;
@ -277,3 +277,5 @@ double genrand_res53(MTdata d)
unsigned long a = genrand_int32(d) >> 5, b = genrand_int32(d) >> 6;
return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);
}
bool genrand_bool(MTdata d) { return ((cl_uint)genrand_int32(d) & 1); }

View file

@ -90,24 +90,46 @@ double genrand_res53(MTdata /*data*/);
#ifdef __cplusplus
#include <cassert>
/* generates a random boolean */
bool genrand_bool(MTdata /*data*/);
struct MTdataHolder
{
MTdataHolder(cl_uint seed)
#include <cassert>
#include <utility>
class MTdataHolder {
public:
MTdataHolder() = default;
explicit MTdataHolder(cl_uint seed)
{
m_mtdata = init_genrand(seed);
assert(m_mtdata != nullptr);
}
MTdataHolder(MTdata mtdata): m_mtdata(mtdata) {}
// Forbid copy.
MTdataHolder(const MTdataHolder&) = delete;
MTdataHolder& operator=(const MTdataHolder&) = delete;
~MTdataHolder() { free_mtdata(m_mtdata); }
// Support move semantics.
MTdataHolder(MTdataHolder&& h) { std::swap(m_mtdata, h.m_mtdata); }
MTdataHolder& operator=(MTdataHolder&& h)
{
std::swap(m_mtdata, h.m_mtdata);
return *this;
}
operator MTdata() const { return m_mtdata; }
~MTdataHolder()
{
if (m_mtdata) free_mtdata(m_mtdata);
}
operator MTdata() const
{
assert(m_mtdata && "Object wasn't initialised");
return m_mtdata;
}
private:
MTdata m_mtdata;
MTdata m_mtdata = nullptr;
};
#endif // #ifdef __cplusplus

View file

@ -30,8 +30,17 @@
#if defined(__ANDROID__)
#include <android/api-level.h>
#include "harness/mt19937.h"
#endif
#if !defined(_WIN32)
#if defined(__APPLE__)
#include <sys/sysctl.h>
#endif
#include <unistd.h>
#endif
#define CHECK_PTR(ptr) \
if ((ptr) == NULL) \
{ \
@ -199,7 +208,8 @@ static std::string _err_msg(int err, int level)
*/
#if (defined(__ANDROID__) && __ANDROID_API__ < 23) \
|| ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE)
|| ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) \
|| (defined(_GNU_SOURCE) && !defined(__GLIBC__) && !defined(__USE_GNU))
// XSI version of strerror_r.
#warning Not tested!
@ -283,7 +293,7 @@ std::string exe_path()
exit(2);
}; // if
if (len < path.size())
if (static_cast<size_t>(len) < path.size())
{
// We got the path.
path.resize(len);
@ -333,9 +343,6 @@ std::string exe_dir()
#include <windows.h>
#if defined(max)
#undef max
#endif
#include <cctype>
#include <algorithm>
@ -404,7 +411,8 @@ std::string exe_path()
for (;;)
{
DWORD len = GetModuleFileNameA(NULL, &path.front(), path.size());
DWORD len = GetModuleFileNameA(NULL, &path.front(),
static_cast<DWORD>(path.size()));
if (len == 0)
{
@ -558,4 +566,27 @@ char* get_exe_dir()
} // get_exe_dir
char* get_temp_filename()
{
char gFileName[256] = "";
// Create a unique temporary file to allow parallel executed tests.
#if (defined(__linux__) || defined(__APPLE__)) && (!defined(__ANDROID__))
sprintf(gFileName, "/tmp/tmpfile.XXXXXX");
int fd = mkstemp(gFileName);
if (fd == -1) return strdup(gFileName);
close(fd);
#elif defined(_WIN32)
UINT ret = GetTempFileName(".", "tmp", 0, gFileName);
if (ret == 0) return strdup(gFileName);
#else
MTdata d = init_genrand((cl_uint)time(NULL));
sprintf(gFileName, "tmpfile.%u", genrand_int32(d));
#endif
char* fn = strdup(gFileName);
CHECK_PTR(fn);
return fn;
}
// end of file //

View file

@ -41,5 +41,7 @@ char* get_err_msg(int err); // Returns system error message. Subject to free.
char* get_dir_sep(); // Returns dir separator. Subject to free.
char* get_exe_path(); // Returns path of current executable. Subject to free.
char* get_exe_dir(); // Returns dir of current executable. Subject to free.
char* get_temp_filename(); // returns temporary file name
#endif // __os_helpers_h__

View file

@ -25,14 +25,16 @@
#include <sys/stat.h>
#include <string.h>
using namespace std;
#define DEFAULT_COMPILATION_PROGRAM "cl_offline_compiler"
#define DEFAULT_SPIRV_VALIDATOR "spirv-val"
CompilationMode gCompilationMode = kOnline;
CompilationCacheMode gCompilationCacheMode = kCacheModeCompileIfAbsent;
std::string gCompilationCachePath = ".";
std::string gCompilationProgram = DEFAULT_COMPILATION_PROGRAM;
bool gDisableSPIRVValidation = false;
std::string gSPIRVValidator = DEFAULT_SPIRV_VALIDATOR;
unsigned gNumWorkerThreads;
void helpInfo()
{
@ -45,6 +47,8 @@ void helpInfo()
online Use online compilation (default)
binary Use binary offline compilation
spir-v Use SPIR-V offline compilation
--num-worker-threads <num>
Select parallel execution with the specified number of worker threads.
For offline compilation (binary and spir-v modes) only:
--compilation-cache-mode <cache-mode>
@ -62,7 +66,14 @@ For offline compilation (binary and spir-v modes) only:
Path for offline compiler output and CL source
--compilation-program <prog>
Program to use for offline compilation, defaults to:
)" DEFAULT_COMPILATION_PROGRAM "\n\n");
)" DEFAULT_COMPILATION_PROGRAM R"(
For spir-v mode only:
--disable-spirv-validation
Disable validation of SPIR-V using the SPIR-V validator
--spirv-validator
Path for SPIR-V validator, defaults to )" DEFAULT_SPIRV_VALIDATOR "\n"
"\n");
}
int parseCustomParam(int argc, const char *argv[], const char *ignore)
@ -127,6 +138,23 @@ int parseCustomParam(int argc, const char *argv[], const char *ignore)
return -1;
}
}
else if (!strcmp(argv[i], "--num-worker-threads"))
{
delArg++;
if ((i + 1) < argc)
{
delArg++;
const char *numthstr = argv[i + 1];
gNumWorkerThreads = atoi(numthstr);
}
else
{
log_error(
"A parameter to --num-worker-threads must be provided!\n");
return -1;
}
}
else if (!strcmp(argv[i], "--compilation-cache-mode"))
{
delArg++;
@ -198,6 +226,26 @@ int parseCustomParam(int argc, const char *argv[], const char *ignore)
return -1;
}
}
else if (!strcmp(argv[i], "--disable-spirv-validation"))
{
delArg++;
gDisableSPIRVValidation = true;
}
else if (!strcmp(argv[i], "--spirv-validator"))
{
delArg++;
if ((i + 1) < argc)
{
delArg++;
gSPIRVValidator = argv[i + 1];
}
else
{
log_error("Program argument for --spirv-validator was not "
"specified.\n");
return -1;
}
}
// cleaning parameters from argv tab
for (int j = i; j < argc - delArg; j++) argv[j] = argv[j + delArg];

View file

@ -38,6 +38,8 @@ extern CompilationMode gCompilationMode;
extern CompilationCacheMode gCompilationCacheMode;
extern std::string gCompilationCachePath;
extern std::string gCompilationProgram;
extern bool gDisableSPIRVValidation;
extern std::string gSPIRVValidator;
extern int parseCustomParam(int argc, const char *argv[],
const char *ignore = 0);

View file

@ -19,6 +19,7 @@
#include <assert.h>
#include <algorithm>
#include <cinttypes>
#include <vector>
static bool findProperty(const std::vector<cl_properties>& props,
@ -97,14 +98,15 @@ int compareProperties(const std::vector<cl_properties>& queried,
if (!found)
{
log_error("ERROR: expected property 0x%x not found!\n",
log_error("ERROR: expected property 0x%" PRIx64 " not found!\n",
check_prop);
return TEST_FAIL;
}
else if (check_value != queried_value)
{
log_error("ERROR: mis-matched value for property 0x%x: wanted "
"0x%x, got 0x%x\n",
log_error("ERROR: mis-matched value for property 0x%" PRIx64
": wanted "
"0x%" PRIx64 ", got 0x%" PRIx64 "\n",
check_prop, check_value, queried_value);
return TEST_FAIL;
}
@ -113,7 +115,7 @@ int compareProperties(const std::vector<cl_properties>& queried,
if (queried.size() > check.size())
{
log_error("ERROR: all properties found but there are extra "
"properties: expected %d, got %d.\n",
"properties: expected %zu, got %zu.\n",
check.size(), queried.size());
return TEST_FAIL;
}

View file

@ -48,7 +48,7 @@ RoundingMode set_round(RoundingMode r, Type outType)
const int *p = int_rounds;
if (outType == kfloat || outType == kdouble) p = flt_rounds;
int fpscr = 0;
int64_t fpscr = 0;
RoundingMode oldRound = get_round();
_FPU_GETCW(fpscr);
@ -59,7 +59,7 @@ RoundingMode set_round(RoundingMode r, Type outType)
RoundingMode get_round(void)
{
int fpscr;
int64_t fpscr;
int oldRound;
_FPU_GETCW(fpscr);
@ -197,19 +197,21 @@ RoundingMode get_round(void)
#include <xmmintrin.h>
#elif defined(__PPC__)
#include <fpu_control.h>
#elif defined(__mips__)
#include "mips/m32c1.h"
#endif
void *FlushToZero(void)
{
#if defined(__APPLE__) || defined(__linux__) || defined(_WIN32)
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
union {
int i;
unsigned int i;
void *p;
} u = { _mm_getcsr() };
_mm_setcsr(u.i | 0x8040);
return u.p;
#elif defined(__arm__) || defined(__aarch64__)
int fpscr;
int64_t fpscr;
_FPU_GETCW(fpscr);
_FPU_SETCW(fpscr | FPSCR_FZ);
return NULL;
@ -219,6 +221,9 @@ void *FlushToZero(void)
flags |= _FPU_MASK_NI;
_FPU_SETCW(flags);
return NULL;
#elif defined(__mips__)
fpa_bissr(FPA_CSR_FS);
return NULL;
#else
#error Unknown arch
#endif
@ -235,11 +240,11 @@ void UnFlushToZero(void *p)
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER)
union {
void *p;
int i;
unsigned int i;
} u = { p };
_mm_setcsr(u.i);
#elif defined(__arm__) || defined(__aarch64__)
int fpscr;
int64_t fpscr;
_FPU_GETCW(fpscr);
_FPU_SETCW(fpscr & ~FPSCR_FZ);
#elif defined(__PPC__)
@ -247,6 +252,8 @@ void UnFlushToZero(void *p)
_FPU_GETCW(flags);
flags &= ~_FPU_MASK_NI;
_FPU_SETCW(flags);
#elif defined(__mips__)
fpa_bicsr(FPA_CSR_FS);
#else
#error Unknown arch
#endif

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2017-2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
#ifndef __ROUNDING_MODE_H__
#define __ROUNDING_MODE_H__
#pragma STDC FENV_ACCESS ON
#include "compat.h"
#if (defined(_WIN32) && defined(_MSC_VER))
@ -44,10 +42,11 @@ typedef enum
kshort = 3,
kuint = 4,
kint = 5,
kfloat = 6,
kdouble = 7,
kulong = 8,
klong = 9,
khalf = 6,
kfloat = 7,
kdouble = 8,
kulong = 9,
klong = 10,
// This goes last
kTypeCount

View file

@ -0,0 +1,42 @@
//
// Copyright (c) 2023 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef STRING_HELPERS_H
#define STRING_HELPERS_H
#include <memory>
#include <stdexcept>
#include <string>
inline std::string concat_kernel(const char *sstr[], int num)
{
std::string res;
for (int i = 0; i < num; i++) res += std::string(sstr[i]);
return res;
}
template <typename... Args>
inline std::string str_sprintf(const std::string &str, Args... args)
{
int str_size = std::snprintf(nullptr, 0, str.c_str(), args...) + 1;
if (str_size <= 0) throw std::runtime_error("Formatting error.");
size_t s = static_cast<size_t>(str_size);
std::unique_ptr<char[]> buffer(new char[s]);
std::snprintf(buffer.get(), s, str.c_str(), args...);
return std::string(buffer.get(), buffer.get() + s - 1);
}
#endif // STRING_HELPERS_H

View file

@ -20,9 +20,11 @@
#include <stdlib.h>
#include <string.h>
#include <cassert>
#include <deque>
#include <mutex>
#include <stdexcept>
#include <thread>
#include <vector>
#include "threadTesting.h"
#include "errorHelpers.h"
#include "kernelHelpers.h"
#include "fpcontrol.h"
@ -60,6 +62,75 @@ bool gCoreILProgram = true;
#define DEFAULT_NUM_ELEMENTS 0x4000
test_definition *test_registry::definitions() { return &m_definitions[0]; }
size_t test_registry::num_tests() { return m_definitions.size(); }
void test_registry::add_test(test *t, const char *name, Version version)
{
m_tests.push_back(t);
test_definition testDef;
testDef.func = t->getFunction();
testDef.name = name;
testDef.min_version = version;
m_definitions.push_back(testDef);
}
test_registry &test_registry::getInstance()
{
static test_registry instance;
return instance;
}
static int saveResultsToJson(const char *suiteName, test_definition testList[],
unsigned char selectedTestList[],
test_status resultTestList[], int testNum)
{
char *fileName = getenv("CL_CONFORMANCE_RESULTS_FILENAME");
if (fileName == nullptr)
{
return EXIT_SUCCESS;
}
FILE *file = fopen(fileName, "w");
if (NULL == file)
{
log_error("ERROR: Failed to open '%s' for writing results.\n",
fileName);
return EXIT_FAILURE;
}
const char *save_map[] = { "success", "failure" };
const char *result_map[] = { "pass", "fail", "skip" };
const char *linebreak[] = { "", ",\n" };
int add_linebreak = 0;
fprintf(file, "{\n");
fprintf(file, "\t\"cmd\": \"%s\",\n", suiteName);
fprintf(file, "\t\"results\": {\n");
for (int i = 0; i < testNum; ++i)
{
if (selectedTestList[i])
{
fprintf(file, "%s\t\t\"%s\": \"%s\"", linebreak[add_linebreak],
testList[i].name, result_map[(int)resultTestList[i]]);
add_linebreak = 1;
}
}
fprintf(file, "\n");
fprintf(file, "\t}\n");
fprintf(file, "}\n");
int ret = fclose(file) ? EXIT_FAILURE : EXIT_SUCCESS;
log_info("Saving results to %s: %s!\n", fileName, save_map[ret]);
return ret;
}
int runTestHarness(int argc, const char *argv[], int testNum,
test_definition testList[], int forceNoContextCreation,
cl_command_queue_properties queueProps)
@ -68,19 +139,28 @@ int runTestHarness(int argc, const char *argv[], int testNum,
forceNoContextCreation, queueProps, NULL);
}
int skip_init_info(int count)
int suite_did_not_pass_init(const char *suiteName, test_status status,
int testNum, test_definition testList[])
{
log_info("Test skipped while initialization\n");
log_info("SKIPPED %d of %d tests.\n", count, count);
return EXIT_SUCCESS;
std::vector<unsigned char> selectedTestList(testNum, 1);
std::vector<test_status> resultTestList(testNum, status);
int ret = saveResultsToJson(suiteName, testList, selectedTestList.data(),
resultTestList.data(), testNum);
log_info("Test %s while initialization\n",
status == TEST_SKIP ? "skipped" : "failed");
log_info("%s %d of %d tests.\n", status == TEST_SKIP ? "SKIPPED" : "FAILED",
testNum, testNum);
if (ret != EXIT_SUCCESS)
{
return ret;
}
return status == TEST_SKIP ? EXIT_SUCCESS : EXIT_FAILURE;
}
int fail_init_info(int count)
{
log_info("Test failed while initialization\n");
log_info("FAILED %d of %d tests.\n", count, count);
return EXIT_FAILURE;
}
void version_expected_info(const char *test_name, const char *api_name,
const char *expected_version,
const char *device_version)
@ -126,6 +206,9 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
else if (strcmp(env_mode, "accelerator") == 0
|| strcmp(env_mode, "CL_DEVICE_TYPE_ACCELERATOR") == 0)
device_type = CL_DEVICE_TYPE_ACCELERATOR;
else if (strcmp(env_mode, "custom") == 0
|| strcmp(env_mode, "CL_DEVICE_TYPE_CUSTOM") == 0)
device_type = CL_DEVICE_TYPE_CUSTOM;
else if (strcmp(env_mode, "default") == 0
|| strcmp(env_mode, "CL_DEVICE_TYPE_DEFAULT") == 0)
device_type = CL_DEVICE_TYPE_DEFAULT;
@ -255,6 +338,12 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
device_type = CL_DEVICE_TYPE_ACCELERATOR;
argc--;
}
else if (strcmp(argv[argc - 1], "custom") == 0
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_CUSTOM") == 0)
{
device_type = CL_DEVICE_TYPE_CUSTOM;
argc--;
}
else if (strcmp(argv[argc - 1], "CL_DEVICE_TYPE_DEFAULT") == 0)
{
device_type = CL_DEVICE_TYPE_DEFAULT;
@ -292,6 +381,9 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
case CL_DEVICE_TYPE_ACCELERATOR:
log_info("Requesting Accelerator device ");
break;
case CL_DEVICE_TYPE_CUSTOM:
log_info("Requesting Custom device ");
break;
case CL_DEVICE_TYPE_DEFAULT:
log_info("Requesting Default device ");
break;
@ -470,6 +562,7 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
log_error("Invalid device address bit size returned by device.\n");
return EXIT_FAILURE;
}
const char *suiteName = argv[0];
if (gCompilationMode == kSpir_v)
{
test_status spirv_readiness = check_spirv_compilation_readiness(device);
@ -478,9 +571,15 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
switch (spirv_readiness)
{
case TEST_PASS: break;
case TEST_FAIL: return fail_init_info(testNum);
case TEST_SKIP: return skip_init_info(testNum);
case TEST_SKIPPED_ITSELF: return skip_init_info(testNum);
case TEST_FAIL:
return suite_did_not_pass_init(suiteName, TEST_FAIL,
testNum, testList);
case TEST_SKIP:
return suite_did_not_pass_init(suiteName, TEST_SKIP,
testNum, testList);
case TEST_SKIPPED_ITSELF:
return suite_did_not_pass_init(suiteName, TEST_SKIP,
testNum, testList);
}
}
}
@ -492,9 +591,15 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
switch (status)
{
case TEST_PASS: break;
case TEST_FAIL: return fail_init_info(testNum);
case TEST_SKIP: return skip_init_info(testNum);
case TEST_SKIPPED_ITSELF: return skip_init_info(testNum);
case TEST_FAIL:
return suite_did_not_pass_init(suiteName, TEST_FAIL, testNum,
testList);
case TEST_SKIP:
return suite_did_not_pass_init(suiteName, TEST_SKIP, testNum,
testList);
case TEST_SKIPPED_ITSELF:
return suite_did_not_pass_init(suiteName, TEST_SKIP, testNum,
testList);
}
}
@ -514,10 +619,12 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
FPU_mode_type oldMode;
DisableFTZ(&oldMode);
#endif
extern unsigned gNumWorkerThreads;
test_harness_config config = { forceNoContextCreation, num_elements,
queueProps, gNumWorkerThreads };
int error = parseAndCallCommandLineTests(argc, argv, device, testNum,
testList, forceNoContextCreation,
queueProps, num_elements);
testList, config);
#if defined(__APPLE__) && defined(__arm__)
// Restore the old FP mode before leaving.
@ -574,49 +681,6 @@ static int find_matching_tests(test_definition testList[],
return EXIT_SUCCESS;
}
static int saveResultsToJson(const char *fileName, const char *suiteName,
test_definition testList[],
unsigned char selectedTestList[],
test_status resultTestList[], int testNum)
{
FILE *file = fopen(fileName, "w");
if (NULL == file)
{
log_error("ERROR: Failed to open '%s' for writing results.\n",
fileName);
return EXIT_FAILURE;
}
const char *save_map[] = { "success", "failure" };
const char *result_map[] = { "pass", "fail", "skip" };
const char *linebreak[] = { "", ",\n" };
int add_linebreak = 0;
fprintf(file, "{\n");
fprintf(file, "\t\"cmd\": \"%s\",\n", suiteName);
fprintf(file, "\t\"results\": {\n");
for (int i = 0; i < testNum; ++i)
{
if (selectedTestList[i])
{
fprintf(file, "%s\t\t\"%s\": \"%s\"", linebreak[add_linebreak],
testList[i].name, result_map[(int)resultTestList[i]]);
add_linebreak = 1;
}
}
fprintf(file, "\n");
fprintf(file, "\t}\n");
fprintf(file, "}\n");
int ret = fclose(file) ? 1 : 0;
log_info("Saving results to %s: %s!\n", fileName, save_map[ret]);
return ret;
}
static void print_results(int failed, int count, const char *name)
{
if (count < failed)
@ -646,19 +710,17 @@ static void print_results(int failed, int count, const char *name)
log_error("FAILED %s.\n", name);
}
}
fflush(stdout);
}
int parseAndCallCommandLineTests(int argc, const char *argv[],
cl_device_id device, int testNum,
test_definition testList[],
int forceNoContextCreation,
cl_command_queue_properties queueProps,
int num_elements)
const test_harness_config &config)
{
int ret = EXIT_SUCCESS;
unsigned char *selectedTestList = (unsigned char *)calloc(testNum, 1);
test_status *resultTestList = NULL;
if (argc == 1)
{
@ -697,24 +759,18 @@ int parseAndCallCommandLineTests(int argc, const char *argv[],
if (ret == EXIT_SUCCESS)
{
resultTestList =
(test_status *)calloc(testNum, sizeof(*resultTestList));
std::vector<test_status> resultTestList(testNum, TEST_PASS);
callTestFunctions(testList, selectedTestList, resultTestList, testNum,
device, forceNoContextCreation, num_elements,
queueProps);
callTestFunctions(testList, selectedTestList, resultTestList.data(),
testNum, device, config);
print_results(gFailCount, gTestCount, "sub-test");
print_results(gTestsFailed, gTestsFailed + gTestsPassed, "test");
char *filename = getenv("CL_CONFORMANCE_RESULTS_FILENAME");
if (filename != NULL)
{
ret = saveResultsToJson(filename, argv[0], testList,
selectedTestList, resultTestList, testNum);
}
ret = saveResultsToJson(argv[0], testList, selectedTestList,
resultTestList.data(), testNum);
if (std::any_of(resultTestList, resultTestList + testNum,
if (std::any_of(resultTestList.begin(), resultTestList.end(),
[](test_status result) {
switch (result)
{
@ -730,26 +786,101 @@ int parseAndCallCommandLineTests(int argc, const char *argv[],
}
free(selectedTestList);
free(resultTestList);
return ret;
}
struct test_harness_state
{
test_definition *tests;
test_status *results;
cl_device_id device;
test_harness_config config;
};
static std::deque<int> gTestQueue;
static std::mutex gTestStateMutex;
void test_function_runner(test_harness_state *state)
{
int testID;
test_definition test;
while (true)
{
// Attempt to get a test
{
std::lock_guard<std::mutex> lock(gTestStateMutex);
// The queue is empty, we're done
if (gTestQueue.size() == 0)
{
return;
}
// Get the test at the front of the queue
testID = gTestQueue.front();
gTestQueue.pop_front();
test = state->tests[testID];
}
// Execute test
auto status =
callSingleTestFunction(test, state->device, state->config);
// Store result
{
std::lock_guard<std::mutex> lock(gTestStateMutex);
state->results[testID] = status;
}
}
}
void callTestFunctions(test_definition testList[],
unsigned char selectedTestList[],
test_status resultTestList[], int testNum,
cl_device_id deviceToUse, int forceNoContextCreation,
int numElementsToUse,
cl_command_queue_properties queueProps)
cl_device_id deviceToUse,
const test_harness_config &config)
{
for (int i = 0; i < testNum; ++i)
// Execute tests serially
if (config.numWorkerThreads == 0)
{
if (selectedTestList[i])
for (int i = 0; i < testNum; ++i)
{
resultTestList[i] = callSingleTestFunction(
testList[i], deviceToUse, forceNoContextCreation,
numElementsToUse, queueProps);
if (selectedTestList[i])
{
resultTestList[i] =
callSingleTestFunction(testList[i], deviceToUse, config);
}
}
// Execute tests in parallel with the specified number of worker threads
}
else
{
// Queue all tests that need to run
for (int i = 0; i < testNum; ++i)
{
if (selectedTestList[i])
{
gTestQueue.push_back(i);
}
}
// Spawn thread pool
std::vector<std::thread *> threads;
test_harness_state state = { testList, resultTestList, deviceToUse,
config };
for (unsigned i = 0; i < config.numWorkerThreads; i++)
{
log_info("Spawning worker thread %u\n", i);
threads.push_back(new std::thread(test_function_runner, &state));
}
// Wait for all threads to complete
for (auto th : threads)
{
th->join();
}
assert(gTestQueue.size() == 0);
}
}
@ -762,9 +893,7 @@ void CL_CALLBACK notify_callback(const char *errinfo, const void *private_info,
// Actual function execution
test_status callSingleTestFunction(test_definition test,
cl_device_id deviceToUse,
int forceNoContextCreation,
int numElementsToUse,
const cl_queue_properties queueProps)
const test_harness_config &config)
{
test_status status;
cl_int error;
@ -783,28 +912,39 @@ test_status callSingleTestFunction(test_definition test,
return TEST_SKIP;
}
if (!check_functions_for_offline_compiler(test.name))
{
log_info("Subtest %s tests is not supported in offline compiler "
"execution path!\n",
test.name);
return TEST_SKIP;
}
/* Create a context to work with, unless we're told not to */
if (!forceNoContextCreation)
if (!config.forceNoContextCreation)
{
context = clCreateContext(NULL, 1, &deviceToUse, notify_callback, NULL,
&error);
if (!context)
{
print_error(error, "Unable to create testing context");
gFailCount++;
gTestsFailed++;
return TEST_FAIL;
}
if (device_version < Version(2, 0))
{
queue =
clCreateCommandQueue(context, deviceToUse, queueProps, &error);
queue = clCreateCommandQueue(context, deviceToUse,
config.queueProps, &error);
}
else
{
const cl_command_queue_properties cmd_queueProps =
(queueProps) ? CL_QUEUE_PROPERTIES : 0;
cl_command_queue_properties queueCreateProps[] = { cmd_queueProps,
queueProps, 0 };
(config.queueProps) ? CL_QUEUE_PROPERTIES : 0;
cl_command_queue_properties queueCreateProps[] = {
cmd_queueProps, config.queueProps, 0
};
queue = clCreateCommandQueueWithProperties(
context, deviceToUse, &queueCreateProps[0], &error);
}
@ -812,14 +952,14 @@ test_status callSingleTestFunction(test_definition test,
if (queue == NULL)
{
print_error(error, "Unable to create testing command queue");
clReleaseContext(context);
gFailCount++;
gTestsFailed++;
return TEST_FAIL;
}
}
/* Run the test and print the result */
error = check_functions_for_offline_compiler(test.name, deviceToUse);
test_missing_support_offline_cmpiler(error, test.name);
if (test.func == NULL)
{
// Skip unimplemented test, can happen when all of the tests are
@ -829,7 +969,8 @@ test_status callSingleTestFunction(test_definition test,
}
else
{
int ret = test.func(deviceToUse, context, queue, numElementsToUse);
int ret =
test.func(deviceToUse, context, queue, config.numElementsToUse);
if (ret == TEST_SKIPPED_ITSELF)
{
/* Tests can also let us know they're not supported by the
@ -856,12 +997,14 @@ test_status callSingleTestFunction(test_definition test,
}
/* Release the context */
if (!forceNoContextCreation)
if (!config.forceNoContextCreation)
{
int error = clFinish(queue);
if (error)
{
log_error("clFinish failed: %d", error);
log_error("clFinish failed: %s\n", IGetErrorString(error));
gFailCount++;
gTestsFailed++;
status = TEST_FAIL;
}
clReleaseCommandQueue(queue);
@ -1087,18 +1230,21 @@ Version get_device_spirv_il_version(cl_device_id device)
ASSERT_SUCCESS(err, "clGetDeviceInfo");
}
if (strstr(str.data(), "SPIR-V_1.0") != NULL)
return Version(1, 0);
else if (strstr(str.data(), "SPIR-V_1.1") != NULL)
return Version(1, 1);
else if (strstr(str.data(), "SPIR-V_1.2") != NULL)
return Version(1, 2);
else if (strstr(str.data(), "SPIR-V_1.3") != NULL)
return Version(1, 3);
// Because this query returns a space-separated list of IL version strings
// we should check for SPIR-V versions in reverse order, to return the
// highest version supported.
if (strstr(str.data(), "SPIR-V_1.5") != NULL)
return Version(1, 5);
else if (strstr(str.data(), "SPIR-V_1.4") != NULL)
return Version(1, 4);
else if (strstr(str.data(), "SPIR-V_1.5") != NULL)
return Version(1, 5);
else if (strstr(str.data(), "SPIR-V_1.3") != NULL)
return Version(1, 3);
else if (strstr(str.data(), "SPIR-V_1.2") != NULL)
return Version(1, 2);
else if (strstr(str.data(), "SPIR-V_1.1") != NULL)
return Version(1, 1);
else if (strstr(str.data(), "SPIR-V_1.0") != NULL)
return Version(1, 0);
throw std::runtime_error(std::string("Unknown SPIR-V version: ")
+ str.data());
@ -1170,9 +1316,46 @@ cl_platform_id getPlatformFromDevice(cl_device_id deviceID)
return platform;
}
/**
* Helper to return a string containing platform information
* for the specified platform info parameter.
*/
std::string get_platform_info_string(cl_platform_id platform,
cl_platform_info param_name)
{
size_t size = 0;
int err;
if ((err = clGetPlatformInfo(platform, param_name, 0, NULL, &size))
!= CL_SUCCESS
|| size == 0)
{
throw std::runtime_error("clGetPlatformInfo failed\n");
}
std::vector<char> info(size);
if ((err = clGetPlatformInfo(platform, param_name, size, info.data(), NULL))
!= CL_SUCCESS)
{
throw std::runtime_error("clGetPlatformInfo failed\n");
}
/* The returned string does not include the null terminator. */
return std::string(info.data(), size - 1);
}
bool is_platform_extension_available(cl_platform_id platform,
const char *extensionName)
{
std::string extString =
get_platform_info_string(platform, CL_PLATFORM_EXTENSIONS);
return extString.find(extensionName) != std::string::npos;
}
void PrintArch(void)
{
vlog("sizeof( void*) = %ld\n", sizeof(void *));
vlog("sizeof( void*) = %zu\n", sizeof(void *));
#if defined(__ppc__)
vlog("ARCH:\tppc\n");
#elif defined(__ppc64__)
@ -1189,6 +1372,8 @@ void PrintArch(void)
vlog("ARCH:\taarch64\n");
#elif defined(_WIN32)
vlog("ARCH:\tWindows\n");
#elif defined(__mips__)
vlog("ARCH:\tmips\n");
#else
#error unknown arch
#endif

View file

@ -16,32 +16,41 @@
#ifndef _testHarness_h
#define _testHarness_h
#include "threadTesting.h"
#include "clImageHelper.h"
#include <string>
#include <sstream>
#include <string>
#include <vector>
class Version {
public:
Version(): m_major(0), m_minor(0) {}
Version(int major, int minor): m_major(major), m_minor(minor) {}
bool operator>(const Version &rhs) const { return to_int() > rhs.to_int(); }
bool operator<(const Version &rhs) const { return to_int() < rhs.to_int(); }
Version(cl_uint major, cl_uint minor): m_major(major), m_minor(minor) {}
int major() const { return m_major; }
int minor() const { return m_minor; }
bool operator>(const Version &rhs) const
{
return to_uint() > rhs.to_uint();
}
bool operator<(const Version &rhs) const
{
return to_uint() < rhs.to_uint();
}
bool operator<=(const Version &rhs) const
{
return to_int() <= rhs.to_int();
return to_uint() <= rhs.to_uint();
}
bool operator>=(const Version &rhs) const
{
return to_int() >= rhs.to_int();
return to_uint() >= rhs.to_uint();
}
bool operator==(const Version &rhs) const
{
return to_int() == rhs.to_int();
return to_uint() == rhs.to_uint();
}
int to_int() const { return m_major * 10 + m_minor; }
cl_uint to_uint() const { return m_major * 10 + m_minor; }
std::string to_string() const
{
std::stringstream ss;
@ -50,8 +59,8 @@ public:
}
private:
int m_major;
int m_minor;
cl_uint m_major;
cl_uint m_minor;
};
Version get_device_cl_version(cl_device_id device);
@ -67,9 +76,12 @@ Version get_device_cl_version(cl_device_id device);
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
typedef int (*test_function_pointer)(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
typedef struct test_definition
{
basefn func;
test_function_pointer func;
const char *name;
Version min_version;
} test_definition;
@ -83,6 +95,72 @@ typedef enum test_status
TEST_SKIPPED_ITSELF = -100,
} test_status;
struct test_harness_config
{
int forceNoContextCreation;
int numElementsToUse;
cl_command_queue_properties queueProps;
unsigned numWorkerThreads;
};
struct test
{
virtual test_function_pointer getFunction() = 0;
};
class test_registry {
private:
std::vector<test *> m_tests;
std::vector<test_definition> m_definitions;
public:
static test_registry &getInstance();
test_definition *definitions();
size_t num_tests();
void add_test(test *t, const char *name, Version version);
test_registry() {}
};
template <typename T> T *register_test(const char *name, Version version)
{
T *t = new T();
test_registry::getInstance().add_test((test *)t, name, version);
return t;
}
#define REGISTER_TEST_VERSION(name, version) \
extern int test_##name(cl_device_id device, cl_context context, \
cl_command_queue queue, int num_elements); \
class test_##name##_class : public test { \
private: \
test_function_pointer fn; \
\
public: \
test_##name##_class(): fn(test_##name) {} \
test_function_pointer getFunction() { return fn; } \
}; \
test_##name##_class *var_##name = \
register_test<test_##name##_class>(#name, version); \
int test_##name(cl_device_id device, cl_context context, \
cl_command_queue queue, int num_elements)
#define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2))
#define REQUIRE_EXTENSION(name) \
do \
{ \
if (!is_extension_available(device, name)) \
{ \
log_info(name \
" is not supported on this device. Skipping test.\n"); \
return TEST_SKIPPED_ITSELF; \
} \
} while (0)
extern int gFailCount;
extern int gTestCount;
extern cl_uint gReSeed;
@ -115,9 +193,7 @@ extern int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
extern int parseAndCallCommandLineTests(int argc, const char *argv[],
cl_device_id device, int testNum,
test_definition testList[],
int forceNoContextCreation,
cl_command_queue_properties queueProps,
int num_elements);
const test_harness_config &config);
// Call this function if you need to do all the setup work yourself, and just
// need the function list called/ managed.
@ -129,21 +205,19 @@ extern int parseAndCallCommandLineTests(int argc, const char *argv[],
// resultTestList is an array of statuses which contain the result of each
// selected test testNum is the number of tests in testList, selectedTestList
// and resultTestList contextProps are used to create a testing context for
// each test deviceToUse and numElementsToUse are all just passed to each
// each test deviceToUse and config are all just passed to each
// test function
extern void callTestFunctions(test_definition testList[],
unsigned char selectedTestList[],
test_status resultTestList[], int testNum,
cl_device_id deviceToUse,
int forceNoContextCreation, int numElementsToUse,
cl_command_queue_properties queueProps);
const test_harness_config &config);
// This function is called by callTestFunctions, once per function, to do setup,
// call, logging and cleanup
extern test_status
callSingleTestFunction(test_definition test, cl_device_id deviceToUse,
int forceNoContextCreation, int numElementsToUse,
cl_command_queue_properties queueProps);
extern test_status callSingleTestFunction(test_definition test,
cl_device_id deviceToUse,
const test_harness_config &config);
///// Miscellaneous steps
@ -179,6 +253,10 @@ extern int gHasLong; // This is set to 1 if the device suppots long and ulong
extern bool gCoreILProgram;
extern cl_platform_id getPlatformFromDevice(cl_device_id deviceID);
extern std::string get_platform_info_string(cl_platform_id platform,
cl_platform_info param_name);
extern bool is_platform_extension_available(cl_platform_id platform,
const char *extensionName);
#if !defined(__APPLE__)
void memset_pattern4(void *, const void *, size_t);

View file

@ -1,98 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "compat.h"
#include "threadTesting.h"
#include "errorHelpers.h"
#include <stdio.h>
#include <string.h>
#if !defined(_WIN32)
#include <pthread.h>
#endif
#if 0 // Disabed for now
typedef struct
{
basefn mFunction;
cl_device_id mDevice;
cl_context mContext;
int mNumElements;
} TestFnArgs;
////////////////////////////////////////////////////////////////////////////////
// Thread-based testing. Spawns a new thread to run the given test function,
// then waits for it to complete. The entire idea is that, if the thread crashes,
// we can catch it and report it as a failure instead of crashing the entire suite
////////////////////////////////////////////////////////////////////////////////
void *test_thread_wrapper( void *data )
{
TestFnArgs *args;
int retVal;
cl_context context;
args = (TestFnArgs *)data;
/* Create a new context to use (contexts can't cross threads) */
context = clCreateContext(NULL, args->mDeviceGroup);
if( context == NULL )
{
log_error("clCreateContext failed for new thread\n");
return (void *)(-1);
}
/* Call function */
retVal = args->mFunction( args->mDeviceGroup, args->mDevice, context, args->mNumElements );
clReleaseContext( context );
return (void *)retVal;
}
int test_threaded_function( basefn fnToTest, cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
{
int error;
pthread_t threadHdl;
void *retVal;
TestFnArgs args;
args.mFunction = fnToTest;
args.mDeviceGroup = deviceGroup;
args.mDevice = device;
args.mContext = context;
args.mNumElements = numElements;
error = pthread_create( &threadHdl, NULL, test_thread_wrapper, (void *)&args );
if( error != 0 )
{
log_error( "ERROR: Unable to create thread for testing!\n" );
return -1;
}
/* Thread has been started, now just wait for it to complete (or crash) */
error = pthread_join( threadHdl, &retVal );
if( error != 0 )
{
log_error( "ERROR: Unable to join testing thread!\n" );
return -1;
}
return (int)((intptr_t)retVal);
}
#endif

View file

@ -348,7 +348,7 @@ cl_int clProtectedImage::Create(cl_context context,
const cl_image_format *fmt, size_t width,
size_t height, size_t depth, size_t arraySize)
{
cl_int error;
cl_int error = 0;
#if defined(__APPLE__)
int protect_pages = 1;
cl_device_id devices[16];

View file

@ -16,123 +16,177 @@
#ifndef _typeWrappers_h
#define _typeWrappers_h
#include <stdio.h>
#include <stdlib.h>
#if !defined(_WIN32)
#include <sys/mman.h>
#endif
#include "compat.h"
#include <stdio.h>
#include "mt19937.h"
#include "errorHelpers.h"
#include "kernelHelpers.h"
/* cl_context wrapper */
#include <cstdlib>
#include <type_traits>
class clContextWrapper {
public:
clContextWrapper() { mContext = NULL; }
clContextWrapper(cl_context program) { mContext = program; }
~clContextWrapper()
namespace wrapper_details {
// clRetain*() and clRelease*() functions share the same type.
template <typename T> // T should be cl_context, cl_program, ...
using RetainReleaseType = cl_int CL_API_CALL(T);
// A generic wrapper class that follows OpenCL retain/release semantics.
//
// This Wrapper class implement copy and move semantics, which makes it
// compatible with standard containers for example.
//
// Template parameters:
// - T is the cl_* type (e.g. cl_context, cl_program, ...)
// - Retain is the clRetain* function (e.g. clRetainContext, ...)
// - Release is the clRelease* function (e.g. clReleaseContext, ...)
template <typename T, RetainReleaseType<T> Retain, RetainReleaseType<T> Release>
class Wrapper {
static_assert(std::is_pointer<T>::value, "T should be a pointer type.");
T object = nullptr;
void retain()
{
if (mContext != NULL) clReleaseContext(mContext);
if (!object) return;
auto err = Retain(object);
if (err != CL_SUCCESS)
{
print_error(err, "clRetain*() failed");
std::abort();
}
}
clContextWrapper &operator=(const cl_context &rhs)
void release()
{
mContext = rhs;
if (!object) return;
auto err = Release(object);
if (err != CL_SUCCESS)
{
print_error(err, "clRelease*() failed");
std::abort();
}
}
public:
Wrapper() = default;
// On initialisation, assume the object has a refcount of one.
Wrapper(T object): object(object) {}
// On assignment, assume the object has a refcount of one.
Wrapper &operator=(T rhs)
{
reset(rhs);
return *this;
}
operator cl_context() const { return mContext; }
cl_context *operator&() { return &mContext; }
bool operator==(const cl_context &rhs) { return mContext == rhs; }
protected:
cl_context mContext;
};
/* cl_program wrapper */
class clProgramWrapper {
public:
clProgramWrapper() { mProgram = NULL; }
clProgramWrapper(cl_program program) { mProgram = program; }
~clProgramWrapper()
// Copy semantics, increase retain count.
Wrapper(Wrapper const &w) { *this = w; }
Wrapper &operator=(Wrapper const &w)
{
if (mProgram != NULL) clReleaseProgram(mProgram);
}
clProgramWrapper &operator=(const cl_program &rhs)
{
mProgram = rhs;
reset(w.object);
retain();
return *this;
}
operator cl_program() const { return mProgram; }
cl_program *operator&() { return &mProgram; }
bool operator==(const cl_program &rhs) { return mProgram == rhs; }
protected:
cl_program mProgram;
};
/* cl_kernel wrapper */
class clKernelWrapper {
public:
clKernelWrapper() { mKernel = NULL; }
clKernelWrapper(cl_kernel kernel) { mKernel = kernel; }
~clKernelWrapper()
// Move semantics, directly take ownership.
Wrapper(Wrapper &&w) { *this = std::move(w); }
Wrapper &operator=(Wrapper &&w)
{
if (mKernel != NULL) clReleaseKernel(mKernel);
}
clKernelWrapper &operator=(const cl_kernel &rhs)
{
mKernel = rhs;
reset(w.object);
w.object = nullptr;
return *this;
}
operator cl_kernel() const { return mKernel; }
cl_kernel *operator&() { return &mKernel; }
~Wrapper() { reset(); }
bool operator==(const cl_kernel &rhs) { return mKernel == rhs; }
protected:
cl_kernel mKernel;
};
/* cl_mem (stream) wrapper */
class clMemWrapper {
public:
clMemWrapper() { mMem = NULL; }
clMemWrapper(cl_mem mem) { mMem = mem; }
~clMemWrapper()
// Release the existing object, if any, and own the new one, if any.
void reset(T new_object = nullptr)
{
if (mMem != NULL) clReleaseMemObject(mMem);
release();
object = new_object;
}
clMemWrapper &operator=(const cl_mem &rhs)
operator T() const { return object; }
// Ideally this function should not exist as it breaks encapsulation by
// allowing external mutation of the Wrapper internal state. However, too
// much code currently relies on this. For example, instead of using T* as
// output parameters, existing code can be updated to use Wrapper& instead.
T *operator&() { return &object; }
};
} // namespace wrapper_details
using clContextWrapper =
wrapper_details::Wrapper<cl_context, clRetainContext, clReleaseContext>;
using clProgramWrapper =
wrapper_details::Wrapper<cl_program, clRetainProgram, clReleaseProgram>;
using clKernelWrapper =
wrapper_details::Wrapper<cl_kernel, clRetainKernel, clReleaseKernel>;
using clMemWrapper =
wrapper_details::Wrapper<cl_mem, clRetainMemObject, clReleaseMemObject>;
using clCommandQueueWrapper =
wrapper_details::Wrapper<cl_command_queue, clRetainCommandQueue,
clReleaseCommandQueue>;
using clSamplerWrapper =
wrapper_details::Wrapper<cl_sampler, clRetainSampler, clReleaseSampler>;
using clEventWrapper =
wrapper_details::Wrapper<cl_event, clRetainEvent, clReleaseEvent>;
class clSVMWrapper {
void *Ptr = nullptr;
cl_context Ctx = nullptr;
public:
clSVMWrapper() = default;
clSVMWrapper(cl_context C, size_t Size,
cl_svm_mem_flags F = CL_MEM_READ_WRITE)
: Ctx(C)
{
mMem = rhs;
Ptr = clSVMAlloc(C, F, Size, 0);
}
clSVMWrapper &operator=(void *other) = delete;
clSVMWrapper(clSVMWrapper const &other) = delete;
clSVMWrapper &operator=(clSVMWrapper const &other) = delete;
clSVMWrapper(clSVMWrapper &&other)
{
Ptr = other.Ptr;
Ctx = other.Ctx;
other.Ptr = nullptr;
other.Ctx = nullptr;
}
clSVMWrapper &operator=(clSVMWrapper &&other)
{
Ptr = other.Ptr;
Ctx = other.Ctx;
other.Ptr = nullptr;
other.Ctx = nullptr;
return *this;
}
operator cl_mem() const { return mMem; }
cl_mem *operator&() { return &mMem; }
~clSVMWrapper()
{
if (Ptr) clSVMFree(Ctx, Ptr);
}
bool operator==(const cl_mem &rhs) { return mMem == rhs; }
protected:
cl_mem mMem;
void *operator()() const { return Ptr; }
};
class clProtectedImage {
public:
clProtectedImage()
@ -183,92 +237,12 @@ public:
cl_mem *operator&() { return &image; }
bool operator==(const cl_mem &rhs) { return image == rhs; }
protected:
void *backingStore;
size_t backingStoreSize;
cl_mem image;
};
/* cl_command_queue wrapper */
class clCommandQueueWrapper {
public:
clCommandQueueWrapper() { mMem = NULL; }
clCommandQueueWrapper(cl_command_queue mem) { mMem = mem; }
~clCommandQueueWrapper()
{
if (mMem != NULL)
{
clReleaseCommandQueue(mMem);
}
}
clCommandQueueWrapper &operator=(const cl_command_queue &rhs)
{
mMem = rhs;
return *this;
}
operator cl_command_queue() const { return mMem; }
cl_command_queue *operator&() { return &mMem; }
bool operator==(const cl_command_queue &rhs) { return mMem == rhs; }
protected:
cl_command_queue mMem;
};
/* cl_sampler wrapper */
class clSamplerWrapper {
public:
clSamplerWrapper() { mMem = NULL; }
clSamplerWrapper(cl_sampler mem) { mMem = mem; }
~clSamplerWrapper()
{
if (mMem != NULL) clReleaseSampler(mMem);
}
clSamplerWrapper &operator=(const cl_sampler &rhs)
{
mMem = rhs;
return *this;
}
operator cl_sampler() const { return mMem; }
cl_sampler *operator&() { return &mMem; }
bool operator==(const cl_sampler &rhs) { return mMem == rhs; }
protected:
cl_sampler mMem;
};
/* cl_event wrapper */
class clEventWrapper {
public:
clEventWrapper() { mMem = NULL; }
clEventWrapper(cl_event mem) { mMem = mem; }
~clEventWrapper()
{
if (mMem != NULL) clReleaseEvent(mMem);
}
clEventWrapper &operator=(const cl_event &rhs)
{
mMem = rhs;
return *this;
}
operator cl_event() const { return mMem; }
cl_event *operator&() { return &mMem; }
bool operator==(const cl_event &rhs) { return mMem == rhs; }
protected:
cl_event mMem;
};
/* Generic protected memory buffer, for verifying access within bounds */
class clProtectedArray {
public:
@ -403,4 +377,24 @@ public:
size_t getSize() const { return allocsize; };
};
// scope guard helper to ensure proper releasing of sub devices
struct SubDevicesScopeGuarded
{
SubDevicesScopeGuarded(const cl_int dev_count)
{
sub_devices.resize(dev_count);
}
~SubDevicesScopeGuarded()
{
for (auto &device : sub_devices)
{
cl_int err = clReleaseDevice(device);
if (err != CL_SUCCESS)
log_error("\n Releasing sub-device failed \n");
}
}
std::vector<cl_device_id> sub_devices;
};
#endif // _typeWrappers_h

View file

@ -7,3 +7,8 @@ add_executable(${${MODULE_NAME}_OUT} ${${MODULE_NAME}_SOURCES})
set_property(TARGET ${${MODULE_NAME}_OUT} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}")
TARGET_LINK_LIBRARIES(${${MODULE_NAME}_OUT} ${HARNESS_LIB} ${CLConform_LIBRARIES})
include(GNUInstallDirs)
install(TARGETS ${${MODULE_NAME}_OUT}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/$<CONFIG>)

View file

@ -50,11 +50,12 @@ add_subdirectory( subgroups )
add_subdirectory( workgroups )
add_subdirectory( pipes )
add_subdirectory( device_timer )
if(KHRONOS_OFFLINE_COMPILER)
add_subdirectory( clcpp )
endif()
add_subdirectory( spirv_new )
add_subdirectory( spir )
if(VULKAN_IS_SUPPORTED)
add_subdirectory( common/vulkan_wrapper )
add_subdirectory( vulkan )
endif()
file(GLOB CSV_FILES "opencl_conformance_tests_*.csv")

View file

@ -1,9 +1,9 @@
set(CMAKE_CXX_STANDARD 11)
set(MODULE_NAME SVM)
set(${MODULE_NAME}_SOURCES
main.cpp
test_allocate_shared_buffer.cpp
test_allocate_shared_buffer_negative.cpp
test_byte_granularity.cpp
test_cross_buffer_pointers.cpp
test_enqueue_api.cpp
@ -18,4 +18,6 @@ set(${MODULE_NAME}_SOURCES
test_migrate.cpp
)
set_gnulike_module_compile_flags("-Wno-sometimes-uninitialized -Wno-sign-compare")
include(../CMakeCommon.txt)

View file

@ -81,21 +81,6 @@ extern cl_int verify_linked_lists_on_device(int qi, cl_command_queue q, c
extern cl_int create_linked_lists_on_device_no_map(int qi, cl_command_queue q, size_t *pAllocator, cl_kernel k, size_t numLists );
extern cl_int verify_linked_lists_on_device_no_map(int qi, cl_command_queue q, cl_int *pNum_correct, cl_kernel k, cl_int ListLength, size_t numLists );
extern int test_svm_byte_granularity(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_set_kernel_exec_info_svm_ptrs(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_fine_grain_memory_consistency(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_fine_grain_sync_buffers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_shared_address_space_coarse_grain_old_api(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_shared_address_space_coarse_grain_new_api(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_shared_address_space_fine_grain_buffers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_shared_address_space_fine_grain(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_cross_buffer_pointers_coarse_grain(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_pointer_passing(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_allocate_shared_buffer(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_shared_sub_buffers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_enqueue_api(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_svm_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern cl_int create_cl_objects(cl_device_id device_from_harness, const char** ppCodeString, cl_context* context, cl_program *program, cl_command_queue *queues, cl_uint *num_devices, cl_device_svm_capabilities required_svm_caps, std::vector<std::string> extensions_list = std::vector<std::string>());
extern const char *linked_list_create_and_verify_kernels[];

View file

@ -260,25 +260,6 @@ cl_int create_cl_objects(cl_device_id device_from_harness, const char** ppCodeSt
return 0;
}
test_definition test_list[] = {
ADD_TEST( svm_byte_granularity),
ADD_TEST( svm_set_kernel_exec_info_svm_ptrs ),
ADD_TEST( svm_fine_grain_memory_consistency ),
ADD_TEST( svm_fine_grain_sync_buffers ),
ADD_TEST( svm_shared_address_space_fine_grain ),
ADD_TEST( svm_shared_sub_buffers ),
ADD_TEST( svm_shared_address_space_fine_grain_buffers ),
ADD_TEST( svm_allocate_shared_buffer ),
ADD_TEST( svm_shared_address_space_coarse_grain_old_api ),
ADD_TEST( svm_shared_address_space_coarse_grain_new_api ),
ADD_TEST( svm_cross_buffer_pointers_coarse_grain ),
ADD_TEST( svm_pointer_passing ),
ADD_TEST( svm_enqueue_api ),
ADD_TEST_VERSION( svm_migrate, Version(2, 1)),
};
const int test_num = ARRAY_SIZE( test_list );
test_status InitCL(cl_device_id device) {
auto version = get_device_cl_version(device);
auto expected_min_version = Version(2, 0);
@ -309,6 +290,7 @@ test_status InitCL(cl_device_id device) {
int main(int argc, const char *argv[])
{
return runTestHarnessWithCheck(argc, argv, test_num, test_list, true, 0, InitCL);
return runTestHarnessWithCheck(
argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), true, 0, InitCL);
}

View file

@ -41,71 +41,82 @@ const char* flag_set_names[] = {
};
int test_svm_allocate_shared_buffer(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_allocate_shared_buffer)
{
clContextWrapper context = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
cl_device_svm_capabilities caps;
err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES, sizeof(cl_device_svm_capabilities), &caps, NULL);
test_error(err,"clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");
cl_device_svm_capabilities caps;
err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES,
sizeof(cl_device_svm_capabilities), &caps, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");
// under construction...
err = create_cl_objects(deviceID, NULL, &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(err) return -1;
// under construction...
err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (err) return -1;
size_t size = 1024;
size_t size = 1024;
// iteration over flag combos
int num_flags = sizeof(flag_set)/sizeof(cl_mem_flags);
for(int i = 0; i < num_flags; i++)
{
if (((flag_set[i] & CL_MEM_SVM_FINE_GRAIN_BUFFER) != 0 && (caps & CL_DEVICE_SVM_FINE_GRAIN_BUFFER) == 0)
|| ((flag_set[i] & CL_MEM_SVM_ATOMICS) != 0 && (caps & CL_DEVICE_SVM_ATOMICS) == 0))
// iteration over flag combos
int num_flags = sizeof(flag_set) / sizeof(cl_mem_flags);
for (int i = 0; i < num_flags; i++)
{
log_info("Skipping clSVMalloc with flags: %s\n", flag_set_names[i]);
continue;
}
log_info("Testing clSVMalloc with flags: %s\n", flag_set_names[i]);
cl_char *pBufData1 = (cl_char*) clSVMAlloc(context, flag_set[i], size, 0);
if(pBufData1 == NULL)
{
log_error("SVMalloc returned NULL");
return -1;
}
{
clMemWrapper buf = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, size, pBufData1, &err);
test_error(err,"clCreateBuffer failed");
cl_char *pBufData2 = NULL;
cl_uint flags = CL_MAP_READ | CL_MAP_READ;
if(flag_set[i] & CL_MEM_HOST_READ_ONLY) flags ^= CL_MAP_WRITE;
if(flag_set[i] & CL_MEM_HOST_WRITE_ONLY) flags ^= CL_MAP_READ;
if(!(flag_set[i] & CL_MEM_HOST_NO_ACCESS))
{
pBufData2 = (cl_char*) clEnqueueMapBuffer(queues[0], buf, CL_TRUE, flags, 0, size, 0, NULL,NULL, &err);
test_error(err, "clEnqueueMapBuffer failed");
if(pBufData2 != pBufData1 || NULL == pBufData1)
if (((flag_set[i] & CL_MEM_SVM_FINE_GRAIN_BUFFER) != 0
&& (caps & CL_DEVICE_SVM_FINE_GRAIN_BUFFER) == 0)
|| ((flag_set[i] & CL_MEM_SVM_ATOMICS) != 0
&& (caps & CL_DEVICE_SVM_ATOMICS) == 0))
{
log_error("SVM pointer returned by clEnqueueMapBuffer doesn't match pointer returned by clSVMalloc");
return -1;
log_info("Skipping clSVMalloc with flags: %s\n", flag_set_names[i]);
continue;
}
err = clEnqueueUnmapMemObject(queues[0], buf, pBufData2, 0, NULL, NULL);
test_error(err, "clEnqueueUnmapMemObject failed");
err = clFinish(queues[0]);
test_error(err, "clFinish failed");
}
log_info("Testing clSVMalloc with flags: %s\n", flag_set_names[i]);
cl_char *pBufData1 =
(cl_char *)clSVMAlloc(context, flag_set[i], size, 0);
if (pBufData1 == NULL)
{
log_error("SVMalloc returned NULL");
return -1;
}
{
clMemWrapper buf = clCreateBuffer(context, CL_MEM_USE_HOST_PTR,
size, pBufData1, &err);
test_error(err, "clCreateBuffer failed");
cl_char *pBufData2 = NULL;
cl_uint flags = CL_MAP_READ | CL_MAP_READ;
if (flag_set[i] & CL_MEM_HOST_READ_ONLY) flags ^= CL_MAP_WRITE;
if (flag_set[i] & CL_MEM_HOST_WRITE_ONLY) flags ^= CL_MAP_READ;
if (!(flag_set[i] & CL_MEM_HOST_NO_ACCESS))
{
pBufData2 = (cl_char *)clEnqueueMapBuffer(
queues[0], buf, CL_TRUE, flags, 0, size, 0, NULL, NULL,
&err);
test_error(err, "clEnqueueMapBuffer failed");
if (pBufData2 != pBufData1 || NULL == pBufData1)
{
log_error("SVM pointer returned by clEnqueueMapBuffer "
"doesn't match pointer returned by clSVMalloc");
return -1;
}
err = clEnqueueUnmapMemObject(queues[0], buf, pBufData2, 0,
NULL, NULL);
test_error(err, "clEnqueueUnmapMemObject failed");
err = clFinish(queues[0]);
test_error(err, "clFinish failed");
}
}
clSVMFree(context, pBufData1);
}
clSVMFree(context, pBufData1);
}
return 0;
return 0;
}

View file

@ -0,0 +1,100 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "common.h"
const cl_mem_flags svm_flag_set[] = {
CL_MEM_READ_WRITE,
CL_MEM_WRITE_ONLY,
CL_MEM_READ_ONLY,
CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
CL_MEM_WRITE_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER,
CL_MEM_READ_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER,
CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS,
CL_MEM_WRITE_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS,
CL_MEM_READ_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS,
0
};
const char* svm_flag_set_names[] = {
"CL_MEM_READ_WRITE",
"CL_MEM_WRITE_ONLY",
"CL_MEM_READ_ONLY",
"CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER",
"CL_MEM_WRITE_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER",
"CL_MEM_READ_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER",
"CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS",
"CL_MEM_WRITE_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS",
"CL_MEM_READ_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS",
"0"
};
REGISTER_TEST(svm_allocate_shared_buffer_negative)
{
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
cl_device_svm_capabilities caps;
err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES,
sizeof(cl_device_svm_capabilities), &caps, NULL);
test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES");
// under construction...
err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (err) return err;
size_t size = 1024;
// iteration over flag combos
int num_flags = sizeof(svm_flag_set) / sizeof(cl_mem_flags);
for (int i = 0; i < num_flags; i++)
{
if (((svm_flag_set[i] & CL_MEM_SVM_FINE_GRAIN_BUFFER) != 0
&& (caps & CL_DEVICE_SVM_FINE_GRAIN_BUFFER) == 0)
|| ((svm_flag_set[i] & CL_MEM_SVM_ATOMICS) != 0
&& (caps & CL_DEVICE_SVM_ATOMICS) == 0))
{
log_info("Skipping clSVMalloc with flags: %s\n",
svm_flag_set_names[i]);
continue;
}
log_info("Testing clSVMalloc with flags: %s\n", svm_flag_set_names[i]);
cl_char* pBufData1 =
(cl_char*)clSVMAlloc(context, svm_flag_set[i], size, 0);
if (pBufData1 == NULL)
{
log_error("SVMalloc returned NULL");
return -1;
}
{
clMemWrapper buf1 = clCreateBuffer(context, CL_MEM_USE_HOST_PTR,
2 * size, pBufData1, &err);
test_failure_error(err, CL_INVALID_BUFFER_SIZE,
"clCreateBuffer did not return expected error"
"CL_INVALID_BUFFER_SIZE");
}
clSVMFree(context, pBufData1);
}
return TEST_PASS;
}

View file

@ -48,101 +48,115 @@ const char *byte_manipulation_kernels[] = {
};
int test_svm_byte_granularity(cl_device_id deviceID, cl_context c, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_byte_granularity)
{
clContextWrapper context;
clProgramWrapper program;
clKernelWrapper k1,k2;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper;
clProgramWrapper program;
clKernelWrapper k1, k2;
clCommandQueueWrapper queues[MAXQ];
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
cl_int rval = CL_SUCCESS;
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
err = create_cl_objects(deviceID, &byte_manipulation_kernels[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
if(err == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(err < 0) return -1; // fail test.
err = create_cl_objects(device, &byte_manipulation_kernels[0],
&contextWrapper, &program, &queues[0], &num_devices,
CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
context = contextWrapper;
if (err == 1)
return 0; // no devices capable of requested SVM level, so don't execute
// but count test as passing.
if (err < 0) return -1; // fail test.
cl_uint num_devices_plus_host = num_devices + 1;
cl_uint num_devices_plus_host = num_devices + 1;
k1 = clCreateKernel(program, "write_owned_locations", &err);
test_error(err, "clCreateKernel failed");
k2 = clCreateKernel(program, "sum_neighbor_locations", &err);
test_error(err, "clCreateKernel failed");
k1 = clCreateKernel(program, "write_owned_locations", &err);
test_error(err, "clCreateKernel failed");
k2 = clCreateKernel(program, "sum_neighbor_locations", &err);
test_error(err, "clCreateKernel failed");
cl_char *pA = (cl_char*) clSVMAlloc(context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, sizeof(cl_char) * num_elements, 0);
cl_char *pA = (cl_char *)clSVMAlloc(
context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
sizeof(cl_char) * num_elements, 0);
cl_uint **error_counts = (cl_uint**) malloc(sizeof(void*) * num_devices);
cl_uint **error_counts = (cl_uint **)malloc(sizeof(void *) * num_devices);
for(cl_uint i=0; i < num_devices; i++) {
error_counts[i] = (cl_uint*) clSVMAlloc(context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, sizeof(cl_uint), 0);
*error_counts[i] = 0;
}
for(int i=0; i < num_elements; i++) pA[i] = -1;
for (cl_uint i = 0; i < num_devices; i++)
{
error_counts[i] = (cl_uint *)clSVMAlloc(
context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
sizeof(cl_uint), 0);
*error_counts[i] = 0;
}
for (int i = 0; i < num_elements; i++) pA[i] = -1;
err |= clSetKernelArgSVMPointer(k1, 0, pA);
err |= clSetKernelArg(k1, 1, sizeof(cl_uint), &num_devices_plus_host);
test_error(err, "clSetKernelArg failed");
// get all the devices going simultaneously
size_t element_num = num_elements;
for(cl_uint d=0; d < num_devices; d++) // device ids starting at 1.
{
err = clSetKernelArg(k1, 2, sizeof(cl_uint), &d);
test_error(err, "clSetKernelArg failed");
err = clEnqueueNDRangeKernel(queues[d], k1, 1, NULL, &element_num, NULL, 0, NULL, NULL);
test_error(err,"clEnqueueNDRangeKernel failed");
}
for(cl_uint d=0; d < num_devices; d++) clFlush(queues[d]);
cl_uint host_id = num_devices; // host code will take the id above the devices.
for(int i = (int)num_devices; i < num_elements; i+= num_devices_plus_host) pA[i] = host_id;
for(cl_uint id = 0; id < num_devices; id++) clFinish(queues[id]);
// now check that each device can see the byte writes made by the other devices.
err |= clSetKernelArgSVMPointer(k2, 0, pA);
err |= clSetKernelArg(k2, 1, sizeof(cl_uint), &num_devices_plus_host);
test_error(err, "clSetKernelArg failed");
// adjusted so k2 doesn't read past end of buffer
size_t adjusted_num_elements = num_elements - num_devices;
for(cl_uint id = 0; id < num_devices; id++)
{
err = clSetKernelArgSVMPointer(k2, 2, error_counts[id]);
err |= clSetKernelArgSVMPointer(k1, 0, pA);
err |= clSetKernelArg(k1, 1, sizeof(cl_uint), &num_devices_plus_host);
test_error(err, "clSetKernelArg failed");
err = clEnqueueNDRangeKernel(queues[id], k2, 1, NULL, &adjusted_num_elements, NULL, 0, NULL, NULL);
test_error(err,"clEnqueueNDRangeKernel failed");
}
// get all the devices going simultaneously
size_t element_num = num_elements;
for (cl_uint d = 0; d < num_devices; d++) // device ids starting at 1.
{
err = clSetKernelArg(k1, 2, sizeof(cl_uint), &d);
test_error(err, "clSetKernelArg failed");
err = clEnqueueNDRangeKernel(queues[d], k1, 1, NULL, &element_num, NULL,
0, NULL, NULL);
test_error(err, "clEnqueueNDRangeKernel failed");
}
for(cl_uint id = 0; id < num_devices; id++) clFinish(queues[id]);
for (cl_uint d = 0; d < num_devices; d++) clFlush(queues[d]);
bool failed = false;
cl_uint host_id =
num_devices; // host code will take the id above the devices.
for (int i = (int)num_devices; i < num_elements; i += num_devices_plus_host)
pA[i] = host_id;
// see if any of the devices found errors
for(cl_uint i=0; i < num_devices; i++) {
if(*error_counts[i] > 0)
failed = true;
}
cl_uint expected = (num_devices_plus_host * (num_devices_plus_host - 1))/2;
// check that host can see the byte writes made by the devices.
for(cl_uint i = 0; i < num_elements - num_devices_plus_host; i++)
{
int sum = 0;
for(cl_uint j=0; j < num_devices_plus_host; j++) sum += pA[i+j];
if(sum != expected)
failed = true;
}
for (cl_uint id = 0; id < num_devices; id++) clFinish(queues[id]);
clSVMFree(context, pA);
for(cl_uint i=0; i < num_devices; i++) clSVMFree(context, error_counts[i]);
// now check that each device can see the byte writes made by the other
// devices.
if(failed)
return -1;
return 0;
err |= clSetKernelArgSVMPointer(k2, 0, pA);
err |= clSetKernelArg(k2, 1, sizeof(cl_uint), &num_devices_plus_host);
test_error(err, "clSetKernelArg failed");
// adjusted so k2 doesn't read past end of buffer
size_t adjusted_num_elements = num_elements - num_devices;
for (cl_uint id = 0; id < num_devices; id++)
{
err = clSetKernelArgSVMPointer(k2, 2, error_counts[id]);
test_error(err, "clSetKernelArg failed");
err =
clEnqueueNDRangeKernel(queues[id], k2, 1, NULL,
&adjusted_num_elements, NULL, 0, NULL, NULL);
test_error(err, "clEnqueueNDRangeKernel failed");
}
for (cl_uint id = 0; id < num_devices; id++) clFinish(queues[id]);
bool failed = false;
// see if any of the devices found errors
for (cl_uint i = 0; i < num_devices; i++)
{
if (*error_counts[i] > 0) failed = true;
}
cl_uint expected =
(num_devices_plus_host * (num_devices_plus_host - 1)) / 2;
// check that host can see the byte writes made by the devices.
for (cl_uint i = 0; i < num_elements - num_devices_plus_host; i++)
{
int sum = 0;
for (cl_uint j = 0; j < num_devices_plus_host; j++) sum += pA[i + j];
if (sum != expected) failed = true;
}
clSVMFree(context, pA);
for (cl_uint i = 0; i < num_devices; i++)
clSVMFree(context, error_counts[i]);
if (failed) return -1;
return 0;
}

View file

@ -128,92 +128,128 @@ cl_int verify_linked_lists_on_host(int ci, cl_command_queue cmdq, cl_mem nodes,
// on another device or the host.
// The linked list nodes are allocated from two different buffers this is done to ensure that cross buffer pointers work correctly.
// This basic test is performed for all combinations of devices and the host.
int test_svm_cross_buffer_pointers_coarse_grain(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_cross_buffer_pointers_coarse_grain)
{
clContextWrapper context = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &SVMCrossBufferPointers_test_kernel[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(error) return -1;
error = create_cl_objects(device, &SVMCrossBufferPointers_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (error) return -1;
size_t numLists = num_elements;
cl_int ListLength = 32;
size_t numLists = num_elements;
cl_int ListLength = 32;
clKernelWrapper kernel_create_lists = clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_create_lists =
clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists = clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists =
clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
// this buffer holds some of the linked list nodes.
Node* pNodes = (Node*) clSVMAlloc(context, CL_MEM_READ_WRITE, sizeof(Node)*ListLength*numLists, 0);
// this buffer holds some of the linked list nodes.
Node *pNodes = (Node *)clSVMAlloc(context, CL_MEM_READ_WRITE,
sizeof(Node) * ListLength * numLists, 0);
// this buffer holds some of the linked list nodes.
Node* pNodes2 = (Node*) clSVMAlloc(context, CL_MEM_READ_WRITE, sizeof(Node)*ListLength*numLists, 0);
// this buffer holds some of the linked list nodes.
Node *pNodes2 = (Node *)clSVMAlloc(context, CL_MEM_READ_WRITE,
sizeof(Node) * ListLength * numLists, 0);
{
clMemWrapper nodes = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, sizeof(Node)*ListLength*numLists, pNodes, &error);
test_error(error, "clCreateBuffer failed.");
clMemWrapper nodes2 = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, sizeof(Node)*ListLength*numLists, pNodes2, &error);
test_error(error, "clCreateBuffer failed.");
// this buffer holds the index into the nodes buffer that is used for node allocation
clMemWrapper allocator = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_int), NULL, &error);
test_error(error, "clCreateBuffer failed.");
// this buffer holds the count of correct nodes which is computed by the verify kernel.
clMemWrapper num_correct = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_int), NULL, &error);
test_error(error, "clCreateBuffer failed.");
error |= clSetKernelArg(kernel_create_lists, 0, sizeof(void*), (void *) &nodes);
//error |= clSetKernelArgSVMPointer(kernel_create_lists, 0, (void *) pNodes);
error |= clSetKernelArg(kernel_create_lists, 1, sizeof(void*), (void *) &nodes2);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(void*), (void *) &allocator);
error |= clSetKernelArg(kernel_create_lists, 3, sizeof(cl_int), (void *) &ListLength);
error |= clSetKernelArg(kernel_verify_lists, 0, sizeof(void*), (void *) &nodes);
error |= clSetKernelArg(kernel_verify_lists, 1, sizeof(void*), (void *) &nodes2);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(void*), (void *) &num_correct);
error |= clSetKernelArg(kernel_verify_lists, 3, sizeof(cl_int), (void *) &ListLength);
test_error(error, "clSetKernelArg failed");
// Create linked list on one device and verify on another device (or the host).
// Do this for all possible combinations of devices and host within the platform.
for (int ci=0; ci<(int)num_devices+1; ci++) // ci is CreationIndex, index of device/q to create linked list on
{
for (int vi=0; vi<(int)num_devices+1; vi++) // vi is VerificationIndex, index of device/q to verify linked list on
{
if(ci == num_devices) // last device index represents the host, note the num_device+1 above.
{
error = create_linked_lists_on_host(queues[0], nodes, nodes2, ListLength, numLists);
if(error) return -1;
}
else
{
error = create_linked_lists_on_device(ci, queues[ci], allocator, kernel_create_lists, numLists);
if(error) return -1;
}
clMemWrapper nodes = clCreateBuffer(
context, CL_MEM_USE_HOST_PTR, sizeof(Node) * ListLength * numLists,
pNodes, &error);
test_error(error, "clCreateBuffer failed.");
if(vi == num_devices)
{
error = verify_linked_lists_on_host(vi, queues[0], nodes, nodes2, ListLength, numLists);
if(error) return -1;
}
else
{
error = verify_linked_lists_on_device(vi, queues[vi], num_correct, kernel_verify_lists, ListLength, numLists);
if(error) return -1;
}
} // inner loop, vi
} // outer loop, ci
}
clMemWrapper nodes2 = clCreateBuffer(
context, CL_MEM_USE_HOST_PTR, sizeof(Node) * ListLength * numLists,
pNodes2, &error);
test_error(error, "clCreateBuffer failed.");
clSVMFree(context, pNodes2);
clSVMFree(context, pNodes);
// this buffer holds the index into the nodes buffer that is used for
// node allocation
clMemWrapper allocator = clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(size_t), NULL, &error);
test_error(error, "clCreateBuffer failed.");
return 0;
// this buffer holds the count of correct nodes which is computed by the
// verify kernel.
clMemWrapper num_correct = clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(cl_int), NULL, &error);
test_error(error, "clCreateBuffer failed.");
error |= clSetKernelArg(kernel_create_lists, 0, sizeof(void *),
(void *)&nodes);
// error |= clSetKernelArgSVMPointer(kernel_create_lists, 0, (void *)
// pNodes);
error |= clSetKernelArg(kernel_create_lists, 1, sizeof(void *),
(void *)&nodes2);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(void *),
(void *)&allocator);
error |= clSetKernelArg(kernel_create_lists, 3, sizeof(cl_int),
(void *)&ListLength);
error |= clSetKernelArg(kernel_verify_lists, 0, sizeof(void *),
(void *)&nodes);
error |= clSetKernelArg(kernel_verify_lists, 1, sizeof(void *),
(void *)&nodes2);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(void *),
(void *)&num_correct);
error |= clSetKernelArg(kernel_verify_lists, 3, sizeof(cl_int),
(void *)&ListLength);
test_error(error, "clSetKernelArg failed");
// Create linked list on one device and verify on another device (or the
// host). Do this for all possible combinations of devices and host
// within the platform.
for (int ci = 0; ci < (int)num_devices + 1;
ci++) // ci is CreationIndex, index of device/q to create linked
// list on
{
for (int vi = 0; vi < (int)num_devices + 1;
vi++) // vi is VerificationIndex, index of device/q to verify
// linked list on
{
if (ci == num_devices) // last device index represents the host,
// note the num_device+1 above.
{
error = create_linked_lists_on_host(
queues[0], nodes, nodes2, ListLength, numLists);
if (error) return -1;
}
else
{
error = create_linked_lists_on_device(
ci, queues[ci], allocator, kernel_create_lists,
numLists);
if (error) return -1;
}
if (vi == num_devices)
{
error = verify_linked_lists_on_host(
vi, queues[0], nodes, nodes2, ListLength, numLists);
if (error) return -1;
}
else
{
error = verify_linked_lists_on_device(
vi, queues[vi], num_correct, kernel_verify_lists,
ListLength, numLists);
if (error) return -1;
}
} // inner loop, vi
} // outer loop, ci
}
clSVMFree(context, pNodes2);
clSVMFree(context, pNodes);
return 0;
}

View file

@ -70,240 +70,282 @@ void CL_CALLBACK callback_svm_free(cl_command_queue queue, cl_uint num_svm_point
data->status.store(1, std::memory_order_release);
}
int test_svm_enqueue_api(cl_device_id deviceID, cl_context c, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_enqueue_api)
{
clContextWrapper context = NULL;
clCommandQueueWrapper queues[MAXQ];
cl_uint num_devices = 0;
const size_t elementNum = 1024;
const size_t numSVMBuffers = 32;
cl_int error = CL_SUCCESS;
RandomSeed seed(0);
clContextWrapper contextWrapper = NULL;
clCommandQueueWrapper queues[MAXQ];
cl_uint num_devices = 0;
const size_t elementNum = 1024;
const size_t numSVMBuffers = 32;
cl_int error = CL_SUCCESS;
RandomSeed seed(0);
error = create_cl_objects(deviceID, NULL, &context, NULL, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(error) return TEST_FAIL;
error = create_cl_objects(device, NULL, &contextWrapper, NULL, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (error) return TEST_FAIL;
queue = queues[0];
queue = queues[0];
//all possible sizes of vectors and scalars
size_t typeSizes[] = {
sizeof(cl_uchar),
sizeof(cl_uchar2),
sizeof(cl_uchar3),
sizeof(cl_uchar4),
sizeof(cl_uchar8),
sizeof(cl_uchar16),
sizeof(cl_ushort),
sizeof(cl_ushort2),
sizeof(cl_ushort3),
sizeof(cl_ushort4),
sizeof(cl_ushort8),
sizeof(cl_ushort16),
sizeof(cl_uint),
sizeof(cl_uint2),
sizeof(cl_uint3),
sizeof(cl_uint4),
sizeof(cl_uint8),
sizeof(cl_uint16),
sizeof(cl_ulong),
sizeof(cl_ulong2),
sizeof(cl_ulong3),
sizeof(cl_ulong4),
sizeof(cl_ulong8),
sizeof(cl_ulong16),
};
// all possible sizes of vectors and scalars
size_t typeSizes[] = {
sizeof(cl_uchar), sizeof(cl_uchar2), sizeof(cl_uchar3),
sizeof(cl_uchar4), sizeof(cl_uchar8), sizeof(cl_uchar16),
sizeof(cl_ushort), sizeof(cl_ushort2), sizeof(cl_ushort3),
sizeof(cl_ushort4), sizeof(cl_ushort8), sizeof(cl_ushort16),
sizeof(cl_uint), sizeof(cl_uint2), sizeof(cl_uint3),
sizeof(cl_uint4), sizeof(cl_uint8), sizeof(cl_uint16),
sizeof(cl_ulong), sizeof(cl_ulong2), sizeof(cl_ulong3),
sizeof(cl_ulong4), sizeof(cl_ulong8), sizeof(cl_ulong16),
};
enum allocationTypes {
host,
svm
};
struct TestType {
allocationTypes srcAlloc;
allocationTypes dstAlloc;
TestType(allocationTypes type1, allocationTypes type2): srcAlloc(type1), dstAlloc(type2){}
};
std::vector<TestType> testTypes;
testTypes.push_back(TestType(host, host));
testTypes.push_back(TestType(host, svm));
testTypes.push_back(TestType(svm, host));
testTypes.push_back(TestType(svm, svm));
for (const auto test_case : testTypes)
{
log_info("clEnqueueSVMMemcpy case: src_alloc = %s, dst_alloc = %s\n", test_case.srcAlloc == svm ? "svm" : "host", test_case.dstAlloc == svm ? "svm" : "host");
for (size_t i = 0; i < ARRAY_SIZE(typeSizes); ++i)
enum allocationTypes
{
//generate initial data
std::vector<cl_uchar> fillData0(typeSizes[i]), fillData1(typeSizes[i]);
generate_data(fillData0, typeSizes[i], seed);
generate_data(fillData1, typeSizes[i], seed);
size_t data_size = elementNum * typeSizes[i];
std::vector<cl_uchar> srcHostData(data_size, 0);
std::vector<cl_uchar> dstHostData(data_size, 0);
generate_data(srcHostData, srcHostData.size(), seed);
generate_data(dstHostData, dstHostData.size(), seed);
host,
svm
};
cl_uchar *srcBuffer = (cl_uchar *)clSVMAlloc(context, CL_MEM_READ_WRITE, data_size, 0);
cl_uchar *dstBuffer = (cl_uchar *)clSVMAlloc(context, CL_MEM_READ_WRITE, data_size, 0);
struct TestType
{
allocationTypes srcAlloc;
allocationTypes dstAlloc;
TestType(allocationTypes type1, allocationTypes type2)
: srcAlloc(type1), dstAlloc(type2)
{}
};
clEventWrapper userEvent = clCreateUserEvent(context, &error);
test_error(error, "clCreateUserEvent failed");
clEventWrapper eventMemFillList[2];
std::vector<TestType> testTypes;
error = clEnqueueSVMMemFill(queue, srcBuffer, &fillData0[0], typeSizes[i], data_size, 1, &userEvent, &eventMemFillList[0]);
test_error(error, "clEnqueueSVMMemFill failed");
error = clEnqueueSVMMemFill(queue, dstBuffer, &fillData1[0], typeSizes[i], data_size, 1, &userEvent, &eventMemFillList[1]);
test_error(error, "clEnqueueSVMMemFill failed");
testTypes.push_back(TestType(host, host));
testTypes.push_back(TestType(host, svm));
testTypes.push_back(TestType(svm, host));
testTypes.push_back(TestType(svm, svm));
error = clSetUserEventStatus(userEvent, CL_COMPLETE);
test_error(error, "clSetUserEventStatus failed");
for (const auto test_case : testTypes)
{
log_info("clEnqueueSVMMemcpy case: src_alloc = %s, dst_alloc = %s\n",
test_case.srcAlloc == svm ? "svm" : "host",
test_case.dstAlloc == svm ? "svm" : "host");
for (size_t i = 0; i < ARRAY_SIZE(typeSizes); ++i)
{
// generate initial data
std::vector<cl_uchar> fillData0(typeSizes[i]),
fillData1(typeSizes[i]);
generate_data(fillData0, typeSizes[i], seed);
generate_data(fillData1, typeSizes[i], seed);
size_t data_size = elementNum * typeSizes[i];
std::vector<cl_uchar> srcHostData(data_size, 0);
std::vector<cl_uchar> dstHostData(data_size, 0);
generate_data(srcHostData, srcHostData.size(), seed);
generate_data(dstHostData, dstHostData.size(), seed);
cl_uchar * src_ptr;
cl_uchar * dst_ptr;
if (test_case.srcAlloc == host) {
src_ptr = srcHostData.data();
} else if (test_case.srcAlloc == svm) {
src_ptr = srcBuffer;
}
if (test_case.dstAlloc == host) {
dst_ptr = dstHostData.data();
} else if (test_case.dstAlloc == svm) {
dst_ptr = dstBuffer;
}
clEventWrapper eventMemcpy;
error = clEnqueueSVMMemcpy(queue, CL_FALSE, dst_ptr, src_ptr, data_size, 2, &eventMemFillList[0], &eventMemcpy);
test_error(error, "clEnqueueSVMMemcpy failed");
cl_uchar *srcBuffer = (cl_uchar *)clSVMAlloc(
context, CL_MEM_READ_WRITE, data_size, 0);
cl_uchar *dstBuffer = (cl_uchar *)clSVMAlloc(
context, CL_MEM_READ_WRITE, data_size, 0);
//coarse grain only supported. Synchronization required using map
clEventWrapper eventMap[2];
clEventWrapper userEvent = clCreateUserEvent(context, &error);
test_error(error, "clCreateUserEvent failed");
clEventWrapper eventMemFillList[2];
error = clEnqueueSVMMap(queue, CL_FALSE, CL_MAP_READ, srcBuffer, data_size, 1, &eventMemcpy, &eventMap[0]);
test_error(error, "clEnqueueSVMMap srcBuffer failed");
error = clEnqueueSVMMemFill(queue, srcBuffer, &fillData0[0],
typeSizes[i], data_size, 1, &userEvent,
&eventMemFillList[0]);
test_error(error, "clEnqueueSVMMemFill failed");
error = clEnqueueSVMMemFill(queue, dstBuffer, &fillData1[0],
typeSizes[i], data_size, 1, &userEvent,
&eventMemFillList[1]);
test_error(error, "clEnqueueSVMMemFill failed");
error = clEnqueueSVMMap(queue, CL_FALSE, CL_MAP_READ, dstBuffer, data_size, 1, &eventMemcpy, &eventMap[1]);
test_error(error, "clEnqueueSVMMap dstBuffer failed");
error = clSetUserEventStatus(userEvent, CL_COMPLETE);
test_error(error, "clSetUserEventStatus failed");
error = clWaitForEvents(2, &eventMap[0]);
test_error(error, "clWaitForEvents failed");
cl_uchar *src_ptr = nullptr;
cl_uchar *dst_ptr = nullptr;
if (test_case.srcAlloc == host)
{
src_ptr = srcHostData.data();
}
else if (test_case.srcAlloc == svm)
{
src_ptr = srcBuffer;
}
if (test_case.dstAlloc == host)
{
dst_ptr = dstHostData.data();
}
else if (test_case.dstAlloc == svm)
{
dst_ptr = dstBuffer;
}
clEventWrapper eventMemcpy;
error =
clEnqueueSVMMemcpy(queue, CL_FALSE, dst_ptr, src_ptr, data_size,
2, &eventMemFillList[0], &eventMemcpy);
test_error(error, "clEnqueueSVMMemcpy failed");
//data verification
for (size_t j = 0; j < data_size; ++j)
{
if (dst_ptr[j] != src_ptr[j]) {
log_error("Invalid data at index %ld, dst_ptr %d, src_ptr %d\n", j, dst_ptr[j], src_ptr[j]);
// coarse grain only supported. Synchronization required using map
clEventWrapper eventMap[2];
error = clEnqueueSVMMap(queue, CL_FALSE, CL_MAP_READ, srcBuffer,
data_size, 1, &eventMemcpy, &eventMap[0]);
test_error(error, "clEnqueueSVMMap srcBuffer failed");
error = clEnqueueSVMMap(queue, CL_FALSE, CL_MAP_READ, dstBuffer,
data_size, 1, &eventMemcpy, &eventMap[1]);
test_error(error, "clEnqueueSVMMap dstBuffer failed");
error = clWaitForEvents(2, &eventMap[0]);
test_error(error, "clWaitForEvents failed");
// data verification
for (size_t j = 0; j < data_size; ++j)
{
if (dst_ptr[j] != src_ptr[j])
{
log_error(
"Invalid data at index %zu, dst_ptr %d, src_ptr %d\n",
j, dst_ptr[j], src_ptr[j]);
return TEST_FAIL;
}
}
clEventWrapper eventUnmap[2];
error =
clEnqueueSVMUnmap(queue, srcBuffer, 0, nullptr, &eventUnmap[0]);
test_error(error, "clEnqueueSVMUnmap srcBuffer failed");
error =
clEnqueueSVMUnmap(queue, dstBuffer, 0, nullptr, &eventUnmap[1]);
test_error(error, "clEnqueueSVMUnmap dstBuffer failed");
error = clEnqueueSVMMemFill(queue, srcBuffer, &fillData1[0],
typeSizes[i], data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemFill failed");
error = clEnqueueSVMMemFill(queue, dstBuffer + data_size / 2,
&fillData1[0], typeSizes[i],
data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemFill failed");
error = clEnqueueSVMMemcpy(queue, CL_FALSE, dstBuffer, srcBuffer,
data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemcpy failed");
error = clEnqueueSVMMemcpy(
queue, CL_TRUE, dstBuffer + data_size / 2,
srcBuffer + data_size / 2, data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemcpy failed");
void *ptrs[] = { (void *)srcBuffer, (void *)dstBuffer };
clEventWrapper eventFree;
error = clEnqueueSVMFree(queue, 2, ptrs, 0, 0, 0, 0, &eventFree);
test_error(error, "clEnqueueSVMFree failed");
error = clWaitForEvents(1, &eventFree);
test_error(error, "clWaitForEvents failed");
// event info verification for new SVM commands
cl_command_type commandType;
for (auto &check_event : eventMemFillList)
{
error =
clGetEventInfo(check_event, CL_EVENT_COMMAND_TYPE,
sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_MEMFILL)
{
log_error("Invalid command type returned for "
"clEnqueueSVMMemFill\n");
return TEST_FAIL;
}
}
error = clGetEventInfo(eventMemcpy, CL_EVENT_COMMAND_TYPE,
sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_MEMCPY)
{
log_error(
"Invalid command type returned for clEnqueueSVMMemcpy\n");
return TEST_FAIL;
}
for (size_t map_id = 0; map_id < ARRAY_SIZE(eventMap); map_id++)
{
error =
clGetEventInfo(eventMap[map_id], CL_EVENT_COMMAND_TYPE,
sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_MAP)
{
log_error(
"Invalid command type returned for clEnqueueSVMMap\n");
return TEST_FAIL;
}
error =
clGetEventInfo(eventUnmap[map_id], CL_EVENT_COMMAND_TYPE,
sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_UNMAP)
{
log_error("Invalid command type returned for "
"clEnqueueSVMUnmap\n");
return TEST_FAIL;
}
}
error = clGetEventInfo(eventFree, CL_EVENT_COMMAND_TYPE,
sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_FREE)
{
log_error(
"Invalid command type returned for clEnqueueSVMFree\n");
return TEST_FAIL;
}
}
}
std::vector<void *> buffers(numSVMBuffers, 0);
for (size_t i = 0; i < numSVMBuffers; ++i)
buffers[i] = clSVMAlloc(context, CL_MEM_READ_WRITE, elementNum, 0);
// verify if callback is triggered correctly
CallbackData data;
data.status = 0;
error = clEnqueueSVMFree(queue, buffers.size(), &buffers[0],
callback_svm_free, &data, 0, 0, 0);
test_error(error, "clEnqueueSVMFree failed");
error = clFinish(queue);
test_error(error, "clFinish failed");
// wait for the callback
while (data.status.load(std::memory_order_acquire) == 0)
{
usleep(1);
}
// check if number of SVM pointers returned in the callback matches with
// expected
if (data.num_svm_pointers != buffers.size())
{
log_error("Invalid number of SVM pointers returned in the callback, "
"expected: %zu, got: %d\n",
buffers.size(), data.num_svm_pointers);
return TEST_FAIL;
}
// check if pointers returned in callback are correct
for (size_t i = 0; i < buffers.size(); ++i)
{
if (data.svm_pointers[i] != buffers[i])
{
log_error(
"Invalid SVM pointer returned in the callback, idx: %zu\n", i);
return TEST_FAIL;
}
}
clEventWrapper eventUnmap[2];
error = clEnqueueSVMUnmap(queue, srcBuffer, 0, nullptr, &eventUnmap[0]);
test_error(error, "clEnqueueSVMUnmap srcBuffer failed");
error = clEnqueueSVMUnmap(queue, dstBuffer, 0, nullptr, &eventUnmap[1]);
test_error(error, "clEnqueueSVMUnmap dstBuffer failed");
error = clEnqueueSVMMemFill(queue, srcBuffer, &fillData1[0], typeSizes[i], data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemFill failed");
error = clEnqueueSVMMemFill(queue, dstBuffer + data_size / 2, &fillData1[0], typeSizes[i], data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemFill failed");
error = clEnqueueSVMMemcpy(queue, CL_FALSE, dstBuffer, srcBuffer, data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemcpy failed");
error = clEnqueueSVMMemcpy(queue, CL_TRUE, dstBuffer + data_size / 2, srcBuffer + data_size / 2, data_size / 2, 0, 0, 0);
test_error(error, "clEnqueueSVMMemcpy failed");
void *ptrs[] = { (void *)srcBuffer, (void *)dstBuffer };
clEventWrapper eventFree;
error = clEnqueueSVMFree(queue, 2, ptrs, 0, 0, 0, 0, &eventFree);
test_error(error, "clEnqueueSVMFree failed");
error = clWaitForEvents(1, &eventFree);
test_error(error, "clWaitForEvents failed");
//event info verification for new SVM commands
cl_command_type commandType;
for (auto &check_event : eventMemFillList) {
error = clGetEventInfo(check_event, CL_EVENT_COMMAND_TYPE, sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_MEMFILL)
{
log_error("Invalid command type returned for clEnqueueSVMMemFill\n");
return TEST_FAIL;
}
}
error = clGetEventInfo(eventMemcpy, CL_EVENT_COMMAND_TYPE, sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_MEMCPY)
{
log_error("Invalid command type returned for clEnqueueSVMMemcpy\n");
return TEST_FAIL;
}
for (size_t map_id = 0; map_id < ARRAY_SIZE(eventMap); map_id++) {
error = clGetEventInfo(eventMap[map_id], CL_EVENT_COMMAND_TYPE, sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_MAP)
{
log_error("Invalid command type returned for clEnqueueSVMMap\n");
return TEST_FAIL;
}
error = clGetEventInfo(eventUnmap[map_id], CL_EVENT_COMMAND_TYPE, sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_UNMAP)
{
log_error("Invalid command type returned for clEnqueueSVMUnmap\n");
return TEST_FAIL;
}
}
error = clGetEventInfo(eventFree, CL_EVENT_COMMAND_TYPE, sizeof(cl_command_type), &commandType, NULL);
test_error(error, "clGetEventInfo failed");
if (commandType != CL_COMMAND_SVM_FREE)
{
log_error("Invalid command type returned for clEnqueueSVMFree\n");
return TEST_FAIL;
}
}
}
std::vector<void *> buffers(numSVMBuffers, 0);
for(size_t i = 0; i < numSVMBuffers; ++i) buffers[i] = clSVMAlloc(context, CL_MEM_READ_WRITE, elementNum, 0);
//verify if callback is triggered correctly
CallbackData data;
data.status = 0;
error = clEnqueueSVMFree(queue, buffers.size(), &buffers[0], callback_svm_free, &data, 0, 0, 0);
test_error(error, "clEnqueueSVMFree failed");
error = clFinish(queue);
test_error(error, "clFinish failed");
//wait for the callback
while(data.status.load(std::memory_order_acquire) == 0) {
usleep(1);
}
//check if number of SVM pointers returned in the callback matches with expected
if (data.num_svm_pointers != buffers.size())
{
log_error("Invalid number of SVM pointers returned in the callback, expected: %ld, got: %d\n", buffers.size(), data.num_svm_pointers);
return TEST_FAIL;
}
//check if pointers returned in callback are correct
for (size_t i = 0; i < buffers.size(); ++i)
{
if (data.svm_pointers[i] != buffers[i])
{
log_error("Invalid SVM pointer returned in the callback, idx: %ld\n", i);
return TEST_FAIL;
}
}
return 0;
return 0;
}

View file

@ -126,8 +126,10 @@ int launch_kernels_and_verify(clContextWrapper &context, clCommandQueueWrapper*
// each device and the host inserted all of the pixels, check that none are missing.
if(num_items != num_pixels * (num_devices + 1) )
{
log_error("The hash table is not correct, num items %d, expected num items: %d\n", num_items, num_pixels * (num_devices + 1));
return -1; // test did not pass
log_error("The hash table is not correct, num items %d, expected num "
"items: %zu\n",
num_items, num_pixels * (num_devices + 1));
return -1; // test did not pass
}
return 0;
}
@ -137,44 +139,55 @@ int launch_kernels_and_verify(clContextWrapper &context, clCommandQueueWrapper*
// Each bin in the hash table is a linked list. Each bin is protected against simultaneous
// update using a lock free technique. The correctness of the list is verfied on the host.
// This test requires the new OpenCL 2.0 atomic operations that implement the new seq_cst memory ordering.
int test_svm_fine_grain_memory_consistency(cl_device_id deviceID, cl_context c, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_fine_grain_memory_consistency)
{
clContextWrapper context;
clProgramWrapper program;
clKernelWrapper kernel;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper;
clProgramWrapper program;
clKernelWrapper kernel;
clCommandQueueWrapper queues[MAXQ];
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
std::vector<std::string> required_extensions;
required_extensions.push_back("cl_khr_int64_base_atomics");
required_extensions.push_back("cl_khr_int64_extended_atomics");
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
std::vector<std::string> required_extensions;
required_extensions.push_back("cl_khr_int64_base_atomics");
required_extensions.push_back("cl_khr_int64_extended_atomics");
// Make pragmas visible for 64-bit addresses
hash_table_kernel[4] = sizeof(void *) == 8 ? '1' : '0';
// Make pragmas visible for 64-bit addresses
hash_table_kernel[4] = sizeof(void *) == 8 ? '1' : '0';
char *source[] = { hash_table_kernel };
char *source[] = { hash_table_kernel };
err = create_cl_objects(deviceID, (const char**)source, &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS, required_extensions);
if(err == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(err < 0) return -1; // fail test.
err = create_cl_objects(
device, (const char **)source, &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS,
required_extensions);
context = contextWrapper;
if (err == 1)
return 0; // no devices capable of requested SVM level, so don't execute
// but count test as passing.
if (err < 0) return -1; // fail test.
kernel = clCreateKernel(program, "build_hash_table", &err);
test_error(err, "clCreateKernel failed");
size_t num_pixels = num_elements;
kernel = clCreateKernel(program, "build_hash_table", &err);
test_error(err, "clCreateKernel failed");
size_t num_pixels = num_elements;
int result;
cl_uint numBins = 1; // all work groups in all devices and the host code will hammer on this one lock.
result = launch_kernels_and_verify(context, queues, kernel, num_devices, numBins, num_pixels);
if(result == -1) return result;
int result;
cl_uint numBins = 1; // all work groups in all devices and the host code
// will hammer on this one lock.
result = launch_kernels_and_verify(contextWrapper, queues, kernel,
num_devices, numBins, num_pixels);
if (result == -1) return result;
numBins = 2; // 2 locks within in same cache line will get hit from different devices and host.
result = launch_kernels_and_verify(context, queues, kernel, num_devices, numBins, num_pixels);
if(result == -1) return result;
numBins = 2; // 2 locks within in same cache line will get hit from
// different devices and host.
result = launch_kernels_and_verify(contextWrapper, queues, kernel,
num_devices, numBins, num_pixels);
if (result == -1) return result;
numBins = 29; // locks span a few cache lines.
result = launch_kernels_and_verify(context, queues, kernel, num_devices, numBins, num_pixels);
if(result == -1) return result;
numBins = 29; // locks span a few cache lines.
result = launch_kernels_and_verify(contextWrapper, queues, kernel,
num_devices, numBins, num_pixels);
if (result == -1) return result;
return result;
return result;
}

View file

@ -44,67 +44,87 @@ void spawnAnalysisTask(int location)
// Concept: a device kernel is used to search an input image for regions that match a target pattern.
// The device immediately notifies the host when it finds a target (via an atomic operation that works across host and devices).
// The host is then able to spawn a task that further analyzes the target while the device continues searching for more targets.
int test_svm_fine_grain_sync_buffers(cl_device_id deviceID, cl_context c, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_fine_grain_sync_buffers)
{
clContextWrapper context = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int err = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
err = create_cl_objects(deviceID, &find_targets_kernel[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS);
if(err == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(err < 0) return -1; // fail test.
err = create_cl_objects(
device, &find_targets_kernel[0], &contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS);
context = contextWrapper;
if (err == 1)
return 0; // no devices capable of requested SVM level, so don't execute
// but count test as passing.
if (err < 0) return -1; // fail test.
clKernelWrapper kernel = clCreateKernel(program, "find_targets", &err);
test_error(err, "clCreateKernel failed");
clKernelWrapper kernel = clCreateKernel(program, "find_targets", &err);
test_error(err, "clCreateKernel failed");
size_t num_pixels = num_elements;
//cl_uint num_pixels = 1024*1024*32;
size_t num_pixels = num_elements;
// cl_uint num_pixels = 1024*1024*32;
cl_uint *pInputImage = (cl_uint*) clSVMAlloc(context, CL_MEM_READ_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER, sizeof(cl_uint) * num_pixels, 0);
cl_uint *pNumTargetsFound = (cl_uint*) clSVMAlloc(context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS, sizeof(cl_uint), 0);
cl_int *pTargetLocations = (cl_int* ) clSVMAlloc(context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS, sizeof(cl_int) * MAX_TARGETS, 0);
cl_uint *pInputImage = (cl_uint *)clSVMAlloc(
context, CL_MEM_READ_ONLY | CL_MEM_SVM_FINE_GRAIN_BUFFER,
sizeof(cl_uint) * num_pixels, 0);
cl_uint *pNumTargetsFound = (cl_uint *)clSVMAlloc(
context,
CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS,
sizeof(cl_uint), 0);
cl_int *pTargetLocations = (cl_int *)clSVMAlloc(
context,
CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS,
sizeof(cl_int) * MAX_TARGETS, 0);
cl_uint targetDescriptor = 777;
*pNumTargetsFound = 0;
cl_uint i;
for(i=0; i < MAX_TARGETS; i++) pTargetLocations[i] = -1;
for(i=0; i < num_pixels; i++) pInputImage[i] = 0;
pInputImage[0] = targetDescriptor;
pInputImage[3] = targetDescriptor;
pInputImage[num_pixels - 1] = targetDescriptor;
cl_uint targetDescriptor = 777;
*pNumTargetsFound = 0;
cl_uint i;
for (i = 0; i < MAX_TARGETS; i++) pTargetLocations[i] = -1;
for (i = 0; i < num_pixels; i++) pInputImage[i] = 0;
pInputImage[0] = targetDescriptor;
pInputImage[3] = targetDescriptor;
pInputImage[num_pixels - 1] = targetDescriptor;
err |= clSetKernelArgSVMPointer(kernel, 0, pInputImage);
err |= clSetKernelArg(kernel, 1, sizeof(cl_uint), (void*) &targetDescriptor);
err |= clSetKernelArgSVMPointer(kernel, 2, pNumTargetsFound);
err |= clSetKernelArgSVMPointer(kernel, 3, pTargetLocations);
test_error(err, "clSetKernelArg failed");
err |= clSetKernelArgSVMPointer(kernel, 0, pInputImage);
err |=
clSetKernelArg(kernel, 1, sizeof(cl_uint), (void *)&targetDescriptor);
err |= clSetKernelArgSVMPointer(kernel, 2, pNumTargetsFound);
err |= clSetKernelArgSVMPointer(kernel, 3, pTargetLocations);
test_error(err, "clSetKernelArg failed");
cl_event done;
err = clEnqueueNDRangeKernel(queues[0], kernel, 1, NULL, &num_pixels, NULL, 0, NULL, &done);
test_error(err,"clEnqueueNDRangeKernel failed");
clFlush(queues[0]);
cl_event done;
err = clEnqueueNDRangeKernel(queues[0], kernel, 1, NULL, &num_pixels, NULL,
0, NULL, &done);
test_error(err, "clEnqueueNDRangeKernel failed");
clFlush(queues[0]);
i=0;
cl_int status;
// check for new targets, if found spawn a task to analyze target.
do {
err = clGetEventInfo(done,CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(cl_int), &status, NULL);
test_error(err,"clGetEventInfo failed");
if( AtomicLoadExplicit(&pTargetLocations[i], memory_order_relaxed) != -1) // -1 indicates slot not used yet.
i = 0;
cl_int status;
// check for new targets, if found spawn a task to analyze target.
do
{
spawnAnalysisTask(pTargetLocations[i]);
i++;
}
} while (status != CL_COMPLETE || AtomicLoadExplicit(&pTargetLocations[i], memory_order_relaxed) != -1);
err = clGetEventInfo(done, CL_EVENT_COMMAND_EXECUTION_STATUS,
sizeof(cl_int), &status, NULL);
test_error(err, "clGetEventInfo failed");
if (AtomicLoadExplicit(&pTargetLocations[i], memory_order_relaxed)
!= -1) // -1 indicates slot not used yet.
{
spawnAnalysisTask(pTargetLocations[i]);
i++;
}
} while (status != CL_COMPLETE
|| AtomicLoadExplicit(&pTargetLocations[i], memory_order_relaxed)
!= -1);
clReleaseEvent(done);
clSVMFree(context, pInputImage);
clSVMFree(context, pNumTargetsFound);
clSVMFree(context, pTargetLocations);
clReleaseEvent(done);
clSVMFree(context, pInputImage);
clSVMFree(context, pNumTargetsFound);
clSVMFree(context, pTargetLocations);
if(i != 3) return -1;
return 0;
if (i != 3) return -1;
return 0;
}

View file

@ -16,6 +16,8 @@
#include "common.h"
#include "harness/mt19937.h"
#include <vector>
#define GLOBAL_SIZE 65536
static const char *sources[] = {
@ -73,29 +75,28 @@ wait_and_release(const char* s, cl_event* evs, int n)
return 0;
}
int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_migrate)
{
cl_uint amem[GLOBAL_SIZE];
cl_uint bmem[GLOBAL_SIZE];
cl_uint cmem[GLOBAL_SIZE];
cl_uint ramem[GLOBAL_SIZE];
cl_uint rbmem[GLOBAL_SIZE];
cl_uint rcmem[GLOBAL_SIZE];
std::vector<cl_uint> amem(GLOBAL_SIZE);
std::vector<cl_uint> bmem(GLOBAL_SIZE);
std::vector<cl_uint> cmem(GLOBAL_SIZE);
cl_event evs[20];
const size_t global_size = GLOBAL_SIZE;
RandomSeed seed(0);
clContextWrapper context = NULL;
clContextWrapper contextWrapper = NULL;
clCommandQueueWrapper queues[MAXQ];
cl_uint num_devices = 0;
clProgramWrapper program;
cl_int error;
error = create_cl_objects(deviceID, &sources[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if (error)
return -1;
error = create_cl_objects(device, &sources[0], &contextWrapper, &program,
&queues[0], &num_devices,
CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (error) return -1;
if (num_devices > 1) {
log_info(" Running on two devices.\n");
@ -148,9 +149,9 @@ int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue
test_error(error, "clSetKernelArgSVMPointer failed");
// Initialize host copy of data (and result)
fill_buffer(amem, global_size, seed);
fill_buffer(bmem, global_size, seed);
fill_buffer(cmem, global_size, seed);
fill_buffer(amem.data(), global_size, seed);
fill_buffer(bmem.data(), global_size, seed);
fill_buffer(cmem.data(), global_size, seed);
// Now we're ready to start
{
@ -201,7 +202,7 @@ int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue
// Check the event command type for clEnqueueSVMMigrateMem (OpenCL 3.0 and
// newer)
Version version = get_device_cl_version(deviceID);
Version version = get_device_cl_version(device);
if (version >= Version(3, 0))
{
cl_command_type commandType;
@ -221,9 +222,9 @@ int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue
if (error)
return -1;
memcpy((void *)asvm, (void *)amem, global_size*sizeof(cl_uint));
memcpy((void *)bsvm, (void *)bmem, global_size*sizeof(cl_uint));
memcpy((void *)csvm, (void *)cmem, global_size*sizeof(cl_uint));
memcpy((void *)asvm, (void *)amem.data(), global_size * sizeof(cl_uint));
memcpy((void *)bsvm, (void *)bmem.data(), global_size * sizeof(cl_uint));
memcpy((void *)csvm, (void *)cmem.data(), global_size * sizeof(cl_uint));
{
error = clEnqueueSVMUnmap(queues[1], (void *)asvm, 0, NULL, &evs[0]);
@ -307,9 +308,9 @@ int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue
return -1;
// Check kernel results
bool ok = check("memory a", (cl_uint *)asvm, amem, global_size);
ok &= check("memory b", (cl_uint *)bsvm, bmem, global_size);
ok &= check("memory c", (cl_uint *)csvm, cmem, global_size);
bool ok = check("memory a", (cl_uint *)asvm, amem.data(), global_size);
ok &= check("memory b", (cl_uint *)bsvm, bmem.data(), global_size);
ok &= check("memory c", (cl_uint *)csvm, cmem.data(), global_size);
{
void *ptrs[] = { asvm, bsvm, csvm };

View file

@ -35,81 +35,107 @@ const char *SVMPointerPassing_test_kernel[] = {
// The buffer is initialized to known values at each location.
// The kernel checks that it finds the expected value at each location.
// TODO: possibly make this work across all base types (including typeN?), also check ptr arithmetic ++,--.
int test_svm_pointer_passing(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_pointer_passing)
{
clContextWrapper context = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &SVMPointerPassing_test_kernel[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(error) return -1;
error = create_cl_objects(device, &SVMPointerPassing_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (error) return -1;
clKernelWrapper kernel_verify_char = clCreateKernel(program, "verify_char", &error);
test_error(error,"clCreateKernel failed");
clKernelWrapper kernel_verify_char =
clCreateKernel(program, "verify_char", &error);
test_error(error, "clCreateKernel failed");
size_t bufSize = 256;
cl_uchar *pbuf_svm_alloc = (cl_uchar*) clSVMAlloc(context, CL_MEM_READ_WRITE, sizeof(cl_uchar)*bufSize, 0);
size_t bufSize = 256;
cl_uchar *pbuf_svm_alloc = (cl_uchar *)clSVMAlloc(
context, CL_MEM_READ_WRITE, sizeof(cl_uchar) * bufSize, 0);
cl_int *pNumCorrect = NULL;
pNumCorrect = (cl_int*) clSVMAlloc(context, CL_MEM_READ_WRITE, sizeof(cl_int), 0);
cl_int *pNumCorrect = NULL;
pNumCorrect =
(cl_int *)clSVMAlloc(context, CL_MEM_READ_WRITE, sizeof(cl_int), 0);
{
clMemWrapper buf = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, sizeof(cl_uchar)*bufSize, pbuf_svm_alloc, &error);
test_error(error, "clCreateBuffer failed.");
clMemWrapper num_correct = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, sizeof(cl_int), pNumCorrect, &error);
test_error(error, "clCreateBuffer failed.");
error = clSetKernelArg(kernel_verify_char, 1, sizeof(void*), (void *) &num_correct);
test_error(error, "clSetKernelArg failed");
// put values into buf so that we can expect to see these values in the kernel when we pass a pointer to them.
cl_command_queue cmdq = queues[0];
cl_uchar* pbuf_map_buffer = (cl_uchar*) clEnqueueMapBuffer(cmdq, buf, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, sizeof(cl_uchar)*bufSize, 0, NULL,NULL, &error);
test_error2(error, pbuf_map_buffer, "clEnqueueMapBuffer failed");
for(int i = 0; i<(int)bufSize; i++)
{
pbuf_map_buffer[i]= (cl_uchar)i;
}
error = clEnqueueUnmapMemObject(cmdq, buf, pbuf_map_buffer, 0,NULL,NULL);
test_error(error, "clEnqueueUnmapMemObject failed.");
clMemWrapper buf =
clCreateBuffer(context, CL_MEM_USE_HOST_PTR,
sizeof(cl_uchar) * bufSize, pbuf_svm_alloc, &error);
test_error(error, "clCreateBuffer failed.");
for (cl_uint ii = 0; ii<num_devices; ++ii) // iterate over all devices in the platform.
{
cmdq = queues[ii];
for(int i = 0; i<(int)bufSize; i++)
{
cl_uchar* pChar = &pbuf_svm_alloc[i];
error = clSetKernelArgSVMPointer(kernel_verify_char, 0, pChar); // pass a pointer to a location within the buffer
test_error(error, "clSetKernelArg failed");
error = clSetKernelArg(kernel_verify_char, 2, sizeof(cl_uchar), (void *) &i ); // pass the expected value at the above location.
test_error(error, "clSetKernelArg failed");
error = clEnqueueNDRangeKernel(cmdq, kernel_verify_char, 1, NULL, &bufSize, NULL, 0, NULL, NULL);
test_error(error,"clEnqueueNDRangeKernel failed");
clMemWrapper num_correct = clCreateBuffer(
context, CL_MEM_USE_HOST_PTR, sizeof(cl_int), pNumCorrect, &error);
test_error(error, "clCreateBuffer failed.");
pNumCorrect = (cl_int*) clEnqueueMapBuffer(cmdq, num_correct, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, sizeof(cl_int), 0, NULL,NULL, &error);
test_error2(error, pNumCorrect, "clEnqueueMapBuffer failed");
cl_int correct_count = *pNumCorrect;
error = clEnqueueUnmapMemObject(cmdq, num_correct, pNumCorrect, 0,NULL,NULL);
error = clSetKernelArg(kernel_verify_char, 1, sizeof(void *),
(void *)&num_correct);
test_error(error, "clSetKernelArg failed");
// put values into buf so that we can expect to see these values in the
// kernel when we pass a pointer to them.
cl_command_queue cmdq = queues[0];
cl_uchar *pbuf_map_buffer = (cl_uchar *)clEnqueueMapBuffer(
cmdq, buf, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0,
sizeof(cl_uchar) * bufSize, 0, NULL, NULL, &error);
test_error2(error, pbuf_map_buffer, "clEnqueueMapBuffer failed");
for (int i = 0; i < (int)bufSize; i++)
{
pbuf_map_buffer[i] = (cl_uchar)i;
}
error =
clEnqueueUnmapMemObject(cmdq, buf, pbuf_map_buffer, 0, NULL, NULL);
test_error(error, "clEnqueueUnmapMemObject failed.");
if(correct_count != 1)
for (cl_uint ii = 0; ii < num_devices;
++ii) // iterate over all devices in the platform.
{
log_error("Passing pointer directly to kernel for byte #%d failed on device %d\n", i, ii);
return -1;
cmdq = queues[ii];
for (int i = 0; i < (int)bufSize; i++)
{
cl_uchar *pChar = &pbuf_svm_alloc[i];
error = clSetKernelArgSVMPointer(
kernel_verify_char, 0,
pChar); // pass a pointer to a location within the buffer
test_error(error, "clSetKernelArg failed");
error = clSetKernelArg(kernel_verify_char, 2, sizeof(cl_uchar),
(void *)&i); // pass the expected value
// at the above location.
test_error(error, "clSetKernelArg failed");
error =
clEnqueueNDRangeKernel(cmdq, kernel_verify_char, 1, NULL,
&bufSize, NULL, 0, NULL, NULL);
test_error(error, "clEnqueueNDRangeKernel failed");
pNumCorrect = (cl_int *)clEnqueueMapBuffer(
cmdq, num_correct, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0,
sizeof(cl_int), 0, NULL, NULL, &error);
test_error2(error, pNumCorrect, "clEnqueueMapBuffer failed");
cl_int correct_count = *pNumCorrect;
error = clEnqueueUnmapMemObject(cmdq, num_correct, pNumCorrect,
0, NULL, NULL);
test_error(error, "clEnqueueUnmapMemObject failed.");
if (correct_count != 1)
{
log_error("Passing pointer directly to kernel for byte #%d "
"failed on device %d\n",
i, ii);
return -1;
}
}
error = clFinish(cmdq);
test_error(error, "clFinish failed");
}
}
}
error = clFinish(cmdq);
test_error(error, "clFinish failed");
}
clSVMFree(context, pbuf_svm_alloc);
clSVMFree(context, pNumCorrect);
clSVMFree(context, pbuf_svm_alloc);
clSVMFree(context, pNumCorrect);
return 0;
return 0;
}

View file

@ -42,7 +42,7 @@ const char *set_kernel_exec_info_svm_ptrs_kernel[] = {
// Test that clSetKernelExecInfo works correctly with CL_KERNEL_EXEC_INFO_SVM_PTRS flag.
//
int test_svm_set_kernel_exec_info_svm_ptrs(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_set_kernel_exec_info_svm_ptrs)
{
clContextWrapper c = NULL;
clProgramWrapper program = NULL;
@ -50,8 +50,11 @@ int test_svm_set_kernel_exec_info_svm_ptrs(cl_device_id deviceID, cl_context con
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
//error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN);
error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &c, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
// error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0],
// &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN);
error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0],
&c, &program, &queues[0], &num_devices,
CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(error == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(error < 0) return -1; // fail test.

View file

@ -57,7 +57,6 @@ cl_int create_linked_lists_on_host(cl_command_queue cmdq, cl_mem nodes, Node *pN
cl_int verify_linked_lists_on_host(int ci, cl_command_queue cmdq, cl_mem nodes, Node *pNodes2, cl_int ListLength, size_t numLists, cl_bool useNewAPI )
{
cl_int error = CL_SUCCESS;
cl_int correct_count;
Node *pNodes;
if (useNewAPI == CL_FALSE)
@ -72,8 +71,6 @@ cl_int verify_linked_lists_on_host(int ci, cl_command_queue cmdq, cl_mem nodes,
test_error2(error, pNodes, "clEnqueueSVMMap failed");
}
correct_count = 0;
error = verify_linked_lists(pNodes, numLists, ListLength);
if(error) return -1;
@ -98,7 +95,9 @@ cl_int create_linked_lists_on_device(int ci, cl_command_queue cmdq, cl_mem alloc
cl_int error = CL_SUCCESS;
log_info("SVM: creating linked list on device: %d ", ci);
size_t *pAllocator = (size_t*) clEnqueueMapBuffer(cmdq, allocator, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, sizeof(cl_int), 0, NULL,NULL, &error);
size_t *pAllocator = (size_t *)clEnqueueMapBuffer(
cmdq, allocator, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, sizeof(size_t),
0, NULL, NULL, &error);
test_error2(error, pAllocator, "clEnqueueMapBuffer failed");
// reset allocator index
*pAllocator = numLists; // the first numLists elements of the nodes array are already allocated (they hold the head of each list).
@ -206,7 +205,9 @@ int shared_address_space_coarse_grain(cl_device_id deviceID, cl_context context2
}
// this buffer holds an index into the nodes buffer, it is used for node allocation
clMemWrapper allocator = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_int), NULL, &error);
clMemWrapper allocator = clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(size_t), NULL, &error);
test_error(error, "clCreateBuffer failed.");
error = clGetMemObjectInfo(allocator, CL_MEM_USES_SVM_POINTER, sizeof(cl_bool), &usesSVMpointer, 0);
@ -271,12 +272,14 @@ int shared_address_space_coarse_grain(cl_device_id deviceID, cl_context context2
return 0;
}
int test_svm_shared_address_space_coarse_grain_old_api(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_shared_address_space_coarse_grain_old_api)
{
return shared_address_space_coarse_grain(deviceID, context2, queue, num_elements, CL_FALSE);
return shared_address_space_coarse_grain(device, context, queue,
num_elements, CL_FALSE);
}
int test_svm_shared_address_space_coarse_grain_new_api(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_shared_address_space_coarse_grain_new_api)
{
return shared_address_space_coarse_grain(deviceID, context2, queue, num_elements, CL_TRUE);
return shared_address_space_coarse_grain(device, context, queue,
num_elements, CL_TRUE);
}

View file

@ -20,82 +20,103 @@
// This is done by creating a linked list on a device and then verifying the correctness of the list
// on another device or the host. This basic test is performed for all combinations of devices and the host that exist within
// the platform. The test passes only if every combination passes.
int test_svm_shared_address_space_fine_grain(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_shared_address_space_fine_grain)
{
clContextWrapper context = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &linked_list_create_and_verify_kernels[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM);
if(error == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(error < 0) return -1; // fail test.
error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM);
context = contextWrapper;
if (error == 1)
return 0; // no devices capable of requested SVM level, so don't execute
// but count test as passing.
if (error < 0) return -1; // fail test.
size_t numLists = num_elements;
cl_int ListLength = 32;
size_t numLists = num_elements;
cl_int ListLength = 32;
clKernelWrapper kernel_create_lists = clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_create_lists =
clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists = clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists =
clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
// this allocation holds the linked list nodes.
// FIXME: remove the alignment once prototype can handle it
Node* pNodes = (Node*) align_malloc(numLists*ListLength*sizeof(Node),128);
test_error2(error, pNodes, "malloc failed");
// this allocation holds the linked list nodes.
// FIXME: remove the alignment once prototype can handle it
Node *pNodes =
(Node *)align_malloc(numLists * ListLength * sizeof(Node), 128);
test_error2(error, pNodes, "malloc failed");
// this allocation holds an index into the nodes buffer, it is used for node allocation
size_t* pAllocator = (size_t*) align_malloc(sizeof(cl_int), 128);
test_error2(error, pAllocator, "malloc failed");
// this allocation holds an index into the nodes buffer, it is used for node
// allocation
size_t *pAllocator = (size_t *)align_malloc(sizeof(size_t), 128);
test_error2(error, pAllocator, "malloc failed");
// this allocation holds the count of correct nodes, which is computed by the verify kernel.
cl_int* pNum_correct = (cl_int*) align_malloc(sizeof(cl_int), 128);
test_error2(error, pNum_correct, "malloc failed");
// this allocation holds the count of correct nodes, which is computed by
// the verify kernel.
cl_int *pNum_correct = (cl_int *)align_malloc(sizeof(cl_int), 128);
test_error2(error, pNum_correct, "malloc failed");
error |= clSetKernelArgSVMPointer(kernel_create_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_create_lists, 1, pAllocator);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(cl_int),(void *) &ListLength);
error |= clSetKernelArgSVMPointer(kernel_create_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_create_lists, 1, pAllocator);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(cl_int),
(void *)&ListLength);
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 1, pNum_correct);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(cl_int), (void *) &ListLength);
test_error(error, "clSetKernelArg failed");
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 1, pNum_correct);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(cl_int),
(void *)&ListLength);
test_error(error, "clSetKernelArg failed");
// Create linked list on one device and verify on another device (or the host).
// Do this for all possible combinations of devices and host within the platform.
for (int ci=0; ci<(int)num_devices+1; ci++) // ci is CreationIndex, index of device/q to create linked list on
{
for (int vi=0; vi<(int)num_devices+1; vi++) // vi is VerificationIndex, index of device/q to verify linked list on
// Create linked list on one device and verify on another device (or the
// host). Do this for all possible combinations of devices and host within
// the platform.
for (int ci = 0; ci < (int)num_devices + 1;
ci++) // ci is CreationIndex, index of device/q to create linked list
// on
{
if(ci == num_devices) // last device index represents the host, note the num_device+1 above.
{
log_info("creating linked list on host ");
create_linked_lists(pNodes, numLists, ListLength);
}
else
{
error = create_linked_lists_on_device_no_map(ci, queues[ci], pAllocator, kernel_create_lists, numLists);
if(error) return -1;
}
for (int vi = 0; vi < (int)num_devices + 1;
vi++) // vi is VerificationIndex, index of device/q to verify
// linked list on
{
if (ci == num_devices) // last device index represents the host,
// note the num_device+1 above.
{
log_info("creating linked list on host ");
create_linked_lists(pNodes, numLists, ListLength);
}
else
{
error = create_linked_lists_on_device_no_map(
ci, queues[ci], pAllocator, kernel_create_lists, numLists);
if (error) return -1;
}
if(vi == num_devices)
{
error = verify_linked_lists(pNodes, numLists, ListLength);
if(error) return -1;
}
else
{
error = verify_linked_lists_on_device_no_map(vi, queues[vi], pNum_correct, kernel_verify_lists, ListLength, numLists);
if(error) return -1;
}
if (vi == num_devices)
{
error = verify_linked_lists(pNodes, numLists, ListLength);
if (error) return -1;
}
else
{
error = verify_linked_lists_on_device_no_map(
vi, queues[vi], pNum_correct, kernel_verify_lists,
ListLength, numLists);
if (error) return -1;
}
}
}
}
align_free(pNodes);
align_free(pAllocator);
align_free(pNum_correct);
return 0;
align_free(pNodes);
align_free(pAllocator);
align_free(pNum_correct);
return 0;
}

View file

@ -61,78 +61,104 @@ cl_int verify_linked_lists_on_device_no_map(int vi, cl_command_queue cmdq,cl_int
// This is done by creating a linked list on a device and then verifying the correctness of the list
// on another device or the host. This basic test is performed for all combinations of devices and the host that exist within
// the platform. The test passes only if every combination passes.
int test_svm_shared_address_space_fine_grain_buffers(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_shared_address_space_fine_grain_buffers)
{
clContextWrapper context = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &linked_list_create_and_verify_kernels[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
if(error == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing.
if(error < 0) return -1; // fail test.
error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER);
context = contextWrapper;
if (error == 1)
return 0; // no devices capable of requested SVM level, so don't execute
// but count test as passing.
if (error < 0) return -1; // fail test.
size_t numLists = num_elements;
cl_int ListLength = 32;
size_t numLists = num_elements;
cl_int ListLength = 32;
clKernelWrapper kernel_create_lists = clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_create_lists =
clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists = clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists =
clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
// this buffer holds the linked list nodes.
Node* pNodes = (Node*) clSVMAlloc(context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, sizeof(Node)*ListLength*numLists, 0);
// this buffer holds the linked list nodes.
Node *pNodes = (Node *)clSVMAlloc(
context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
sizeof(Node) * ListLength * numLists, 0);
// this buffer holds an index into the nodes buffer, it is used for node allocation
size_t *pAllocator = (size_t*) clSVMAlloc(context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, sizeof(size_t), 0);
// this buffer holds an index into the nodes buffer, it is used for node
// allocation
size_t *pAllocator = (size_t *)clSVMAlloc(
context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
sizeof(size_t), 0);
// this buffer holds the count of correct nodes, which is computed by the verify kernel.
cl_int *pNumCorrect = (cl_int*) clSVMAlloc(context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, sizeof(cl_int), 0);
// this buffer holds the count of correct nodes, which is computed by the
// verify kernel.
cl_int *pNumCorrect = (cl_int *)clSVMAlloc(
context, CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER,
sizeof(cl_int), 0);
error |= clSetKernelArgSVMPointer(kernel_create_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_create_lists, 1, pAllocator);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(cl_int), (void *) &ListLength);
error |= clSetKernelArgSVMPointer(kernel_create_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_create_lists, 1, pAllocator);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(cl_int),
(void *)&ListLength);
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 1, pNumCorrect);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(cl_int), (void *) &ListLength);
test_error(error, "clSetKernelArg failed");
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 0, pNodes);
error |= clSetKernelArgSVMPointer(kernel_verify_lists, 1, pNumCorrect);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(cl_int),
(void *)&ListLength);
test_error(error, "clSetKernelArg failed");
// Create linked list on one device and verify on another device (or the host).
// Do this for all possible combinations of devices and host within the platform.
for (int ci=0; ci<(int)num_devices+1; ci++) // ci is CreationIndex, index of device/q to create linked list on
{
for (int vi=0; vi<(int)num_devices+1; vi++) // vi is VerificationIndex, index of device/q to verify linked list on
// Create linked list on one device and verify on another device (or the
// host). Do this for all possible combinations of devices and host within
// the platform.
for (int ci = 0; ci < (int)num_devices + 1;
ci++) // ci is CreationIndex, index of device/q to create linked list
// on
{
if(ci == num_devices) // last device index represents the host, note the num_device+1 above.
{
log_info("SVM: creating linked list on host ");
create_linked_lists(pNodes, numLists, ListLength);
}
else
{
error = create_linked_lists_on_device_no_map(ci, queues[ci], pAllocator, kernel_create_lists, numLists);
if(error) return -1;
}
for (int vi = 0; vi < (int)num_devices + 1;
vi++) // vi is VerificationIndex, index of device/q to verify
// linked list on
{
if (ci == num_devices) // last device index represents the host,
// note the num_device+1 above.
{
log_info("SVM: creating linked list on host ");
create_linked_lists(pNodes, numLists, ListLength);
}
else
{
error = create_linked_lists_on_device_no_map(
ci, queues[ci], pAllocator, kernel_create_lists, numLists);
if (error) return -1;
}
if(vi == num_devices)
{
error = verify_linked_lists(pNodes, numLists, ListLength);
if(error) return -1;
}
else
{
error = verify_linked_lists_on_device_no_map(vi, queues[vi], pNumCorrect, kernel_verify_lists, ListLength, numLists);
if(error) return -1;
}
if (vi == num_devices)
{
error = verify_linked_lists(pNodes, numLists, ListLength);
if (error) return -1;
}
else
{
error = verify_linked_lists_on_device_no_map(
vi, queues[vi], pNumCorrect, kernel_verify_lists,
ListLength, numLists);
if (error) return -1;
}
}
}
}
clSVMFree(context, pNodes);
clSVMFree(context, pAllocator);
clSVMFree(context, pNumCorrect);
clSVMFree(context, pNodes);
clSVMFree(context, pAllocator);
clSVMFree(context, pNumCorrect);
return 0;
return 0;
}

View file

@ -125,117 +125,160 @@ cl_int verify_linked_lists_on_host_sb(int ci, cl_command_queue cmdq, cl_mem node
// on another device or the host.
// The linked list nodes are allocated from two different buffers this is done to ensure that cross buffer pointers work correctly.
// This basic test is performed for all combinations of devices and the host.
int test_svm_shared_sub_buffers(cl_device_id deviceID, cl_context context2, cl_command_queue queue, int num_elements)
REGISTER_TEST(svm_shared_sub_buffers)
{
clContextWrapper context = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
clContextWrapper contextWrapper = NULL;
clProgramWrapper program = NULL;
cl_uint num_devices = 0;
cl_int error = CL_SUCCESS;
clCommandQueueWrapper queues[MAXQ];
error = create_cl_objects(deviceID, &shared_sub_buffers_test_kernel[0], &context, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
if(error) return -1;
error = create_cl_objects(device, &shared_sub_buffers_test_kernel[0],
&contextWrapper, &program, &queues[0],
&num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER);
context = contextWrapper;
if (error) return -1;
size_t numLists = num_elements;
if(numLists & 0x1) numLists++; // force even size, so we can easily create two sub-buffers of same size.
size_t numLists = num_elements;
if (numLists & 0x1)
numLists++; // force even size, so we can easily create two sub-buffers
// of same size.
cl_int ListLength = 32;
cl_int ListLength = 32;
clKernelWrapper kernel_create_lists = clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_create_lists =
clCreateKernel(program, "create_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists = clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
clKernelWrapper kernel_verify_lists =
clCreateKernel(program, "verify_linked_lists", &error);
test_error(error, "clCreateKernel failed");
size_t nodes_bufsize = sizeof(Node)*ListLength*numLists;
Node* pNodes = (Node*) clSVMAlloc(context, CL_MEM_READ_WRITE, nodes_bufsize, 0);
Node* pNodes2 = (Node*) clSVMAlloc(context, CL_MEM_READ_WRITE, nodes_bufsize, 0);
size_t nodes_bufsize = sizeof(Node) * ListLength * numLists;
Node *pNodes =
(Node *)clSVMAlloc(context, CL_MEM_READ_WRITE, nodes_bufsize, 0);
Node *pNodes2 =
(Node *)clSVMAlloc(context, CL_MEM_READ_WRITE, nodes_bufsize, 0);
{
// this buffer holds some of the linked list nodes.
clMemWrapper nodes = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, nodes_bufsize, pNodes, &error);
test_error(error, "clCreateBuffer failed.");
cl_buffer_region r;
r.origin = 0;
r.size = nodes_bufsize / 2;
// this should inherit the flag settings from nodes buffer
clMemWrapper nodes_sb1 = clCreateSubBuffer(nodes, 0, CL_BUFFER_CREATE_TYPE_REGION, (void*)&r, &error);
test_error(error, "clCreateSubBuffer");
r.origin = nodes_bufsize / 2;
clMemWrapper nodes_sb2 = clCreateSubBuffer(nodes, 0, CL_BUFFER_CREATE_TYPE_REGION, (void*)&r, &error);
test_error(error, "clCreateSubBuffer");
// this buffer holds some of the linked list nodes.
clMemWrapper nodes2 = clCreateBuffer(context, CL_MEM_USE_HOST_PTR, sizeof(Node)*ListLength*numLists, pNodes2, &error);
test_error(error, "clCreateBuffer failed.");
r.origin = 0;
r.size = nodes_bufsize / 2;
// this should inherit the flag settings from nodes buffer
clMemWrapper nodes2_sb1 = clCreateSubBuffer(nodes2, 0, CL_BUFFER_CREATE_TYPE_REGION, (void*)&r, &error);
test_error(error, "clCreateSubBuffer");
r.origin = nodes_bufsize / 2;
clMemWrapper nodes2_sb2 = clCreateSubBuffer(nodes2, 0, CL_BUFFER_CREATE_TYPE_REGION,(void*)&r, &error);
test_error(error, "clCreateSubBuffer");
// this buffer holds the index into the nodes buffer that is used for node allocation
clMemWrapper allocator = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_int), NULL, &error);
test_error(error, "clCreateBuffer failed.");
// this buffer holds the count of correct nodes which is computed by the verify kernel.
clMemWrapper num_correct = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_int), NULL, &error);
test_error(error, "clCreateBuffer failed.");
error |= clSetKernelArg(kernel_create_lists, 0, sizeof(void*), (void *) &nodes_sb1);
error |= clSetKernelArg(kernel_create_lists, 1, sizeof(void*), (void *) &nodes2_sb1);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(void*), (void *) &nodes_sb2);
error |= clSetKernelArg(kernel_create_lists, 3, sizeof(void*), (void *) &nodes2_sb2);
error |= clSetKernelArg(kernel_create_lists, 4, sizeof(void*), (void *) &allocator);
error |= clSetKernelArg(kernel_create_lists, 5, sizeof(cl_int),(void *) &ListLength);
error |= clSetKernelArg(kernel_verify_lists, 0, sizeof(void*), (void *) &nodes_sb1);
error |= clSetKernelArg(kernel_verify_lists, 1, sizeof(void*), (void *) &nodes2_sb1);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(void*), (void *) &nodes_sb2);
error |= clSetKernelArg(kernel_verify_lists, 3, sizeof(void*), (void *) &nodes2_sb2);
error |= clSetKernelArg(kernel_verify_lists, 4, sizeof(void*), (void *) &num_correct);
error |= clSetKernelArg(kernel_verify_lists, 5, sizeof(cl_int),(void *) &ListLength);
test_error(error, "clSetKernelArg failed");
// Create linked list on one device and verify on another device (or the host).
// Do this for all possible combinations of devices and host within the platform.
for (int ci=0; ci<(int)num_devices+1; ci++) // ci is CreationIndex, index of device/q to create linked list on
{
for (int vi=0; vi<(int)num_devices+1; vi++) // vi is VerificationIndex, index of device/q to verify linked list on
{
if(ci == num_devices) // last device index represents the host, note the num_device+1 above.
{
error = create_linked_lists_on_host_sb(queues[0], nodes, nodes2, ListLength, numLists);
if(error) return -1;
}
else
{
error = create_linked_lists_on_device(ci, queues[ci], allocator, kernel_create_lists, numLists);
if(error) return -1;
}
// this buffer holds some of the linked list nodes.
clMemWrapper nodes = clCreateBuffer(context, CL_MEM_USE_HOST_PTR,
nodes_bufsize, pNodes, &error);
test_error(error, "clCreateBuffer failed.");
if(vi == num_devices)
{
error = verify_linked_lists_on_host_sb(vi, queues[0], nodes, nodes2, ListLength, numLists);
if(error) return -1;
}
else
{
error = verify_linked_lists_on_device(vi, queues[vi], num_correct, kernel_verify_lists, ListLength, numLists);
if(error) return -1;
}
} // inner loop, vi
} // outer loop, ci
}
clSVMFree(context, pNodes2);
clSVMFree(context, pNodes);
cl_buffer_region r;
r.origin = 0;
r.size = nodes_bufsize / 2;
// this should inherit the flag settings from nodes buffer
clMemWrapper nodes_sb1 = clCreateSubBuffer(
nodes, 0, CL_BUFFER_CREATE_TYPE_REGION, (void *)&r, &error);
test_error(error, "clCreateSubBuffer");
r.origin = nodes_bufsize / 2;
clMemWrapper nodes_sb2 = clCreateSubBuffer(
nodes, 0, CL_BUFFER_CREATE_TYPE_REGION, (void *)&r, &error);
test_error(error, "clCreateSubBuffer");
return 0;
// this buffer holds some of the linked list nodes.
clMemWrapper nodes2 = clCreateBuffer(
context, CL_MEM_USE_HOST_PTR, sizeof(Node) * ListLength * numLists,
pNodes2, &error);
test_error(error, "clCreateBuffer failed.");
r.origin = 0;
r.size = nodes_bufsize / 2;
// this should inherit the flag settings from nodes buffer
clMemWrapper nodes2_sb1 = clCreateSubBuffer(
nodes2, 0, CL_BUFFER_CREATE_TYPE_REGION, (void *)&r, &error);
test_error(error, "clCreateSubBuffer");
r.origin = nodes_bufsize / 2;
clMemWrapper nodes2_sb2 = clCreateSubBuffer(
nodes2, 0, CL_BUFFER_CREATE_TYPE_REGION, (void *)&r, &error);
test_error(error, "clCreateSubBuffer");
// this buffer holds the index into the nodes buffer that is used for
// node allocation
clMemWrapper allocator = clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(size_t), NULL, &error);
test_error(error, "clCreateBuffer failed.");
// this buffer holds the count of correct nodes which is computed by the
// verify kernel.
clMemWrapper num_correct = clCreateBuffer(context, CL_MEM_READ_WRITE,
sizeof(cl_int), NULL, &error);
test_error(error, "clCreateBuffer failed.");
error |= clSetKernelArg(kernel_create_lists, 0, sizeof(void *),
(void *)&nodes_sb1);
error |= clSetKernelArg(kernel_create_lists, 1, sizeof(void *),
(void *)&nodes2_sb1);
error |= clSetKernelArg(kernel_create_lists, 2, sizeof(void *),
(void *)&nodes_sb2);
error |= clSetKernelArg(kernel_create_lists, 3, sizeof(void *),
(void *)&nodes2_sb2);
error |= clSetKernelArg(kernel_create_lists, 4, sizeof(void *),
(void *)&allocator);
error |= clSetKernelArg(kernel_create_lists, 5, sizeof(cl_int),
(void *)&ListLength);
error |= clSetKernelArg(kernel_verify_lists, 0, sizeof(void *),
(void *)&nodes_sb1);
error |= clSetKernelArg(kernel_verify_lists, 1, sizeof(void *),
(void *)&nodes2_sb1);
error |= clSetKernelArg(kernel_verify_lists, 2, sizeof(void *),
(void *)&nodes_sb2);
error |= clSetKernelArg(kernel_verify_lists, 3, sizeof(void *),
(void *)&nodes2_sb2);
error |= clSetKernelArg(kernel_verify_lists, 4, sizeof(void *),
(void *)&num_correct);
error |= clSetKernelArg(kernel_verify_lists, 5, sizeof(cl_int),
(void *)&ListLength);
test_error(error, "clSetKernelArg failed");
// Create linked list on one device and verify on another device (or the
// host). Do this for all possible combinations of devices and host
// within the platform.
for (int ci = 0; ci < (int)num_devices + 1;
ci++) // ci is CreationIndex, index of device/q to create linked
// list on
{
for (int vi = 0; vi < (int)num_devices + 1;
vi++) // vi is VerificationIndex, index of device/q to verify
// linked list on
{
if (ci == num_devices) // last device index represents the host,
// note the num_device+1 above.
{
error = create_linked_lists_on_host_sb(
queues[0], nodes, nodes2, ListLength, numLists);
if (error) return -1;
}
else
{
error = create_linked_lists_on_device(
ci, queues[ci], allocator, kernel_create_lists,
numLists);
if (error) return -1;
}
if (vi == num_devices)
{
error = verify_linked_lists_on_host_sb(
vi, queues[0], nodes, nodes2, ListLength, numLists);
if (error) return -1;
}
else
{
error = verify_linked_lists_on_device(
vi, queues[vi], num_correct, kernel_verify_lists,
ListLength, numLists);
if (error) return -1;
}
} // inner loop, vi
} // outer loop, ci
}
clSVMFree(context, pNodes2);
clSVMFree(context, pNodes);
return 0;
}

View file

@ -8,4 +8,6 @@ set(${MODULE_NAME}_SOURCES
allocation_utils.cpp
)
set_gnulike_module_compile_flags("-Wno-sign-compare")
include(../CMakeCommon.txt)

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -16,18 +16,27 @@
#include "allocation_execute.h"
#include "allocation_functions.h"
#include <vector>
const char *buffer_kernel_pattern = {
"__kernel void sample_test(%s __global uint *result, __global %s *array_sizes, uint per_item)\n"
"__kernel void sample_test(%s __global uint *result, __global %s "
"*array_sizes, uint per_item)\n"
"{\n"
"\tint tid = get_global_id(0);\n"
"\tuint r = 0;\n"
"\t%s i;\n"
"\tfor(i=(%s)tid*(%s)per_item; i<(%s)(1+tid)*(%s)per_item; i++) {\n"
"%s"
"\t}\n"
"\tresult[tid] = r;\n"
"}\n" };
"}\n"
};
const char *accumulate_pattern = {
"\t%s end%d = min((%s)(1+tid)*(%s)per_item, array_sizes[%d]);\n"
"\tfor(i=(%s)tid*(%s)per_item; i<end%d; i++) {\n"
"\t\tr += buffer%d[i];\n"
"\t}\n"
};
const char *image_kernel_pattern = {
"__kernel void sample_test(%s __global uint *result)\n"
@ -38,7 +47,8 @@ const char *image_kernel_pattern = {
"\tint x, y;\n"
"%s"
"\tresult[get_global_id(0)] += color.x + color.y + color.z + color.w;\n"
"}\n" };
"}\n"
};
const char *read_pattern = {
"\tfor(y=0; y<get_image_height(image%d); y++)\n"
@ -48,11 +58,11 @@ const char *read_pattern = {
"\t\t\t}\n"
};
const char *offset_pattern =
"\tconst uint4 offset = (uint4)(0,1,2,3);\n";
const char *offset_pattern = "\tconst uint4 offset = (uint4)(0,1,2,3);\n";
const char *sampler_pattern =
"\tconst sampler_t sampler = CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST | CLK_NORMALIZED_COORDS_FALSE;\n";
"\tconst sampler_t sampler = CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST | "
"CLK_NORMALIZED_COORDS_FALSE;\n";
const char *write_pattern = {
@ -66,7 +76,8 @@ const char *write_pattern = {
};
int check_image(cl_command_queue queue, cl_mem mem) {
int check_image(cl_command_queue queue, cl_mem mem)
{
int error;
cl_mem_object_type type;
size_t width, height;
@ -74,30 +85,42 @@ int check_image(cl_command_queue queue, cl_mem mem) {
cl_uint *data;
error = clGetMemObjectInfo(mem, CL_MEM_TYPE, sizeof(type), &type, NULL);
if (error) {
if (error)
{
print_error(error, "clGetMemObjectInfo failed for CL_MEM_TYPE.");
return -1;
}
if (type == CL_MEM_OBJECT_BUFFER) {
log_error("Expected image object, not buffer.\n");
return -1;
} else if (type == CL_MEM_OBJECT_IMAGE2D) {
error = clGetImageInfo(mem, CL_IMAGE_WIDTH, sizeof(width), &width, NULL);
if (error) {
print_error(error, "clGetMemObjectInfo failed for CL_IMAGE_WIDTH.");
switch (type)
{
case CL_MEM_OBJECT_BUFFER:
log_error("Expected image object, not buffer.\n");
return -1;
}
error = clGetImageInfo(mem, CL_IMAGE_HEIGHT, sizeof(height), &height, NULL);
if (error) {
print_error(error, "clGetMemObjectInfo failed for CL_IMAGE_HEIGHT.");
return -1;
}
case CL_MEM_OBJECT_IMAGE2D:
error = clGetImageInfo(mem, CL_IMAGE_WIDTH, sizeof(width), &width,
NULL);
if (error)
{
print_error(error,
"clGetMemObjectInfo failed for CL_IMAGE_WIDTH.");
return -1;
}
error = clGetImageInfo(mem, CL_IMAGE_HEIGHT, sizeof(height),
&height, NULL);
if (error)
{
print_error(error,
"clGetMemObjectInfo failed for CL_IMAGE_HEIGHT.");
return -1;
}
break;
default: log_error("unexpected object type"); return -1;
}
data = (cl_uint*)malloc(width*4*sizeof(cl_uint));
if (data == NULL) {
data = (cl_uint *)malloc(width * 4 * sizeof(cl_uint));
if (data == NULL)
{
log_error("Failed to malloc host buffer for writing into image.\n");
return FAILED_ABORT;
}
@ -107,19 +130,27 @@ int check_image(cl_command_queue queue, cl_mem mem) {
region[0] = width;
region[1] = 1;
region[2] = 1;
for (origin[1] = 0; origin[1] < height; origin[1]++) {
error = clEnqueueReadImage(queue, mem, CL_TRUE, origin, region, 0, 0, data, 0, NULL, NULL);
if (error) {
for (origin[1] = 0; origin[1] < height; origin[1]++)
{
error = clEnqueueReadImage(queue, mem, CL_TRUE, origin, region, 0, 0,
data, 0, NULL, NULL);
if (error)
{
print_error(error, "clEnqueueReadImage failed");
free(data);
return error;
}
for (x=0; x<width; x++) {
for (j=0; j<4; j++) {
if (data[x*4+j] != (cl_uint)(x*origin[1]+j)) {
log_error("Pixel %d, %d, component %d, expected %u, got %u.\n",
(int)x, (int)origin[1], (int)j, (cl_uint)(x*origin[1]+j), data[x*4+j]);
for (x = 0; x < width; x++)
{
for (j = 0; j < 4; j++)
{
if (data[x * 4 + j] != (cl_uint)(x * origin[1] + j))
{
log_error(
"Pixel %d, %d, component %d, expected %u, got %u.\n",
(int)x, (int)origin[1], (int)j,
(cl_uint)(x * origin[1] + j), data[x * 4 + j]);
return -1;
}
}
@ -130,9 +161,11 @@ int check_image(cl_command_queue queue, cl_mem mem) {
}
#define NUM_OF_WORK_ITEMS 8192*2
int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id device_id, int test, cl_mem mems[], int number_of_mems_used, int verify_checksum) {
int execute_kernel(cl_context context, cl_command_queue *queue,
cl_device_id device_id, int test, cl_mem mems[],
int number_of_mems_used, int verify_checksum,
unsigned int number_of_work_items)
{
char *argument_string;
char *access_string;
@ -145,73 +178,112 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev
size_t global_dims[3];
cl_uint per_item;
cl_uint per_item_uint;
cl_uint returned_results[NUM_OF_WORK_ITEMS], final_result;
cl_uint final_result;
std::vector<cl_uint> returned_results(number_of_work_items);
clEventWrapper event;
cl_int event_status;
// Allocate memory for the kernel source
argument_string = (char*)malloc(sizeof(char)*MAX_NUMBER_TO_ALLOCATE*64);
access_string = (char*)malloc(sizeof(char)*MAX_NUMBER_TO_ALLOCATE*(strlen(read_pattern)+10));
kernel_string = (char*)malloc(sizeof(char)*MAX_NUMBER_TO_ALLOCATE*(strlen(read_pattern)+10+64)+1024);
char *used_pattern = nullptr;
if (test == BUFFER || test == BUFFER_NON_BLOCKING)
{
used_pattern = (char *)accumulate_pattern;
}
else if (test == IMAGE_READ || test == IMAGE_READ_NON_BLOCKING)
{
used_pattern = (char *)read_pattern;
}
else if (test == IMAGE_WRITE || test == IMAGE_WRITE_NON_BLOCKING)
{
used_pattern = (char *)write_pattern;
}
argument_string =
(char *)malloc(sizeof(char) * MAX_NUMBER_TO_ALLOCATE * 64);
access_string = (char *)malloc(sizeof(char) * MAX_NUMBER_TO_ALLOCATE
* (strlen(used_pattern) + 10));
kernel_string = (char *)malloc(sizeof(char) * MAX_NUMBER_TO_ALLOCATE
* (strlen(used_pattern) + 10 + 64)
+ 1024);
argument_string[0] = '\0';
access_string[0] = '\0';
kernel_string[0] = '\0';
// Zero the results.
for (i=0; i<NUM_OF_WORK_ITEMS; i++)
returned_results[i] = 0;
for (i = 0; i < number_of_work_items; i++) returned_results[i] = 0;
// detect if device supports ulong/int64
//detect whether profile of the device is embedded
// detect whether profile of the device is embedded
bool support64 = true;
char profile[1024] = "";
error = clGetDeviceInfo(device_id, CL_DEVICE_PROFILE, sizeof(profile), profile, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PROFILE failed\n" );
if ((NULL != strstr(profile, "EMBEDDED_PROFILE")) &&
(!is_extension_available(device_id, "cles_khr_int64"))) {
support64 = false;
error = clGetDeviceInfo(device_id, CL_DEVICE_PROFILE, sizeof(profile),
profile, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PROFILE failed\n");
if ((NULL != strstr(profile, "EMBEDDED_PROFILE"))
&& (!is_extension_available(device_id, "cles_khr_int64")))
{
support64 = false;
}
// Build the kernel source
if (test == BUFFER || test == BUFFER_NON_BLOCKING) {
for(i=0; i<number_of_mems_used; i++) {
sprintf(argument_string + strlen(argument_string), " __global uint *buffer%d, ", i);
sprintf(access_string + strlen( access_string), "\t\tif (i<array_sizes[%d]) r += buffer%d[i];\n", i, i);
}
if (test == BUFFER || test == BUFFER_NON_BLOCKING)
{
char type[10];
if (support64) {
if (support64)
{
sprintf(type, "ulong");
}
else {
else
{
sprintf(type, "uint");
}
sprintf(kernel_string, buffer_kernel_pattern, argument_string, type, type, type, type, type, type, access_string);
}
else if (test == IMAGE_READ || test == IMAGE_READ_NON_BLOCKING) {
for(i=0; i<number_of_mems_used; i++) {
sprintf(argument_string + strlen(argument_string), " read_only image2d_t image%d, ", i);
sprintf(access_string + strlen(access_string), read_pattern, i, "%", i, i);
for (i = 0; i < number_of_mems_used; i++)
{
sprintf(argument_string + strlen(argument_string),
" __global uint *buffer%d, ", i);
sprintf(access_string + strlen(access_string), accumulate_pattern,
type, i, type, type, i, type, type, i, i);
}
sprintf(kernel_string, image_kernel_pattern, argument_string, sampler_pattern, access_string);
sprintf(kernel_string, buffer_kernel_pattern, argument_string, type,
type, access_string);
}
else if (test == IMAGE_WRITE || test == IMAGE_WRITE_NON_BLOCKING) {
for(i=0; i<number_of_mems_used; i++) {
sprintf(argument_string + strlen(argument_string), " write_only image2d_t image%d, ", i);
sprintf(access_string + strlen( access_string), write_pattern, i, "%", i, i);
else if (test == IMAGE_READ || test == IMAGE_READ_NON_BLOCKING)
{
for (i = 0; i < number_of_mems_used; i++)
{
sprintf(argument_string + strlen(argument_string),
" read_only image2d_t image%d, ", i);
sprintf(access_string + strlen(access_string), read_pattern, i, "%",
i, i);
}
sprintf(kernel_string, image_kernel_pattern, argument_string, offset_pattern, access_string);
sprintf(kernel_string, image_kernel_pattern, argument_string,
sampler_pattern, access_string);
}
else if (test == IMAGE_WRITE || test == IMAGE_WRITE_NON_BLOCKING)
{
for (i = 0; i < number_of_mems_used; i++)
{
sprintf(argument_string + strlen(argument_string),
" write_only image2d_t image%d, ", i);
sprintf(access_string + strlen(access_string), write_pattern, i,
"%", i, i);
}
sprintf(kernel_string, image_kernel_pattern, argument_string,
offset_pattern, access_string);
}
ptr = kernel_string;
// Create the kernel
error = create_single_kernel_helper( context, &program, &kernel, 1, (const char **)&ptr, "sample_test" );
error = create_single_kernel_helper(context, &program, &kernel, 1,
(const char **)&ptr, "sample_test");
free(argument_string);
free(access_string);
free(kernel_string);
result = check_allocation_error(context, device_id, error, queue);
if (result != SUCCEEDED) {
if (result != SUCCEEDED)
{
if (result == FAILED_TOO_BIG)
log_info("\t\tCreate kernel failed: %s.\n", IGetErrorString(error));
else
@ -220,78 +292,109 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev
}
// Set the arguments
for (i=0; i<number_of_mems_used; i++) {
for (i = 0; i < number_of_mems_used; i++)
{
error = clSetKernelArg(kernel, i, sizeof(cl_mem), &mems[i]);
test_error(error, "clSetKernelArg failed");
}
// Set the result
result_mem = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, sizeof(cl_uint)*NUM_OF_WORK_ITEMS, &returned_results, &error);
result_mem =
clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
sizeof(cl_uint) * number_of_work_items,
returned_results.data(), &error);
test_error(error, "clCreateBuffer failed");
error = clSetKernelArg(kernel, i, sizeof(result_mem), &result_mem);
test_error(error, "clSetKernelArg failed");
// Thread dimensions for execution
global_dims[0] = NUM_OF_WORK_ITEMS; global_dims[1] = 1; global_dims[2] = 1;
global_dims[0] = number_of_work_items;
global_dims[1] = 1;
global_dims[2] = 1;
// We have extra arguments for the buffer kernel because we need to pass in the buffer sizes
// We have extra arguments for the buffer kernel because we need to pass in
// the buffer sizes
cl_ulong *ulSizes = NULL;
cl_uint *uiSizes = NULL;
if (support64) {
ulSizes = (cl_ulong*)malloc(sizeof(cl_ulong)*number_of_mems_used);
cl_uint *uiSizes = NULL;
if (support64)
{
ulSizes = (cl_ulong *)malloc(sizeof(cl_ulong) * number_of_mems_used);
}
else {
uiSizes = (cl_uint*)malloc(sizeof(cl_uint)*number_of_mems_used);
else
{
uiSizes = (cl_uint *)malloc(sizeof(cl_uint) * number_of_mems_used);
}
cl_ulong max_size = 0;
clMemWrapper buffer_sizes;
if (test == BUFFER || test == BUFFER_NON_BLOCKING) {
for (i=0; i<number_of_mems_used; i++) {
if (test == BUFFER || test == BUFFER_NON_BLOCKING)
{
for (i = 0; i < number_of_mems_used; i++)
{
size_t size;
error = clGetMemObjectInfo(mems[i], CL_MEM_SIZE, sizeof(size), &size, NULL);
test_error_abort(error, "clGetMemObjectInfo failed for CL_MEM_SIZE.");
if (support64) {
ulSizes[i] = size/sizeof(cl_uint);
error = clGetMemObjectInfo(mems[i], CL_MEM_SIZE, sizeof(size),
&size, NULL);
test_error_abort(error,
"clGetMemObjectInfo failed for CL_MEM_SIZE.");
if (support64)
{
ulSizes[i] = size / sizeof(cl_uint);
}
else {
uiSizes[i] = (cl_uint)size/sizeof(cl_uint);
else
{
uiSizes[i] = (cl_uint)size / sizeof(cl_uint);
}
if (size/sizeof(cl_uint) > max_size)
max_size = size/sizeof(cl_uint);
if (size / sizeof(cl_uint) > max_size)
max_size = size / sizeof(cl_uint);
}
if (support64) {
buffer_sizes = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, sizeof(cl_ulong)*number_of_mems_used, ulSizes, &error);
if (support64)
{
buffer_sizes = clCreateBuffer(
context, CL_MEM_COPY_HOST_PTR,
sizeof(cl_ulong) * number_of_mems_used, ulSizes, &error);
}
else {
buffer_sizes = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, sizeof(cl_uint)*number_of_mems_used, uiSizes, &error);
else
{
buffer_sizes = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR,
sizeof(cl_uint) * number_of_mems_used,
uiSizes, &error);
}
test_error_abort(error, "clCreateBuffer failed");
error = clSetKernelArg(kernel, number_of_mems_used+1, sizeof(cl_mem), &buffer_sizes);
error = clSetKernelArg(kernel, number_of_mems_used + 1, sizeof(cl_mem),
&buffer_sizes);
test_error(error, "clSetKernelArg failed");
per_item = (cl_uint)ceil((double)max_size/global_dims[0]);
per_item = (cl_uint)ceil((double)max_size / global_dims[0]);
if (per_item > CL_UINT_MAX)
log_error("Size is too large for a uint parameter to the kernel. Expect invalid results.\n");
log_error("Size is too large for a uint parameter to the kernel. "
"Expect invalid results.\n");
per_item_uint = (cl_uint)per_item;
error = clSetKernelArg(kernel, number_of_mems_used+2, sizeof(per_item_uint), &per_item_uint);
error = clSetKernelArg(kernel, number_of_mems_used + 2,
sizeof(per_item_uint), &per_item_uint);
test_error(error, "clSetKernelArg failed");
}
if (ulSizes) {
if (ulSizes)
{
free(ulSizes);
}
if (uiSizes) {
if (uiSizes)
{
free(uiSizes);
}
size_t local_dims[3] = {1,1,1};
error = get_max_common_work_group_size(context, kernel, global_dims[0], &local_dims[0]);
size_t local_dims[3] = { 1, 1, 1 };
error = get_max_common_work_group_size(context, kernel, global_dims[0],
&local_dims[0]);
test_error(error, "get_max_common_work_group_size failed");
// Execute the kernel
error = clEnqueueNDRangeKernel(*queue, kernel, 1, NULL, global_dims, local_dims, 0, NULL, &event);
error = clEnqueueNDRangeKernel(*queue, kernel, 1, NULL, global_dims,
local_dims, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result != SUCCEEDED) {
if (result != SUCCEEDED)
{
if (result == FAILED_TOO_BIG)
log_info("\t\tExecute kernel failed: %s (global dim: %ld, local dim: %ld)\n", IGetErrorString(error), global_dims[0], local_dims[0]);
log_info("\t\tExecute kernel failed: %s (global dim: %zu, local "
"dim: %zu)\n",
IGetErrorString(error), global_dims[0], local_dims[0]);
else
print_error(error, "clEnqueueNDRangeKernel failed");
return result;
@ -302,7 +405,8 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev
result = check_allocation_error(context, device_id, error, queue);
if (result != SUCCEEDED) {
if (result != SUCCEEDED)
{
if (result == FAILED_TOO_BIG)
log_info("\t\tclFinish failed: %s.\n", IGetErrorString(error));
else
@ -311,13 +415,20 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev
}
// Verify that the event from the execution did not have an error
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(event_status), &event_status, NULL);
test_error_abort(error, "clGetEventInfo for CL_EVENT_COMMAND_EXECUTION_STATUS failed");
if (event_status < 0) {
result = check_allocation_error(context, device_id, event_status, queue);
if (result != SUCCEEDED) {
error = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
sizeof(event_status), &event_status, NULL);
test_error_abort(
error, "clGetEventInfo for CL_EVENT_COMMAND_EXECUTION_STATUS failed");
if (event_status < 0)
{
result =
check_allocation_error(context, device_id, event_status, queue);
if (result != SUCCEEDED)
{
if (result == FAILED_TOO_BIG)
log_info("\t\tEvent returned from kernel execution indicates failure: %s.\n", IGetErrorString(event_status));
log_info("\t\tEvent returned from kernel execution indicates "
"failure: %s.\n",
IGetErrorString(event_status));
else
print_error(event_status, "clEnqueueNDRangeKernel failed");
return result;
@ -325,31 +436,46 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev
}
// If we are not verifying the checksum return here
if (!verify_checksum) {
log_info("Note: Allocations were not initialized so kernel execution can not verify correct results.\n");
if (!verify_checksum)
{
log_info("Note: Allocations were not initialized so kernel execution "
"can not verify correct results.\n");
return SUCCEEDED;
}
// Verify the checksum.
// Read back the result
error = clEnqueueReadBuffer(*queue, result_mem, CL_TRUE, 0, sizeof(cl_uint)*NUM_OF_WORK_ITEMS, &returned_results, 0, NULL, NULL);
error = clEnqueueReadBuffer(*queue, result_mem, CL_TRUE, 0,
sizeof(cl_uint) * number_of_work_items,
returned_results.data(), 0, NULL, NULL);
test_error_abort(error, "clEnqueueReadBuffer failed");
final_result = 0;
if (test == BUFFER || test == IMAGE_READ || test == BUFFER_NON_BLOCKING || test == IMAGE_READ_NON_BLOCKING) {
// For buffers or read images we are just looking at the sum of what each thread summed up
for (i=0; i<NUM_OF_WORK_ITEMS; i++) {
if (test == BUFFER || test == IMAGE_READ || test == BUFFER_NON_BLOCKING
|| test == IMAGE_READ_NON_BLOCKING)
{
// For buffers or read images we are just looking at the sum of what
// each thread summed up
for (i = 0; i < number_of_work_items; i++)
{
final_result += returned_results[i];
}
if (final_result != checksum) {
log_error("\t\tChecksum failed to verify. Expected %u got %u.\n", checksum, final_result);
if (final_result != checksum)
{
log_error("\t\tChecksum failed to verify. Expected %u got %u.\n",
checksum, final_result);
return FAILED_ABORT;
}
log_info("\t\tChecksum verified (%u == %u).\n", checksum, final_result);
} else {
}
else
{
// For write images we need to verify the values
for (i=0; i<number_of_mems_used; i++) {
if (check_image(*queue, mems[i])) {
log_error("\t\tImage contents failed to verify for image %d.\n", (int)i);
for (i = 0; i < number_of_mems_used; i++)
{
if (check_image(*queue, mems[i]))
{
log_error("\t\tImage contents failed to verify for image %d.\n",
(int)i);
return FAILED_ABORT;
}
}
@ -359,7 +485,8 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev
// Finish the test
error = clFinish(*queue);
result = check_allocation_error(context, device_id, error, queue);
if (result != SUCCEEDED) {
if (result != SUCCEEDED)
{
if (result == FAILED_TOO_BIG)
log_info("\t\tclFinish failed: %s.\n", IGetErrorString(error));
else
@ -369,5 +496,3 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev
return SUCCEEDED;
}

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -17,6 +17,7 @@
#include "allocation_utils.h"
int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id device_id, int test, cl_mem mems[], int number_of_mems_used, int verify_checksum);
int execute_kernel(cl_context context, cl_command_queue *queue,
cl_device_id device_id, int test, cl_mem mems[],
int number_of_mems_used, int verify_checksum,
unsigned int number_of_work_items);

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -15,315 +15,387 @@
//
#include "allocation_fill.h"
#define BUFFER_CHUNK_SIZE 8*1024*1024
#define BUFFER_CHUNK_SIZE 8 * 1024 * 1024
#define IMAGE_LINES 8
#include "harness/compat.h"
int fill_buffer_with_data(cl_context context, cl_device_id device_id, cl_command_queue *queue, cl_mem mem, size_t size, MTdata d, cl_bool blocking_write) {
size_t i, j;
cl_uint *data;
int error, result;
cl_uint checksum_delta = 0;
cl_event event;
int fill_buffer_with_data(cl_context context, cl_device_id device_id,
cl_command_queue *queue, cl_mem mem, size_t size,
MTdata d, cl_bool blocking_write)
{
size_t i, j;
cl_uint *data;
int error, result;
cl_uint checksum_delta = 0;
cl_event event;
size_t size_to_use = BUFFER_CHUNK_SIZE;
if (size_to_use > size)
size_to_use = size;
size_t size_to_use = BUFFER_CHUNK_SIZE;
if (size_to_use > size) size_to_use = size;
data = (cl_uint*)malloc(size_to_use);
if (data == NULL) {
log_error("Failed to malloc host buffer for writing into buffer.\n");
data = (cl_uint *)malloc(size_to_use);
if (data == NULL)
{
log_error("Failed to malloc host buffer for writing into buffer.\n");
return FAILED_ABORT;
}
for (i = 0; i < size - size_to_use; i += size_to_use)
{
// Put values in the data, and keep a checksum as we go along.
for (j = 0; j < size_to_use / sizeof(cl_uint); j++)
{
data[j] = genrand_int32(d);
checksum_delta += data[j];
}
if (blocking_write)
{
error = clEnqueueWriteBuffer(*queue, mem, CL_TRUE, i, size_to_use,
data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
free(data);
clReleaseMemObject(mem);
return result;
}
}
else
{
error = clEnqueueWriteBuffer(*queue, mem, CL_FALSE, i, size_to_use,
data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
free(data);
clReleaseMemObject(mem);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue,
&event);
if (result == FAILED_ABORT)
{
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
// Deal with any leftover bits
if (i < size)
{
// Put values in the data, and keep a checksum as we go along.
for (j = 0; j < (size - i) / sizeof(cl_uint); j++)
{
data[j] = (cl_uint)genrand_int32(d);
checksum_delta += data[j];
}
if (blocking_write)
{
error = clEnqueueWriteBuffer(*queue, mem, CL_TRUE, i, size - i,
data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
}
else
{
error = clEnqueueWriteBuffer(*queue, mem, CL_FALSE, i, size - i,
data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue,
&event);
if (result == FAILED_ABORT)
{
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
free(data);
// Only update the checksum if this succeeded.
checksum += checksum_delta;
return SUCCEEDED;
}
int fill_image_with_data(cl_context context, cl_device_id device_id,
cl_command_queue *queue, cl_mem mem, size_t width,
size_t height, MTdata d, cl_bool blocking_write)
{
size_t origin[3], region[3], j;
int error, result;
cl_uint *data;
cl_uint checksum_delta = 0;
cl_event event;
size_t image_lines_to_use;
image_lines_to_use = IMAGE_LINES;
if (image_lines_to_use > height) image_lines_to_use = height;
data = (cl_uint *)malloc(width * 4 * sizeof(cl_uint) * image_lines_to_use);
if (data == NULL)
{
log_error("Failed to malloc host buffer for writing into image.\n");
return FAILED_ABORT;
}
origin[0] = 0;
origin[1] = 0;
origin[2] = 0;
region[0] = width;
region[1] = image_lines_to_use;
region[2] = 1;
for (origin[1] = 0; origin[1] < height - image_lines_to_use;
origin[1] += image_lines_to_use)
{
// Put values in the data, and keep a checksum as we go along.
for (j = 0; j < width * 4 * image_lines_to_use; j++)
{
data[j] = (cl_uint)genrand_int32(d);
checksum_delta += data[j];
}
if (blocking_write)
{
error = clEnqueueWriteImage(*queue, mem, CL_TRUE, origin, region, 0,
0, data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
result = clFinish(*queue);
if (result != SUCCEEDED)
{
print_error(
error,
"clFinish failed after successful enqueuing filling "
"buffer with data.");
return result;
}
}
else
{
error = clEnqueueWriteImage(*queue, mem, CL_FALSE, origin, region,
0, 0, data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue,
&event);
if (result == FAILED_ABORT)
{
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED)
{
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
// Deal with any leftover bits
if (origin[1] < height)
{
// Put values in the data, and keep a checksum as we go along.
for (j = 0; j < width * 4 * (height - origin[1]); j++)
{
data[j] = (cl_uint)genrand_int32(d);
checksum_delta += data[j];
}
region[1] = height - origin[1];
if (blocking_write)
{
error = clEnqueueWriteImage(*queue, mem, CL_TRUE, origin, region, 0,
0, data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
}
else
{
error = clEnqueueWriteImage(*queue, mem, CL_FALSE, origin, region,
0, 0, data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT)
{
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue,
&event);
if (result == FAILED_ABORT)
{
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED)
{
clFinish(*queue);
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
free(data);
// Only update the checksum if this succeeded.
checksum += checksum_delta;
return SUCCEEDED;
}
int fill_mem_with_data(cl_context context, cl_device_id device_id,
cl_command_queue *queue, cl_mem mem, MTdata d,
cl_bool blocking_write)
{
int error;
cl_mem_object_type type;
size_t size, width, height;
error = clGetMemObjectInfo(mem, CL_MEM_TYPE, sizeof(type), &type, NULL);
test_error_abort(error, "clGetMemObjectInfo failed for CL_MEM_TYPE.");
if (type == CL_MEM_OBJECT_BUFFER)
{
error = clGetMemObjectInfo(mem, CL_MEM_SIZE, sizeof(size), &size, NULL);
test_error_abort(error, "clGetMemObjectInfo failed for CL_MEM_SIZE.");
return fill_buffer_with_data(context, device_id, queue, mem, size, d,
blocking_write);
}
else if (type == CL_MEM_OBJECT_IMAGE2D)
{
error =
clGetImageInfo(mem, CL_IMAGE_WIDTH, sizeof(width), &width, NULL);
test_error_abort(error, "clGetImageInfo failed for CL_IMAGE_WIDTH.");
error =
clGetImageInfo(mem, CL_IMAGE_HEIGHT, sizeof(height), &height, NULL);
test_error_abort(error, "clGetImageInfo failed for CL_IMAGE_HEIGHT.");
return fill_image_with_data(context, device_id, queue, mem, width,
height, d, blocking_write);
}
log_error("Invalid CL_MEM_TYPE: %d\n", type);
return FAILED_ABORT;
}
for (i=0; i<size-size_to_use; i+=size_to_use) {
// Put values in the data, and keep a checksum as we go along.
for (j=0; j<size_to_use/sizeof(cl_uint); j++) {
data[j] = genrand_int32(d);
checksum_delta += data[j];
}
if (blocking_write) {
error = clEnqueueWriteBuffer(*queue, mem, CL_TRUE, i, size_to_use, data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
free(data);
clReleaseMemObject(mem);
return result;
}
} else {
error = clEnqueueWriteBuffer(*queue, mem, CL_FALSE, i, size_to_use, data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
free(data);
clReleaseMemObject(mem);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue, &event);
if (result == FAILED_ABORT) {
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
// Deal with any leftover bits
if (i < size) {
// Put values in the data, and keep a checksum as we go along.
for (j=0; j<(size-i)/sizeof(cl_uint); j++) {
data[j] = (cl_uint)genrand_int32(d);
checksum_delta += data[j];
}
if (blocking_write) {
error = clEnqueueWriteBuffer(*queue, mem, CL_TRUE, i, size-i, data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
} else {
error = clEnqueueWriteBuffer(*queue, mem, CL_FALSE, i, size-i, data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteBuffer failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue, &event);
if (result == FAILED_ABORT) {
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
free(data);
// Only update the checksum if this succeeded.
checksum += checksum_delta;
return SUCCEEDED;
}
int fill_image_with_data(cl_context context, cl_device_id device_id, cl_command_queue *queue, cl_mem mem, size_t width, size_t height, MTdata d, cl_bool blocking_write) {
size_t origin[3], region[3], j;
int error, result;
cl_uint *data;
cl_uint checksum_delta = 0;
cl_event event;
size_t image_lines_to_use;
image_lines_to_use = IMAGE_LINES;
if (image_lines_to_use > height)
image_lines_to_use = height;
data = (cl_uint*)malloc(width*4*sizeof(cl_uint)*image_lines_to_use);
if (data == NULL) {
log_error("Failed to malloc host buffer for writing into image.\n");
return FAILED_ABORT;
}
origin[0] = 0;
origin[1] = 0;
origin[2] = 0;
region[0] = width;
region[1] = image_lines_to_use;
region[2] = 1;
for (origin[1] = 0; origin[1] < height - image_lines_to_use; origin[1] += image_lines_to_use) {
// Put values in the data, and keep a checksum as we go along.
for (j=0; j<width*4*image_lines_to_use; j++) {
data[j] = (cl_uint)genrand_int32(d);
checksum_delta += data[j];
}
if (blocking_write) {
error = clEnqueueWriteImage(*queue, mem, CL_TRUE, origin, region, 0, 0, data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
result = clFinish(*queue);
if (result != SUCCEEDED)
{
print_error(error, "clFinish failed after successful enquing filling buffer with data.");
return result;
}
} else {
error = clEnqueueWriteImage(*queue, mem, CL_FALSE, origin, region, 0, 0, data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue, &event);
if (result == FAILED_ABORT) {
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED) {
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
// Deal with any leftover bits
if (origin[1] < height) {
// Put values in the data, and keep a checksum as we go along.
for (j=0; j<width*4*(height-origin[1]); j++) {
data[j] = (cl_uint)genrand_int32(d);
checksum_delta += data[j];
}
region[1] = height-origin[1];
if(blocking_write) {
error = clEnqueueWriteImage(*queue, mem, CL_TRUE, origin, region, 0, 0, data, 0, NULL, NULL);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
} else {
error = clEnqueueWriteImage(*queue, mem, CL_FALSE, origin, region, 0, 0, data, 0, NULL, &event);
result = check_allocation_error(context, device_id, error, queue);
if (result == FAILED_ABORT) {
print_error(error, "clEnqueueWriteImage failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseMemObject(mem);
free(data);
return result;
}
error = clWaitForEvents(1, &event);
result = check_allocation_error(context, device_id, error, queue, &event);
if (result == FAILED_ABORT) {
print_error(error, "clWaitForEvents failed.");
}
if (result != SUCCEEDED) {
clFinish(*queue);
clReleaseEvent(event);
free(data);
clReleaseMemObject(mem);
return result;
}
clReleaseEvent(event);
}
}
free(data);
// Only update the checksum if this succeeded.
checksum += checksum_delta;
return SUCCEEDED;
}
int fill_mem_with_data(cl_context context, cl_device_id device_id, cl_command_queue *queue, cl_mem mem, MTdata d, cl_bool blocking_write) {
int error;
cl_mem_object_type type;
size_t size, width, height;
error = clGetMemObjectInfo(mem, CL_MEM_TYPE, sizeof(type), &type, NULL);
test_error_abort(error, "clGetMemObjectInfo failed for CL_MEM_TYPE.");
if (type == CL_MEM_OBJECT_BUFFER) {
error = clGetMemObjectInfo(mem, CL_MEM_SIZE, sizeof(size), &size, NULL);
test_error_abort(error, "clGetMemObjectInfo failed for CL_MEM_SIZE.");
return fill_buffer_with_data(context, device_id, queue, mem, size, d, blocking_write);
} else if (type == CL_MEM_OBJECT_IMAGE2D) {
error = clGetImageInfo(mem, CL_IMAGE_WIDTH, sizeof(width), &width, NULL);
test_error_abort(error, "clGetImageInfo failed for CL_IMAGE_WIDTH.");
error = clGetImageInfo(mem, CL_IMAGE_HEIGHT, sizeof(height), &height, NULL);
test_error_abort(error, "clGetImageInfo failed for CL_IMAGE_HEIGHT.");
return fill_image_with_data(context, device_id, queue, mem, width, height, d, blocking_write);
}
log_error("Invalid CL_MEM_TYPE: %d\n", type);
return FAILED_ABORT;
}

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -16,4 +16,6 @@
#include "testBase.h"
#include "allocation_utils.h"
int fill_mem_with_data(cl_context context, cl_device_id device_id, cl_command_queue *queue, cl_mem mem, MTdata d, cl_bool blocking_write);
int fill_mem_with_data(cl_context context, cl_device_id device_id,
cl_command_queue *queue, cl_mem mem, MTdata d,
cl_bool blocking_write);

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -17,273 +17,367 @@
#include "allocation_fill.h"
static cl_image_format image_format = { CL_RGBA, CL_UNSIGNED_INT32 };
static cl_image_format image_format = { CL_RGBA, CL_UNSIGNED_INT32 };
int allocate_buffer(cl_context context, cl_command_queue *queue, cl_device_id device_id, cl_mem *mem, size_t size_to_allocate, cl_bool blocking_write) {
int error;
// log_info("\t\tAttempting to allocate a %gMB array and fill with %s writes.\n", (size_to_allocate/(1024.0*1024.0)), (blocking_write ? "blocking" : "non-blocking"));
*mem = clCreateBuffer(context, CL_MEM_READ_WRITE, size_to_allocate, NULL, &error);
return check_allocation_error(context, device_id, error, queue);
int allocate_buffer(cl_context context, cl_command_queue *queue,
cl_device_id device_id, cl_mem *mem,
size_t size_to_allocate, cl_bool blocking_write)
{
int error;
// log_info("\t\tAttempting to allocate a %gMB array and fill with %s
// writes.\n", (size_to_allocate/(1024.0*1024.0)), (blocking_write ?
// "blocking" : "non-blocking"));
*mem = clCreateBuffer(context, CL_MEM_READ_WRITE, size_to_allocate, NULL,
&error);
return check_allocation_error(context, device_id, error, queue);
}
int find_good_image_size(cl_device_id device_id, size_t size_to_allocate, size_t *width, size_t *height, size_t* max_size) {
size_t max_width, max_height, num_pixels, found_width, found_height;
int error;
int find_good_image_size(cl_device_id device_id, size_t size_to_allocate,
size_t *width, size_t *height, size_t *max_size)
{
size_t max_width, max_height, num_pixels, found_width, found_height;
int error;
if (checkForImageSupport(device_id)) {
log_info("Can not allocate an image on this device because it does not support images.");
return FAILED_ABORT;
}
if (size_to_allocate == 0) {
log_error("Trying to allcoate a zero sized image.\n");
return FAILED_ABORT;
}
error = clGetDeviceInfo( device_id, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( max_width ), &max_width, NULL );
test_error_abort(error, "clGetDeviceInfo failed.");
error = clGetDeviceInfo( device_id, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( max_height ), &max_height, NULL );
test_error_abort(error, "clGetDeviceInfo failed.");
num_pixels = size_to_allocate / (sizeof(cl_uint)*4);
// Use a 64-bit variable to avoid overflow in 32-bit architectures
long long unsigned max_pixels = (long long unsigned)max_width * max_height;
if (num_pixels > max_pixels) {
if(NULL != max_size) {
*max_size = max_width * max_height * sizeof(cl_uint) * 4;
if (checkForImageSupport(device_id))
{
log_info("Can not allocate an image on this device because it does not "
"support images.");
return FAILED_ABORT;
}
return FAILED_TOO_BIG;
}
// We want a close-to-square aspect ratio.
// Note that this implicitly assumes that max width >= max height
found_width = (int)sqrt( (double) num_pixels );
if( found_width > max_width ) {
found_width = max_width;
}
if (found_width == 0)
found_width = 1;
if (size_to_allocate == 0)
{
log_error("Trying to allocate a zero sized image.\n");
return FAILED_ABORT;
}
found_height = (size_t)num_pixels/found_width;
if (found_height > max_height) {
found_height = max_height;
}
if (found_height == 0)
found_height = 1;
error = clGetDeviceInfo(device_id, CL_DEVICE_IMAGE2D_MAX_WIDTH,
sizeof(max_width), &max_width, NULL);
test_error_abort(error, "clGetDeviceInfo failed.");
error = clGetDeviceInfo(device_id, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
sizeof(max_height), &max_height, NULL);
test_error_abort(error, "clGetDeviceInfo failed.");
*width = found_width;
*height = found_height;
num_pixels = size_to_allocate / (sizeof(cl_uint) * 4);
if(NULL != max_size) {
*max_size = found_width * found_height * sizeof(cl_uint) * 4;
}
// Use a 64-bit variable to avoid overflow in 32-bit architectures
long long unsigned max_pixels = (long long unsigned)max_width * max_height;
return SUCCEEDED;
if (num_pixels > max_pixels)
{
if (NULL != max_size)
{
*max_size = max_width * max_height * sizeof(cl_uint) * 4;
}
return FAILED_TOO_BIG;
}
// We want a close-to-square aspect ratio.
// Note that this implicitly assumes that max width >= max height
found_width = (int)sqrt((double)num_pixels);
if (found_width > max_width)
{
found_width = max_width;
}
if (found_width == 0) found_width = 1;
found_height = (size_t)num_pixels / found_width;
if (found_height > max_height)
{
found_height = max_height;
}
if (found_height == 0) found_height = 1;
*width = found_width;
*height = found_height;
if (NULL != max_size)
{
*max_size = found_width * found_height * sizeof(cl_uint) * 4;
}
return SUCCEEDED;
}
int allocate_image2d_read(cl_context context, cl_command_queue *queue, cl_device_id device_id, cl_mem *mem, size_t size_to_allocate, cl_bool blocking_write) {
size_t width, height;
int error;
int allocate_image2d_read(cl_context context, cl_command_queue *queue,
cl_device_id device_id, cl_mem *mem,
size_t size_to_allocate, cl_bool blocking_write)
{
size_t width, height;
int error;
error = find_good_image_size(device_id, size_to_allocate, &width, &height, NULL);
if (error != SUCCEEDED)
return error;
error = find_good_image_size(device_id, size_to_allocate, &width, &height,
NULL);
if (error != SUCCEEDED) return error;
log_info("\t\tAttempting to allocate a %gMB read-only image (%d x %d) and fill with %s writes.\n",
(size_to_allocate/(1024.0*1024.0)), (int)width, (int)height, (blocking_write ? "blocking" : "non-blocking"));
*mem = create_image_2d(context, CL_MEM_READ_ONLY, &image_format, width, height, 0, NULL, &error);
log_info("\t\tAttempting to allocate a %gMB read-only image (%d x %d) and "
"fill with %s writes.\n",
(size_to_allocate / (1024.0 * 1024.0)), (int)width, (int)height,
(blocking_write ? "blocking" : "non-blocking"));
*mem = create_image_2d(context, CL_MEM_READ_ONLY, &image_format, width,
height, 0, NULL, &error);
return check_allocation_error(context, device_id, error, queue);
return check_allocation_error(context, device_id, error, queue);
}
int allocate_image2d_write(cl_context context, cl_command_queue *queue, cl_device_id device_id, cl_mem *mem, size_t size_to_allocate, cl_bool blocking_write) {
size_t width, height;
int error;
int allocate_image2d_write(cl_context context, cl_command_queue *queue,
cl_device_id device_id, cl_mem *mem,
size_t size_to_allocate, cl_bool blocking_write)
{
size_t width, height;
int error;
error = find_good_image_size(device_id, size_to_allocate, &width, &height, NULL);
if (error != SUCCEEDED)
return error;
error = find_good_image_size(device_id, size_to_allocate, &width, &height,
NULL);
if (error != SUCCEEDED) return error;
//log_info("\t\tAttempting to allocate a %gMB write-only image (%d x %d) and fill with %s writes.\n",
//(size_to_allocate/(1024.0*1024.0)), (int)width, (int)height, (blocking_write ? "blocking" : "non-blocking"));
*mem = create_image_2d(context, CL_MEM_WRITE_ONLY, &image_format, width, height, 0, NULL, &error);
// log_info("\t\tAttempting to allocate a %gMB write-only image (%d x %d)
// and fill with %s writes.\n", (size_to_allocate/(1024.0*1024.0)),
//(int)width, (int)height, (blocking_write ? "blocking" : "non-blocking"));
*mem = create_image_2d(context, CL_MEM_WRITE_ONLY, &image_format, width,
height, 0, NULL, &error);
return check_allocation_error(context, device_id, error, queue);
return check_allocation_error(context, device_id, error, queue);
}
int do_allocation(cl_context context, cl_command_queue *queue, cl_device_id device_id, size_t size_to_allocate, int type, cl_mem *mem) {
if (type == BUFFER) return allocate_buffer(context, queue, device_id, mem, size_to_allocate, true);
if (type == IMAGE_READ) return allocate_image2d_read(context, queue, device_id, mem, size_to_allocate, true);
if (type == IMAGE_WRITE) return allocate_image2d_write(context, queue, device_id, mem, size_to_allocate, true);
if (type == BUFFER_NON_BLOCKING) return allocate_buffer(context, queue, device_id, mem, size_to_allocate, false);
if (type == IMAGE_READ_NON_BLOCKING) return allocate_image2d_read(context, queue, device_id, mem, size_to_allocate, false);
if (type == IMAGE_WRITE_NON_BLOCKING) return allocate_image2d_write(context, queue, device_id, mem, size_to_allocate, false);
int do_allocation(cl_context context, cl_command_queue *queue,
cl_device_id device_id, size_t size_to_allocate, int type,
cl_mem *mem)
{
if (type == BUFFER)
return allocate_buffer(context, queue, device_id, mem, size_to_allocate,
true);
if (type == IMAGE_READ)
return allocate_image2d_read(context, queue, device_id, mem,
size_to_allocate, true);
if (type == IMAGE_WRITE)
return allocate_image2d_write(context, queue, device_id, mem,
size_to_allocate, true);
if (type == BUFFER_NON_BLOCKING)
return allocate_buffer(context, queue, device_id, mem, size_to_allocate,
false);
if (type == IMAGE_READ_NON_BLOCKING)
return allocate_image2d_read(context, queue, device_id, mem,
size_to_allocate, false);
if (type == IMAGE_WRITE_NON_BLOCKING)
return allocate_image2d_write(context, queue, device_id, mem,
size_to_allocate, false);
log_error("Invalid allocation type: %d\n", type);
return FAILED_ABORT;
return FAILED_ABORT;
}
int allocate_size(cl_context context, cl_command_queue *queue, cl_device_id device_id, int multiple_allocations, size_t size_to_allocate,
int type, cl_mem mems[], int *number_of_mems, size_t *final_size, int force_fill, MTdata d) {
int allocate_size(cl_context context, cl_command_queue *queue,
cl_device_id device_id, int multiple_allocations,
size_t size_to_allocate, int type, cl_mem mems[],
int *number_of_mems, size_t *final_size, int force_fill,
MTdata d)
{
cl_ulong max_individual_allocation_size, global_mem_size;
int error, result;
size_t amount_allocated;
size_t reduction_amount;
int current_allocation;
size_t allocation_this_time, actual_allocation;
int error, result;
size_t amount_allocated;
size_t reduction_amount;
int current_allocation;
size_t allocation_this_time, actual_allocation;
// Set the number of mems used to 0 so if we fail to create even a single one we don't end up returning a garbage value
*number_of_mems = 0;
// Set the number of mems used to 0 so if we fail to create even a single
// one we don't end up returning a garbage value
*number_of_mems = 0;
error = clGetDeviceInfo(device_id, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(max_individual_allocation_size), &max_individual_allocation_size, NULL);
test_error_abort( error, "clGetDeviceInfo failed for CL_DEVICE_MAX_MEM_ALLOC_SIZE");
error = clGetDeviceInfo(device_id, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(global_mem_size), &global_mem_size, NULL);
test_error_abort( error, "clGetDeviceInfo failed for CL_DEVICE_GLOBAL_MEM_SIZE");
max_individual_allocation_size =
get_device_info_max_mem_alloc_size(device_id);
global_mem_size = get_device_info_global_mem_size(device_id);
if (global_mem_size > (cl_ulong)SIZE_MAX) {
global_mem_size = (cl_ulong)SIZE_MAX;
}
// log_info("Device reports CL_DEVICE_MAX_MEM_ALLOC_SIZE=%llu bytes (%gMB), CL_DEVICE_GLOBAL_MEM_SIZE=%llu bytes (%gMB).\n",
// max_individual_allocation_size, toMB(max_individual_allocation_size),
// global_mem_size, toMB(global_mem_size));
if (size_to_allocate > global_mem_size) {
log_error("Can not allocate more than the global memory size.\n");
return FAILED_ABORT;
}
amount_allocated = 0;
current_allocation = 0;
// If allocating for images, reduce the maximum allocation size to the maximum image size.
// If we don't do this, then the value of CL_DEVICE_MAX_MEM_ALLOC_SIZE / 4 can be higher
// than the maximum image size on systems with 16GB or RAM or more. In this case, we
// succeed in allocating an image but its size is less than CL_DEVICE_MAX_MEM_ALLOC_SIZE / 4
// (min_allocation_allowed) and thus we fail the allocation below.
if(type == IMAGE_READ || type == IMAGE_READ_NON_BLOCKING || type == IMAGE_WRITE || type == IMAGE_WRITE_NON_BLOCKING) {
size_t width;
size_t height;
size_t max_size;
error = find_good_image_size(device_id, size_to_allocate, &width, &height, &max_size);
if (!(error == SUCCEEDED || error == FAILED_TOO_BIG))
return error;
if(max_size < max_individual_allocation_size)
max_individual_allocation_size = max_size;
}
reduction_amount = (size_t)max_individual_allocation_size/16;
if (type == BUFFER || type == BUFFER_NON_BLOCKING) log_info("\tAttempting to allocate a buffer of size %gMB.\n", toMB(size_to_allocate));
else if (type == IMAGE_READ || type == IMAGE_READ_NON_BLOCKING) log_info("\tAttempting to allocate a read-only image of size %gMB.\n", toMB(size_to_allocate));
else if (type == IMAGE_WRITE || type == IMAGE_WRITE_NON_BLOCKING) log_info("\tAttempting to allocate a write-only image of size %gMB.\n", toMB(size_to_allocate));
// log_info("\t\t(Reduction size is %gMB per iteration, minimum allowable individual allocation size is %gMB.)\n",
// toMB(reduction_amount), toMB(min_allocation_allowed));
// if (force_fill && type != IMAGE_WRITE && type != IMAGE_WRITE_NON_BLOCKING) log_info("\t\t(Allocations will be filled with random data for checksum calculation.)\n");
// If we are only doing a single allocation, only allow 1
int max_to_allocate = multiple_allocations ? MAX_NUMBER_TO_ALLOCATE : 1;
// Make sure that the maximum number of images allocated is constrained by the
// maximum that may be passed to a kernel
if (type != BUFFER && type != BUFFER_NON_BLOCKING) {
cl_device_info param_name = (type == IMAGE_READ || type == IMAGE_READ_NON_BLOCKING) ?
CL_DEVICE_MAX_READ_IMAGE_ARGS : CL_DEVICE_MAX_WRITE_IMAGE_ARGS;
cl_uint max_image_args;
error = clGetDeviceInfo(device_id, param_name, sizeof(max_image_args), &max_image_args, NULL);
test_error( error, "clGetDeviceInfo failed for CL_DEVICE_MAX IMAGE_ARGS");
if ((int)max_image_args < max_to_allocate) {
log_info("\t\tMaximum number of images per kernel limited to %d\n",(int)max_image_args);
max_to_allocate = max_image_args;
if (global_mem_size > (cl_ulong)SIZE_MAX)
{
global_mem_size = (cl_ulong)SIZE_MAX;
}
if (size_to_allocate > global_mem_size)
{
log_error("Can not allocate more than the global memory size.\n");
return FAILED_ABORT;
}
amount_allocated = 0;
current_allocation = 0;
// If allocating for images, reduce the maximum allocation size to the
// maximum image size. If we don't do this, then the value of
// CL_DEVICE_MAX_MEM_ALLOC_SIZE / 4 can be higher than the maximum image
// size on systems with 16GB or RAM or more. In this case, we succeed in
// allocating an image but its size is less than
// CL_DEVICE_MAX_MEM_ALLOC_SIZE / 4 (min_allocation_allowed) and thus we
// fail the allocation below.
if (type == IMAGE_READ || type == IMAGE_READ_NON_BLOCKING
|| type == IMAGE_WRITE || type == IMAGE_WRITE_NON_BLOCKING)
{
size_t width;
size_t height;
size_t max_size;
error = find_good_image_size(device_id, size_to_allocate, &width,
&height, &max_size);
if (!(error == SUCCEEDED || error == FAILED_TOO_BIG)) return error;
if (max_size < max_individual_allocation_size)
max_individual_allocation_size = max_size;
}
reduction_amount = (size_t)max_individual_allocation_size / 16;
if (type == BUFFER || type == BUFFER_NON_BLOCKING)
log_info("\tAttempting to allocate a buffer of size %gMB.\n",
toMB(size_to_allocate));
else if (type == IMAGE_READ || type == IMAGE_READ_NON_BLOCKING)
log_info("\tAttempting to allocate a read-only image of size %gMB.\n",
toMB(size_to_allocate));
else if (type == IMAGE_WRITE || type == IMAGE_WRITE_NON_BLOCKING)
log_info("\tAttempting to allocate a write-only image of size %gMB.\n",
toMB(size_to_allocate));
// log_info("\t\t(Reduction size is %gMB per iteration, minimum allowable
// individual allocation size is %gMB.)\n",
// toMB(reduction_amount), toMB(min_allocation_allowed));
// if (force_fill && type != IMAGE_WRITE && type !=
// IMAGE_WRITE_NON_BLOCKING) log_info("\t\t(Allocations will be filled with
// random data for checksum calculation.)\n");
// If we are only doing a single allocation, only allow 1
int max_to_allocate = multiple_allocations ? MAX_NUMBER_TO_ALLOCATE : 1;
// Make sure that the maximum number of images allocated is constrained by
// the maximum that may be passed to a kernel
if (type != BUFFER && type != BUFFER_NON_BLOCKING)
{
cl_device_info param_name =
(type == IMAGE_READ || type == IMAGE_READ_NON_BLOCKING)
? CL_DEVICE_MAX_READ_IMAGE_ARGS
: CL_DEVICE_MAX_WRITE_IMAGE_ARGS;
cl_uint max_image_args;
error = clGetDeviceInfo(device_id, param_name, sizeof(max_image_args),
&max_image_args, NULL);
test_error(error,
"clGetDeviceInfo failed for CL_DEVICE_MAX IMAGE_ARGS");
if ((int)max_image_args < max_to_allocate)
{
log_info("\t\tMaximum number of images per kernel limited to %d\n",
(int)max_image_args);
max_to_allocate = max_image_args;
}
}
}
// Try to allocate the requested amount.
while (amount_allocated != size_to_allocate && current_allocation < max_to_allocate) {
// Try to allocate the requested amount.
while (amount_allocated != size_to_allocate
&& current_allocation < max_to_allocate)
{
// Determine how much more is needed
allocation_this_time = size_to_allocate - amount_allocated;
// Determine how much more is needed
allocation_this_time = size_to_allocate - amount_allocated;
// Bound by the individual allocation size
if (allocation_this_time > max_individual_allocation_size)
allocation_this_time = (size_t)max_individual_allocation_size;
// Bound by the individual allocation size
if (allocation_this_time > max_individual_allocation_size)
allocation_this_time = (size_t)max_individual_allocation_size;
// Allocate the largest object possible
result = FAILED_TOO_BIG;
//log_info("\t\tTrying sub-allocation %d at size %gMB.\n", current_allocation, toMB(allocation_this_time));
while (result == FAILED_TOO_BIG && allocation_this_time != 0) {
// Allocate the largest object possible
result = FAILED_TOO_BIG;
// log_info("\t\tTrying sub-allocation %d at size %gMB.\n",
// current_allocation, toMB(allocation_this_time));
while (result == FAILED_TOO_BIG && allocation_this_time != 0)
{
// Create the object
result = do_allocation(context, queue, device_id, allocation_this_time, type, &mems[current_allocation]);
if (result == SUCCEEDED) {
// Allocation succeeded, another memory object was added to the array
*number_of_mems = (current_allocation+1);
// Create the object
result =
do_allocation(context, queue, device_id, allocation_this_time,
type, &mems[current_allocation]);
if (result == SUCCEEDED)
{
// Allocation succeeded, another memory object was added to the
// array
*number_of_mems = (current_allocation + 1);
// Verify the size is correct to within 1MB.
actual_allocation = get_actual_allocation_size(mems[current_allocation]);
if (fabs((double)allocation_this_time - (double)actual_allocation) > 1024.0*1024.0) {
log_error("Allocation not of expected size. Expected %gMB, got %gMB.\n", toMB(allocation_this_time), toMB( actual_allocation));
return FAILED_ABORT;
// Verify the size is correct to within 1MB.
actual_allocation =
get_actual_allocation_size(mems[current_allocation]);
if (fabs((double)allocation_this_time
- (double)actual_allocation)
> 1024.0 * 1024.0)
{
log_error("Allocation not of expected size. Expected %gMB, "
"got %gMB.\n",
toMB(allocation_this_time),
toMB(actual_allocation));
return FAILED_ABORT;
}
// If we are filling the allocation for verification do so
if (force_fill)
{
// log_info("\t\t\tWriting random values to object and
// calculating checksum.\n");
cl_bool blocking_write = true;
if (type == BUFFER_NON_BLOCKING
|| type == IMAGE_READ_NON_BLOCKING
|| type == IMAGE_WRITE_NON_BLOCKING)
{
blocking_write = false;
}
result = fill_mem_with_data(context, device_id, queue,
mems[current_allocation], d,
blocking_write);
}
}
// If creation failed, try to create a smaller object
if (result == FAILED_TOO_BIG)
{
// log_info("\t\t\tAllocation %d failed at size %gMB. Trying
// smaller.\n", current_allocation, toMB(allocation_this_time));
if (allocation_this_time > reduction_amount)
allocation_this_time -= reduction_amount;
else if (reduction_amount > 1)
{
reduction_amount /= 2;
}
else
{
allocation_this_time = 0;
}
}
}
// If we are filling the allocation for verification do so
if (force_fill) {
//log_info("\t\t\tWriting random values to object and calculating checksum.\n");
cl_bool blocking_write = true;
if (type == BUFFER_NON_BLOCKING || type == IMAGE_READ_NON_BLOCKING || type == IMAGE_WRITE_NON_BLOCKING) {
blocking_write = false;
}
result = fill_mem_with_data(context, device_id, queue, mems[current_allocation], d, blocking_write);
}
}
// If creation failed, try to create a smaller object
if (result == FAILED_TOO_BIG) {
//log_info("\t\t\tAllocation %d failed at size %gMB. Trying smaller.\n", current_allocation, toMB(allocation_this_time));
if (allocation_this_time > reduction_amount)
allocation_this_time -= reduction_amount;
else if (reduction_amount > 1) {
reduction_amount /= 2;
}
else {
allocation_this_time = 0;
if (result == FAILED_ABORT)
{
log_error("\t\tAllocation failed.\n");
return FAILED_ABORT;
}
}
if (!allocation_this_time)
{
log_info("\t\tFailed to allocate %gMB across several objects.\n",
toMB(size_to_allocate));
return FAILED_TOO_BIG;
}
// Otherwise we succeeded
if (result != SUCCEEDED)
{
log_error("Test logic error.");
exit(-1);
}
amount_allocated += allocation_this_time;
*final_size = amount_allocated;
current_allocation++;
}
if (result == FAILED_ABORT) {
log_error("\t\tAllocation failed.\n");
return FAILED_ABORT;
}
if (!allocation_this_time) {
log_info("\t\tFailed to allocate %gMB across several objects.\n", toMB(size_to_allocate));
return FAILED_TOO_BIG;
}
// Otherwise we succeeded
if (result != SUCCEEDED) {
log_error("Test logic error.");
exit(-1);
}
amount_allocated += allocation_this_time;
*final_size = amount_allocated;
current_allocation++;
}
log_info("\t\tSucceeded in allocating %gMB using %d memory objects.\n", toMB(amount_allocated), current_allocation);
return SUCCEEDED;
log_info("\t\tSucceeded in allocating %gMB using %d memory objects.\n",
toMB(amount_allocated), current_allocation);
return SUCCEEDED;
}

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -16,9 +16,20 @@
#include "testBase.h"
#include "allocation_utils.h"
int do_allocation(cl_context context, cl_command_queue *queue, cl_device_id device_id, size_t size_to_allocate, int type, cl_mem *mem);
int allocate_buffer(cl_context context, cl_command_queue *queue, cl_device_id device_id, cl_mem *mem, size_t size_to_allocate);
int allocate_image2d_read(cl_context context, cl_command_queue *queue, cl_device_id device_id, cl_mem *mem, size_t size_to_allocate);
int allocate_image2d_write(cl_context context, cl_command_queue *queue, cl_device_id device_id, cl_mem *mem, size_t size_to_allocate);
int allocate_size(cl_context context, cl_command_queue *queue, cl_device_id device_id, int multiple_allocations, size_t size_to_allocate,
int type, cl_mem mems[], int *number_of_mems, size_t *final_size, int force_fill, MTdata d);
int do_allocation(cl_context context, cl_command_queue *queue,
cl_device_id device_id, size_t size_to_allocate, int type,
cl_mem *mem);
int allocate_buffer(cl_context context, cl_command_queue *queue,
cl_device_id device_id, cl_mem *mem,
size_t size_to_allocate);
int allocate_image2d_read(cl_context context, cl_command_queue *queue,
cl_device_id device_id, cl_mem *mem,
size_t size_to_allocate);
int allocate_image2d_write(cl_context context, cl_command_queue *queue,
cl_device_id device_id, cl_mem *mem,
size_t size_to_allocate);
int allocate_size(cl_context context, cl_command_queue *queue,
cl_device_id device_id, int multiple_allocations,
size_t size_to_allocate, int type, cl_mem mems[],
int *number_of_mems, size_t *final_size, int force_fill,
MTdata d);

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -15,90 +15,116 @@
//
#include "allocation_utils.h"
cl_command_queue reset_queue(cl_context context, cl_device_id device_id, cl_command_queue *queue, int *error)
cl_command_queue reset_queue(cl_context context, cl_device_id device_id,
cl_command_queue *queue, int *error)
{
log_info("Invalid command queue. Releasing and recreating the command queue.\n");
clReleaseCommandQueue(*queue);
log_info(
"Invalid command queue. Releasing and recreating the command queue.\n");
clReleaseCommandQueue(*queue);
*queue = clCreateCommandQueue(context, device_id, 0, error);
return *queue;
return *queue;
}
int check_allocation_error(cl_context context, cl_device_id device_id, int error, cl_command_queue *queue, cl_event *event) {
//log_info("check_allocation_error context=%p device_id=%p error=%d *queue=%p\n", context, device_id, error, *queue);
if (error == CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST && event != 0)
{
// check for errors from clWaitForEvents (e.g after clEnqueueWriteBuffer)
cl_int eventError;
error = clGetEventInfo(*event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(error), &eventError, 0);
if (CL_SUCCESS != error)
int check_allocation_error(cl_context context, cl_device_id device_id,
int error, cl_command_queue *queue, cl_event *event)
{
// log_info("check_allocation_error context=%p device_id=%p error=%d
// *queue=%p\n", context, device_id, error, *queue);
if (error == CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST && event != 0)
{
log_error("Failed to get event execution status: %s\n", IGetErrorString(error));
return FAILED_ABORT;
// check for errors from clWaitForEvents (e.g after
// clEnqueueWriteBuffer)
cl_int eventError;
error = clGetEventInfo(*event, CL_EVENT_COMMAND_EXECUTION_STATUS,
sizeof(error), &eventError, 0);
if (CL_SUCCESS != error)
{
log_error("Failed to get event execution status: %s\n",
IGetErrorString(error));
return FAILED_ABORT;
}
if (eventError >= 0)
{
log_error("Non-negative event execution status after "
"CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: %s\n",
IGetErrorString(error));
return FAILED_ABORT;
}
error = eventError;
}
if (eventError >= 0)
if ((error == CL_MEM_OBJECT_ALLOCATION_FAILURE)
|| (error == CL_OUT_OF_RESOURCES) || (error == CL_OUT_OF_HOST_MEMORY)
|| (error == CL_INVALID_IMAGE_SIZE))
{
log_error("Non-negative event execution status after CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: %s\n", IGetErrorString(error));
return FAILED_ABORT;
return FAILED_TOO_BIG;
}
error = eventError;
}
if ((error == CL_MEM_OBJECT_ALLOCATION_FAILURE ) || (error == CL_OUT_OF_RESOURCES ) || (error == CL_OUT_OF_HOST_MEMORY) || (error == CL_INVALID_IMAGE_SIZE)) {
return FAILED_TOO_BIG;
} else if (error == CL_INVALID_COMMAND_QUEUE) {
*queue = reset_queue(context, device_id, queue, &error);
if (CL_SUCCESS != error)
else if (error == CL_INVALID_COMMAND_QUEUE)
{
log_error("Failed to reset command queue after corrupted queue: %s\n", IGetErrorString(error));
return FAILED_ABORT;
*queue = reset_queue(context, device_id, queue, &error);
if (CL_SUCCESS != error)
{
log_error(
"Failed to reset command queue after corrupted queue: %s\n",
IGetErrorString(error));
return FAILED_ABORT;
}
// Try again with smaller resources.
return FAILED_TOO_BIG;
}
// Try again with smaller resources.
return FAILED_TOO_BIG;
} else if (error != CL_SUCCESS) {
log_error("Allocation failed with %s.\n", IGetErrorString(error));
return FAILED_ABORT;
}
return SUCCEEDED;
else if (error != CL_SUCCESS)
{
log_error("Allocation failed with %s.\n", IGetErrorString(error));
return FAILED_ABORT;
}
return SUCCEEDED;
}
double toMB(cl_ulong size_in) {
return (double)size_in/(1024.0*1024.0);
}
double toMB(cl_ulong size_in) { return (double)size_in / (1024.0 * 1024.0); }
size_t get_actual_allocation_size(cl_mem mem) {
int error;
cl_mem_object_type type;
size_t size, width, height;
size_t get_actual_allocation_size(cl_mem mem)
{
int error;
cl_mem_object_type type;
size_t size, width, height;
error = clGetMemObjectInfo(mem, CL_MEM_TYPE, sizeof(type), &type, NULL);
if (error) {
print_error(error, "clGetMemObjectInfo failed for CL_MEM_TYPE.");
error = clGetMemObjectInfo(mem, CL_MEM_TYPE, sizeof(type), &type, NULL);
if (error)
{
print_error(error, "clGetMemObjectInfo failed for CL_MEM_TYPE.");
return 0;
}
if (type == CL_MEM_OBJECT_BUFFER)
{
error = clGetMemObjectInfo(mem, CL_MEM_SIZE, sizeof(size), &size, NULL);
if (error)
{
print_error(error, "clGetMemObjectInfo failed for CL_MEM_SIZE.");
return 0;
}
return size;
}
else if (type == CL_MEM_OBJECT_IMAGE2D)
{
error =
clGetImageInfo(mem, CL_IMAGE_WIDTH, sizeof(width), &width, NULL);
if (error)
{
print_error(error, "clGetMemObjectInfo failed for CL_IMAGE_WIDTH.");
return 0;
}
error =
clGetImageInfo(mem, CL_IMAGE_HEIGHT, sizeof(height), &height, NULL);
if (error)
{
print_error(error,
"clGetMemObjectInfo failed for CL_IMAGE_HEIGHT.");
return 0;
}
return width * height * 4 * sizeof(cl_uint);
}
log_error("Invalid CL_MEM_TYPE: %d\n", type);
return 0;
}
if (type == CL_MEM_OBJECT_BUFFER) {
error = clGetMemObjectInfo(mem, CL_MEM_SIZE, sizeof(size), &size, NULL);
if (error) {
print_error(error, "clGetMemObjectInfo failed for CL_MEM_SIZE.");
return 0;
}
return size;
} else if (type == CL_MEM_OBJECT_IMAGE2D) {
error = clGetImageInfo(mem, CL_IMAGE_WIDTH, sizeof(width), &width, NULL);
if (error) {
print_error(error, "clGetMemObjectInfo failed for CL_IMAGE_WIDTH.");
return 0;
}
error = clGetImageInfo(mem, CL_IMAGE_HEIGHT, sizeof(height), &height, NULL);
if (error) {
print_error(error, "clGetMemObjectInfo failed for CL_IMAGE_HEIGHT.");
return 0;
}
return width*height*4*sizeof(cl_uint);
}
log_error("Invalid CL_MEM_TYPE: %d\n", type);
return 0;
}

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -20,7 +20,9 @@
extern cl_uint checksum;
int check_allocation_error(cl_context context, cl_device_id device_id, int error, cl_command_queue *queue, cl_event *event = 0);
int check_allocation_error(cl_context context, cl_device_id device_id,
int error, cl_command_queue *queue,
cl_event *event = 0);
double toMB(cl_ulong size_in);
size_t get_actual_allocation_size(cl_mem mem);

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -24,85 +24,100 @@
typedef long long unsigned llu;
#define REDUCTION_PERCENTAGE_DEFAULT 50
#define BYTES_PER_WORK_ITEM 2048ULL
int g_repetition_count = 1;
int g_reduction_percentage = 100;
int g_reduction_percentage = REDUCTION_PERCENTAGE_DEFAULT;
int g_write_allocations = 1;
int g_multiple_allocations = 0;
int g_execute_kernel = 1;
static size_t g_max_size;
static RandomSeed g_seed( gRandomSeed );
static RandomSeed g_seed(gRandomSeed);
cl_long g_max_individual_allocation_size;
cl_long g_global_mem_size;
cl_uint checksum;
static void printUsage( const char *execName );
static void printUsage(const char *execName);
test_status init_cl( cl_device_id device ) {
test_status init_cl(cl_device_id device)
{
int error;
error = clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(g_max_individual_allocation_size), &g_max_individual_allocation_size, NULL );
if ( error ) {
print_error( error, "clGetDeviceInfo failed for CL_DEVICE_MAX_MEM_ALLOC_SIZE");
return TEST_FAIL;
}
error = clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(g_global_mem_size), &g_global_mem_size, NULL );
if ( error ) {
print_error( error, "clGetDeviceInfo failed for CL_DEVICE_GLOBAL_MEM_SIZE");
return TEST_FAIL;
}
g_max_individual_allocation_size =
get_device_info_max_mem_alloc_size(device);
g_global_mem_size = get_device_info_global_mem_size(device);
log_info("Device reports CL_DEVICE_MAX_MEM_ALLOC_SIZE=%llu bytes (%gMB), CL_DEVICE_GLOBAL_MEM_SIZE=%llu bytes (%gMB).\n",
llu( g_max_individual_allocation_size ), toMB( g_max_individual_allocation_size ),
llu( g_global_mem_size ), toMB( g_global_mem_size ) );
log_info("Device reports CL_DEVICE_MAX_MEM_ALLOC_SIZE=%llu bytes (%gMB), "
"CL_DEVICE_GLOBAL_MEM_SIZE=%llu bytes (%gMB).\n",
llu(g_max_individual_allocation_size),
toMB(g_max_individual_allocation_size), llu(g_global_mem_size),
toMB(g_global_mem_size));
if( g_global_mem_size > (cl_ulong)SIZE_MAX )
if (g_global_mem_size > (cl_ulong)SIZE_MAX)
{
g_global_mem_size = (cl_ulong)SIZE_MAX;
}
if( g_max_individual_allocation_size > g_global_mem_size )
if (g_max_individual_allocation_size > g_global_mem_size)
{
log_error( "FAILURE: CL_DEVICE_MAX_MEM_ALLOC_SIZE (%llu) is greater than the CL_DEVICE_GLOBAL_MEM_SIZE (%llu)\n",
llu( g_max_individual_allocation_size ), llu( g_global_mem_size ) );
log_error("FAILURE: CL_DEVICE_MAX_MEM_ALLOC_SIZE (%llu) is greater "
"than the CL_DEVICE_GLOBAL_MEM_SIZE (%llu)\n",
llu(g_max_individual_allocation_size),
llu(g_global_mem_size));
return TEST_FAIL;
}
// We may need to back off the global_mem_size on unified memory devices to leave room for application and operating system code
// and associated data in the working set, so we dont start pathologically paging.
// Check to see if we are a unified memory device
// We may need to back off the global_mem_size on unified memory devices to
// leave room for application and operating system code and associated data
// in the working set, so we dont start pathologically paging. Check to see
// if we are a unified memory device
cl_bool hasUnifiedMemory = CL_FALSE;
if( ( error = clGetDeviceInfo( device, CL_DEVICE_HOST_UNIFIED_MEMORY, sizeof( hasUnifiedMemory ), &hasUnifiedMemory, NULL ) ) )
if ((error = clGetDeviceInfo(device, CL_DEVICE_HOST_UNIFIED_MEMORY,
sizeof(hasUnifiedMemory), &hasUnifiedMemory,
NULL)))
{
print_error( error, "clGetDeviceInfo failed for CL_DEVICE_HOST_UNIFIED_MEMORY");
print_error(error,
"clGetDeviceInfo failed for CL_DEVICE_HOST_UNIFIED_MEMORY");
return TEST_FAIL;
}
// we share unified memory so back off to 1/2 the global memory size.
if( CL_TRUE == hasUnifiedMemory )
if (CL_TRUE == hasUnifiedMemory)
{
g_global_mem_size -= g_global_mem_size /2;
log_info( "Device shares memory with the host, so backing off the maximum combined allocation size to be %gMB to avoid rampant paging.\n",
toMB( g_global_mem_size ) );
g_global_mem_size -= g_global_mem_size / 2;
log_info(
"Device shares memory with the host, so backing off the maximum "
"combined allocation size to be %gMB to avoid rampant paging.\n",
toMB(g_global_mem_size));
}
else
{
// Lets just use 60% of total available memory as framework/driver may not allow using all of it
// e.g. vram on GPU is used by window server and even for this test, we need some space for context,
// queue, kernel code on GPU.
// Lets just use 60% of total available memory as framework/driver may
// not allow using all of it e.g. vram on GPU is used by window server
// and even for this test, we need some space for context, queue, kernel
// code on GPU.
g_global_mem_size *= 0.60;
}
if( gReSeed )
/* Cap the allocation size as the global size was deduced */
if (g_max_individual_allocation_size > g_global_mem_size)
{
g_seed = RandomSeed( gRandomSeed );
g_max_individual_allocation_size = g_global_mem_size;
}
if (gReSeed)
{
g_seed = RandomSeed(gRandomSeed);
}
return TEST_PASS;
}
int doTest( cl_device_id device, cl_context context, cl_command_queue queue, AllocType alloc_type )
int doTest(cl_device_id device, cl_context context, cl_command_queue queue,
AllocType alloc_type)
{
int error;
int failure_counts = 0;
@ -111,115 +126,145 @@ int doTest( cl_device_id device, cl_context context, cl_command_queue queue, All
cl_mem mems[MAX_NUMBER_TO_ALLOCATE];
int number_of_mems_used;
cl_ulong max_individual_allocation_size = g_max_individual_allocation_size;
cl_ulong global_mem_size = g_global_mem_size ;
cl_ulong global_mem_size = g_global_mem_size;
unsigned int number_of_work_items;
const bool allocate_image =
(alloc_type != BUFFER) && (alloc_type != BUFFER_NON_BLOCKING);
static const char* alloc_description[] = {
"buffer(s)",
"read-only image(s)",
"write-only image(s)",
"buffer(s)",
"read-only image(s)",
"write-only image(s)",
static const char *alloc_description[] = {
"buffer(s)", "read-only image(s)", "write-only image(s)",
"buffer(s)", "read-only image(s)", "write-only image(s)",
};
// Skip image tests if we don't support images on the device
if( alloc_type > BUFFER && checkForImageSupport( device ) )
if (allocate_image && checkForImageSupport(device))
{
log_info( "Can not test image allocation because device does not support images.\n" );
log_info("Can not test image allocation because device does not "
"support images.\n");
return 0;
}
// This section was added in order to fix a bug in the test
// If CL_DEVICE_MAX_MEM_ALLOC_SIZE is much grater than CL_DEVICE_IMAGE2D_MAX_WIDTH * CL_DEVICE_IMAGE2D_MAX_HEIGHT
// The test will fail in image allocations as the size requested for the allocation will be much grater than the maximum size allowed for image
if( ( alloc_type != BUFFER ) && ( alloc_type != BUFFER_NON_BLOCKING ) )
// If CL_DEVICE_MAX_MEM_ALLOC_SIZE is much grater than
// CL_DEVICE_IMAGE2D_MAX_WIDTH * CL_DEVICE_IMAGE2D_MAX_HEIGHT The test will
// fail in image allocations as the size requested for the allocation will
// be much grater than the maximum size allowed for image
if (allocate_image)
{
size_t max_width, max_height;
error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( max_width ), &max_width, NULL );
test_error_abort( error, "clGetDeviceInfo failed for CL_DEVICE_IMAGE2D_MAX_WIDTH" );
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH,
sizeof(max_width), &max_width, NULL);
test_error_abort(
error, "clGetDeviceInfo failed for CL_DEVICE_IMAGE2D_MAX_WIDTH");
error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( max_height ), &max_height, NULL );
test_error_abort( error, "clGetDeviceInfo failed for CL_DEVICE_IMAGE2D_MAX_HEIGHT" );
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT,
sizeof(max_height), &max_height, NULL);
test_error_abort(
error, "clGetDeviceInfo failed for CL_DEVICE_IMAGE2D_MAX_HEIGHT");
cl_ulong max_image2d_size = (cl_ulong)max_height * max_width * 4 * sizeof(cl_uint);
cl_ulong max_image2d_size =
(cl_ulong)max_height * max_width * 4 * sizeof(cl_uint);
if( max_individual_allocation_size > max_image2d_size )
if (max_individual_allocation_size > max_image2d_size)
{
max_individual_allocation_size = max_image2d_size;
}
}
// Pick the baseline size based on whether we are doing a single large or multiple allocations
g_max_size = g_multiple_allocations ? (size_t)global_mem_size : (size_t)max_individual_allocation_size;
// Pick the baseline size based on whether we are doing a single large or
// multiple allocations
g_max_size = g_multiple_allocations
? (size_t)global_mem_size
: (size_t)max_individual_allocation_size;
// Adjust based on the percentage
if( g_reduction_percentage != 100 )
if (g_reduction_percentage != 100)
{
log_info( "NOTE: reducing max allocations to %d%%.\n", g_reduction_percentage );
g_max_size = (size_t)( (double)g_max_size * (double)g_reduction_percentage / 100.0 );
log_info("NOTE: reducing max allocations to %d%%.\n",
g_reduction_percentage);
g_max_size = (size_t)((double)g_max_size
* (double)g_reduction_percentage / 100.0);
}
// Round to nearest MB.
g_max_size &= (size_t)(0xFFFFFFFFFF00000ULL);
log_info( "** Target allocation size (rounded to nearest MB) is: %llu bytes (%gMB).\n", llu( g_max_size ), toMB( g_max_size ) );
log_info( "** Allocating %s to size %gMB.\n", alloc_description[alloc_type], toMB( g_max_size ) );
// Scales the number of work-items to keep the amount of bytes processed
// per work-item the same.
number_of_work_items =
std::max(g_max_size / BYTES_PER_WORK_ITEM, 8192ULL * 2ULL);
for( int count = 0; count < g_repetition_count; count++ )
log_info("** Target allocation size (rounded to nearest MB) is: %llu bytes "
"(%gMB).\n",
llu(g_max_size), toMB(g_max_size));
log_info("** Allocating %s to size %gMB.\n", alloc_description[alloc_type],
toMB(g_max_size));
for (int count = 0; count < g_repetition_count; count++)
{
current_test_size = g_max_size;
error = FAILED_TOO_BIG;
log_info( " => Allocation %d\n", count + 1 );
log_info(" => Allocation %d\n", count + 1);
while( ( error == FAILED_TOO_BIG ) && ( current_test_size > g_max_size / 8 ) )
while ((error == FAILED_TOO_BIG)
&& (current_test_size > g_max_size / 8))
{
// Reset our checksum for each allocation
checksum = 0;
// Do the allocation
error = allocate_size( context, &queue, device, g_multiple_allocations, current_test_size, alloc_type,
mems, &number_of_mems_used, &final_size, g_write_allocations, g_seed );
error = allocate_size(context, &queue, device,
g_multiple_allocations, current_test_size,
alloc_type, mems, &number_of_mems_used,
&final_size, g_write_allocations, g_seed);
// If we succeeded and we're supposed to execute a kernel, do so.
if( error == SUCCEEDED && g_execute_kernel )
if (error == SUCCEEDED && g_execute_kernel)
{
log_info( "\tExecuting kernel with memory objects.\n" );
error = execute_kernel( context, &queue, device, alloc_type, mems, number_of_mems_used,
g_write_allocations );
log_info("\tExecuting kernel with memory objects.\n");
error =
execute_kernel(context, &queue, device, alloc_type, mems,
number_of_mems_used, g_write_allocations,
number_of_work_items);
}
// If we failed to allocate more than 1/8th of the requested amount return a failure.
if( final_size < (size_t)g_max_size / 8 )
// If we failed to allocate more than 1/8th of the requested amount
// return a failure.
if (final_size < (size_t)g_max_size / 8)
{
log_error( "===> Allocation %d failed to allocate more than 1/8th of the requested size.\n", count + 1 );
log_error("===> Allocation %d failed to allocate more than "
"1/8th of the requested size.\n",
count + 1);
failure_counts++;
}
// Clean up.
for( int i = 0; i < number_of_mems_used; i++ )
for (int i = 0; i < number_of_mems_used; i++)
{
clReleaseMemObject( mems[i] );
clReleaseMemObject(mems[i]);
}
if( error == FAILED_ABORT )
if (error == FAILED_ABORT)
{
log_error( " => Allocation %d failed.\n", count + 1 );
log_error(" => Allocation %d failed.\n", count + 1);
failure_counts++;
}
if( error == FAILED_TOO_BIG )
if (error == FAILED_TOO_BIG)
{
current_test_size -= g_max_size / 16;
log_info( "\tFailed at this size; trying a smaller size of %gMB.\n", toMB( current_test_size ) );
log_info(
"\tFailed at this size; trying a smaller size of %gMB.\n",
toMB(current_test_size));
}
}
if( error == SUCCEEDED && current_test_size == g_max_size )
if (error == SUCCEEDED && current_test_size == g_max_size)
{
log_info("\tPASS: Allocation succeeded.\n");
}
else if( error == SUCCEEDED && current_test_size > g_max_size / 8 )
else if (error == SUCCEEDED && current_test_size > g_max_size / 8)
{
log_info("\tPASS: Allocation succeeded at reduced size.\n");
}
@ -233,41 +278,27 @@ int doTest( cl_device_id device, cl_context context, cl_command_queue queue, All
return failure_counts;
}
int test_buffer(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(buffer) { return doTest(device, context, queue, BUFFER); }
REGISTER_TEST(image2d_read)
{
return doTest( device, context, queue, BUFFER );
return doTest(device, context, queue, IMAGE_READ);
}
int test_image2d_read(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(image2d_write)
{
return doTest( device, context, queue, IMAGE_READ );
return doTest(device, context, queue, IMAGE_WRITE);
}
int test_image2d_write(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(buffer_non_blocking)
{
return doTest( device, context, queue, IMAGE_WRITE );
return doTest(device, context, queue, BUFFER_NON_BLOCKING);
}
int test_buffer_non_blocking(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(image2d_read_non_blocking)
{
return doTest( device, context, queue, BUFFER_NON_BLOCKING );
return doTest(device, context, queue, IMAGE_READ_NON_BLOCKING);
}
int test_image2d_read_non_blocking(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(image2d_write_non_blocking)
{
return doTest( device, context, queue, IMAGE_READ_NON_BLOCKING );
return doTest(device, context, queue, IMAGE_WRITE_NON_BLOCKING);
}
int test_image2d_write_non_blocking(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
{
return doTest( device, context, queue, IMAGE_WRITE_NON_BLOCKING );
}
test_definition test_list[] = {
ADD_TEST( buffer ),
ADD_TEST( image2d_read ),
ADD_TEST( image2d_write ),
ADD_TEST( buffer_non_blocking ),
ADD_TEST( image2d_read_non_blocking ),
ADD_TEST( image2d_write_non_blocking ),
};
const int test_num = ARRAY_SIZE( test_list );
int main(int argc, const char *argv[])
{
@ -280,11 +311,11 @@ int main(int argc, const char *argv[])
return 1;
}
const char ** argList = (const char **)calloc( argc, sizeof( char*) );
const char **argList = (const char **)calloc(argc, sizeof(char *));
if( NULL == argList )
if (NULL == argList)
{
log_error( "Failed to allocate memory for argList array.\n" );
log_error("Failed to allocate memory for argList array.\n");
return 1;
}
@ -292,38 +323,41 @@ int main(int argc, const char *argv[])
size_t argCount = 1;
// Parse arguments
for( int i = 1; i < argc; i++ )
for (int i = 1; i < argc; i++)
{
if( strcmp( argv[i], "multiple" ) == 0 )
if (strcmp(argv[i], "multiple") == 0)
g_multiple_allocations = 1;
else if( strcmp( argv[i], "single" ) == 0 )
else if (strcmp(argv[i], "single") == 0)
g_multiple_allocations = 0;
else if( ( r = (int)strtol( argv[i], &endPtr, 10 ) ) && ( endPtr != argv[i] ) && ( *endPtr == 0 ) )
else if ((r = (int)strtol(argv[i], &endPtr, 10)) && (endPtr != argv[i])
&& (*endPtr == 0))
{
// By spec, that means the entire string was an integer, so take it as a repetition count
// By spec, that means the entire string was an integer, so take it
// as a repetition count
g_repetition_count = r;
}
else if( strchr( argv[i], '%' ) != NULL )
else if (strchr(argv[i], '%') != NULL)
{
// Reduction percentage (let strtol ignore the percentage)
g_reduction_percentage = (int)strtol( argv[i], NULL, 10 );
g_reduction_percentage = (int)strtol(argv[i], NULL, 10);
}
else if( strcmp( argv[i], "do_not_force_fill" ) == 0 )
else if (strcmp(argv[i], "do_not_force_fill") == 0)
{
g_write_allocations = 0;
}
else if( strcmp( argv[i], "do_not_execute" ) == 0 )
else if (strcmp(argv[i], "do_not_execute") == 0)
{
g_execute_kernel = 0;
}
else if ( strcmp( argv[i], "--help" ) == 0 || strcmp( argv[i], "-h" ) == 0 )
else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
{
printUsage( argv[0] );
printUsage(argv[0]);
free(argList);
return -1;
}
@ -334,35 +368,43 @@ int main(int argc, const char *argv[])
}
}
int ret = runTestHarnessWithCheck( argCount, argList, test_num, test_list, false, 0, init_cl );
int ret = runTestHarnessWithCheck(
argCount, argList, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0, init_cl);
free(argList);
return ret;
}
void printUsage( const char *execName )
void printUsage(const char *execName)
{
const char *p = strrchr( execName, '/' );
if( p != NULL )
execName = p + 1;
const char *p = strrchr(execName, '/');
if (p != NULL) execName = p + 1;
log_info( "Usage: %s [options] [test_names]\n", execName );
log_info( "Options:\n" );
log_info( "\trandomize - Uses random seed\n" );
log_info( "\tsingle - Tests using a single allocation as large as possible\n" );
log_info( "\tmultiple - Tests using as many allocations as possible\n" );
log_info( "\n" );
log_info( "\tnumReps - Optional integer specifying the number of repetitions to run and average the result (defaults to 1)\n" );
log_info( "\treduction%% - Optional integer, followed by a %% sign, that acts as a multiplier for the target amount of memory.\n" );
log_info( "\t Example: target amount of 512MB and a reduction of 75%% will result in a target of 384MB.\n" );
log_info( "\n" );
log_info( "\tdo_not_force_fill - Disable explicitly write data to all memory objects after creating them.\n" );
log_info( "\t Without this, the kernel execution can not verify its checksum.\n" );
log_info( "\tdo_not_execute - Disable executing a kernel that accesses all of the memory objects.\n" );
log_info( "\n" );
log_info( "Test names (Allocation Types):\n" );
for( int i = 0; i < test_num; i++ )
log_info("Usage: %s [options] [test_names]\n", execName);
log_info("Options:\n");
log_info("\trandomize - Uses random seed\n");
log_info(
"\tsingle - Tests using a single allocation as large as possible\n");
log_info("\tmultiple - Tests using as many allocations as possible\n");
log_info("\n");
log_info("\tnumReps - Optional integer specifying the number of "
"repetitions to run and average the result (defaults to 1)\n");
log_info("\treduction%% - Optional integer, followed by a %% sign, that "
"acts as a multiplier for the target amount of memory.\n");
log_info("\t Example: target amount of 512MB and a reduction "
"of 75%% will result in a target of 384MB.\n");
log_info("\n");
log_info("\tdo_not_force_fill - Disable explicitly write data to all "
"memory objects after creating them.\n");
log_info("\t Without this, the kernel execution can not "
"verify its checksum.\n");
log_info("\tdo_not_execute - Disable executing a kernel that accesses all "
"of the memory objects.\n");
log_info("\n");
log_info("Test names (Allocation Types):\n");
for (int i = 0; i < test_registry::getInstance().num_tests(); i++)
{
log_info( "\t%s\n", test_list[i].name );
log_info("\t%s\n", test_registry::getInstance().definitions()[i].name);
}
}

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -39,9 +39,10 @@
#define FAILED_CORRUPTED_QUEUE -2
#define FAILED_ABORT -1
#define FAILED_TOO_BIG 1
// On Windows macro `SUCCEEDED' is defined in `WinError.h'. It causes compiler warnings. Let us avoid them.
#if defined( _WIN32 ) && defined( SUCCEEDED )
#undef SUCCEEDED
// On Windows macro `SUCCEEDED' is defined in `WinError.h'. It causes compiler
// warnings. Let us avoid them.
#if defined(_WIN32) && defined(SUCCEEDED)
#undef SUCCEEDED
#endif
#define SUCCEEDED 0
@ -55,11 +56,16 @@ enum AllocType
IMAGE_WRITE_NON_BLOCKING,
};
#define test_error_abort(errCode,msg) test_error_ret_abort(errCode,msg,errCode)
#define test_error_ret_abort(errCode,msg,retValue) { if( errCode != CL_SUCCESS ) { print_error( errCode, msg ); return FAILED_ABORT ; } }
#define test_error_abort(errCode, msg) \
test_error_ret_abort(errCode, msg, errCode)
#define test_error_ret_abort(errCode, msg, retValue) \
{ \
if (errCode != CL_SUCCESS) \
{ \
print_error(errCode, msg); \
return FAILED_ABORT; \
} \
}
#endif // _testBase_h

View file

@ -3,6 +3,7 @@ set(MODULE_NAME API)
set(${MODULE_NAME}_SOURCES
main.cpp
negative_platform.cpp
negative_queue.cpp
test_api_consistency.cpp
test_bool.cpp
test_retain.cpp
@ -10,10 +11,12 @@ set(${MODULE_NAME}_SOURCES
test_queries.cpp
test_create_kernels.cpp
test_kernels.cpp
test_kernel_local_memory_size.cpp
test_kernel_private_memory_size.cpp
test_api_min_max.cpp
test_kernel_arg_changes.cpp
test_kernel_arg_multi_setup.cpp
test_kernel_attributes.cpp
test_binary.cpp
test_native_kernel.cpp
test_mem_objects.cpp
@ -21,7 +24,6 @@ set(${MODULE_NAME}_SOURCES
test_device_min_data_type_align_size_alignment.cpp
test_platform.cpp
test_kernel_arg_info.cpp
test_kernel_arg_info_compatibility.cpp
test_null_buffer_arg.cpp
test_mem_object_info.cpp
test_min_image_formats.cpp
@ -35,6 +37,8 @@ set(${MODULE_NAME}_SOURCES
test_mem_object_properties_queries.cpp
test_queue_properties_queries.cpp
test_pipe_properties_queries.cpp
test_wg_suggested_local_work_size.cpp
test_device_command_queue.cpp
)
include(../CMakeCommon.txt)

View file

@ -13,146 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "harness/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "procs.h"
#include "harness/testHarness.h"
#if !defined(_WIN32)
#include <unistd.h>
#endif
// FIXME: To use certain functions in harness/imageHelpers.h
// (for example, generate_random_image_data()), the tests are required to
// declare the following variables (<rdar://problem/11111245>):
test_definition test_list[] = {
ADD_TEST(get_platform_info),
ADD_TEST_VERSION(get_sampler_info, Version(2, 0)),
ADD_TEST(get_sampler_info_compatibility),
ADD_TEST_VERSION(get_command_queue_info, Version(2, 0)),
ADD_TEST(get_command_queue_info_compatibility),
ADD_TEST(get_context_info),
ADD_TEST(get_device_info),
ADD_TEST(enqueue_task),
ADD_TEST(binary_get),
ADD_TEST(binary_create),
ADD_TEST(kernel_required_group_size),
ADD_TEST(release_kernel_order),
ADD_TEST(release_during_execute),
ADD_TEST(load_single_kernel),
ADD_TEST(load_two_kernels),
ADD_TEST(load_two_kernels_in_one),
ADD_TEST(load_two_kernels_manually),
ADD_TEST(get_program_info_kernel_names),
ADD_TEST(get_kernel_arg_info),
ADD_TEST(get_kernel_arg_info_compatibility),
ADD_TEST(create_kernels_in_program),
ADD_TEST(get_kernel_info),
ADD_TEST(kernel_private_memory_size),
ADD_TEST(execute_kernel_local_sizes),
ADD_TEST(set_kernel_arg_by_index),
ADD_TEST(set_kernel_arg_constant),
ADD_TEST(set_kernel_arg_struct_array),
ADD_TEST(kernel_global_constant),
ADD_TEST(min_max_thread_dimensions),
ADD_TEST(min_max_work_items_sizes),
ADD_TEST(min_max_work_group_size),
ADD_TEST(min_max_read_image_args),
ADD_TEST(min_max_write_image_args),
ADD_TEST(min_max_mem_alloc_size),
ADD_TEST(min_max_image_2d_width),
ADD_TEST(min_max_image_2d_height),
ADD_TEST(min_max_image_3d_width),
ADD_TEST(min_max_image_3d_height),
ADD_TEST(min_max_image_3d_depth),
ADD_TEST(min_max_image_array_size),
ADD_TEST(min_max_image_buffer_size),
ADD_TEST(min_max_parameter_size),
ADD_TEST(min_max_samplers),
ADD_TEST(min_max_constant_buffer_size),
ADD_TEST(min_max_constant_args),
ADD_TEST(min_max_compute_units),
ADD_TEST(min_max_address_bits),
ADD_TEST(min_max_single_fp_config),
ADD_TEST(min_max_double_fp_config),
ADD_TEST(min_max_local_mem_size),
ADD_TEST(min_max_kernel_preferred_work_group_size_multiple),
ADD_TEST(min_max_execution_capabilities),
ADD_TEST(min_max_queue_properties),
ADD_TEST(min_max_device_version),
ADD_TEST(min_max_language_version),
ADD_TEST(kernel_arg_changes),
ADD_TEST(kernel_arg_multi_setup_random),
ADD_TEST(native_kernel),
ADD_TEST(create_context_from_type),
ADD_TEST(platform_extensions),
ADD_TEST(get_platform_ids),
ADD_TEST(bool_type),
ADD_TEST(repeated_setup_cleanup),
ADD_TEST(retain_queue_single),
ADD_TEST(retain_queue_multiple),
ADD_TEST(retain_mem_object_single),
ADD_TEST(retain_mem_object_multiple),
ADD_TEST(retain_mem_object_set_kernel_arg),
ADD_TEST(min_data_type_align_size_alignment),
ADD_TEST_VERSION(context_destructor_callback, Version(3, 0)),
ADD_TEST(mem_object_destructor_callback),
ADD_TEST(null_buffer_arg),
ADD_TEST(get_buffer_info),
ADD_TEST(get_image2d_info),
ADD_TEST(get_image3d_info),
ADD_TEST(get_image1d_info),
ADD_TEST(get_image1d_array_info),
ADD_TEST(get_image2d_array_info),
ADD_TEST(queue_flush_on_release),
ADD_TEST(queue_hint),
ADD_TEST(queue_properties),
ADD_TEST_VERSION(sub_group_dispatch, Version(2, 1)),
ADD_TEST_VERSION(clone_kernel, Version(2, 1)),
ADD_TEST_VERSION(zero_sized_enqueue, Version(2, 1)),
ADD_TEST_VERSION(buffer_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(image_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(queue_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(pipe_properties_queries, Version(3, 0)),
ADD_TEST_VERSION(consistency_svm, Version(3, 0)),
ADD_TEST_VERSION(consistency_memory_model, Version(3, 0)),
ADD_TEST_VERSION(consistency_device_enqueue, Version(3, 0)),
ADD_TEST_VERSION(consistency_pipes, Version(3, 0)),
ADD_TEST_VERSION(consistency_progvar, Version(3, 0)),
ADD_TEST_VERSION(consistency_non_uniform_work_group, Version(3, 0)),
ADD_TEST_VERSION(consistency_read_write_images, Version(3, 0)),
ADD_TEST_VERSION(consistency_2d_image_from_buffer, Version(3, 0)),
ADD_TEST_VERSION(consistency_depth_images, Version(3, 0)),
ADD_TEST_VERSION(consistency_device_and_host_timer, Version(3, 0)),
ADD_TEST_VERSION(consistency_il_programs, Version(3, 0)),
ADD_TEST_VERSION(consistency_subgroups, Version(3, 0)),
ADD_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0)),
ADD_TEST_VERSION(consistency_3d_image_writes, Version(3, 0)),
ADD_TEST(min_image_formats),
ADD_TEST(negative_get_platform_info),
ADD_TEST(negative_get_platform_ids),
};
const int test_num = ARRAY_SIZE(test_list);
int main(int argc, const char *argv[])
{
return runTestHarness(argc, argv, test_num, test_list, false, 0);
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0);
}

View file

@ -16,8 +16,7 @@
#include "testBase.h"
int test_negative_get_platform_ids(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(negative_get_platform_ids)
{
cl_platform_id platform;
cl_int err = clGetPlatformIDs(0, &platform, nullptr);
@ -37,31 +36,13 @@ int test_negative_get_platform_ids(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_negative_get_platform_info(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST(negative_get_platform_info)
{
cl_platform_id platform = getPlatformFromDevice(deviceID);
cl_int err = clGetPlatformInfo(nullptr, CL_PLATFORM_VERSION, sizeof(char*),
nullptr, nullptr);
test_failure_error_ret(
err, CL_INVALID_PLATFORM,
"clGetPlatformInfo should return CL_INVALID_PLATFORM when: \"platform "
"is not a valid platform\" using a nullptr",
TEST_FAIL);
err =
clGetPlatformInfo(reinterpret_cast<cl_platform_id>(deviceID),
CL_PLATFORM_VERSION, sizeof(char*), nullptr, nullptr);
test_failure_error_ret(
err, CL_INVALID_PLATFORM,
"clGetPlatformInfo should return CL_INVALID_PLATFORM when: \"platform "
"is not a valid platform\" using a valid object which is NOT a "
"platform",
TEST_FAIL);
cl_platform_id platform = getPlatformFromDevice(device);
constexpr cl_platform_info INVALID_PARAM_VALUE = 0;
err = clGetPlatformInfo(platform, INVALID_PARAM_VALUE, 0, nullptr, nullptr);
cl_int err =
clGetPlatformInfo(platform, INVALID_PARAM_VALUE, 0, nullptr, nullptr);
test_failure_error_ret(
err, CL_INVALID_VALUE,
"clGetPlatformInfo should return CL_INVALID_VALUE when: \"param_name "

View file

@ -0,0 +1,168 @@
//
// Copyright (c) 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "testBase.h"
#include "harness/typeWrappers.h"
REGISTER_TEST(negative_create_command_queue)
{
cl_command_queue_properties device_props = 0;
cl_int error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");
// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE is the only optional property to
// clCreateCommandQueue, CL_QUEUE_PROFILING_ENABLE is mandatory.
const bool out_of_order_device_support =
device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
if (out_of_order_device_support)
{
// Early return as we can't check correct error is returned for
// unsupported property.
return TEST_PASS;
}
// Try create a command queue with out-of-order property and check return
// code
cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_queue = clCreateCommandQueue(
context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &test_error);
test_failure_error_ret(
test_error, CL_INVALID_QUEUE_PROPERTIES,
"clCreateCommandQueue should return CL_INVALID_QUEUE_PROPERTIES if "
"values specified in properties are valid but are not supported by "
"the "
"device.",
TEST_FAIL);
return TEST_PASS;
}
REGISTER_TEST_VERSION(negative_create_command_queue_with_properties,
Version(2, 0))
{
cl_command_queue_properties device_props = 0;
cl_int error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");
cl_command_queue_properties device_on_host_props = 0;
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
sizeof(device_on_host_props), &device_on_host_props,
NULL);
test_error(error,
"clGetDeviceInfo for CL_DEVICE_QUEUE_ON_HOST_PROPERTIES failed");
if (device_on_host_props != device_props)
{
log_error(
"ERROR: CL_DEVICE_QUEUE_PROPERTIES and "
"CL_DEVICE_QUEUE_ON_HOST_PROPERTIES properties should match\n");
return TEST_FAIL;
}
// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE is the only optional host-queue
// property to clCreateCommandQueueWithProperties,
// CL_QUEUE_PROFILING_ENABLE is mandatory.
const bool out_of_order_device_support =
device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
if (out_of_order_device_support)
{
// Early return as we can't check correct error is returned for
// unsupported property.
return TEST_PASS;
}
// Try create a command queue with out-of-order property and check return
// code
cl_command_queue_properties queue_prop_def[] = {
CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0
};
cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_queue = clCreateCommandQueueWithProperties(
context, device, queue_prop_def, &test_error);
test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES,
"clCreateCommandQueueWithProperties should "
"return CL_INVALID_QUEUE_PROPERTIES if "
"values specified in properties are valid but "
"are not supported by the "
"device.",
TEST_FAIL);
return TEST_PASS;
}
REGISTER_TEST(negative_create_command_queue_with_properties_khr)
{
if (!is_extension_available(device, "cl_khr_create_command_queue"))
{
return TEST_SKIPPED_ITSELF;
}
cl_platform_id platform;
cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM,
sizeof(cl_platform_id), &platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed");
clCreateCommandQueueWithPropertiesKHR_fn
clCreateCommandQueueWithPropertiesKHR =
(clCreateCommandQueueWithPropertiesKHR_fn)
clGetExtensionFunctionAddressForPlatform(
platform, "clCreateCommandQueueWithPropertiesKHR");
if (clCreateCommandQueueWithPropertiesKHR == NULL)
{
log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n");
return -1;
}
cl_command_queue_properties device_props = 0;
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");
// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE is the only optional host-queue
// property to clCreateCommandQueueWithPropertiesKHR,
// CL_QUEUE_PROFILING_ENABLE is mandatory.
const bool out_of_order_device_support =
device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
if (out_of_order_device_support)
{
// Early return as we can't check correct error is returned for
// unsupported property.
return TEST_PASS;
}
// Try create a command queue with out-of-order property and check return
// code
cl_queue_properties_khr queue_prop_def[] = {
CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0
};
cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_khr_queue =
clCreateCommandQueueWithPropertiesKHR(context, device, queue_prop_def,
&test_error);
test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES,
"clCreateCommandQueueWithPropertiesKHR should "
"return CL_INVALID_QUEUE_PROPERTIES if "
"values specified in properties are valid but "
"are not supported by the "
"device.",
TEST_FAIL);
return TEST_PASS;
}

View file

@ -1,205 +0,0 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "harness/errorHelpers.h"
#include "harness/kernelHelpers.h"
#include "harness/typeWrappers.h"
#include "harness/clImageHelper.h"
#include "harness/imageHelpers.h"
extern float calculate_ulperror(float a, float b);
extern int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_load_two_kernels_manually(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_platform_extensions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_platform_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_sampler_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_sampler_info_compatibility(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_command_queue_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_command_queue_info_compatibility(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_context_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_release_kernel_order(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_release_during_execute(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_kernel_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_private_memory_size(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_execute_kernel_local_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_by_index(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_struct(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_work_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_read_image_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_write_image_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_parameter_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_samplers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_constant_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_compute_units(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_address_bits(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_single_fp_config(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_double_fp_config(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_kernel_preferred_work_group_size_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_execution_capabilities(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_queue_properties(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_device_version(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_max_language_version(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems );
extern int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_get_platform_ids(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_arg_changes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_kernel_arg_multi_setup_random(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_queue_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_queue_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_mem_object_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_mem_object_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_retain_mem_object_set_kernel_arg(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_min_data_type_align_size_alignment(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems );
extern int test_context_destructor_callback(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_mem_object_destructor_callback(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_null_buffer_arg( cl_device_id device_id, cl_context context, cl_command_queue queue, int num_elements );
extern int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image2d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image3d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image1d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image1d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_image2d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements );
extern int test_get_kernel_arg_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
extern int test_get_kernel_arg_info_compatibility( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
extern int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements);
extern int test_queue_properties( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements );
extern int test_queue_flush_on_release(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_buffer_properties_queries(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_image_properties_queries(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_queue_properties_queries(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
int test_pipe_properties_queries(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_svm(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_memory_model(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_device_enqueue(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_pipes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_progvar(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_non_uniform_work_group(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_read_write_images(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_depth_images(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_il_programs(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_consistency_prog_ctor_dtor(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_consistency_3d_image_writes(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_min_image_formats(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_negative_get_platform_info(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_negative_get_platform_ids(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);

View file

@ -1,6 +1,6 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -17,15 +17,14 @@
#define _testBase_h
#include "harness/compat.h"
#include "harness/testHarness.h"
#include "harness/typeWrappers.h"
#include "harness/imageHelpers.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#endif // _testBase_h

View file

@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <cinttypes>
#include "testBase.h"
#include "harness/testHarness.h"
#include "harness/deviceInfo.h"
@ -23,8 +25,7 @@ __kernel void test(__global int* dst) {
}
)CLC";
int test_consistency_svm(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_svm, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_SVM_CAPABILITIES:
// May return 0, indicating that device does not support Shared Virtual
@ -37,8 +38,8 @@ int test_consistency_svm(cl_device_id deviceID, cl_context context,
clKernelWrapper kernel;
cl_device_svm_capabilities svmCaps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES,
sizeof(svmCaps), &svmCaps, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES, sizeof(svmCaps),
&svmCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_SVM_CAPABILITIES");
if (svmCaps == 0)
@ -158,8 +159,9 @@ static int check_atomic_capabilities(cl_device_atomic_capabilities atomicCaps,
{
if ((atomicCaps & requiredCaps) != requiredCaps)
{
log_error("Atomic capabilities %llx is missing support for at least "
"one required capability %llx!\n",
log_error("Atomic capabilities %" PRIx64
" is missing support for at least "
"one required capability %" PRIx64 "!\n",
atomicCaps, requiredCaps);
return TEST_FAIL;
}
@ -199,13 +201,12 @@ static int check_atomic_capabilities(cl_device_atomic_capabilities atomicCaps,
return TEST_PASS;
}
int test_consistency_memory_model(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_memory_model, Version(3, 0))
{
cl_int error;
cl_device_atomic_capabilities atomicCaps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES,
error = clGetDeviceInfo(device, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES,
sizeof(atomicCaps), &atomicCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES");
@ -218,7 +219,7 @@ int test_consistency_memory_model(cl_device_id deviceID, cl_context context,
return error;
}
error = clGetDeviceInfo(deviceID, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES,
error = clGetDeviceInfo(device, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES,
sizeof(atomicCaps), &atomicCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_ATOMIC_FENCE_CAPABILITIES");
@ -235,8 +236,7 @@ int test_consistency_memory_model(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_device_enqueue, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES
// May return 0, indicating that device does not support Device-Side Enqueue
@ -244,7 +244,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
cl_int error;
cl_device_device_enqueue_capabilities dseCaps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES,
error = clGetDeviceInfo(device, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES,
sizeof(dseCaps), &dseCaps, NULL);
test_error(error, "Unable to query CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES");
@ -255,7 +255,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
// On-Device Queues.
cl_command_queue_properties devQueueProps = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES,
sizeof(devQueueProps), &devQueueProps, NULL);
test_error(error,
"Unable to query CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES");
@ -275,7 +275,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
cl_uint u = 0;
error =
clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE,
clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE,
sizeof(u), &u, NULL);
test_error(error,
"Unable to query CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE");
@ -284,7 +284,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
"but CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE "
"returned a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE");
test_assert_error(
@ -292,7 +292,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 but "
"CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE returned a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_ON_DEVICE_QUEUES,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_QUEUES,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_ON_DEVICE_QUEUES");
test_assert_error(
@ -300,7 +300,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 but "
"CL_DEVICE_MAX_ON_DEVICE_QUEUES returned a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_ON_DEVICE_EVENTS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_EVENTS,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_ON_DEVICE_EVENTS");
test_assert_error(
@ -331,7 +331,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
// clSetDefaultDeviceCommandQueue
// Returns CL_INVALID_OPERATION if device does not support On-Device
// Queues.
error = clSetDefaultDeviceCommandQueue(context, deviceID, NULL);
error = clSetDefaultDeviceCommandQueue(context, device, NULL);
test_failure_error(error, CL_INVALID_OPERATION,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 "
"but clSetDefaultDeviceCommandQueue did not return "
@ -344,7 +344,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
// clSetDefaultDeviceCommandQueue
// Returns CL_INVALID_OPERATION if device does not support a
// replaceable default On-Device Queue.
error = clSetDefaultDeviceCommandQueue(context, deviceID, NULL);
error = clSetDefaultDeviceCommandQueue(context, device, NULL);
test_failure_error(
error, CL_INVALID_OPERATION,
"CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES did not "
@ -368,9 +368,9 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
if ((dseCaps & CL_DEVICE_QUEUE_SUPPORTED) != 0)
{
cl_bool b;
error = clGetDeviceInfo(deviceID,
CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
error =
clGetDeviceInfo(device, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
test_error(
error,
"Unable to query CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT");
@ -384,16 +384,15 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_pipes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_pipes, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_PIPE_SUPPORT
// May return CL_FALSE, indicating that device does not support Pipes.
cl_int error;
cl_bool pipeSupport = CL_FALSE;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_SUPPORT,
sizeof(pipeSupport), &pipeSupport, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PIPE_SUPPORT, sizeof(pipeSupport),
&pipeSupport, NULL);
test_error(error, "Unable to query CL_DEVICE_PIPE_SUPPORT");
if (pipeSupport == CL_FALSE)
@ -406,16 +405,15 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
cl_uint u = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PIPE_ARGS, sizeof(u),
&u, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_MAX_PIPE_ARGS, sizeof(u), &u,
NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_PIPE_ARGS");
test_assert_error(u == 0,
"CL_DEVICE_PIPE_SUPPORT returned CL_FALSE, but "
"CL_DEVICE_MAX_PIPE_ARGS returned a non-zero value");
error =
clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS,
sizeof(u), &u, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS,
sizeof(u), &u, NULL);
test_error(error,
"Unable to query CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS");
test_assert_error(u == 0,
@ -423,7 +421,7 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
"CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS returned "
"a non-zero value");
error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_PACKET_SIZE,
sizeof(u), &u, NULL);
test_error(error, "Unable to query CL_DEVICE_PIPE_MAX_PACKET_SIZE");
test_assert_error(
@ -458,9 +456,8 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
// Devices that support pipes must also return CL_TRUE
// for CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT.
cl_bool b;
error =
clGetDeviceInfo(deviceID, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT,
sizeof(b), &b, NULL);
test_error(error,
"Unable to query CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT");
test_assert_error(
@ -472,8 +469,7 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_progvar(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_progvar, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE
// May return 0, indicating that device does not support Program Scope
@ -484,7 +480,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
clKernelWrapper kernel;
size_t maxGlobalVariableSize = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE,
sizeof(maxGlobalVariableSize),
&maxGlobalVariableSize, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE");
@ -503,7 +499,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
// CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE
// Returns 0 if device does not support Program Scope Global Variables.
error = clGetDeviceInfo(deviceID,
error = clGetDeviceInfo(device,
CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE,
sizeof(sz), &sz, NULL);
test_error(
@ -520,7 +516,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
// Returns 0 if device does not support Program Scope Global Variables.
error = clGetProgramBuildInfo(
program, deviceID, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE,
program, device, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE,
sizeof(sz), &sz, NULL);
test_error(
error,
@ -534,10 +530,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_non_uniform_work_group(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST_VERSION(consistency_non_uniform_work_group, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT:
// May return CL_FALSE, indicating that device does not support Non-Uniform
@ -550,7 +543,7 @@ int test_consistency_non_uniform_work_group(cl_device_id deviceID,
clKernelWrapper kernel;
cl_bool nonUniformWorkGroupSupport = CL_FALSE;
error = clGetDeviceInfo(deviceID, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT,
error = clGetDeviceInfo(device, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT,
sizeof(nonUniformWorkGroupSupport),
&nonUniformWorkGroupSupport, NULL);
test_error(error,
@ -617,9 +610,7 @@ int test_consistency_non_uniform_work_group(cl_device_id deviceID,
return TEST_PASS;
}
int test_consistency_read_write_images(cl_device_id deviceID,
cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_read_write_images, Version(3, 0))
{
// clGetDeviceInfo, passing
// CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS May return 0,
@ -627,7 +618,7 @@ int test_consistency_read_write_images(cl_device_id deviceID,
cl_int error;
cl_uint maxReadWriteImageArgs = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS,
sizeof(maxReadWriteImageArgs),
&maxReadWriteImageArgs, NULL);
test_error(error,
@ -647,7 +638,7 @@ int test_consistency_read_write_images(cl_device_id deviceID,
CL_MEM_OBJECT_IMAGE2D, CL_MEM_OBJECT_IMAGE3D,
CL_MEM_OBJECT_IMAGE1D_ARRAY, CL_MEM_OBJECT_IMAGE2D_ARRAY,
};
for (int i = 0; i < ARRAY_SIZE(image_types); i++)
for (size_t i = 0; i < ARRAY_SIZE(image_types); i++)
{
cl_uint numImageFormats = 0;
error = clGetSupportedImageFormats(
@ -680,10 +671,7 @@ int test_consistency_read_write_images(cl_device_id deviceID,
return TEST_PASS;
}
int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST_VERSION(consistency_2d_image_from_buffer, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_IMAGE_PITCH_ALIGNMENT or
// CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT
@ -700,7 +688,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
clMemWrapper image;
cl_uint imagePitchAlignment = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
sizeof(imagePitchAlignment), &imagePitchAlignment,
NULL);
test_error(error,
@ -708,7 +696,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
"CL_DEVICE_IMAGE_PITCH_ALIGNMENT");
cl_uint imageBaseAddressAlignment = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
sizeof(imageBaseAddressAlignment),
&imageBaseAddressAlignment, NULL);
test_error(error,
@ -716,7 +704,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
"CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT");
bool supports_cl_khr_image2d_from_buffer =
is_extension_available(deviceID, "cl_khr_image2d_from_buffer");
is_extension_available(device, "cl_khr_image2d_from_buffer");
if (imagePitchAlignment == 0 || imageBaseAddressAlignment == 0)
{
@ -787,8 +775,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID,
// All of the sRGB Image Channel Orders (such as CL_​sRGBA) are optional for
// devices supporting OpenCL 3.0.
int test_consistency_depth_images(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_depth_images, Version(3, 0))
{
// The CL_DEPTH Image Channel Order is optional for devices supporting
// OpenCL 3.0.
@ -801,7 +788,7 @@ int test_consistency_depth_images(cl_device_id deviceID, cl_context context,
CL_MEM_READ_WRITE,
CL_MEM_KERNEL_READ_AND_WRITE,
};
for (int i = 0; i < ARRAY_SIZE(mem_flags); i++)
for (size_t i = 0; i < ARRAY_SIZE(mem_flags); i++)
{
cl_uint numImageFormats = 0;
error = clGetSupportedImageFormats(context, mem_flags[i],
@ -827,7 +814,7 @@ int test_consistency_depth_images(cl_device_id deviceID, cl_context context,
}
bool supports_cl_khr_depth_images =
is_extension_available(deviceID, "cl_khr_depth_images");
is_extension_available(device, "cl_khr_depth_images");
if (totalDepthImageFormats == 0)
{
@ -845,10 +832,7 @@ int test_consistency_depth_images(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
REGISTER_TEST_VERSION(consistency_device_and_host_timer, Version(3, 0))
{
// clGetPlatformInfo, passing CL_PLATFORM_HOST_TIMER_RESOLUTION
// May return 0, indicating that platform does not support Device and Host
@ -856,7 +840,7 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_int error;
cl_platform_id platform = NULL;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform),
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "Unable to query CL_DEVICE_PLATFORM");
@ -875,13 +859,13 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID,
cl_ulong dt = 0;
cl_ulong ht = 0;
error = clGetDeviceAndHostTimer(deviceID, &dt, &ht);
error = clGetDeviceAndHostTimer(device, &dt, &ht);
test_failure_error(
error, CL_INVALID_OPERATION,
"CL_PLATFORM_HOST_TIMER_RESOLUTION returned 0 but "
"clGetDeviceAndHostTimer did not return CL_INVALID_OPERATION");
error = clGetHostTimer(deviceID, &ht);
error = clGetHostTimer(device, &ht);
test_failure_error(
error, CL_INVALID_OPERATION,
"CL_PLATFORM_HOST_TIMER_RESOLUTION returned 0 but "
@ -891,8 +875,7 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID,
return TEST_PASS;
}
int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_il_programs, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_IL_VERSION or
// CL_DEVICE_ILS_WITH_VERSION
@ -906,14 +889,14 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
// Even if the device does not support Intermediate Language Programs the
// size of the string query should not be zero.
size_t sz = SIZE_MAX;
error = clGetDeviceInfo(deviceID, CL_DEVICE_IL_VERSION, 0, NULL, &sz);
error = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &sz);
test_error(error, "Unable to query CL_DEVICE_IL_VERSION");
test_assert_error(sz != 0,
"CL_DEVICE_IL_VERSION should return a non-zero size");
std::string ilVersion = get_device_il_version_string(deviceID);
std::string ilVersion = get_device_il_version_string(device);
error = clGetDeviceInfo(deviceID, CL_DEVICE_ILS_WITH_VERSION, 0, NULL, &sz);
error = clGetDeviceInfo(device, CL_DEVICE_ILS_WITH_VERSION, 0, NULL, &sz);
test_error(error, "Unable to query CL_DEVICE_ILS_WITH_VERSION");
if (ilVersion == "" || sz == 0)
@ -932,7 +915,7 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
"but CL_DEVICE_IL_VERSION returned an empty string");
bool supports_cl_khr_il_program =
is_extension_available(deviceID, "cl_khr_il_program");
is_extension_available(device, "cl_khr_il_program");
test_assert_error(supports_cl_khr_il_program == false,
"Device does not support IL Programs but does "
"support cl_khr_il_program");
@ -982,8 +965,7 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_subgroups, Version(3, 0))
{
// clGetDeviceInfo, passing CL_DEVICE_MAX_NUM_SUB_GROUPS
// May return 0, indicating that device does not support Subgroups.
@ -993,7 +975,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
clKernelWrapper kernel;
cl_uint maxNumSubGroups = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_NUM_SUB_GROUPS,
error = clGetDeviceInfo(device, CL_DEVICE_MAX_NUM_SUB_GROUPS,
sizeof(maxNumSubGroups), &maxNumSubGroups, NULL);
test_error(error, "Unable to query CL_DEVICE_MAX_NUM_SUB_GROUPS");
@ -1011,7 +993,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
cl_bool ifp = CL_FALSE;
error = clGetDeviceInfo(
deviceID, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
device, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
sizeof(ifp), &ifp, NULL);
test_error(
error,
@ -1026,7 +1008,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
// device does not support Subgroups.
bool supports_cl_khr_subgroups =
is_extension_available(deviceID, "cl_khr_subgroups");
is_extension_available(device, "cl_khr_subgroups");
test_assert_error(supports_cl_khr_subgroups == false,
"Device does not support Subgroups but does "
"support cl_khr_subgroups");
@ -1035,7 +1017,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
// Returns CL_INVALID_OPERATION if device does not support Subgroups.
size_t sz = SIZE_MAX;
error = clGetKernelSubGroupInfo(kernel, deviceID,
error = clGetKernelSubGroupInfo(kernel, device,
CL_KERNEL_MAX_NUM_SUB_GROUPS, 0, NULL,
sizeof(sz), &sz, NULL);
test_failure_error(
@ -1049,8 +1031,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context,
static void CL_CALLBACK program_callback(cl_program, void*) {}
int test_consistency_prog_ctor_dtor(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0))
{
cl_int error;
@ -1096,8 +1077,7 @@ int test_consistency_prog_ctor_dtor(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(consistency_3d_image_writes, Version(3, 0))
{
// clGetSupportedImageFormats, passing CL_MEM_OBJECT_IMAGE3D and one of
// CL_MEM_WRITE_ONLY, CL_MEM_READ_WRITE, or CL_MEM_KERNEL_READ_AND_WRITE
@ -1114,7 +1094,7 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context,
CL_MEM_READ_WRITE,
CL_MEM_KERNEL_READ_AND_WRITE,
};
for (int i = 0; i < ARRAY_SIZE(mem_flags); i++)
for (size_t i = 0; i < ARRAY_SIZE(mem_flags); i++)
{
cl_uint numImageFormats = 0;
error = clGetSupportedImageFormats(context, mem_flags[i],
@ -1128,7 +1108,7 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context,
}
bool supports_cl_khr_3d_image_writes =
is_extension_available(deviceID, "cl_khr_3d_image_writes");
is_extension_available(device, "cl_khr_3d_image_writes");
if (total3DImageWriteFormats == 0)
{
@ -1148,3 +1128,137 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context,
return TEST_PASS;
}
REGISTER_TEST(consistency_requirements_fp64)
{
cl_int error = CL_SUCCESS;
cl_device_fp_config value = 0;
if (is_extension_available(device, "cl_khr_fp64"))
{
const Version version = get_device_cl_version(device);
error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG,
sizeof(value), &value, nullptr);
test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG");
test_assert_error(
value > 0, "CL_DEVICE_DOUBLE_FP_CONFIG must return nonzero value");
if (version < Version(2, 0))
{
test_assert_error(
value
& (CL_FP_FMA | CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO
| CL_FP_ROUND_TO_INF | CL_FP_INF_NAN | CL_FP_DENORM),
"Reported double fp config doesn't meet minimum set "
"for OpenCL 1.0, OpenCL 1.1, OpenCL 1.2 devices");
}
else
{
test_assert_error(
value
& (CL_FP_FMA | CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN
| CL_FP_DENORM),
"Reported double fp config doesn't meet minimum set "
"for OpenCL 2.0 or newer devices");
}
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(
error,
"Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE");
test_assert_error(value > 0,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return "
"nonzero value");
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE");
test_assert_error(
value > 0,
"CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE must return nonzero value");
}
else
{
error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG,
sizeof(value), &value, nullptr);
test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG");
test_assert_error(value == 0,
"CL_DEVICE_DOUBLE_FP_CONFIG must return 0");
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(
error,
"Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE");
test_assert_error(
value == 0,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return 0");
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE");
test_assert_error(value == 0,
"CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE must return 0");
}
return TEST_PASS;
}
REGISTER_TEST(consistency_requirements_fp16)
{
cl_int error = CL_SUCCESS;
cl_device_fp_config value = 0;
if (is_extension_available(device, "cl_khr_fp16"))
{
error = clGetDeviceInfo(device, CL_DEVICE_HALF_FP_CONFIG, sizeof(value),
&value, nullptr);
test_error(error, "Unable to get device CL_DEVICE_HALF_FP_CONFIG");
test_assert_error(value > 0,
"CL_DEVICE_HALF_FP_CONFIG must return nonzero value");
test_assert_error((value & (CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN))
|| (value & CL_FP_ROUND_TO_ZERO),
"Reported half fp config doesn't meet minimum set");
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(
error,
"Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF");
test_assert_error(value > 0,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return "
"nonzero value");
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF");
test_assert_error(
value > 0,
"CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF must return nonzero value");
}
else
{
error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(
error,
"Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF");
test_assert_error(value == 0,
"CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return "
"0");
error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF");
test_assert_error(value == 0,
"CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF must return 0");
}
return TEST_PASS;
}

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,7 @@ static const char *sample_binary_kernel_source[] = {
"}\n" };
int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(binary_get)
{
int error;
clProgramWrapper program;
@ -71,7 +71,7 @@ int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue
}
int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(binary_create)
{
/* To test this in a self-contained fashion, we have to create a program with
source, then get the binary, then use that binary to reload the program, and then verify */
@ -103,12 +103,13 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que
test_error( error, "Unable to get program binary" );
cl_int loadErrors[ 1 ];
program_from_binary = clCreateProgramWithBinary( context, 1, &deviceID, &binarySize, buffers, loadErrors, &error );
program_from_binary = clCreateProgramWithBinary(
context, 1, &device, &binarySize, buffers, loadErrors, &error);
test_error( error, "Unable to load valid program binary" );
test_error( loadErrors[ 0 ], "Unable to load valid device binary into program" );
error = clBuildProgram( program_from_binary, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build binary program" );
error = clBuildProgram(program_from_binary, 1, &device, NULL, NULL, NULL);
test_error(error, "Unable to build binary program");
// Get the size of the binary built from the first binary
size_t binary2Size;
@ -123,10 +124,11 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que
// Try again, this time without passing the status ptr in, to make sure we still
// get a valid binary
clProgramWrapper programWithoutStatus = clCreateProgramWithBinary( context, 1, &deviceID, &binary2Size, buffers, NULL, &error );
clProgramWrapper programWithoutStatus = clCreateProgramWithBinary(
context, 1, &device, &binary2Size, buffers, NULL, &error);
test_error( error, "Unable to load valid program binary when binary_status pointer is NULL" );
error = clBuildProgram( programWithoutStatus, 1, &deviceID, NULL, NULL, NULL );
error = clBuildProgram(programWithoutStatus, 1, &device, NULL, NULL, NULL);
test_error( error, "Unable to build binary program created without binary_status" );
// Get the size of the binary created without passing binary_status
@ -214,5 +216,3 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que
free(out_data_binary);
return 0;
}

View file

@ -35,7 +35,7 @@ const char *kernel_with_bool[] = {
"}\n"
};
int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(bool_type)
{
clProgramWrapper program;
@ -48,4 +48,3 @@ int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue q
"kernel_with_bool" );
return err;
}

View file

@ -20,8 +20,6 @@
#include <string>
#include <cmath>
using namespace std;
const char *clone_kernel_test_img[] =
{
"__kernel void img_read_kernel(read_only image2d_t img, sampler_t sampler, __global int* outbuf)\n"
@ -94,19 +92,9 @@ struct structArg
float f;
};
static unsigned char *
generate_8888_image(int w, int h, MTdata d)
{
unsigned char *ptr = (unsigned char*)malloc(w * h * 4);
int i;
for (i=0; i<w*h*4; i++)
ptr[i] = (unsigned char)genrand_int32( d);
return ptr;
}
int test_image_arg_shallow_clone(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, void* pbufRes, clMemWrapper& bufOut)
int test_image_arg_shallow_clone(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements,
void* pbufRes, clMemWrapper& bufOut)
{
int error;
cl_image_format img_format;
@ -205,7 +193,9 @@ int test_image_arg_shallow_clone(cl_device_id deviceID, cl_context context, cl_c
return 0;
}
int test_double_arg_clone(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, void* pbufRes, clMemWrapper& bufOut)
int test_double_arg_clone(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements,
void* pbufRes, clMemWrapper& bufOut)
{
int error = 0;
clProgramWrapper program;
@ -242,7 +232,7 @@ int test_double_arg_clone(cl_device_id deviceID, cl_context context, cl_command_
return 0;
}
int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(clone_kernel, Version(2, 1))
{
int error;
clProgramWrapper program;
@ -264,11 +254,12 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu
cl_bool bimg = CL_FALSE;
cl_bool bdouble = CL_FALSE;
// test image support
error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &bimg, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool),
&bimg, NULL);
test_error( error, "clGetDeviceInfo failed." );
// test double support
if (is_extension_available(deviceID, "cl_khr_fp64"))
if (is_extension_available(device, "cl_khr_fp64"))
{
bdouble = CL_TRUE;
}
@ -323,6 +314,14 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu
clKernelWrapper clonek = clCloneKernel(kernel, &error);
test_error( error, "clCloneKernel failed." );
// enqueue the kernel before the last arg is set
error = clEnqueueNDRangeKernel(queue, clonek, 1, NULL, &ndrange1, NULL, 0,
NULL, NULL);
test_failure_error(error, CL_INVALID_KERNEL_ARGS,
"A kernel cloned before all args are set should return "
"CL_INVALID_KERNEL_ARGS if enqueued before the "
"remaining args are set");
// set the last arg and enqueue
error = clSetKernelArg(clonek, 4, sizeof(cl_mem), &bufOut);
test_error( error, "clSetKernelArg failed." );
@ -383,13 +382,15 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu
if (bimg)
{
error = test_image_arg_shallow_clone(deviceID, context, queue, num_elements, pbufRes, bufOut);
error = test_image_arg_shallow_clone(device, context, queue,
num_elements, pbufRes, bufOut);
test_error( error, "image arg shallow clone test failed." );
}
if (bdouble)
{
error = test_double_arg_clone(deviceID, context, queue, num_elements, pbufRes, bufOut);
error = test_double_arg_clone(device, context, queue, num_elements,
pbufRes, bufOut);
test_error( error, "double arg clone test failed." );
}
@ -398,4 +399,3 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu
return 0;
}

View file

@ -26,12 +26,11 @@ void CL_CALLBACK context_destructor_callback(cl_context context, void *userData)
*userPtr = ++sDestructorIndex;
}
int test_context_destructor_callback(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
REGISTER_TEST_VERSION(context_destructor_callback, Version(3, 0))
{
cl_int error;
clContextWrapper localContext =
clCreateContext(NULL, 1, &deviceID, NULL, NULL, &error);
clCreateContext(NULL, 1, &device, NULL, NULL, &error);
test_error(error, "Unable to create local context");
// Set up some variables to catch the order in which callbacks are called
@ -52,12 +51,7 @@ int test_context_destructor_callback(cl_device_id deviceID, cl_context context,
test_error(error, "Unable to set destructor callback");
// Now release the context, which SHOULD call the callbacks
error = clReleaseContext(localContext);
test_error(error, "Unable to release local context");
// Note: since we manually released the context, we need to set it to NULL
// to prevent a double-release
localContext = NULL;
localContext.reset();
// At this point, all three callbacks should have already been called
int numErrors = 0;

View file

@ -21,8 +21,9 @@
#endif
#include "harness/conversions.h"
#include <bitset>
int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(create_context_from_type)
{
int error;
clProgramWrapper program;
@ -46,11 +47,12 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_
"}\n" };
cl_device_type type;
error = clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n");
cl_platform_id platform;
error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL);
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n");
cl_context_properties properties[3] = {
@ -66,7 +68,7 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_
return -1;
}
queue_to_test = clCreateCommandQueue(context_to_test, deviceID, 0, &error);
queue_to_test = clCreateCommandQueue(context_to_test, device, 0, &error);
test_error(error, "clCreateCommandQueue failed");
if (queue_to_test == NULL) {
log_error("clCreateCommandQueue returned NULL, but error was CL_SUCCESS.");
@ -127,4 +129,107 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_
return 0;
}
REGISTER_TEST(create_context_from_type_device_type_all)
{
cl_device_type type;
cl_int error =
clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n");
std::bitset<sizeof(cl_device_type)> type_bits(type);
if (type_bits.count() > 1 || (type & CL_DEVICE_TYPE_DEFAULT))
{
log_error("clGetDeviceInfo(CL_DEVICE_TYPE) must report a single device "
"type, which must not be CL_DEVICE_TYPE_DEFAULT or "
"CL_DEVICE_TYPE_ALL.\n");
return -1;
}
cl_platform_id platform;
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n");
cl_context_properties properties[3] = {
(cl_context_properties)CL_CONTEXT_PLATFORM,
(cl_context_properties)platform, 0
};
clContextWrapper context_to_test = clCreateContextFromType(
properties, CL_DEVICE_TYPE_ALL, notify_callback, NULL, &error);
test_error(error, "clCreateContextFromType failed");
cl_uint num_devices = 0;
error = clGetContextInfo(context_to_test, CL_CONTEXT_NUM_DEVICES,
sizeof(cl_uint), &num_devices, nullptr);
test_error(error, "clGetContextInfo CL_CONTEXT_NUM_DEVICES failed\n");
test_assert_error(num_devices >= 1,
"Context must contain at least one device\n");
return 0;
}
REGISTER_TEST(create_context_from_type_device_type_default)
{
cl_device_type type;
cl_int error =
clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n");
std::bitset<sizeof(cl_device_type)> type_bits(type);
if (type_bits.count() > 1 || (type & CL_DEVICE_TYPE_DEFAULT))
{
log_error("clGetDeviceInfo(CL_DEVICE_TYPE) must report a single device "
"type, which must not be CL_DEVICE_TYPE_DEFAULT or "
"CL_DEVICE_TYPE_ALL.\n");
return -1;
}
cl_platform_id platform;
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
&platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n");
cl_context_properties properties[3] = {
(cl_context_properties)CL_CONTEXT_PLATFORM,
(cl_context_properties)platform, 0
};
clContextWrapper context_to_test = clCreateContextFromType(
properties, CL_DEVICE_TYPE_DEFAULT, notify_callback, NULL, &error);
test_error(error, "clCreateContextFromType failed");
cl_uint num_devices = 0;
error = clGetContextInfo(context_to_test, CL_CONTEXT_NUM_DEVICES,
sizeof(cl_uint), &num_devices, nullptr);
test_error(error, "clGetContextInfo CL_CONTEXT_NUM_DEVICES failed\n");
std::vector<cl_device_id> devices(num_devices);
error = clGetContextInfo(context_to_test, CL_CONTEXT_DEVICES,
num_devices * sizeof(cl_device_id), devices.data(),
nullptr);
test_error(error, "clGetContextInfo CL_CONTEXT_DEVICES failed\n");
test_assert_error(devices.size() == 1,
"Context must contain exactly one device\n");
cl_uint num_platform_devices;
error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_DEFAULT, 0, NULL,
&num_platform_devices);
test_error(error, "clGetDeviceIDs failed.\n");
test_assert_error(num_platform_devices == 1,
"clGetDeviceIDs must return exactly one device\n");
std::vector<cl_device_id> platform_devices(num_platform_devices);
error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_DEFAULT,
num_platform_devices, platform_devices.data(), NULL);
test_error(error, "clGetDeviceIDs failed.\n");
test_assert_error(platform_devices[0] == devices[0],
"device in the context must be equivalent to device "
"returned by clGetDeviceIDs\n");
return 0;
}

View file

@ -72,8 +72,7 @@ const char *repeate_test_kernel =
"}\n";
int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_single_kernel)
{
int error;
clProgramWrapper program;
@ -159,7 +158,7 @@ int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_comman
return 0;
}
int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_two_kernels)
{
int error;
clProgramWrapper program;
@ -239,7 +238,7 @@ int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_
return 0;
}
int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_two_kernels_in_one)
{
int error;
clProgramWrapper program;
@ -320,7 +319,7 @@ int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_c
return 0;
}
int test_load_two_kernels_manually( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(load_two_kernels_manually)
{
clProgramWrapper program;
clKernelWrapper kernel1, kernel2;
@ -351,7 +350,7 @@ int test_load_two_kernels_manually( cl_device_id deviceID, cl_context context, c
return 0;
}
int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(get_program_info_kernel_names)
{
clProgramWrapper program;
clKernelWrapper kernel1, kernel2;
@ -406,8 +405,8 @@ int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context contex
if (i == sizeof( actual_names ) / sizeof( actual_names[0] ) )
{
free(kernel_names);
log_error( "Kernel names \"%s\" did not match:\n", kernel_names );
free(kernel_names);
for( i = 0; i < sizeof( actual_names ) / sizeof( actual_names[0] ); i++ )
log_error( "\t\t\"%s\"\n", actual_names[0] );
return -1;
@ -442,7 +441,7 @@ static const char *single_task_kernel[] = {
"\n"
"}\n" };
int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(enqueue_task)
{
int error;
clProgramWrapper program;
@ -491,9 +490,8 @@ int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queu
}
#define TEST_SIZE 1000
int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements)
REGISTER_TEST(repeated_setup_cleanup)
{
cl_context local_context;
@ -519,10 +517,11 @@ int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_co
for (i=0; i<100; i++) {
memset(outData, 0, sizeof(cl_int)*TEST_SIZE);
local_context = clCreateContext(NULL, 1, &deviceID, notify_callback, NULL, &error);
local_context =
clCreateContext(NULL, 1, &device, notify_callback, NULL, &error);
test_error( error, "clCreateContext failed");
local_queue = clCreateCommandQueue(local_context, deviceID, 0, &error);
local_queue = clCreateCommandQueue(local_context, device, 0, &error);
test_error( error, "clCreateCommandQueue failed");
error = create_single_kernel_helper(
@ -590,6 +589,3 @@ int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_co
return 0;
}

View file

@ -0,0 +1,85 @@
//
// Copyright (c) 2021 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "testBase.h"
#include <array>
using namespace std;
int test_command_queue_helper(cl_context context, cl_device_id deviceID,
cl_command_queue queue)
{
cl_int error;
cl_command_queue check_queue;
error = clSetDefaultDeviceCommandQueue(context, deviceID, queue);
test_error(error, "clSetDefaultDeviceCommandQueue failed ");
error = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE_DEFAULT,
sizeof(check_queue), &check_queue, nullptr);
test_error(error,
"clGetCommandQueueInfo failed for CL_QUEUE_DEVICE_DEFAULT");
test_assert_error(
(check_queue == queue),
"Expected the queue to be returned as default device queue failed");
return TEST_PASS;
}
REGISTER_TEST_VERSION(set_default_device_command_queue, Version(2, 1))
{
cl_int error;
constexpr cl_command_queue_properties PROPERTIES = CL_QUEUE_ON_DEVICE
| CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE;
std::array<cl_queue_properties, 3> properties = {
CL_QUEUE_PROPERTIES, (PROPERTIES | CL_QUEUE_ON_DEVICE_DEFAULT), 0
};
if (get_device_cl_version(device) >= Version(3, 0))
{
cl_device_device_enqueue_capabilities dseCaps = 0;
error = clGetDeviceInfo(device, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES,
sizeof(dseCaps), &dseCaps, NULL);
test_error(error,
"Unable to query CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES");
if (0 == (dseCaps & CL_DEVICE_QUEUE_REPLACEABLE_DEFAULT))
return TEST_SKIPPED_ITSELF;
}
clCommandQueueWrapper cmd_queue_1 = clCreateCommandQueueWithProperties(
context, device, properties.data(), &error);
test_error(error, "clCreateCommandQueueWithProperties failed");
properties[1] = PROPERTIES;
clCommandQueueWrapper cmd_queue_2 = clCreateCommandQueueWithProperties(
context, device, properties.data(), &error);
test_error(error, "clCreateCommandQueueWithProperties failed");
// cmd_queue_1
if (test_command_queue_helper(context, device, cmd_queue_1) != 0)
{
test_fail("test_command_queue_helper failed for cmd_queue_1.\n");
}
// cmd_queue_2 - without CL_QUEUE_ON_DEVICE_DEFAULT
if (test_command_queue_helper(context, device, cmd_queue_2) != 0)
{
test_fail("test_command_queue_helper failed for cmd_queue_2.\n");
}
return TEST_PASS;
}

Some files were not shown because too many files have changed in this diff Show more