The following tests create an OpenCL semaphore using (fd == -1) then
call `clEnqueueSignalSemaphoresKHR` on that semaphore. (fd == -1) refers
to an object that has already signaled and enqueueing a signal command
on it will lead to undefined behavior.
Quoting OpenCL specification:
```
The special value -1 for fd is treated like a valid sync file descriptor
referring to an object that has already signaled.
```
And
```
Signaling the same binary semaphore twice without an interleaving wait
may lead to undefined behavior.
```
- external_semaphores_simple_1
- external_semaphores_reuse
- external_semaphores_cross_queues_ooo
- external_semaphores_cross_queues_io
- external_semaphores_cross_queues_io2
This commit changes the tests to avoid signaling an already signaled
semaphore and correctly re-import the semaphore's fd after enqueueing a
wait successfully.
Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
Co-authored-by: Michael Rizkalla <michael.rizkalla@arm.com>
Due to discussion from #2542 and following work from closed PR #2568
This change refactors the external semaphore tests by unifying
`external_semaphores_import_export_fd` with
`external_semaphores_cross_context` tests, removing duplicated logic and
avoiding OS-specific conditions. The updated test now covers all
import/export handle types consistently across single- and multi-context
scenarios.
While the cl_khr_semaphore extension spec does state that are no
implicit dependencies between already enqueued commands and the
clEnqueueSignalSemaphoresKHR, it's nothing special as this is already
true for any other event that's not a barrier or marker.
Also, the CTS can't reliably assume implementations to reorder events
even in an out of order queue as this is highly implementation defined
behavior and implementations may or may not choose to reorder events in
a specific order.
I don't see a reason why this should be tested for semaphores, but not
for any other commands, especially as it imposes a restriction on how to
implement out of order queues that wasn't enforced before.
Closes: https://github.com/KhronosGroup/OpenCL-CTS/issues/2439
In CMake 3.24+, there is built-in support for adding -Werror that does
not require adding -Werror explicitly, and allows it to be downgraded to
a warning if the user wants that. Use this, to account for warnings that
have false positives.
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>
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>
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>
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.
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).
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>
* 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.
* 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.
Modify the external semaphore extension test
to use SYNC_FD, if available on the device.
Deleted tests that are not compatible with blocking
semaphores.
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>
* 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>