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

Test for [[sycl::reqd_work_group_size]] exception when mismatched nd_range was given #285

Merged
Show file tree
Hide file tree
Changes from 15 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
3 changes: 3 additions & 0 deletions tests/optional_kernel_features/CMakeLists.txt
@@ -0,0 +1,3 @@
file(GLOB test_cases_list *.cpp)

add_cts_test(${test_cases_list})
@@ -0,0 +1,105 @@
/*******************************************************************************
//
// SYCL 2020 Conformance Test Suite
//
// Provides tests for the exception that is thrown by
// [[sycl::reqd_work_group_size]] attribute when use nd_range of wrong size in
// kernel.
//
*******************************************************************************/

#include "../common/common.h"
#include "../common/disabled_for_test_case.h"
#include "catch2/catch_template_test_macros.hpp"

namespace kernel_features_mismatched_nd_range_exception {
using namespace sycl_cts;

struct kernel_separate_lambda;
struct kernel_functor;
struct kernel_submission_call;

// Define required size of work group for attribute
constexpr int testing_wg_size = 1;

class Functor {
public:
[[sycl::reqd_work_group_size(testing_wg_size)]] void operator()(
sycl::nd_item<1>) const {}
};

DISABLED_FOR_TEST_CASE(hipSYCL)
("Submitting a kernel with an nd-range that does not match."
"[[sycl::reqd_work_group_size]] throws an exception",
"[kernel_features]")({
auto queue = util::get_cts_object::queue();
const size_t max_wg_size =
queue.get_device().get_info<sycl::info::device::max_work_group_size>();
if (max_wg_size < testing_wg_size) {
WARN("Device supported work group size too small. Skipping..");
return;
}

const bool is_exception_expected = true;
sycl::errc errc_expected = sycl::errc::nd_range;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the spec:

In order to guarantee source code portability of SYCL applications that use optional kernel features, all SYCL implementations must be able to compile device code that uses these optional features regardless of whether the implementation supports the features on any of its devices.

You've marked two implementations in the CI as not passing (adding the test to the filter), but I believe they should be able to pass the test even if they don't implement the features, otherwise they wouldn't be able to pass conformance in the current CTS design.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand CI doesn't run tests, it's just built it. Here you can find output from the building of tests on CI. ComputeCpp and hipsycl failed building due to some errors.

From hipsycl logs, line 1970: error: ‘errc’ is not a member of ‘sycl’. Looks like enum with error codes is not implemented yet and attributes too (line 1966).

Similar situation for computecpp.

But maybe I was wrong when I put these two implementations in the filter because both of them give the error message: no known conversion from 'cl::sycl::nd_item<1>' to 'sycl::item<1>' error, so it can be bug of tests itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was my mistake. I changed to nd_item but now getting another error. Right now investigating it.


const auto separate_lambda = [=](sycl::nd_item<1>)
[[sycl::reqd_work_group_size(testing_wg_size)]]{};

// Create nd_range that have to cause an exception
sycl::nd_range<1> mismatched_nd_rage(sycl::range(max_wg_size + 1),
sycl::range(max_wg_size + 1));

SECTION("Task as separate lambda") {
bool is_exception_thrown = false;
try {
queue
.submit([&](sycl::handler& cgh) {
cgh.parallel_for<kernel_separate_lambda>(mismatched_nd_rage,
separate_lambda);
})
.wait_and_throw();
} catch (const sycl::exception& e) {
is_exception_thrown = true;
INFO("Error code check");
CHECK(e.code() == errc_expected);
andreyromanof marked this conversation as resolved.
Show resolved Hide resolved
}
CHECK(is_exception_expected == is_exception_thrown);
}

SECTION("Task as functor") {
bool is_exception_thrown = false;
try {
queue
.submit([&](sycl::handler& cgh) {
cgh.parallel_for<kernel_functor>(mismatched_nd_rage, Functor{});
})
.wait_and_throw();
} catch (const sycl::exception& e) {
is_exception_thrown = true;
INFO("Error code check");
CHECK(e.code() == errc_expected);
}
CHECK(is_exception_expected == is_exception_thrown);
}

SECTION("Task as submission call") {
bool is_exception_thrown = false;
try {
queue
.submit([&](sycl::handler& cgh) {
cgh.parallel_for<kernel_submission_call>(
mismatched_nd_rage,
[](sycl::nd_item<1>)
[[sycl::reqd_work_group_size(testing_wg_size)]]{});
})
.wait_and_throw();
} catch (const sycl::exception& e) {
is_exception_thrown = true;
INFO("Error code check");
CHECK(e.code() == errc_expected);
}
CHECK(is_exception_expected == is_exception_thrown);
}
});
} // namespace kernel_features_mismatched_nd_range_exception