From 4308c960ad36a62d47ced888c1b9ac5651b39bc9 Mon Sep 17 00:00:00 2001 From: Nol Moonen Date: Thu, 8 Dec 2022 15:52:14 +0100 Subject: [PATCH 1/5] add stream test --- tests/stream/stream_api.cpp | 58 ++++++++++++++++++---------- tests/stream/stream_api_fp16.cpp | 1 - tests/stream/stream_api_fp64.cpp | 5 +-- tests/stream/stream_constructors.cpp | 21 ++++++++++ 4 files changed, 60 insertions(+), 25 deletions(-) diff --git a/tests/stream/stream_api.cpp b/tests/stream/stream_api.cpp index 351c62fb7..d8b67da4c 100644 --- a/tests/stream/stream_api.cpp +++ b/tests/stream/stream_api.cpp @@ -154,21 +154,52 @@ class TEST_NAME : public util::test_base { sycl::stream os(2048, 80, cgh); /** check get_size() - */ + */ +#ifdef SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS { auto size = os.get_size(); - check_return_type(log, size, - "sycl::context::get_size()"); + check_return_type(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(log, size, "sycl::stream::size()"); + CHECK(noexcept(os.size())); + } +#else + WARN( + "DPCPP does not define sycl::stream:size(). " + "Skipping the test case."); +#endif + + /** get_max_statement_size get_size() + */ +#ifdef SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS { auto maxStatementSize = os.get_max_statement_size(); + check_return_type(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 maxStatementSize = os.get_work_item_buffer_size(); check_return_type( log, maxStatementSize, - "sycl::context::get_max_statement_size()"); + "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([=]() {}); }); @@ -214,23 +245,8 @@ class TEST_NAME : public util::test_base { auto multiPtr = sycl::private_ptr(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('c')); - check_all_vec_dims(os, cl_int(5)); - check_all_vec_dims(os, static_cast(5)); - check_all_vec_dims(os, cl_short(5)); - check_all_vec_dims(os, static_cast(5)); - check_all_vec_dims(os, cl_long(5)); - check_all_vec_dims(os, static_cast(5)); - check_all_vec_dims(os, cl_float(5.5f)); - check_type(os, static_cast(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)); diff --git a/tests/stream/stream_api_fp16.cpp b/tests/stream/stream_api_fp16.cpp index b37995c80..3d7dde6f9 100644 --- a/tests/stream/stream_api_fp16.cpp +++ b/tests/stream/stream_api_fp16.cpp @@ -58,7 +58,6 @@ class TEST_NAME : public util::test_base { cgh.single_task([=]() { check_all_vec_dims(os, sycl::half(0.2f)); - check_all_vec_dims(os, sycl::cl_half(0.3f)); }); }); diff --git a/tests/stream/stream_api_fp64.cpp b/tests/stream/stream_api_fp64.cpp index 9a60ba262..bd932c563 100644 --- a/tests/stream/stream_api_fp64.cpp +++ b/tests/stream/stream_api_fp64.cpp @@ -2,7 +2,7 @@ // // SYCL 2020 Conformance Test Suite // -// Provides stream tests for double and sycl::cl_double +// Provides stream tests for double // *******************************************************************************/ @@ -30,7 +30,7 @@ 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)) { @@ -45,7 +45,6 @@ class TEST_NAME : public util::test_base { cgh.single_task([=]() { check_all_vec_dims(os, double(5.5)); - check_all_vec_dims(os, sycl::cl_double(5.5)); }); }); diff --git a/tests/stream/stream_constructors.cpp b/tests/stream/stream_constructors.cpp index 794c7470e..2e4d171cb 100644 --- a/tests/stream/stream_constructors.cpp +++ b/tests/stream/stream_constructors.cpp @@ -80,6 +80,27 @@ class TEST_NAME : public util::test_base { }); } + /** check (size_t, size_t, sycl::handler&, sycl::property_list&) + * constructor + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::property_list property_list{}; + sycl::stream os(bufferSize, maxStatementSize, handler, property_list); + + if (os.get_size() != bufferSize) { + FAIL(log, "sycl::context::get_size() returned an incorrect value."); + } + if (os.get_max_statement_size() != maxStatementSize) { + FAIL(log, + "sycl::context::get_max_statement_size() returned an " + "incorrect value."); + } + + handler.single_task(stream_kernel{}); + }); + } + /** check copy constructor */ { From 990a47a07fd14179b19dc47805277811df3542ee Mon Sep 17 00:00:00 2001 From: Nol Moonen Date: Wed, 11 Jan 2023 10:42:55 +0100 Subject: [PATCH 2/5] apply formatting --- tests/stream/stream_api.cpp | 68 ++++++++++++++------------------ tests/stream/stream_api_fp16.cpp | 14 +++---- tests/stream/stream_api_fp64.cpp | 11 +++--- 3 files changed, 42 insertions(+), 51 deletions(-) diff --git a/tests/stream/stream_api.cpp b/tests/stream/stream_api.cpp index d8b67da4c..0a2f04434 100644 --- a/tests/stream/stream_api.cpp +++ b/tests/stream/stream_api.cpp @@ -48,14 +48,12 @@ template void check_nd_item_dims(sycl::range &range1, sycl::range &range2) { auto testQueue = util::get_cts_object::queue(); testQueue.submit([&](sycl::handler &cgh) { - sycl::stream os(2048, 80, cgh); cgh.parallel_for>( - sycl::nd_range(range1, range2), - [=](sycl::nd_item ndItem) { + sycl::nd_range(range1, range2), [=](sycl::nd_item ndItem) { /** check stream operator for nd_item - */ + */ check_type(os, ndItem); // check stream operator for nd_range @@ -70,19 +68,18 @@ void check_nd_item_dims(sycl::range &range1, sycl::range &range2) { * Function that create a sycl::stream object and streams item. */ template -void check_item_dims(sycl::range &range){ +void check_item_dims(sycl::range &range) { auto testQueue = util::get_cts_object::queue(); testQueue.submit([&](sycl::handler &cgh) { - sycl::stream os(2048, 80, cgh); cgh.parallel_for>(range, - [=](sycl::item it) { - /** check stream operator for - * item - */ - check_type(os, it); - }); + [=](sycl::item it) { + /** check stream operator for + * item + */ + check_type(os, it); + }); }); testQueue.wait_and_throw(); @@ -92,21 +89,21 @@ void check_item_dims(sycl::range &range){ * Function that create a sycl::stream object and streams group and h_item. */ template -void check_group_h_item_dims(sycl::range &range1, sycl::range &range2) { +void check_group_h_item_dims(sycl::range &range1, + sycl::range &range2) { auto testQueue = util::get_cts_object::queue(); testQueue.submit([&](sycl::handler &cgh) { - sycl::stream os(2048, 80, cgh); - cgh.parallel_for_work_group>(range1, range2, - [=](const sycl::group gp) { + cgh.parallel_for_work_group>( + range1, range2, [=](const sycl::group gp) { /** check stream operator for sycl::group - */ + */ check_type(os, gp); gp.parallel_for_work_item([&](sycl::h_item hit) { /** check stream operator for sycl::h_item - */ + */ check_type(os, hit); }); }); @@ -116,7 +113,7 @@ void check_group_h_item_dims(sycl::range &range1, sycl::range &range } /** test sycl::stream interface -*/ + */ class TEST_NAME : public util::test_base { public: /** return information about this test @@ -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); @@ -146,11 +143,10 @@ 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() @@ -208,17 +204,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([=]() { - /** check stream operator for basic types - */ + */ check_type(os, "hello world!"); check_type(os, const_cast("hello world!")); check_all_vec_dims(os, char('c')); @@ -240,13 +234,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(aPtr); check_type(os, multiPtr); /** check stream operator for sycl types - */ + */ check_type(os, sycl::id<1>(1)); check_type(os, sycl::id<2>(1, 2)); check_type(os, sycl::id<3>(1, 2, 3)); @@ -255,15 +249,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); @@ -286,7 +280,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); @@ -299,11 +293,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); @@ -316,7 +309,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); @@ -329,7 +322,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); - } } } diff --git a/tests/stream/stream_api_fp16.cpp b/tests/stream/stream_api_fp16.cpp index 3d7dde6f9..7e0af9223 100644 --- a/tests/stream/stream_api_fp16.cpp +++ b/tests/stream/stream_api_fp16.cpp @@ -30,7 +30,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 @@ -49,16 +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([=]() { - check_all_vec_dims(os, sycl::half(0.2f)); - }); + cgh.single_task( + [=]() { check_all_vec_dims(os, sycl::half(0.2f)); }); }); testQueue.wait_and_throw(); diff --git a/tests/stream/stream_api_fp64.cpp b/tests/stream/stream_api_fp64.cpp index bd932c563..aa6a285c7 100644 --- a/tests/stream/stream_api_fp64.cpp +++ b/tests/stream/stream_api_fp64.cpp @@ -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 @@ -35,17 +35,16 @@ class TEST_NAME : public util::test_base { 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([=]() { - check_all_vec_dims(os, double(5.5)); - }); + cgh.single_task( + [=]() { check_all_vec_dims(os, double(5.5)); }); }); testQueue.wait_and_throw(); From a2977be8e1eb31e0d4033e8634e9db9f776b5ff8 Mon Sep 17 00:00:00 2001 From: Nol Moonen Date: Fri, 13 Jan 2023 13:00:10 +0100 Subject: [PATCH 3/5] remove deprecated api from constructor test, fix typo --- tests/stream/stream_api.cpp | 11 +-- tests/stream/stream_constructors.cpp | 117 +++++++++++++-------------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/tests/stream/stream_api.cpp b/tests/stream/stream_api.cpp index 0a2f04434..3dace13af 100644 --- a/tests/stream/stream_api.cpp +++ b/tests/stream/stream_api.cpp @@ -168,11 +168,11 @@ class TEST_NAME : public util::test_base { } #else WARN( - "DPCPP does not define sycl::stream:size(). " + "DPCPP does not define sycl::stream::size(). " "Skipping the test case."); #endif - /** get_max_statement_size get_size() + /** get_max_statement_size() */ #ifdef SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS { @@ -186,14 +186,15 @@ class TEST_NAME : public util::test_base { */ #ifndef SYCL_CTS_COMPILING_WITH_DPCPP { - auto maxStatementSize = os.get_work_item_buffer_size(); + auto workItemBufferSize = os.get_work_item_buffer_size(); check_return_type( - log, maxStatementSize, + log, workItemBufferSize, "sycl::stream::get_work_item_buffer_size()"); } #else WARN( - "DPCPP does not define sycl::stream:get_work_item_buffer_size(). " + "DPCPP does not define " + "sycl::stream::get_work_item_buffer_size(). " "Skipping the test case."); #endif diff --git a/tests/stream/stream_constructors.cpp b/tests/stream/stream_constructors.cpp index 2e4d171cb..f2db40721 100644 --- a/tests/stream/stream_constructors.cpp +++ b/tests/stream/stream_constructors.cpp @@ -32,7 +32,7 @@ struct stream_kernel { }; /** tests the constructors for sycl::stream -*/ + */ class TEST_NAME : public util::test_base { public: /** return information about this test @@ -45,9 +45,9 @@ class TEST_NAME : public util::test_base { * otherwise */ bool areEqual(sycl::stream &osA, sycl::stream &osB) { - if (osA.get_max_statement_size() == osB.get_max_statement_size() || + if (osA.get_work_item_buffer_size() == osB.get_work_item_buffer_size() || osA.get_precision() == osB.get_precision() || - osA.get_size() == osB.get_size() || + osA.size() == osB.size() || osA.get_stream_mode() == osB.get_stream_mode()) return false; return true; @@ -58,21 +58,20 @@ class TEST_NAME : public util::test_base { { auto queue = util::get_cts_object::queue(); size_t bufferSize = 2048; - size_t maxStatementSize = 80; + size_t workItemBufferSize = 80; /** check (size_t, size_t, sycl::handler&) constructor - */ + */ { queue.submit([&](sycl::handler &handler) { - sycl::stream os(bufferSize, maxStatementSize, handler); + sycl::stream os(bufferSize, workItemBufferSize, handler); - if (os.get_size() != bufferSize) { - FAIL(log, - "sycl::context::get_size() returned an incorrect value."); + if (os.size() != bufferSize) { + FAIL(log, "sycl::context::size() returned an incorrect value."); } - if (os.get_max_statement_size() != maxStatementSize) { + if (os.get_work_item_buffer_size() != workItemBufferSize) { FAIL(log, - "sycl::context::get_max_statement_size() returned an " + "sycl::context::get_work_item_buffer_size() returned an " "incorrect value."); } @@ -86,14 +85,15 @@ class TEST_NAME : public util::test_base { { queue.submit([&](sycl::handler &handler) { sycl::property_list property_list{}; - sycl::stream os(bufferSize, maxStatementSize, handler, property_list); + sycl::stream os(bufferSize, workItemBufferSize, handler, + property_list); - if (os.get_size() != bufferSize) { - FAIL(log, "sycl::context::get_size() returned an incorrect value."); + if (os.size() != bufferSize) { + FAIL(log, "sycl::context::size() returned an incorrect value."); } - if (os.get_max_statement_size() != maxStatementSize) { + if (os.get_work_item_buffer_size() != workItemBufferSize) { FAIL(log, - "sycl::context::get_max_statement_size() returned an " + "sycl::context::get_work_item_buffer_size() returned an " "incorrect value."); } @@ -102,36 +102,37 @@ class TEST_NAME : public util::test_base { } /** check copy constructor - */ + */ { queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, maxStatementSize, handler); + sycl::stream osA(bufferSize, workItemBufferSize, handler); sycl::stream osB(osA); - if (osA.get_max_statement_size() != osB.get_max_statement_size()) { + if (osA.get_work_item_buffer_size() != + osB.get_work_item_buffer_size()) { FAIL(log, "stream is not copy constructed correctly. " - "(get_max_statement_size)"); + "(get_work_item_buffer_size)"); } if (osA.get_precision() != osB.get_precision()) { FAIL(log, "stream is not copy constructed correctly. (get_precision)"); } - if (osA.get_size() != osB.get_size()) { - FAIL(log, "stream is not copy constructed correctly. (get_size)"); + if (osA.size() != osB.size()) { + FAIL(log, "stream is not copy constructed correctly. (size)"); } if (osA.get_stream_mode() != osB.get_stream_mode()) { FAIL(log, "stream is not copy constructed correctly. (get_stream_mode)"); } - if (osB.get_size() != bufferSize) { + if (osB.size() != bufferSize) { FAIL(log, - "sycl::context::get_size() returned an incorrect value " + "sycl::context::size() returned an incorrect value " "after copy constructed."); } - if (osB.get_max_statement_size() != maxStatementSize) { + if (osB.get_work_item_buffer_size() != workItemBufferSize) { FAIL(log, - "sycl::context::get_max_statement_size() returned an " + "sycl::context::get_work_item_buffer_size() returned an " "incorrect value after copy constructed."); } @@ -140,38 +141,38 @@ class TEST_NAME : public util::test_base { } /** check assignment operator - */ + */ { queue.submit([&](sycl::handler &handler) { - - sycl::stream osA(bufferSize, maxStatementSize, handler); - sycl::stream osB(bufferSize / 2, maxStatementSize / 2, handler); + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB(bufferSize / 2, workItemBufferSize / 2, handler); osB = osA; - if (osA.get_max_statement_size() != osB.get_max_statement_size()) { + if (osA.get_work_item_buffer_size() != + osB.get_work_item_buffer_size()) { FAIL(log, "stream is not copy constructed correctly. " - "(get_max_statement_size)"); + "(get_work_item_buffer_size)"); } if (osA.get_precision() != osB.get_precision()) { FAIL(log, "stream is not copy constructed correctly. (get_precision)"); } - if (osA.get_size() != osB.get_size()) { - FAIL(log, "stream is not copy constructed correctly. (get_size)"); + if (osA.size() != osB.size()) { + FAIL(log, "stream is not copy constructed correctly. (size)"); } if (osA.get_stream_mode() != osB.get_stream_mode()) { FAIL(log, "stream is not copy constructed correctly. (get_stream_mode)"); } - if (osB.get_size() != bufferSize) { + if (osB.size() != bufferSize) { FAIL(log, - "sycl::context::get_size() returned an incorrect value " + "sycl::context::size() returned an incorrect value " "after copy assigned."); } - if (osB.get_max_statement_size() != maxStatementSize) { + if (osB.get_work_item_buffer_size() != workItemBufferSize) { FAIL(log, - "sycl::context::get_max_statement_size() returned an " + "sycl::context::get_work_item_buffer_size() returned an " "incorrect value after copy assigned."); } @@ -180,21 +181,20 @@ class TEST_NAME : public util::test_base { } /* check move constructor - */ + */ { queue.submit([&](sycl::handler &handler) { - - sycl::stream osA(bufferSize, maxStatementSize, handler); + sycl::stream osA(bufferSize, workItemBufferSize, handler); sycl::stream osB(std::move(osA)); - if (osB.get_size() != bufferSize) { + if (osB.size() != bufferSize) { FAIL(log, - "sycl::context::get_size() returned an incorrect value " + "sycl::context::size() returned an incorrect value " "after move constructed."); } - if (osB.get_max_statement_size() != maxStatementSize) { + if (osB.get_work_item_buffer_size() != workItemBufferSize) { FAIL(log, - "sycl::context::get_max_statement_size() returned an " + "sycl::context::get_work_item_buffer_size() returned an " "incorrect value after move constructed."); } @@ -203,22 +203,21 @@ class TEST_NAME : public util::test_base { } /* check move assignment operator - */ + */ { queue.submit([&](sycl::handler &handler) { - - sycl::stream osA(bufferSize, maxStatementSize, handler); - sycl::stream osB(bufferSize / 2, maxStatementSize / 2, handler); + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB(bufferSize / 2, workItemBufferSize / 2, handler); osB = std::move(osA); - if (osB.get_size() != bufferSize) { + if (osB.size() != bufferSize) { FAIL(log, - "sycl::context::get_size() returned an incorrect value " + "sycl::context::size() returned an incorrect value " "after move assigned."); } - if (osB.get_max_statement_size() != maxStatementSize) { + if (osB.get_work_item_buffer_size() != workItemBufferSize) { FAIL(log, - "sycl::context::get_max_statement_size() returned an " + "sycl::context::get_work_item_buffer_size() returned an " "incorrect value after move assigned."); } @@ -227,14 +226,14 @@ class TEST_NAME : public util::test_base { } /** check equality operator - */ + */ { queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, maxStatementSize, handler); + sycl::stream osA(bufferSize, workItemBufferSize, handler); sycl::stream osB(osA); - sycl::stream osC(bufferSize * 2, maxStatementSize * 2, handler); + sycl::stream osC(bufferSize * 2, workItemBufferSize * 2, handler); osC = osA; - sycl::stream osD(bufferSize * 2, maxStatementSize * 2, handler); + sycl::stream osD(bufferSize * 2, workItemBufferSize * 2, handler); if (!(osA == osB) && areEqual(osA, osB)) { FAIL(log, @@ -271,10 +270,10 @@ class TEST_NAME : public util::test_base { } /** check hashing - */ + */ { queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, maxStatementSize, handler); + sycl::stream osA(bufferSize, workItemBufferSize, handler); sycl::stream osB = osA; std::hash hasher; From 194c4f2e3f6831409dd16831e217cb2eff1f500f Mon Sep 17 00:00:00 2001 From: Nol Moonen Date: Fri, 13 Jan 2023 13:44:53 +0100 Subject: [PATCH 4/5] disable for dpcpp, update license header --- tests/stream/stream_api.cpp | 2 +- tests/stream/stream_constructors.cpp | 456 +++++++++++++-------------- 2 files changed, 214 insertions(+), 244 deletions(-) diff --git a/tests/stream/stream_api.cpp b/tests/stream/stream_api.cpp index 3dace13af..5eb803f38 100644 --- a/tests/stream/stream_api.cpp +++ b/tests/stream/stream_api.cpp @@ -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. diff --git a/tests/stream/stream_constructors.cpp b/tests/stream/stream_constructors.cpp index f2db40721..261ec7e5f 100644 --- a/tests/stream/stream_constructors.cpp +++ b/tests/stream/stream_constructors.cpp @@ -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. @@ -20,279 +20,249 @@ *******************************************************************************/ #include "../common/common.h" - -#define TEST_NAME stream_constructors - -namespace TEST_NAMESPACE { - -using namespace sycl_cts; +#include "../common/disabled_for_test_case.h" struct stream_kernel { void operator()() const {} }; -/** tests the constructors for sycl::stream - */ -class TEST_NAME : public util::test_base { - public: - /** return information about this test +// DPCPP does not define stream::size nor stream::get_work_item_buffer_size +#ifndef SYCL_CTS_COMPILING_WITH_DPCPP +/** + * Check equality of two stream objects. Returns true on equal, false + * otherwise. */ +static bool areEqual(sycl::stream &osA, sycl::stream &osB) { + if (osA.get_work_item_buffer_size() == osB.get_work_item_buffer_size() || + osA.get_precision() == osB.get_precision() || osA.size() == osB.size() || + osA.get_stream_mode() == osB.get_stream_mode()) + return false; + return true; +} +#endif // SYCL_CTS_COMPILING_WITH_DPCPP + +DISABLED_FOR_TEST_CASE(DPCPP) +("stream_constructors", "[stream]")({ + auto queue = sycl_cts::util::get_cts_object::queue(); + size_t bufferSize = 2048; + size_t workItemBufferSize = 80; + + /** check (size_t, size_t, sycl::handler&) constructor */ - void get_info(test_base::info &out) const override { - set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE); - } + { + queue.submit([&](sycl::handler &handler) { + sycl::stream os(bufferSize, workItemBufferSize, handler); - /** check equality of two stream objects. Returns true on equal, false - * otherwise - */ - bool areEqual(sycl::stream &osA, sycl::stream &osB) { - if (osA.get_work_item_buffer_size() == osB.get_work_item_buffer_size() || - osA.get_precision() == osB.get_precision() || - osA.size() == osB.size() || - osA.get_stream_mode() == osB.get_stream_mode()) - return false; - return true; - } - /** execute the test - */ - void run(util::logger &log) override { - { - auto queue = util::get_cts_object::queue(); - size_t bufferSize = 2048; - size_t workItemBufferSize = 80; - - /** check (size_t, size_t, sycl::handler&) constructor - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::stream os(bufferSize, workItemBufferSize, handler); - - if (os.size() != bufferSize) { - FAIL(log, "sycl::context::size() returned an incorrect value."); - } - if (os.get_work_item_buffer_size() != workItemBufferSize) { - FAIL(log, - "sycl::context::get_work_item_buffer_size() returned an " - "incorrect value."); - } - - handler.single_task(stream_kernel{}); - }); + if (os.size() != bufferSize) { + FAIL("sycl::context::size() returned an incorrect value."); + } + if (os.get_work_item_buffer_size() != workItemBufferSize) { + FAIL( + "sycl::context::get_work_item_buffer_size() returned an " + "incorrect value."); } - /** check (size_t, size_t, sycl::handler&, sycl::property_list&) - * constructor - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::property_list property_list{}; - sycl::stream os(bufferSize, workItemBufferSize, handler, - property_list); + handler.single_task(stream_kernel{}); + }); + } - if (os.size() != bufferSize) { - FAIL(log, "sycl::context::size() returned an incorrect value."); - } - if (os.get_work_item_buffer_size() != workItemBufferSize) { - FAIL(log, - "sycl::context::get_work_item_buffer_size() returned an " - "incorrect value."); - } + /** check (size_t, size_t, sycl::handler&, sycl::property_list&) + * constructor + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::property_list property_list{}; + sycl::stream os(bufferSize, workItemBufferSize, handler, property_list); - handler.single_task(stream_kernel{}); - }); + if (os.size() != bufferSize) { + FAIL("sycl::context::size() returned an incorrect value."); + } + if (os.get_work_item_buffer_size() != workItemBufferSize) { + FAIL( + "sycl::context::get_work_item_buffer_size() returned an " + "incorrect value."); } - /** check copy constructor - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, workItemBufferSize, handler); - sycl::stream osB(osA); - - if (osA.get_work_item_buffer_size() != - osB.get_work_item_buffer_size()) { - FAIL(log, - "stream is not copy constructed correctly. " - "(get_work_item_buffer_size)"); - } - if (osA.get_precision() != osB.get_precision()) { - FAIL(log, - "stream is not copy constructed correctly. (get_precision)"); - } - if (osA.size() != osB.size()) { - FAIL(log, "stream is not copy constructed correctly. (size)"); - } - if (osA.get_stream_mode() != osB.get_stream_mode()) { - FAIL(log, - "stream is not copy constructed correctly. (get_stream_mode)"); - } - if (osB.size() != bufferSize) { - FAIL(log, - "sycl::context::size() returned an incorrect value " - "after copy constructed."); - } - if (osB.get_work_item_buffer_size() != workItemBufferSize) { - FAIL(log, - "sycl::context::get_work_item_buffer_size() returned an " - "incorrect value after copy constructed."); - } + handler.single_task(stream_kernel{}); + }); + } - handler.single_task(stream_kernel{}); - }); + /** check copy constructor + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB(osA); + + if (osA.get_work_item_buffer_size() != osB.get_work_item_buffer_size()) { + FAIL( + "stream is not copy constructed correctly. " + "(get_work_item_buffer_size)"); + } + if (osA.get_precision() != osB.get_precision()) { + FAIL("stream is not copy constructed correctly. (get_precision)"); + } + if (osA.size() != osB.size()) { + FAIL("stream is not copy constructed correctly. (size)"); + } + if (osA.get_stream_mode() != osB.get_stream_mode()) { + FAIL("stream is not copy constructed correctly. (get_stream_mode)"); + } + if (osB.size() != bufferSize) { + FAIL( + "sycl::context::size() returned an incorrect value " + "after copy constructed."); + } + if (osB.get_work_item_buffer_size() != workItemBufferSize) { + FAIL( + "sycl::context::get_work_item_buffer_size() returned an " + "incorrect value after copy constructed."); } - /** check assignment operator - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, workItemBufferSize, handler); - sycl::stream osB(bufferSize / 2, workItemBufferSize / 2, handler); - osB = osA; - - if (osA.get_work_item_buffer_size() != - osB.get_work_item_buffer_size()) { - FAIL(log, - "stream is not copy constructed correctly. " - "(get_work_item_buffer_size)"); - } - if (osA.get_precision() != osB.get_precision()) { - FAIL(log, - "stream is not copy constructed correctly. (get_precision)"); - } - if (osA.size() != osB.size()) { - FAIL(log, "stream is not copy constructed correctly. (size)"); - } - if (osA.get_stream_mode() != osB.get_stream_mode()) { - FAIL(log, - "stream is not copy constructed correctly. (get_stream_mode)"); - } - if (osB.size() != bufferSize) { - FAIL(log, - "sycl::context::size() returned an incorrect value " - "after copy assigned."); - } - if (osB.get_work_item_buffer_size() != workItemBufferSize) { - FAIL(log, - "sycl::context::get_work_item_buffer_size() returned an " - "incorrect value after copy assigned."); - } + handler.single_task(stream_kernel{}); + }); + } - handler.single_task(stream_kernel{}); - }); + /** check assignment operator + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB(bufferSize / 2, workItemBufferSize / 2, handler); + osB = osA; + + if (osA.get_work_item_buffer_size() != osB.get_work_item_buffer_size()) { + FAIL( + "stream is not copy constructed correctly. " + "(get_work_item_buffer_size)"); + } + if (osA.get_precision() != osB.get_precision()) { + FAIL("stream is not copy constructed correctly. (get_precision)"); + } + if (osA.size() != osB.size()) { + FAIL("stream is not copy constructed correctly. (size)"); + } + if (osA.get_stream_mode() != osB.get_stream_mode()) { + FAIL("stream is not copy constructed correctly. (get_stream_mode)"); + } + if (osB.size() != bufferSize) { + FAIL( + "sycl::context::size() returned an incorrect value " + "after copy assigned."); + } + if (osB.get_work_item_buffer_size() != workItemBufferSize) { + FAIL( + "sycl::context::get_work_item_buffer_size() returned an " + "incorrect value after copy assigned."); } - /* check move constructor - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, workItemBufferSize, handler); - sycl::stream osB(std::move(osA)); - - if (osB.size() != bufferSize) { - FAIL(log, - "sycl::context::size() returned an incorrect value " - "after move constructed."); - } - if (osB.get_work_item_buffer_size() != workItemBufferSize) { - FAIL(log, - "sycl::context::get_work_item_buffer_size() returned an " - "incorrect value after move constructed."); - } + handler.single_task(stream_kernel{}); + }); + } - handler.single_task(stream_kernel{}); - }); + /* check move constructor + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB(std::move(osA)); + + if (osB.size() != bufferSize) { + FAIL( + "sycl::context::size() returned an incorrect value " + "after move constructed."); + } + if (osB.get_work_item_buffer_size() != workItemBufferSize) { + FAIL( + "sycl::context::get_work_item_buffer_size() returned an " + "incorrect value after move constructed."); } - /* check move assignment operator - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, workItemBufferSize, handler); - sycl::stream osB(bufferSize / 2, workItemBufferSize / 2, handler); - osB = std::move(osA); - - if (osB.size() != bufferSize) { - FAIL(log, - "sycl::context::size() returned an incorrect value " - "after move assigned."); - } - if (osB.get_work_item_buffer_size() != workItemBufferSize) { - FAIL(log, - "sycl::context::get_work_item_buffer_size() returned an " - "incorrect value after move assigned."); - } + handler.single_task(stream_kernel{}); + }); + } - handler.single_task(stream_kernel{}); - }); + /* check move assignment operator + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB(bufferSize / 2, workItemBufferSize / 2, handler); + osB = std::move(osA); + + if (osB.size() != bufferSize) { + FAIL( + "sycl::context::size() returned an incorrect value " + "after move assigned."); + } + if (osB.get_work_item_buffer_size() != workItemBufferSize) { + FAIL( + "sycl::context::get_work_item_buffer_size() returned an " + "incorrect value after move assigned."); } - /** check equality operator - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, workItemBufferSize, handler); - sycl::stream osB(osA); - sycl::stream osC(bufferSize * 2, workItemBufferSize * 2, handler); - osC = osA; - sycl::stream osD(bufferSize * 2, workItemBufferSize * 2, handler); - - if (!(osA == osB) && areEqual(osA, osB)) { - FAIL(log, - "stream equality does not work correctly (copy constructed)"); - } + handler.single_task(stream_kernel{}); + }); + } - if (!(osA == osC) && areEqual(osA, osC)) { - FAIL(log, - "stream equality does not work correctly (copy assigned)"); - } - if (osA != osB) { - FAIL(log, - "stream non-equality does not work correctly" - "(copy constructed)"); - } - if (osA != osC) { - FAIL(log, - "stream non-equality does not work correctly" - "(copy assigned)"); - } - if (osC == osD) { - FAIL(log, - "stream equality does not work correctly" - "(comparing same)"); - } - if (!(osC != osD)) { - FAIL(log, - "stream non-equality does not work correctly" - "(comparing same)"); - } + /** check equality operator + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB(osA); + sycl::stream osC(bufferSize * 2, workItemBufferSize * 2, handler); + osC = osA; + sycl::stream osD(bufferSize * 2, workItemBufferSize * 2, handler); + + if (!(osA == osB) && areEqual(osA, osB)) { + FAIL("stream equality does not work correctly (copy constructed)"); + } - handler.single_task(stream_kernel{}); - }); + if (!(osA == osC) && areEqual(osA, osC)) { + FAIL("stream equality does not work correctly (copy assigned)"); + } + if (osA != osB) { + FAIL( + "stream non-equality does not work correctly" + "(copy constructed)"); + } + if (osA != osC) { + FAIL( + "stream non-equality does not work correctly" + "(copy assigned)"); + } + if (osC == osD) { + FAIL( + "stream equality does not work correctly" + "(comparing same)"); + } + if (!(osC != osD)) { + FAIL( + "stream non-equality does not work correctly" + "(comparing same)"); } - /** check hashing - */ - { - queue.submit([&](sycl::handler &handler) { - sycl::stream osA(bufferSize, workItemBufferSize, handler); - sycl::stream osB = osA; + handler.single_task(stream_kernel{}); + }); + } - std::hash hasher; + /** check hashing + */ + { + queue.submit([&](sycl::handler &handler) { + sycl::stream osA(bufferSize, workItemBufferSize, handler); + sycl::stream osB = osA; - if (hasher(osA) != hasher(osB)) { - FAIL(log, - "stream hashing does not work correctly (hashing of equal " - "failed)"); - } - handler.single_task(stream_kernel{}); - }); - } + std::hash hasher; - queue.wait_and_throw(); - } + if (hasher(osA) != hasher(osB)) { + FAIL( + "stream hashing does not work correctly (hashing of equal " + "failed)"); + } + handler.single_task(stream_kernel{}); + }); } -}; - -// register this test with the test_collection. -util::test_proxy proxy; -} /* namespace TEST_NAMESPACE */ + queue.wait_and_throw(); +}); From d4d155c109117d2b185bf312b41e0eb3d5f04644 Mon Sep 17 00:00:00 2001 From: Nol Moonen Date: Mon, 16 Jan 2023 10:10:43 +0100 Subject: [PATCH 5/5] update license header in remaining files --- tests/stream/stream_api_fp16.cpp | 2 +- tests/stream/stream_api_fp64.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/stream/stream_api_fp16.cpp b/tests/stream/stream_api_fp16.cpp index 7e0af9223..b4f5c9def 100644 --- a/tests/stream/stream_api_fp16.cpp +++ b/tests/stream/stream_api_fp16.cpp @@ -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. diff --git a/tests/stream/stream_api_fp64.cpp b/tests/stream/stream_api_fp64.cpp index aa6a285c7..cfe749411 100644 --- a/tests/stream/stream_api_fp64.cpp +++ b/tests/stream/stream_api_fp64.cpp @@ -2,7 +2,19 @@ // // SYCL 2020 Conformance Test Suite // -// Provides stream tests for double +// Copyright (c) 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. // *******************************************************************************/