-
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1388c4b
Convert id tests to Catch2
psalz a458011
Add `id` to ComputeCpp CI filter
psalz a5ac811
Test id ctors more thoroughly on host
psalz bd2630f
Add .editorconfig
psalz 16f08df
Address reviewer comments
psalz 970fbc0
Merge branch 'SYCL-2020' into convert-id-tests-catch2
psalz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ buffer | |
exceptions | ||
handler | ||
hierarchical | ||
id | ||
invoke | ||
item | ||
math_builtin_api | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; }); \ | ||
}) \ | ||
.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) | ||
|
||
#endif // __SYCLCTS_TESTS_COMMON_DEVICE_EVAL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
orDEVICE_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. :-(