This is a test plan for the common reference semantics as described in Section 4.5.2. of the SYCL 2020 specification. The estimated development time is two days.
No negative test are included.
All the tests described below are not backend-specific and are performed for any SYCL backend.
The common reference semantics are defined for the following runtime classes in the sycl
namespace (Section 4.5.2.):
accessor
, buffer
, context
, device
, device_image
, event
, host_accessor
, host_sampled_image_accessor
, host_unsampled_image_accessor
, kernel
, kernel_id
, kernel_bundle
, local_accessor
, platform
, queue
, sampled_image
, sampled_image_accessor
, stream
, unsampled_image
, and unsampled_image_accessor
.
Of these, the following classes are legal kernel parameter types (Section 4.12.4.): accessor
(when templated with target::device
or the deprecated target::global_buffer
, target::constant_buffer
, or target::local
), local_accessor
, unsampled_image_accessor
(when templated with image_target::device
), sampled_image_accessor
(when templated with image_target::device
), stream
.
The following "host types" are identified:
-
accessor<int, 1, access_mode::read_write, target::host_task>
-
buffer<int>
-
context
-
device
-
device_image<bundle_state::executable>
-
event
-
host_accessor<int>
-
host_sampled_image_accessor<int, 1>
-
host_unsampled_image_accessor<int>
-
kernel
-
kernel_id
-
kernel_bundle<bundle_state::executable>
-
platform
-
queue
-
sampled_image
-
unsampled_image
The following "kernel types" are identified:
-
accessor<int, 1, access_mode::read_write, target::device>
-
local_accessor<int, 0>
-
unsampled_image_accessor<int, 1, access_mode::read>
-
sampled_image_accessor<int, 1>
-
stream
These tests are run from a host application for all host types and kernel types.
This test is repeated for the copy constructor and for copy assignment. For class T
:
-
Create an instance
t0
ofT
. -
Create a copy of
t0
,t1
. -
Check that
t0 == t1
andt1 == t0
. -
Check that
std::hash<T>{}(t0) == std::hash<T>{}(t1)
.
This test is not executed for: device_image
, device
if only one device is available and platform
if only one platform is available. For class T
:
-
Create an instance
t0
ofT
. -
Create an instance
t1
ofT
, which is distinct fromt0
. -
Check that
t0 != t1
andt1 != t0
. -
Check that
std::hash<T>{}(t0) != std::hash<T>{}(t1)
.
For class T
:
-
Create an instance
t0
ofT
. -
Check that
t0 == t0
. -
Check that
std::hash<T>{}(t0) == std::hash<T>{}(t0)
.
The tests in this section tests are run from a host application for all host types and kernel types, and from a kernel function for all kernel types.
The tests below assert equality without the equality operator, such that they may also be executed in a kernel function. The "state" denotes the results of calling member functions of an object.
For class T
, check that the following statements evaluate to true
.
-
std::is_copy_constructible_v<T>
. -
std::is_copy_assignable_v<T>
-
std::is_destructible_v<T>
-
std::is_move_constructible_v<T>
-
std::is_move_assignable_v<T>
This test is repeated for the copy constructor and for copy assignment. For class T
:
-
Create an instance
t0
ofT
. -
Store the state of
t0
. -
Create a copy of
t0
,t1
. -
Check that the state of
t1
is the same as the state stored in Step 2.
The tests in this plan replace common/common_by_reference.h
and its usages (in kernel_id_common_reference_semantics.cpp
). The test will be implemented in a common
header, and be executed from implementation files located in the types' respective directories. The tests in accessor_legacy
and event
will be rewritten to use this common header.
The tests below tests specify a "mutation" of an instance T
. This means to change an instance such that the change can be detected in a copy of that instance. This is only possible for the following types:
-
accessor<int, 1, access_mode::read_write, target::host_task>
by writing to the accessor (in the host application):-
mutation: write to the accessor.
-
detection: read from the accessor.
-
-
accessor<int, 1, access_mode::read_write, target::device>
(in a kernel function):-
mutation: write to the accessor.
-
detection: read from the accessor.
-
-
buffer<int>
by obtaining an accessor and writing to the accessor (in the host application):-
mutation: create an accessor, write to the accessor.
-
detection: create an accessor, read from the accessor.
-
-
event
(in the host application): an evente0
can be created by scheduling a command group with a host task that waits for a future value to become available. Evente0
can be resolved by making this value available. Evente1
is created by scheduling a command group that depends on an evente0
.-
mutation: resolve the event
e0
which is in the wait list ofe1
. -
detection: query the contents of the wait list of
e1
.
-
-
host_accessor
(in the host application):-
mutation: write to the accessor.
-
detection: read from the accessor.
-
-
host_unsampled_image_accessor<int>
(in the host application):-
mutation: write to the accessor.
-
detection: read from the accessor.
-
-
local_accessor<int, 0>
(in a kernel function):-
mutation: write to the accessor.
-
detection: read from the accessor.
-
-
unsampled_image
(in the host application):-
mutation: create an accessor, write to the accessor.
-
detection: create an accessor, read from the accessor.
-
host_sampled_image_accessor
, sampled_image
, and sampled_image_accessor
are not included since a sampled image is read-only. unsampled_image_accessor
is not included since access mode is either read or write, not both.
-
Create an instance
t0
ofT
. -
Make a copy of
t0
,t1
. -
Mutate
t1
. -
Check that
t0
has been changed accordingly.
-
Create an instance
t0
ofT
. -
Make a copy of
t0
,t1
. -
Mutate
t0
. -
Check that
t1
has been changed accordingly.