Skip to content
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

[SYCL][NewOffload][E2E] add a single test for --offload-new-driver #14129

Merged
merged 11 commits into from
Jun 12, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions sycl/test-e2e/NewOffloadDriver/buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// REQUIRES: level_zero
maarquitos14 marked this conversation as resolved.
Show resolved Hide resolved
// RUN: %clangxx --offload-new-driver -o %t.out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need -fsycl here

// RUN: %{run} %t.out

#include <sycl/detail/core.hpp>

int main() {
// Creating buffer of 4 elements to be used inside the kernel code
jasonlizhengjian marked this conversation as resolved.
Show resolved Hide resolved
sycl::buffer<size_t, 1> Buffer(4);

// Creating SYCL queue
jasonlizhengjian marked this conversation as resolved.
Show resolved Hide resolved
sycl::queue Queue;

// Size of index space for kernel
jasonlizhengjian marked this conversation as resolved.
Show resolved Hide resolved
sycl::range<1> NumOfWorkItems{Buffer.size()};

// Submitting command group(work) to queue
jasonlizhengjian marked this conversation as resolved.
Show resolved Hide resolved
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
jasonlizhengjian marked this conversation as resolved.
Show resolved Hide resolved
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
jasonlizhengjian marked this conversation as resolved.
Show resolved Hide resolved
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;
}
Loading