This is a test plan for the math array types described in SYCL 2020 Section 4.14.3.
Estimated development time is four days.
This plan does not include negative tests.
All the tests described below are performed only on the default device that is selected on the CTS command line.
The interface tests and memory layout and alignment tests (Sections 2.1 and 2.3 below) are performed using each of the following types as the underlying type the DataT
template variable of marray
, unless stated otherwise.
In regular mode:
-
char
-
int
-
float
-
std::int8_t
-
std::int32_t
-
A user-defined struct that meets the NumericType requirements of the C++ standard.
In addition, if the device has aspect::fp64
:
-
double
In addition, if the device has aspect::fp16
:
-
half
In full conformance mode:
-
char
-
signed char
-
unsigned char
-
short
-
unsigned short
-
int
-
unsigned int
-
long
-
unsigned long
-
long long
-
unsigned long long
-
float
-
bool
-
std::int8_t
-
std::uint8_t
-
std::int16_t
-
std::uint16_t
-
std::int32_t
-
std::uint32_t
-
std::int64_t
-
std::uint64_t
-
A user-defined struct that meets the NumericType requirements of the C++ standard.
In addition, if the device has aspect::fp64
:
-
double
In addition, if the device has aspect::fp16
:
-
half
This section tests Section 4.14.3.1 of the SYCL 2020 specification.
-
Call constructor
marray()
to initialize an instancema
. Check that all the values ofma
are equal to the default-constructed elementsDataT
.
Repeat the below test twice: once to construct a constexpr
instance and once to construct a non-constexpr
instance.
-
Call constructor
explicit constexpr marray(const DataT& arg)
withDataT(1)
to initialize an instancema
. Check usingoperator[]
that all values ofma
are equal toDataT(1)
. -
Call the constructor
template <typename… ArgTN> constexpr marray(const ArgTN&… args)
to initialize an instancema
, with:-
NumElements
instancesDataT
initialized with the sequence1
,2
,3
, etc. Check usingoperator[]
that the values ofma
follow the sequence1
,2
,3
, etc. -
If
NumElements > 1
: one instance ofDataT
initialized with1
followed by one instance ofmarray<DataT, N>
whereN
isNumElements - 1
.marray<DataT, N>
is initialized with the sequence2
,3
,4
, etc. Check usingoperator[]
that the values ofma
follow the sequence1
,2
,3
, etc. -
If
NumElements > 1
: instance ofmarray<DataT, N>
whereN
isNumElements - 1
followed by one instance ofDataT
initialized withNumElements - 1
.marray<DataT, N>
is initialized with the sequence1
,2
,3
, etc. Check usingoperator[]
that the values ofma
follow the sequence1
,2
,3
, etc.
-
-
Call the constructor
constexpr marray(const marray<DataT, NumElements>& rhs)
withrhs
initialized with the sequence1
,2
,3
, etc. Check usingoperator[]
that the elements ofma
are the sequence1
,2
,3
, etc. -
Call the constructor
constexpr marray(marray<DataT, NumElements>&& rhs)
withrhs
initialized with the sequence1
,2
,3
, etc. to initializeconstexpr marray<DataT, NumElements> inst
. Check usingoperator[]
that the elements ofma
are the sequence1
,2
,3
, etc.
Declare marray<DataT, NumElements>
instance ma_inc
with its elements initialized as the sequence 1
, 2
, 3
, etc. Declare ma_const
as a copy of ma_inc
, declare it as const
.
-
If
NumElements == 1
: calloperator DataT() const
onma_inc
. Check that the result is equal toDataT(1)
. -
Call
static constexpr std::size_t size() noexcept
onma_inc
. Check that the result is equal toNumElements
. Check the function itself fornoexcept
. -
Call
DataT& operator[](std::size_t index)
onma_inc
withindex
of0
. Check that the result is equal to1
. Assign toDataT& operator[](std::size_t index)
ofma_inc
withindex
of0
a value ofDataT(0)
. CallDataT& operator[](std::size_t index)
onma_inc
withindex
of0
. Check that the result is equal toDataT(0)
. -
Call
const DataT& operator[](std::size_t index) const
onma_const
withindex
of0
. Check that the result is equal toDataT(1)
. -
Construct an
marray<DataT, NumElements>
instancema_tmp
with its elements initialized toDataT(0)
. Callmarray& operator=(const marray& rhs)
onma_tmp
instance withrhs
ofconst
. Check that the elements ofma_tmp
are equal toma_const
. -
Construct an
marray<DataT, NumElements>
instancema_tmp
with its elements initialized toDataT(0)
. Callmarray& operator=(const DataT& rhs)
onma_tmp
withrhs
ofDataT(1)
. Check that the elements ofma_tmp
are equal toDataT(1)
. -
For both
ma_inc
andma_const
, do:-
Obtain the iterator
it_ma
using<const>iterator begin()
. -
Make a copy
it_ma_tmp
using assignment. -
Increment
it_ma
by one. -
If
NumElements > 1
, check that the value pointed to byit_ma
is equal toDataT(2)
. -
Decrement
it_ma
by one. -
Check that
it_ma
is equal toit_ma_tmp
.
-
-
For both
ma_inc
andma_const
, do:-
Obtain the iterator
it_ma
using<const>iterator end()
. -
Make a copy
it_ma_tmp
using assignment. -
Decrement
it_ma
by one. -
Check that the value pointed to by
it_ma
is equal toDataT(NumElements)
. -
Increment
it_ma
by one. -
Check that
it_ma
is equal toit_ma_tmp
.
-
2.1.3. Hidden friend functions
Declare the following marray<DataT, NumElements>
instances:
-
ma_inc
as the sequence1
,2
,3
,4
,5
, etc. -
ma_dec
as the sequenceNumElements
,NumElements - 1
,NumElements - 2
,NumElements - 3
,NumElements - 4
, etc. -
ma_one
as the sequence1
,1
,1
,1
,1
, etc. -
ma_two
as the sequence2
,2
,2
,2
,2
, etc.
Declare the following DataT
instances:
-
dt_one
asDataT(1)
. -
dt_two
asDataT(2)
.
Call the below operators using all possible combinations of the defined input instances. The equivalent operations are executed using std::valarray<DataT>
, and the results of both operations are checked to be equal using element-wise comparisons with operator[]
.
The tests where OP
is %
, %=
, &
, |
, ^
, &=
, |=
, ^=
, <<
, >>
, <<=
, >>=
, or ~
are not executed when DataT
is a floating-point type, i.e. float
, double
, or half
.
-
marray operatorOP(const marray& lhs, const marray& rhs)
,OP
is+
,-
,*
,/
, or%
. -
marray operatorOP(const marray& lhs, const DataT& rhs)
,OP
is+
,-
,*
,/
, or%
. -
marray& operatorOP(marray& lhs, const marray& rhs)
,OP
is+=
,-=
,*=
,/=
, or%=
. -
marray& operatorOP(marray& lhs, const DataT& rhs)
,OP
is+=
,-=
,*=
,/=
, or%=
. -
marray& operatorOP(marray& v)
,OP
is++
or--
. -
marray operatorOP(marray& v, int)
,OP
is++
or--
. -
marray operatorOP(marray& v)
,OP
is unary+
or-
. -
marray operatorOP(const marray& lhs, const marray& rhs)
,OP
is&
,|
, or^
. -
marray operatorOP(const marray& lhs, const DataT& rhs)
,OP
is&
,|
, or^
. -
marray& operatorOP(marray& lhs, const marray& rhs)
,OP
is&=
,|=
, or^=
. -
marray& operatorOP(marray& lhs, const DataT& rhs)
,OP
is&=
,|=
, or^=
. -
marray<bool, NumElements> operatorOP(const marray& lhs, const marray& rhs)
,OP
is&&
or||
. -
marray<bool, NumElements> operatorOP(const marray& lhs, const DataT& rhs)
,OP
is&&
or||
. -
marray operatorOP(const marray& lhs, const marray& rhs)
,OP
is<<
or>>
. -
marray operatorOP(const marray& lhs, const DataT& rhs)
,OP
is<<
or>>
. -
marray& operatorOP(marray& lhs, const marray& rhs)
,OP
is<<=
or>>=
. -
marray& operatorOP(marray& lhs, const DataT& rhs)
,OP
is<<=
or>>=
. -
marray<bool, NumElements> operatorOP(const marray& lhs, const marray& rhs)
,OP
is==
,!=
,<
,>
,<=
, or>=
. -
marray<bool, NumElements> operatorOP(const marray& lhs, const DataT& rhs)
,OP
is==
,!=
,<
,>
,<=
, or>=
. -
marray operatorOP(const DataT& lhs, const marray& rhs)
,OP
is+
,-
,*
,/
,%
. -
marray operatorOP(const DataT& lhs, const marray& rhs)
,OP
is&
,|
, or^
. -
marray<RET, NumElements> operatorOP(const DataT& lhs, const marray& rhs)
,OP
is&&
or||
. -
marray operatorOP(const DataT& lhs, const marray& rhs)
,OP
is<<
or>>
. -
marray<bool, NumElements> operatorOP(const DataT& lhs, const marray& rhs)
,OP
is==
,!=
,<
,>
,<=
, or>=
. -
marray& operator~(const marray& v)
-
marray<bool, NumElements> operator!(const marray& v)
This section tests Section 4.14.3.2 of the SYCL 2020 specification.
This test is executed for <elems>
and pairings of <type>, <storage-type>
. <elems>
is 2
, 3
, 4
, 8
, and 16
. The pairings <type>
and <storage-type>
are char
and int8_t
, uchar
and uint8_t
, short
and int16_t
, ushort
and uint16_t
, int
and int32_t
, uint
and uint32_t
, long
and int64_t
, ulong
and uint64_t
, both float
, and both bool
. In addition, if the device has aspect::fp64
: both are double
. Furthermore, if the device has aspect::half
: both are half
.
-
Check that
std::is_same_v<m<type><elems>, marray<<storage-type>, <elems>>>
.
This section tests Section 4.14.3.3 of the SYCL 2020 specification.
-
Check that
alignof(marray<DataT, NumElements>)
is equal toalignof(std::array<DataT, NumElements>)
. -
Check that
sizeof(marray<DataT, NumElements>)
is equal tosizeof(std::array<DataT, NumElements>)
. -
Declare
marray<DataT, NumElements>
instancema_inc
with its elements initialized as the sequence1
,2
,3
, etc. Declarestd::array<DataT, NumElements>
instancesa_inc
with its elements initialized as the sequence1
,2
,3
, etc. Check thatstd::memcmp(&ma_inc, &sa_inc, sizeof(ma_inc)) == 0
.