-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL] Fix operators for bool
swizzled vec
#12001
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
030c8b4
[SYCL] Fix operators for `bool` swizzled vec
0x12CC 7c3610e
Fix broken test cases
0x12CC d664b98
Merge branch 'sycl' into vec_bool_swizzle
0x12CC bbe1335
Merge branch 'sycl' into vec_bool_swizzle
0x12CC db0786d
Address review comments
0x12CC f31cc82
Update sycl/test-e2e/Regression/vec_rel_swizzle_ops.cpp
0x12CC eb594c0
Add example cases to comment
0x12CC 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
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,68 @@ | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
// RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes %s -o %t2.out %} | ||
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %} | ||
|
||
#include <cstdlib> | ||
#include <sycl/sycl.hpp> | ||
|
||
template <typename T, typename ResultT> | ||
bool testAndOperator(const std::string &typeName) { | ||
constexpr int N = 5; | ||
std::array<ResultT, N> results{}; | ||
|
||
sycl::queue q; | ||
sycl::buffer<ResultT, 1> buffer{results.data(), N}; | ||
q.submit([&](sycl::handler &cgh) { | ||
sycl::accessor acc{buffer, cgh, sycl::write_only}; | ||
cgh.parallel_for(sycl::range<1>{1}, [=](sycl::id<1> id) { | ||
auto testVec1 = sycl::vec<T, 1>(static_cast<T>(1)); | ||
auto testVec2 = sycl::vec<T, 1>(static_cast<T>(2)); | ||
sycl::vec<ResultT, 1> resVec; | ||
|
||
ResultT expected = static_cast<ResultT>( | ||
-(static_cast<ResultT>(1) && static_cast<ResultT>(2))); | ||
acc[0] = expected; | ||
|
||
// LHS swizzle | ||
resVec = testVec1.template swizzle<sycl::elem::s0>() && testVec2; | ||
acc[1] = resVec[0]; | ||
|
||
// RHS swizzle | ||
resVec = testVec1 && testVec2.template swizzle<sycl::elem::s0>(); | ||
acc[2] = resVec[0]; | ||
|
||
// No swizzle | ||
resVec = testVec1 && testVec2; | ||
acc[3] = resVec[0]; | ||
|
||
// Both swizzle | ||
resVec = testVec1.template swizzle<sycl::elem::s0>() && | ||
testVec2.template swizzle<sycl::elem::s0>(); | ||
acc[4] = resVec[0]; | ||
}); | ||
}).wait(); | ||
|
||
bool passed = true; | ||
ResultT expected = results[0]; | ||
|
||
std::cout << "Testing with T = " << typeName << std::endl; | ||
std::cout << "Expected: " << (int)expected << std::endl; | ||
for (int i = 1; i < N; i++) { | ||
std::cout << "Test " << (i - 1) << ": " << ((int)results[i]) << std::endl; | ||
passed &= expected == results[i]; | ||
} | ||
std::cout << std::endl; | ||
return passed; | ||
} | ||
|
||
int main() { | ||
bool passed = true; | ||
passed &= testAndOperator<bool, std::int8_t>("bool"); | ||
passed &= testAndOperator<std::int8_t, std::int8_t>("std::int8_t"); | ||
passed &= testAndOperator<float, std::int32_t>("float"); | ||
passed &= testAndOperator<int, std::int32_t>("int"); | ||
std::cout << (passed ? "Pass" : "Fail") << std::endl; | ||
return (passed ? EXIT_SUCCESS : EXIT_FAILURE); | ||
} |
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.