-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL][CUDA] Select only NVPTX64 device binaries #1223
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
3 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 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
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,70 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice,nvptx64-unknown-unknown-sycldevice %s -o %t-spir64-nvptx64.out | ||
// RUN: env SYCL_BE=PI_OPENCL %t-spir64-nvptx64.out | ||
// RUN: env SYCL_BE=PI_CUDA %t-spir64-nvptx64.out | ||
// RUN: %clangxx -fsycl -fsycl-targets=nvptx64-unknown-unknown-sycldevice,spir64-unknown-unknown-sycldevice %s -o %t-nvptx64-spir64.out | ||
// RUN: env SYCL_BE=PI_OPENCL %t-nvptx64-spir64.out | ||
// RUN: env SYCL_BE=PI_CUDA %t-nvptx64-spir64.out | ||
|
||
// REQUIRES: opencl, cuda | ||
|
||
//==------- sycl-targets-order.cpp - SYCL -fsycl-targets order 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <CL/sycl.hpp> | ||
#include <iostream> | ||
|
||
int main(int argc, char **argv) { | ||
|
||
// select the default SYCL device | ||
cl::sycl::device device{cl::sycl::default_selector{}}; | ||
romanovvlad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::cout << "Running on SYCL device " << device.get_info<cl::sycl::info::device::name>() | ||
<< ", driver version " << device.get_info<cl::sycl::info::device::driver_version>() | ||
<< std::endl; | ||
|
||
// create a queue | ||
cl::sycl::queue queue{device}; | ||
|
||
// create a buffer of 4 ints to be used inside the kernel code | ||
cl::sycl::buffer<unsigned int, 1> buffer(4); | ||
|
||
// size of the index space for the kernel | ||
cl::sycl::range<1> NumOfWorkItems{buffer.get_count()}; | ||
|
||
// submit a command group(work) to the queue | ||
queue.submit([&](cl::sycl::handler &cgh) { | ||
// get write only access to the buffer on a device | ||
auto accessor = buffer.get_access<cl::sycl::access::mode::write>(cgh); | ||
// executing the kernel | ||
cgh.parallel_for<class FillBuffer>( | ||
NumOfWorkItems, [=](cl::sycl::id<1> WIid) { | ||
// fill the buffer with indexes | ||
accessor[WIid] = WIid.get(0); | ||
}); | ||
}); | ||
|
||
// get read-only access to the buffer on the host | ||
// introduce an implicit barrier waiting for queue to complete the work | ||
const auto host_accessor = buffer.get_access<cl::sycl::access::mode::read>(); | ||
|
||
// check the results | ||
bool mismatch = false; | ||
for (unsigned int i = 0; i < buffer.get_count(); ++i) { | ||
if (host_accessor[i] != i) { | ||
std::cout << "The result is incorrect for element: " << i | ||
<< " , expected: " << i << " , got: " << host_accessor[i] | ||
<< std::endl; | ||
mismatch = true; | ||
} | ||
} | ||
|
||
if (not mismatch) { | ||
std::cout << "The results are correct!" << std::endl; | ||
} | ||
fwyzard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return mismatch; | ||
} |
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.