-
Notifications
You must be signed in to change notification settings - Fork 75
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
Tests for [[device_has]]
attribute from optional kernel features
#287
Tests for [[device_has]]
attribute from optional kernel features
#287
Conversation
* Added cmake for deivce_has tests * Added common code for device_has tests * Added tests for device_has attribute * Tests added to filter for computecpp and hipsycl
a50e287
to
5cb9077
Compare
ci/computecpp.filter
Outdated
@@ -28,3 +28,4 @@ usm | |||
vector_api | |||
vector_constructors | |||
vector_swizzles | |||
optional_kernel_features |
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.
Same naming question as in #285
According to spec SYCL_EXTERNAL is optional and can be unsupported by some implemetations. If implementation doesn't define SYCL_EXTERNAL then tests with external functions will be disabled
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
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.
@andreyromanof, could you extend the description of the PR with the information about what prevent the compilation of this test with computcpp/dpcpp/hipsycl?
Done |
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.
You could remove some useless ()
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
Also changed `device_has()` to `get_device().has()`
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.
- Build fails on computecpp due to linkage error, which I was unable to solve.
@andreyromanof, the link points to the log for a different PR. According to @psalz, there are at least two issues with compiling this PR with computecpp:
- tests use unnamed lambda
- tests use "device_has"
I expected you to list both in the description.
I suggest we remove optional_kernel_features from all the filters and disable specific test cases with the macro introduced by #293.
That makes sense. I'm going to patch this test and tests from other PRs. |
…into optional_kernel_features/device_has_exception
I added compile time disable of the test and removed this test from the filter.
@psalz could you please verify is this a bug or not. |
Build still fails on hipSYCL because there is no |
|
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Outdated
Show resolved
Hide resolved
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.
Will this work?
tests/optional_kernel_features/kernel_features_device_has_exceptions.cpp
Show resolved
Hide resolved
…into optional_kernel_features/device_has_exception
@andreyromanof, does merging #299 and #296 fix pre-commit? |
Can't say for sure. |
…into optional_kernel_features/device_has_exception
/** | ||
* @brief Macro for generating code that will use TYPE | ||
*/ | ||
#define USE_FEATURE(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.
Not clear why you are using a macro instead of a generic function or lambda.
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 macro should help to test cases, when user try to use feature function directly in kernel body, wihout functions or lambda. For example:
// using feature directly from kernel
queue.submit([&](sycl::handler &cgh) {
cgh.single_task([] {
dobule d = 0;
d += 42;
});
});
// using feature in function call
queue.submit([&](sycl::handler &cgh) {
cgh.single_task([] {
some_function_use_double();
});
});
The goal was test separately cases with functions, that use some feature and test cases, when feature is used by kernel directly.
} \ | ||
CHECK(is_exception_thrown == IS_EXCEPTION_EXPECTED); \ | ||
check_async_exception(QUEUE, false); \ | ||
} \ |
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 such a huge macro instead of a function/class/lambda? Is this to pass the attribute with the preprocessor?
Also a lot of copy-paste inside the macro itself.
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 used macro because in some cases kernel should be sent as a submission call (without storing it in separate lambda or class functor for example). To achieve that I wrote this huge macro, that should paste code with submission call.
This macro also refactored in this commit: 2fb2d5e
} | ||
} | ||
CHECK(is_exception_thrown == is_exception_expected); | ||
check_async_exception(queue, false); |
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 have the feeling to mostly see 3 times the same code.
Factorize in a function/lambda called 3 times and taking a lambda for executing the different code?
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.
You're right, it looks like I can optimize these places. I tried to refactor these functions in this commit: 2fb2d5e
} | ||
} | ||
CHECK(is_exception_thrown == is_exception_expected); | ||
check_async_exception(queue, false); |
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: mostly 3 copy-pastes.
…into optional_kernel_features/device_has_exception
Change try/catch blocks to CHECK_THROW_MATCHES and CHECK_NOTHROW Moved exception check to separate function
@bader Right now computecpp build fails, because there are using unnamed kernels in the code. Spec says that it's allowed. Should we use a workaround with the named kernel to avoid this build issue, or these tests can just wait in the filter(disabled by macro Also, computecpp will not compile even with named kernels due to a linkage error that looks like an implementation bug. (This error occurs in other PR where named kernels are used. Link to linkage error in other PR) |
@psalz I don't understand why code in |
Fixed in #303. |
…into optional_kernel_features/device_has_exception
Thanks. |
Early pulldown for `id` tests fix from KhronosGroup#301
This PR provides tests for optional kernel features.
Test decorates kernel or function invoked by the kernel with the attribute
[[sycl::device_has(aspect)]]
and expected exception if a device doesn't support aspect, otherwise expect no throw.Depends on: