-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][NewOffload][E2E] add a single test for --offload-new-driver #14129
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
11 commits
Select commit
Hold shift + click to select a range
5837aa4
[SYCL] add a single test for --offload-new-driver
2b4097f
format
d451ead
force JIT only
6c2a182
change build parameters
4b7f984
add -fsycl to build
667167d
fix build issue
d048875
add extra newline
5cb0809
add a comment to describe the test
8e0907d
format
17576ac
format
9df6e07
Apply suggestions from code review
jasonlizhengjian 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,58 @@ | ||
//==------------------- buffer.cpp - SYCL buffer basic test ----------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// A basic test using the --offload-new-driver flag. | ||
|
||
// REQUIRES: level_zero | ||
// RUN: %clangxx -fsycl --offload-new-driver %s -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
#include <sycl/detail/core.hpp> | ||
|
||
int main() { | ||
// Creating buffer of 4 elements to be used inside the kernel code. | ||
sycl::buffer<size_t, 1> Buffer(4); | ||
|
||
// Creating SYCL queue. | ||
sycl::queue Queue; | ||
|
||
// Size of index space for kernel. | ||
sycl::range<1> NumOfWorkItems{Buffer.size()}; | ||
|
||
// Submitting command group(work) to queue. | ||
Queue.submit([&](sycl::handler &cgh) { | ||
// Getting write only access to the buffer on a device. | ||
sycl::accessor Accessor{Buffer, cgh, sycl::write_only}; | ||
// Executing kernel. | ||
cgh.parallel_for<class FillBuffer>(NumOfWorkItems, [=](sycl::id<1> WIid) { | ||
// Fill buffer with indexes. | ||
Accessor[WIid] = WIid.get(0); | ||
}); | ||
}); | ||
|
||
// Getting read only access to the buffer on the host. | ||
// Implicit barrier waiting for queue to complete the work. | ||
sycl::host_accessor HostAccessor{Buffer, sycl::read_only}; | ||
|
||
// Check the results. | ||
bool MismatchFound = false; | ||
for (size_t I = 0; I < Buffer.size(); ++I) { | ||
if (HostAccessor[I] != I) { | ||
std::cout << "The result is incorrect for element: " << I | ||
<< " , expected: " << I << " , got: " << HostAccessor[I] | ||
<< std::endl; | ||
MismatchFound = true; | ||
} | ||
} | ||
|
||
if (!MismatchFound) { | ||
std::cout << "The results are correct!" << std::endl; | ||
} | ||
|
||
return MismatchFound; | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.