-
Notifications
You must be signed in to change notification settings - Fork 80
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
Convert id
tests to Catch2, update for SYCL 2020
#246
Conversation
(Looks like I forgot to add |
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.
Interesting.
I wonder whether it would not me to have more functional programming to have kernel fusion to have all the DEVICE_EVAL
contents to be evaluated in a few kernels instead of 1 kernel per DEVICE_EVAL
. I am just thinking to the kernel compilation time on FPGA... ;-)
tests/common/device_eval.h
Outdated
*/ | ||
#define DEVICE_EVAL(expr) DEVICE_EVAL_T(decltype(expr), expr) | ||
|
||
#endif // __SYCLCTS_TESTS_COMMON_DEVICE_EVAL_H |
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.
Missing EOL
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've added an .editorconfig
file with the appropriate setting.
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.
Interesting https://editorconfig.org/
I didn't know about it.
* - Operands must exist in surrounding scope ([=] capture). | ||
* - No lambda expressions (requires C++20). Use DEVICE_EVAL_T instead. | ||
*/ | ||
#define DEVICE_EVAL(expr) DEVICE_EVAL_T(decltype(expr), expr) |
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 using macros DEVICE_EVAL_T
or DEVICE_EVAL
at the first place instead of functions or lambdas?
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 what you mean, how would I pass an unevaluated expression into a function/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.
I see: no C++20. :-(
tests/common/device_eval.h
Outdated
#include <sycl/sycl.hpp> | ||
|
||
#define DEVICE_EVAL_T(T, expr) \ | ||
([=]() { \ |
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.
([=]() { \ | |
([=] { \ |
tests/common/device_eval.h
Outdated
sycl_cts::util::get_cts_object::queue() \ | ||
.submit([=, &result_buf](sycl::handler& cgh) { \ | ||
sycl::accessor result{result_buf, cgh, sycl::write_only}; \ | ||
cgh.single_task([=]() { result[0] = expr; }); \ |
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.
cgh.single_task([=]() { result[0] = expr; }); \ | |
cgh.single_task([=] { result[0] = expr; }); \ |
tests/common/string_makers.h
Outdated
}; | ||
} // namespace Catch | ||
|
||
#endif // __SYCLCTS_TESTS_COMMON_STRING_MAKERS_H |
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.
Missing EOL
tests/id/id.cpp
Outdated
CHECK(DEVICE_EVAL(a[i]) == values[i]); | ||
} | ||
|
||
#define ASSIGN_COMPONENT(operand_value, c, 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 a macro?
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.
Because once you work with macros too much, everything seems like an opportunity for a macro ;-). Fixed.
CHECK(DEVICE_EVAL(b >= a) == idh<D>::get(0, 0, 1)); | ||
} | ||
|
||
#define COMPOUND_OP(operand_value, expr) \ |
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 a macro?
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 as for DEVICE_EVAL
, I want to pass an unevaluated expr
into here.
Configured to use UNIX line endings for all files and add final newline.
I've addressed some of the feedback and added a note to the common by-value semantics test case that there is some uncertainty around its definition (cf KhronosGroup/SYCL-Docs#210). Also I need to take a look at @vasilytric's |
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!
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.
Recent changes in the target branch conflict with this patch.
This is a comprehensive overhaul of the tests for the
sycl::id
class, using the new Catch2 testing framework idioms. The tests should now cover everything prescribed by the SYCL 2020 Revision 4 specification.I'm trying out a new pattern here, where instead of performing a bunch of tests on a SYCL device and recording each "assertion's" result in a buffer that is then bulk-asserted on the host, I'm offloading individual expressions to the device using the
DEVICE_EVAL
macro. This, in my opinion, makes for overall much more readable test cases.It currently only compiles for DPC++ because: