-
Notifications
You must be signed in to change notification settings - Fork 745
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
Add e2e test for queue::fill with a range of pattern sizes #15991
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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,81 @@ | ||
// RUN: %{build} -o %t1.out | ||
// RUN: %{run} %t1.out | ||
// XFAIL: (opencl && cpu) | ||
// XFAIL-TRACKER: https://github.com/oneapi-src/unified-runtime/issues/2440 | ||
|
||
/** | ||
* Test of the queue::fill interface with a range of pattern sizes and values. | ||
* | ||
* Loops over pattern sizes from 1 to MaxPatternSize bytes and calls queue::fill | ||
* with std::array<uint8_t,Size> for the pattern. Two pattern values are tested, | ||
* all zeros and value=index+42. The output is copied back to host and | ||
* validated. | ||
*/ | ||
|
||
#include <array> | ||
#include <cstdio> | ||
#include <sycl/detail/core.hpp> | ||
#include <sycl/usm.hpp> | ||
|
||
constexpr size_t MaxPatternSize{32}; // Bytes. | ||
constexpr size_t NumElements{10}; | ||
constexpr size_t NumRepeats{1}; | ||
constexpr bool verbose{false}; | ||
|
||
template <size_t PatternSize, bool SameValue> | ||
int test(sycl::queue &q, uint8_t firstValue = 0) { | ||
using T = std::array<uint8_t, PatternSize>; | ||
T value{}; | ||
for (size_t i{0}; i < PatternSize; ++i) { | ||
if constexpr (SameValue) { | ||
value[i] = firstValue; | ||
} else { | ||
value[i] = firstValue + i; | ||
} | ||
} | ||
|
||
T *dptr{sycl::malloc_device<T>(NumElements, q)}; | ||
for (size_t repeat{0}; repeat < NumRepeats; ++repeat) { | ||
q.fill(dptr, value, NumElements).wait(); | ||
} | ||
|
||
std::array<T, NumElements> host{}; | ||
q.copy<T>(dptr, host.data(), NumElements).wait(); | ||
bool pass{true}; | ||
for (size_t i{0}; i < NumElements; ++i) { | ||
for (size_t j{0}; j < PatternSize; ++j) { | ||
if (host[i][j] != value[j]) { | ||
pass = false; | ||
} | ||
} | ||
} | ||
sycl::free(dptr, q); | ||
|
||
if (!pass || verbose) { | ||
printf("Pattern size %3zu bytes, %s values (initial %3u) %s\n", PatternSize, | ||
(SameValue ? " equal" : "varied"), firstValue, | ||
(pass ? "== PASS ==" : "== FAIL ==")); | ||
} | ||
|
||
return !pass; | ||
} | ||
|
||
template <size_t Size> int testOneSize(sycl::queue &q) { | ||
return test<Size, true>(q, 0) + test<Size, false>(q, 42); | ||
} | ||
|
||
template <size_t... Sizes> | ||
int testSizes(sycl::queue &q, std::index_sequence<Sizes...>) { | ||
return (testOneSize<1u + Sizes>(q) + ...); | ||
} | ||
|
||
int main() { | ||
sycl::queue q{}; | ||
int failures = testSizes(q, std::make_index_sequence<MaxPatternSize>{}); | ||
if (failures > 0) { | ||
printf("%d / %zu tests failed\n", failures, 2u * MaxPatternSize); | ||
} else { | ||
printf("All %zu tests passed\n", 2u * MaxPatternSize); | ||
} | ||
return failures; | ||
} |
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.
The issue says
meaning the failure is flaky and sometimes the test passes. How are you marking it with XFAIL then? We're also seeing "Unexpected Passes" occasionally in downstream now (at least, maybe here as well).