Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ endfunction()
function(get_no_vec_alias_type OUT_LIST)
set(NO_VEC_ALIAS_LIST "")
list(APPEND NO_VEC_ALIAS_LIST sycl::byte)
list(APPEND NO_VEC_ALIAS_LIST std::byte)

set(${OUT_LIST} ${${OUT_LIST}} ${NO_VEC_ALIAS_LIST} PARENT_SCOPE)
endfunction()
Expand Down
68 changes: 46 additions & 22 deletions tests/common/common_python_vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Data:
standard_sizes = [1, 2, 3, 4, 8, 16]
standard_types = [
'bool', 'char', 'short', 'int', 'long', 'long long', 'float',
'double', 'sycl::half'
'double', 'sycl::half', 'std::byte'
]
standard_type_dict = {
(True, 'bool'): 'bool',
Expand All @@ -46,7 +46,8 @@ class Data:
(True, 'long long'): 'long long',
(True, 'float'): 'float',
(True, 'double'): 'double',
(True, 'sycl::half'): 'sycl::half'
(True, 'sycl::half'): 'sycl::half',
(False, 'std::byte'): 'std::byte'
}

fixed_width_types = [
Expand Down Expand Up @@ -92,7 +93,8 @@ class Data:
'bool': 'false',
'float': '0.0f',
'double': '0.0',
'sycl::half': '0.0f'
'sycl::half': '0.0f',
'std::byte': 'std::byte{0}'
})
vec_name_dict = {
1: 'One',
Expand Down Expand Up @@ -245,7 +247,8 @@ def remove_namespaces_whitespaces(type_str):
Clear type name from namespaces and whitespaces
"""
return type_str.replace('sycl::', '').replace(
' ', '_').replace('std::', '')
' ', '_').replace('std::byte', 'std_byte').replace(
'std::', '')

def wrap_with_kernel(type_str, kernel_name, test_name, test_string):
"""
Expand Down Expand Up @@ -338,7 +341,7 @@ def wrap_with_extension_checks(type_str, test_string):
return test_string


def append_fp_postfix(type_str, input_val_list):
def make_fp_or_byte_explicit(type_str, input_val_list):
"""Generates and returns a new list from the input, with .0f or .0 appended
to each value in the list if type_str is 'float', 'double' or 'sycl::half'"""
result_val_list = []
Expand All @@ -348,6 +351,8 @@ def append_fp_postfix(type_str, input_val_list):
result_val_list.append(val + '.0f')
elif type_str == 'double':
result_val_list.append(val + '.0')
elif type_str == 'std::byte':
result_val_list.append('std::byte{{{}}}'.format(val))
else:
result_val_list.append(val)
return result_val_list
Expand All @@ -359,7 +364,7 @@ def generate_value_list(type_str, size):
vec_val_list = []
for val in Data.vals_list_dict[size]:
vec_val_list.append(val)
vec_val_list = append_fp_postfix(type_str, vec_val_list)
vec_val_list = make_fp_or_byte_explicit(type_str, vec_val_list)
vec_val_string = ', '.join(vec_val_list)
return str(vec_val_string)

Expand Down Expand Up @@ -419,12 +424,30 @@ def get_ifdef_string(source, type_str):
source = source.replace('$ENDIF', '')
return source

def replace_ifbyte_strings(source, type_str):
if type_str == 'std::byte':
source = source.replace('$EXCLUDE_IF_SIMSYCL_BYTE_BEGIN',
'#if !SYCL_CTS_COMPILING_WITH_SIMSYCL')
source = source.replace('$EXCLUDE_IF_SIMSYCL_BYTE_END',
'#endif')
source = source.replace('$FAIL_IF_SIMSYCL_BYTE',
'''#if SYCL_CTS_COMPILING_WITH_SIMSYCL
FAIL_CHECK("SimSYCL doesn't support sycl::vec<N, std::byte>");
#endif''')
else:
source = source.replace('$EXCLUDE_IF_SIMSYCL_BYTE_BEGIN', '')
source = source.replace('$EXCLUDE_IF_SIMSYCL_BYTE_END', '')
source = source.replace('$FAIL_IF_SIMSYCL_BYTE', '')
return source

def write_source_file(test_str, func_calls, test_name, input_file, output_file,
type_str):

with open(input_file, 'r') as source_file:
source = source_file.read()

source = replace_ifbyte_strings(source, type_str)

source = replace_string_in_source_string(source,
remove_namespaces_whitespaces(type_str),
'$TYPE_NAME')
Expand All @@ -444,6 +467,8 @@ def get_types():
if (base_type == 'float' or base_type == 'double' or base_type == 'bool'
or base_type == 'sycl::half') and sign is False:
continue
if base_type == 'std::byte' and sign is True:
continue
types.append(Data.standard_type_dict[(sign, base_type)])

for base_type in Data.fixed_width_types:
Expand Down Expand Up @@ -581,7 +606,6 @@ def substitute_swizzles_templates(type_str, size, index_subset, value_subset, co
for index, value in zip(index_subset, value_subset):
index_list.append(index)
val_list.append(value)
val_list = append_fp_postfix(type_str, val_list)
index_string = ''.join(index_list)
test_string = SwizzleData.swizzle_template.substitute(
name=Data.vec_name_dict[size],
Expand Down Expand Up @@ -624,6 +648,7 @@ def substitute_swizzles_templates(type_str, size, index_subset, value_subset, co

def gen_swizzle_test(type_str, convert_type_str, as_type_str, size, num_batches, batch_index):
string = ''
val_list = make_fp_or_byte_explicit(type_str, Data.vals_list_dict[size])
if size > 4:
test_string = SwizzleData.swizzle_full_test_template.substitute(
name=Data.vec_name_dict[size],
Expand All @@ -639,17 +664,15 @@ def gen_swizzle_test(type_str, convert_type_str, as_type_str, size, num_batches,
swap_pairs(Data.swizzle_elem_list_dict[size])),
reverse_order_reversed_pair_swiz_indexes=', '.join(
swap_pairs(Data.swizzle_elem_list_dict[size][::-1])),
in_order_vals=', '.join(Data.vals_list_dict[size]),
reversed_vals=', '.join(Data.vals_list_dict[size][::-1]),
in_order_pair_vals=', '.join(
swap_pairs(Data.vals_list_dict[size])),
reverse_order_pair_vals=', '.join(
swap_pairs(Data.vals_list_dict[size][::-1])))
in_order_vals=', '.join(val_list),
reversed_vals=', '.join(val_list[::-1]),
in_order_pair_vals=', '.join(swap_pairs(val_list)),
reverse_order_pair_vals=', '.join(swap_pairs(val_list[::-1])))
string += wrap_with_swizzle_kernel(
type_str, str(size), ', '.join(Data.vals_list_dict[size]),
', '.join(Data.vals_list_dict[size][::-1]),
', '.join(swap_pairs(Data.vals_list_dict[size])),
', '.join(swap_pairs(Data.vals_list_dict[size][::-1])),
type_str, str(size), ', '.join(val_list),
', '.join(val_list[::-1]),
', '.join(swap_pairs(val_list)),
', '.join(swap_pairs(val_list[::-1])),
'ELEM_KERNEL_' + type_str + str(size) +
''.join(Data.swizzle_elem_list_dict[size][:size]).replace(
'sycl::elem::', ''),
Expand All @@ -672,7 +695,7 @@ def gen_swizzle_test(type_str, convert_type_str, as_type_str, size, num_batches,
product(
Data.swizzle_xyzw_list_dict[size][:size],
repeat=length),
product(Data.vals_list_dict[size][:size], repeat=length)):
product(val_list[:size], repeat=length)):
total_tests += 1
batch_size = ceil(total_tests / num_batches)
cur_index = 0
Expand All @@ -682,7 +705,7 @@ def gen_swizzle_test(type_str, convert_type_str, as_type_str, size, num_batches,
product(
Data.swizzle_xyzw_list_dict[size][:size],
repeat=length),
product(Data.vals_list_dict[size][:size], repeat=length)):
product(val_list[:size], repeat=length)):
cur_batch = floor(cur_index / batch_size)
if cur_batch > batch_index:
break
Expand All @@ -700,7 +723,7 @@ def gen_swizzle_test(type_str, convert_type_str, as_type_str, size, num_batches,
Data.swizzle_rgba_list_dict[size][:size],
repeat=length),
product(
Data.vals_list_dict[size][:size], repeat=length)):
val_list[:size], repeat=length)):
total_tests += 1
batch_size = ceil(total_tests / num_batches)
cur_index = 0
Expand All @@ -710,8 +733,7 @@ def gen_swizzle_test(type_str, convert_type_str, as_type_str, size, num_batches,
product(
Data.swizzle_rgba_list_dict[size][:size],
repeat=length),
product(
Data.vals_list_dict[size][:size], repeat=length)):
product(val_list[:size], repeat=length)):
cur_batch = floor(cur_index / batch_size)
if cur_batch > batch_index:
break
Expand All @@ -727,6 +749,8 @@ def write_swizzle_source_file(swizzles, input_file, output_file, type_str):
with open(input_file, 'r') as source_file:
source = source_file.read()

