This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 130
[SYCL] Test reduction for complex numbers. #1609
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2c41b1d
[SYCL] Test reduction for complex numbers.
uditagarwal97 0d1a477
Fix formatting.
uditagarwal97 1482780
Update test case to only check for std::complex<float> and std::compl…
uditagarwal97 3c99d05
Minor changes.
uditagarwal97 9d8f19f
Fix test failure on windows.
uditagarwal97 5d5dab8
Minor formatting changes.
uditagarwal97 06c2de8
Replace range with nd_range
uditagarwal97 ef48bdf
Fix typo.
uditagarwal97 f33c528
Fix assert statement.
uditagarwal97 297a086
Fix formatting.
uditagarwal97 cc90560
More formatting changes.
uditagarwal97 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 hidden or 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,50 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
||
#include <complex> | ||
#include <numeric> | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
|
||
// Currently, Identityless reduction for complex numbers is | ||
// only valid for plus operator. | ||
// TODO: Extend this test case once we support known_identity for std::complex | ||
// and more operators (apart from plus). | ||
template <typename T> | ||
void test_identityless_reduction_for_complex_nums(queue &q) { | ||
// Allocate and initialize buffer on the host with all 1's. | ||
buffer<std::complex<T>> valuesBuf{1024}; | ||
{ | ||
host_accessor a{valuesBuf}; | ||
T n = 0; | ||
std::generate(a.begin(), a.end(), | ||
[&n] { return std::complex<T>(n, ++n + 1); }); | ||
} | ||
|
||
// Buffer to hold the reduction results. | ||
std::complex<T> sumResult = 0; | ||
buffer<std::complex<T>> sumBuf{&sumResult, 1}; | ||
|
||
q.submit([&](handler &cgh) { | ||
accessor inputVals{valuesBuf, cgh, sycl::read_only}; | ||
auto sumReduction = reduction(sumBuf, cgh, plus<std::complex<T>>()); | ||
|
||
cgh.parallel_for(range<1>{1024}, sumReduction, | ||
[=](id<1> idx, auto &sum) { sum += inputVals[idx]; }); | ||
}); | ||
|
||
assert(sumBuf.get_host_access()[0] == std::complex<T>(523776, 525824)); | ||
} | ||
|
||
int main() { | ||
queue q; | ||
|
||
test_identityless_reduction_for_complex_nums<float>(q); | ||
test_identityless_reduction_for_complex_nums<double>(q); | ||
|
||
return 0; | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.