Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for stream class #458

Merged
merged 5 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
131 changes: 70 additions & 61 deletions tests/stream/stream_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2017-2022 Codeplay Software LTD. All Rights Reserved.
// Copyright (c) 2022 The Khronos Group Inc.
// Copyright (c) 2022-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.
Expand Down Expand Up @@ -48,14 +48,12 @@ template <int dims>
void check_nd_item_dims(sycl::range<dims> &range1, sycl::range<dims> &range2) {
auto testQueue = util::get_cts_object::queue();
testQueue.submit([&](sycl::handler &cgh) {

sycl::stream os(2048, 80, cgh);

cgh.parallel_for<class test_kernel_2<dims>>(
sycl::nd_range<dims>(range1, range2),
[=](sycl::nd_item<dims> ndItem) {
sycl::nd_range<dims>(range1, range2), [=](sycl::nd_item<dims> ndItem) {
/** check stream operator for nd_item
*/
*/
check_type(os, ndItem);

// check stream operator for nd_range
Expand All @@ -70,19 +68,18 @@ void check_nd_item_dims(sycl::range<dims> &range1, sycl::range<dims> &range2) {
* Function that create a sycl::stream object and streams item.
*/
template <int dims>
void check_item_dims(sycl::range<dims> &range){
void check_item_dims(sycl::range<dims> &range) {
auto testQueue = util::get_cts_object::queue();
testQueue.submit([&](sycl::handler &cgh) {

sycl::stream os(2048, 80, cgh);

cgh.parallel_for<class test_kernel_3<dims>>(range,
[=](sycl::item<dims> it) {
/** check stream operator for
* item
*/
check_type(os, it);
});
[=](sycl::item<dims> it) {
/** check stream operator for
* item
*/
check_type(os, it);
});
});

testQueue.wait_and_throw();
Expand All @@ -92,21 +89,21 @@ void check_item_dims(sycl::range<dims> &range){
* Function that create a sycl::stream object and streams group and h_item.
*/
template <int dims>
void check_group_h_item_dims(sycl::range<dims> &range1, sycl::range<dims> &range2) {
void check_group_h_item_dims(sycl::range<dims> &range1,
sycl::range<dims> &range2) {
auto testQueue = util::get_cts_object::queue();
testQueue.submit([&](sycl::handler &cgh) {

sycl::stream os(2048, 80, cgh);

cgh.parallel_for_work_group<class test_kernel_4<dims>>(range1, range2,
[=](const sycl::group<dims> gp) {
cgh.parallel_for_work_group<class test_kernel_4<dims>>(
range1, range2, [=](const sycl::group<dims> gp) {
/** check stream operator for sycl::group
*/
*/
check_type(os, gp);

gp.parallel_for_work_item([&](sycl::h_item<dims> hit) {
/** check stream operator for sycl::h_item
*/
*/
check_type(os, hit);
});
});
Expand All @@ -116,7 +113,7 @@ void check_group_h_item_dims(sycl::range<dims> &range1, sycl::range<dims> &range
}

/** test sycl::stream interface
*/
*/
class TEST_NAME : public util::test_base {
public:
/** return information about this test
Expand All @@ -130,7 +127,7 @@ class TEST_NAME : public util::test_base {
void run(util::logger &log) override {
{
/** check sycl::stream_manipulator
*/
*/
check_enum_class_value(sycl::stream_manipulator::dec);
check_enum_class_value(sycl::stream_manipulator::hex);
check_enum_class_value(sycl::stream_manipulator::oct);
Expand All @@ -146,29 +143,60 @@ class TEST_NAME : public util::test_base {
check_enum_class_value(sycl::stream_manipulator::flush);

/** Check stream interface
*/
*/
{
auto testQueue = util::get_cts_object::queue();
testQueue.submit([&](sycl::handler &cgh) {

sycl::stream os(2048, 80, cgh);

/** check get_size()
*/
*/
#ifdef SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS
{
auto size = os.get_size();
check_return_type<size_t>(log, size,
"sycl::context::get_size()");
check_return_type<size_t>(log, size, "sycl::stream::get_size()");
}
#endif // SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS

/** check get_max_statement_size()
*/
/** check size()
*/
#ifndef SYCL_CTS_COMPILING_WITH_DPCPP
{
auto size = os.size();
check_return_type<size_t>(log, size, "sycl::stream::size()");
CHECK(noexcept(os.size()));
}
#else
WARN(
bader marked this conversation as resolved.
Show resolved Hide resolved
"DPCPP does not define sycl::stream::size(). "
"Skipping the test case.");
#endif

/** get_max_statement_size()
*/
#ifdef SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS
{
auto maxStatementSize = os.get_max_statement_size();
check_return_type<size_t>(log, maxStatementSize,
"sycl::stream::get_max_statement_size()");
}
#endif // SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS

/** check get_work_item_buffer_size()
*/
#ifndef SYCL_CTS_COMPILING_WITH_DPCPP
{
auto workItemBufferSize = os.get_work_item_buffer_size();
check_return_type<size_t>(
log, maxStatementSize,
"sycl::context::get_max_statement_size()");
log, workItemBufferSize,
"sycl::stream::get_work_item_buffer_size()");
}
#else
WARN(
"DPCPP does not define "
"sycl::stream::get_work_item_buffer_size(). "
"Skipping the test case.");
#endif

cgh.single_task<class test_kernel_0>([=]() {});
});
Expand All @@ -177,17 +205,15 @@ class TEST_NAME : public util::test_base {
}

/** check stream operator for supported types
*/
*/
{
auto testQueue = util::get_cts_object::queue();
testQueue.submit([&](sycl::handler &cgh) {

sycl::stream os(2048, 80, cgh);

cgh.single_task<class test_kernel_1>([=]() {

/** check stream operator for basic types
*/
*/
check_type(os, "hello world!");
check_type(os, const_cast<char *>("hello world!"));
check_all_vec_dims(os, char('c'));
Expand All @@ -209,28 +235,13 @@ class TEST_NAME : public util::test_base {
int a = 5;
int *aPtr = &a;
check_type(os, aPtr);
const int * aConstPtr = &a;
const int *aConstPtr = &a;
check_type(os, aConstPtr);
auto multiPtr = sycl::private_ptr<int>(aPtr);
check_type(os, multiPtr);

/** check stream operator for cl types
*/
check_all_vec_dims(os, cl_char('c'));
check_all_vec_dims(os, static_cast<cl_uchar>('c'));
check_all_vec_dims(os, cl_int(5));
check_all_vec_dims(os, static_cast<cl_uint>(5));
check_all_vec_dims(os, cl_short(5));
check_all_vec_dims(os, static_cast<cl_ushort>(5));
check_all_vec_dims(os, cl_long(5));
check_all_vec_dims(os, static_cast<cl_ulong>(5));
check_all_vec_dims(os, cl_float(5.5f));
check_type(os, static_cast<cl_bool>(true));

/** check stream operator for sycl types
*/
check_all_vec_dims(os, sycl::byte(72));

*/
check_type(os, sycl::id<1>(1));
check_type(os, sycl::id<2>(1, 2));
check_type(os, sycl::id<3>(1, 2, 3));
Expand All @@ -239,15 +250,15 @@ class TEST_NAME : public util::test_base {
check_type(os, sycl::range<2>(1, 2));
check_type(os, sycl::range<3>(1, 2, 3));

check_type(os, sycl::nd_range<1>(sycl::range<1>(2),
sycl::range<1>(1)));
check_type(os,
sycl::nd_range<1>(sycl::range<1>(2), sycl::range<1>(1)));
check_type(os, sycl::nd_range<2>(sycl::range<2>(2, 4),
sycl::range<2>(1, 2)));
sycl::range<2>(1, 2)));
check_type(os, sycl::nd_range<3>(sycl::range<3>(2, 4, 1),
sycl::range<3>(1, 2, 1)));
sycl::range<3>(1, 2, 1)));

/** check stream operator for manipulators
*/
*/
os << sycl::endl;
os << sycl::setprecision(5) << float(5.0f);
os << sycl::setw(3) << float(5.0f);
Expand All @@ -270,7 +281,7 @@ class TEST_NAME : public util::test_base {
}

/** check stream operator for sycl::nd_item
*/
*/
{
sycl::range<1> r11(2);
sycl::range<1> r12(1);
Expand All @@ -283,11 +294,10 @@ class TEST_NAME : public util::test_base {
sycl::range<3> r31(2, 4, 1);
sycl::range<3> r32(1, 2, 1);
check_nd_item_dims(r31, r32);

}

/** check stream operator for sycl::item
*/
*/
{
sycl::range<1> r1(4);
check_item_dims(r1);
Expand All @@ -300,7 +310,7 @@ class TEST_NAME : public util::test_base {
}

/** check stream operator for sycl::group and sycl::h_item
*/
*/
{
sycl::range<1> r11(4);
sycl::range<1> r12(1);
Expand All @@ -313,7 +323,6 @@ class TEST_NAME : public util::test_base {
sycl::range<3> r31(4, 2, 1);
sycl::range<3> r32(1, 1, 1);
check_group_h_item_dims(r31, r32);

}
}
}
Expand Down
15 changes: 7 additions & 8 deletions tests/stream/stream_api_fp16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using namespace sycl_cts;
class test_kernel;
bader marked this conversation as resolved.
Show resolved Hide resolved

/** test sycl::stream interface
*/
*/
class TEST_NAME : public util::test_base {
public:
/** return information about this test
Expand All @@ -49,17 +49,16 @@ class TEST_NAME : public util::test_base {

if (!testQueue.get_device().has(sycl::aspect::fp16)) {
log.note(
"Device does not support half precision floating point operations");
return;
}
"Device does not support half precision floating point "
"operations");
return;
}

testQueue.submit([&](sycl::handler &cgh) {
sycl::stream os(2048, 80, cgh);

cgh.single_task<class test_kernel>([=]() {
check_all_vec_dims(os, sycl::half(0.2f));
check_all_vec_dims(os, sycl::cl_half(0.3f));
});
cgh.single_task<class test_kernel>(
[=]() { check_all_vec_dims(os, sycl::half(0.2f)); });
});

testQueue.wait_and_throw();
Expand Down
16 changes: 7 additions & 9 deletions tests/stream/stream_api_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SYCL 2020 Conformance Test Suite
//
// Provides stream tests for double and sycl::cl_double
// Provides stream tests for double
//
*******************************************************************************/

Expand All @@ -17,7 +17,7 @@ using namespace sycl_cts;
class test_kernel;

/** test sycl::stream interface
*/
*/
class TEST_NAME : public util::test_base {
public:
/** return information about this test
Expand All @@ -30,23 +30,21 @@ class TEST_NAME : public util::test_base {
*/
void run(util::logger &log) override {
{
// Check stream operator for sycl::cl_double and double
// Check stream operator for double
auto testQueue = util::get_cts_object::queue();

if (!testQueue.get_device().has(sycl::aspect::fp64)) {
log.note(
"Device does not support double precision floating point operations");
"Device does not support double precision floating point "
"operations");
return;
}

testQueue.submit([&](sycl::handler &cgh) {

sycl::stream os(2048, 80, cgh);

cgh.single_task<class test_kernel>([=]() {
check_all_vec_dims(os, double(5.5));
check_all_vec_dims(os, sycl::cl_double(5.5));
});
cgh.single_task<class test_kernel>(
[=]() { check_all_vec_dims(os, double(5.5)); });
});

testQueue.wait_and_throw();
Expand Down