-
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
Changes from 3 commits
1388c4b
a458011
a5ac811
bd2630f
16f08df
970fbc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ exceptions | |
group | ||
hierarchical | ||
host_task | ||
id | ||
image | ||
kernel | ||
math_builtin_api | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ buffer | |
exceptions | ||
handler | ||
hierarchical | ||
id | ||
invoke | ||
item | ||
math_builtin_api | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||
/******************************************************************************* | ||||||
// | ||||||
// SYCL 2020 Conformance Test Suite | ||||||
// | ||||||
// Copyright (c) 2022 The Khronos Group Inc. | ||||||
// | ||||||
*******************************************************************************/ | ||||||
|
||||||
#ifndef __SYCLCTS_TESTS_COMMON_DEVICE_EVAL_H | ||||||
#define __SYCLCTS_TESTS_COMMON_DEVICE_EVAL_H | ||||||
|
||||||
#include <sycl/sycl.hpp> | ||||||
|
||||||
#define DEVICE_EVAL_T(T, expr) \ | ||||||
([=]() { \ | ||||||
sycl::buffer<std::decay_t<T>, 1> result_buf{1}; \ | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}) \ | ||||||
.wait_and_throw(); \ | ||||||
sycl::host_accessor acc{result_buf, sycl::read_only}; \ | ||||||
return acc[0]; \ | ||||||
})() | ||||||
|
||||||
/** | ||||||
* Evaluates a given expression on the SYCL device and returns the result. | ||||||
* | ||||||
* Limitations: | ||||||
* - 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 commentThe reason will be displayed to describe this comment to others. Learn more. Why using macros There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I see: no C++20. :-( |
||||||
|
||||||
#endif // __SYCLCTS_TESTS_COMMON_DEVICE_EVAL_H | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I've added an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting https://editorconfig.org/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
// | ||
// SYCL 2020 Conformance Test Suite | ||
// | ||
// Copyright (c) 2022 The Khronos Group Inc. | ||
// | ||
*******************************************************************************/ | ||
|
||
#ifndef __SYCLCTS_TESTS_COMMON_STRING_MAKERS_H | ||
#define __SYCLCTS_TESTS_COMMON_STRING_MAKERS_H | ||
|
||
#include <sstream> | ||
|
||
#include <catch2/catch_tostring.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
namespace Catch { | ||
template <int Dimensions> | ||
struct StringMaker<sycl::id<Dimensions>> { | ||
static std::string convert(const sycl::id<Dimensions>& id) { | ||
std::stringstream ss; | ||
ss << "{"; | ||
for (int d = 0; d < Dimensions; ++d) { | ||
ss << id[d]; | ||
if (d != Dimensions - 1) { | ||
ss << ", "; | ||
} | ||
} | ||
ss << "}"; | ||
return ss.str(); | ||
} | ||
}; | ||
} // namespace Catch | ||
|
||
#endif // __SYCLCTS_TESTS_COMMON_STRING_MAKERS_H | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.