source = replace_ifbyte_strings(source, type_str)

source = replace_string_in_source_string(source,
remove_namespaces_whitespaces(type_str),
'$TYPE_NAME')
Expand Down
16 changes: 8 additions & 8 deletions tests/common/common_vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
// lo()
{
sycl::vec<vecType, mid> loVec{inputVec.lo()};
vecType loVals[mid] = {0};
vecType loVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; i++) {
loVals[i] = vals[i];
}
Expand All @@ -523,7 +523,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
{
sycl::vec<vecType, mid> loVec;
DO_OPERATION_ON_SWIZZLE(N, inputVec, loVec, lo());
vecType loVals[mid] = {0};
vecType loVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; i++) {
loVals[i] = vals[i];
}
Expand All @@ -537,7 +537,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
{
// hi()
sycl::vec<vecType, mid> hiVec{inputVec.hi()};
vecType hiVals[mid] = {0};
vecType hiVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; i++) {
hiVals[i] = vals[i + mid];
}
Expand All @@ -549,7 +549,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
// hi()
sycl::vec<vecType, mid> hiVec;
DO_OPERATION_ON_SWIZZLE(N, inputVec, hiVec, hi());
vecType hiVals[mid] = {0};
vecType hiVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; i++) {
hiVals[i] = vals[i + mid];
}
Expand All @@ -564,7 +564,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
{
// odd()
sycl::vec<vecType, mid> oddVec{inputVec.odd()};
vecType oddVals[mid] = {0};
vecType oddVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; ++i) {
oddVals[i] = vals[i * 2 + 1];
}
Expand All @@ -576,7 +576,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
// odd()
sycl::vec<vecType, mid> oddVec;
DO_OPERATION_ON_SWIZZLE(N, inputVec, oddVec, odd());
vecType oddVals[mid] = {0};
vecType oddVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; ++i) {
oddVals[i] = vals[i * 2 + 1];
}
Expand All @@ -588,7 +588,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
// even()
{
sycl::vec<vecType, mid> evenVec{inputVec.even()};
vecType evenVals[mid] = {0};
vecType evenVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; ++i) {
evenVals[i] = vals[i * 2];
}
Expand All @@ -599,7 +599,7 @@ bool check_lo_hi_odd_even(sycl::vec<vecType, N> inputVec, vecType* vals) {
{
sycl::vec<vecType, mid> evenVec;
DO_OPERATION_ON_SWIZZLE(N, inputVec, evenVec, even());
vecType evenVals[mid] = {0};
vecType evenVals[mid] = {vecType{0}};
for (size_t i = 0; i < mid; ++i) {
evenVals[i] = vals[i * 2];
}
Expand Down
5 changes: 5 additions & 0 deletions tests/common/vector.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ class TEST_NAME : public util::test_base {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

$EXCLUDE_IF_SIMSYCL_BYTE_BEGIN
$TEST_FUNCS
$EXCLUDE_IF_SIMSYCL_BYTE_END

/** execute the test
*/
void run(util::logger &log) override {

$EXCLUDE_IF_SIMSYCL_BYTE_BEGIN
$FUNC_CALLS
$EXCLUDE_IF_SIMSYCL_BYTE_END
$FAIL_IF_SIMSYCL_BYTE

}
};
Expand Down
5 changes: 5 additions & 0 deletions tests/common/vector_swizzle_assignment.template
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ class TEST_NAME : public util::test_base {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

$EXCLUDE_IF_SIMSYCL_BYTE_BEGIN
$TEST_FUNCS
$EXCLUDE_IF_SIMSYCL_BYTE_END

/** execute the test
*/
void run(util::logger &log) override {

$EXCLUDE_IF_SIMSYCL_BYTE_BEGIN
$FUNC_CALLS
$EXCLUDE_IF_SIMSYCL_BYTE_END
$FAIL_IF_SIMSYCL_BYTE

}
};
Expand Down
3 changes: 3 additions & 0 deletions tests/common/vector_swizzles.template
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class TEST_NAME : public util::test_base {
*/
void run(util::logger &log) override {
{
$EXCLUDE_IF_SIMSYCL_BYTE_BEGIN
auto testQueue = util::get_cts_object::queue();
{
auto testDevice = testQueue.get_device();
Expand All @@ -79,6 +80,8 @@ class TEST_NAME : public util::test_base {
}

testQueue.wait_and_throw();
$EXCLUDE_IF_SIMSYCL_BYTE_END
$FAIL_IF_SIMSYCL_BYTE
}
}
};
Expand Down
7 changes: 4 additions & 3 deletions tests/vector_api/generate_vector_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import argparse
from string import Template
sys.path.append('../common/')
from common_python_vec import (Data, ReverseData, append_fp_postfix, wrap_with_kernel,
from common_python_vec import (Data, ReverseData, make_fp_or_byte_explicit, wrap_with_kernel,
wrap_with_test_func, make_func_call,
write_source_file, get_types, cast_to_bool)

Expand Down Expand Up @@ -77,8 +77,9 @@


def gen_checks(type_str, size):
vals_list = append_fp_postfix(type_str, Data.vals_list_dict[size])
if 'double' in type_str or 'half' in type_str or 'float' in type_str:
vals_list = make_fp_or_byte_explicit(type_str, Data.vals_list_dict[size])
if type_str in ('double', 'float', 'half'):
# Want fractions/sign...
vals_list = Data.vals_list_dict_float[size]
reverse_vals_list = vals_list[::-1]
kernel_name = 'KERNEL_API_' + type_str + str(size)
Expand Down
8 changes: 4 additions & 4 deletions tests/vector_constructors/generate_vector_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
sys.path.append('../common/')
from common_python_vec import (Data, ReverseData, wrap_with_kernel, wrap_with_test_func,
make_func_call, write_source_file, get_types, cast_to_bool,
append_fp_postfix)
make_fp_or_byte_explicit)

TEST_NAME = 'CONSTRUCTORS'

Expand All @@ -43,7 +43,7 @@
""")

explicit_constructor_vec_template = Template(
""" const ${type} val = ${val};
""" const ${type} val{${val}};
${type} vals[] = {${vals}};
auto test = sycl::vec<${type}, ${size}>(val);
if (!check_equal_type_bool<sycl::vec<${type}, ${size}>>(test)) {
Expand Down Expand Up @@ -151,8 +151,8 @@ def generate_mixed(type_str, size):
return ''
input_vec_size = size//2
values_size = size - input_vec_size
vals_list1 = append_fp_postfix(type_str, Data.vals_list_dict[size][:input_vec_size])
vals_list2 = append_fp_postfix(type_str, Data.vals_list_dict[size][-values_size:])
vals_list1 = make_fp_or_byte_explicit(type_str, Data.vals_list_dict[size][:input_vec_size])
vals_list2 = make_fp_or_byte_explicit(type_str, Data.vals_list_dict[size][-values_size:])
test_string = mixed_constructor_vec_template.substitute(
type=type_str,
size=size,
Expand Down
Loading