-
Notifications
You must be signed in to change notification settings - Fork 81
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
Various smaller bugfixes in tests #870
Conversation
7319f88
to
dad69ea
Compare
dad69ea
to
f519819
Compare
Thank you for going through all these bugs and addressing them! It makes me wonder if some of these should be part of the spec, simply for usability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a ride!
@@ -58,8 +58,23 @@ void test_accessor_methods(const AccT &accessor, | |||
#endif | |||
} | |||
|
|||
template<typename Accessor> | |||
extern const sycl::target accessor_target_v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this extern
definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the base template that's being specialized below. For a variable template marking it extern allows me to omit the (invalid) definition and cause a compiler error when it's used in a constexpr context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not. :-)
fail_for_accessor<T, dims, mode, target>(log, typeName, | ||
"accessor does not return the correct count"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the problem here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests the legacy accessor<target::local>
specialization, which does not have a size()
member.
@@ -172,15 +172,15 @@ class aquire_release { | |||
refA.store(0); | |||
refB.store(0); | |||
sycl::group_barrier(item.get_group()); | |||
if (item.get_local_id() == 0) { | |||
if (item.get_local_id() == sycl::id(0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so, the constructors are implicit https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#id-class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that is half of the problem, because id
is also implicitly convertible to size_t
. See godbolt. If you switch to gcc and member operation you will get a bit more detailed error message. But I was also surprised by this, apparently I'm not enough familiar with those overload resolution rules.
In our implementation we use some hackery to avoid ambiguity here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So either the special-casing needs to be in the spec, or this explicit construction is correct.
x = refA.load(); | ||
refB.store(1); | ||
} else { | ||
y = refB.load(); | ||
refA.store(1); | ||
} | ||
sycl::group_barrier(item.get_group()); | ||
if (item.get_local_id() == 0) | ||
if (item.get_local_id() == sycl::id(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem.
@@ -194,8 +194,14 @@ TEST_CASE("Constructors for sycl::exception with sycl::errc error codes", | |||
check_exception(copy, errcode, sycl::sycl_category()); | |||
} | |||
SECTION("operator=(const exception& other)") { | |||
// sycl::exception is not default-constructible, so explicitly construct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
static sycl::range<1> id_to_range(sycl::id<1> id) { | ||
return sycl::range<1>(id[0]); | ||
} | ||
static sycl::range<2> id_to_range(sycl::id<2> id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static sycl::range<2> id_to_range(sycl::id<2> id) { | |
static sycl::range<2> to_range(sycl::id<2> id) { |
since the id
is clear as the parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obsolete now because it has been fixed on SYCL-2020 branch in the meantime. Removed entirely.
@@ -239,7 +239,8 @@ TEMPLATE_TEST_CASE_SIG("id can be implicitly conversion-constructed from item", | |||
q.submit([r, &result_buf](sycl::handler& cgh) { | |||
sycl::accessor result{result_buf, cgh, sycl::write_only}; | |||
cgh.parallel_for<kernel_id<D>>(r, [=](sycl::item<D> itm) { | |||
if (itm.get_id() == id<D>{r} - 1) { | |||
// `ul` suffix is necessary to resolve ambiguity for id<1> | |||
if (itm.get_id() == id<D>{r} - 1ul) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why l
?
Just u
does not work?
The real type would be uz
but it is C++23.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but size_t
is at least unsigned long
on all relevant architectures, no?
tests/marray/marray_operators.h
Outdated
named_type_pack<op_upos, op_uneg, op_pre_inc, op_pre_dec, op_lnot, | ||
op_bnot>::generate("unary +", "unary -", "pre ++", | ||
"pre --", "!", "~"); | ||
static const auto unary_operators = make_unary_operators(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it a good opportunity for a lambda with immediate invocation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is!
tests/marray/marray_operators.h
Outdated
if (!std::is_same_v<DataT, bool>) { | ||
static const auto unary_post_operators = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!std::is_same_v<DataT, bool>) { | |
static const auto unary_post_operators = | |
if constexpr (!std::is_same_v<DataT, bool>) { | |
constexpr auto unary_post_operators = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static const
must remain because it's not a literal type (clang error)
} | ||
// The standard does not require ++ and -- (either prefix or postfix) for the | ||
// bool type, so we skip tests for these operators if DataT is bool. This cannot | ||
// be done via `if constexpr` because the type is not a dependent type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it a design bug of the test relying too much on Python to do the metaprogramming instead of leaving the instantiation to C++?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second.
The SYCL WG discussed this, and the review process should continue to merge this. We will then want to follow up on the new features proposed to possibly include in the spec. So, please continue to review and update this PR based on those reviews. Thanks! |
@steffenlarsen, could you open issues in SYCL-Docs project for the items which you think should be part of the spec, please? |
Opened KhronosGroup/SYCL-Docs#540 and KhronosGroup/SYCL-Docs#539. |
As mentioned in the CTS pull request KhronosGroup/SYCL-CTS#870, two device info descriptors, namely `info::device::image_max_array_size` and `info::device::opencl_c_version`, have been deprecated and no longer exist in the SYCL 2020 specification. But they still exist in our implementation, so I'm setting up deprecation warnings for them. Also a related test case has been revised to remove the usage of `info::device::opencl_c_version`. Also `info::device::usm_system_allocator` has been replaced and marked as deprecated 2+ years ago in PR #4007 and #9217 respectively. So I'm cleaning up a few relevant code pieces in our code as well in this PR. --------- Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
Rebased, which allowed me to drop one commit whose problem has been addressed on the target branch in the meantime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -58,8 +58,23 @@ void test_accessor_methods(const AccT &accessor, | |||
#endif | |||
} | |||
|
|||
template<typename Accessor> | |||
extern const sycl::target accessor_target_v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not. :-)
@fknorr, please, fix the formatting check. |
This PR fixes a bunch of discrepancies with the SYCL spec and minor bugs and ambiguities that surfaced when we attempted to build the CTS against SimSYCL.
Some of these issues might not be visible when building against a SYCL implementation (such as DPC++) that implements non-standard type conversions, member functions or other behavior.
In individual commits:
test_accessor
:get_multi_ptr()
is only defined for device- and local accessorstest_accessor_legacy
: legacy accessors do not have member functionsize()
test_atomic_ref
: Typo in function namememory_scope_is_suppoted
test_atomic_ref_stress
:id<1> == int
is ambiguoustest_device_info
:info::device::image_max_array_size
is not part of the Spectest_device_info
:info::device::opencl_c_version
is not part of the Spectest_device_selector
:sycl::runtime_error
is not part of the Spectest_exceptions
:sycl::exception
is not default-constructible(adressed by rebase)test_hierarchical
:sycl::id
is not convertible tosycl::range
test_id
:sycl::id<1> - 1
is ambiguoustest_kernel
: removetemplate
from non-dependent expressiontest_marray
:marray<bool>
does not haveoperator++/--
test_namespace
: Avoid multiple definitions of kernel namestest_scalars
: Regex typo in CMakeLists.txttest_vector_load_store
:sycl::vec
cannot load/store from accessor or load from non-constmulti_ptr
test_vector_operators
:vec<bool>
does not provideoperator++/--
util
: Call toerase_if
is ambiguous with C++20