-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from psalz/convert-id-tests-catch2
- Loading branch information
Showing
7 changed files
with
566 additions
and
309 deletions.
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 | ||
kernel_args | ||
|
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.