-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][WIP] Extend select_device to take parameters #2241
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aa26505
[SYCL] Extend select_device to take parameters
bso-intel f5e0422
fix clang-format
bso-intel fd15567
more clang-format
bso-intel 3c1ac56
Merge remote-tracking branch 'upstream/sycl' into select-device-2
bso-intel 7b9a834
added all backend type
bso-intel 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
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,87 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: %t.out | ||
// RUN: env SYCL_DEVICE_TRIPLES="*" %t.out | ||
// RUN: env SYCL_DEVICE_TRIPLES=gpu:level_zero %t.out | ||
// RUN: env SYCL_DEVICE_TRIPLES=cpu,acc %t.out | ||
// RUN: env SYCL_DEVICE_TRIPLES="*:opencl" %t.out | ||
// RUN: env SYCL_DEVICE_TRIPLES="*:opencl,gpu:level_zero" %t.out | ||
// RUN: env SYCL_DEVICE_TRIPLES=acc:opencl:0 %t.out | ||
// | ||
// Checks that only designated plugins are loaded when SYCL_DEVICE_TRIPLES is | ||
// set. Checks that all different device types can be acquired from | ||
// select_device() | ||
// UNSUPPORTED: windows | ||
|
||
#include <CL/sycl.hpp> | ||
#include <iostream> | ||
|
||
using namespace cl::sycl; | ||
|
||
int main() { | ||
const char *pis = std::getenv("SYCL_DEVICE_TRIPLES"); | ||
std::string forcedPIs; | ||
if (pis) { | ||
forcedPIs = pis; | ||
} | ||
|
||
default_selector ds; | ||
if (!pis || forcedPIs == "*" || | ||
forcedPIs.find("gpu:level_zero") != std::string::npos) { | ||
device d = ds.select_device(info::device_type::gpu, backend::level_zero); | ||
std::cout << "Level-zero GPU Device is found: " << std::boolalpha | ||
<< d.is_gpu() << std::endl; | ||
} | ||
if (!pis || forcedPIs == "*" || | ||
forcedPIs.find("opencl") != std::string::npos) { | ||
device d = ds.select_device(info::device_type::gpu, backend::opencl); | ||
std::cout << "OpenCL GPU Device is found: " << std::boolalpha << d.is_gpu() | ||
<< std::endl; | ||
} | ||
if (!pis || forcedPIs == "*" || | ||
forcedPIs.find("opencl") != std::string::npos || | ||
forcedPIs.find("cpu") != std::string::npos) { | ||
device d = ds.select_device(info::device_type::cpu); | ||
std::cout << "CPU device is found: " << d.is_cpu() << std::endl; | ||
} | ||
// HOST device is always available. | ||
{ | ||
device d = ds.select_device(info::device_type::host); | ||
std::cout << "HOST device is found: " << d.is_host() << std::endl; | ||
} | ||
if (!pis || forcedPIs == "*" || | ||
forcedPIs.find("opencl") != std::string::npos || | ||
forcedPIs.find("acc") != std::string::npos) { | ||
device d = ds.select_device(info::device_type::accelerator); | ||
std::cout << "ACC device is found: " << d.is_accelerator() << std::endl; | ||
} | ||
/* | ||
// Enable the following tests after https://github.com/intel/llvm/pull/2239 | ||
// is merged. | ||
// If SYCL_DEVICE_TRIPLES is set with level_zero, | ||
// CPU device should not be found by get_devices(info::device_type::cpu) | ||
// but GPU should be found by select_device(info::device_type::gpu). | ||
if (pis && forcedPIs.find("level_zero") != std::string::npos && | ||
forcedPIs.find("opencl") == std::string::npos && | ||
forcedPIs.find("cpu") == std::string::npos && | ||
forcedPIs != "*") { | ||
auto devices = device::get_devices(info::device_type::cpu); | ||
for (const device& d : devices) { | ||
assert(!d.is_cpu() && | ||
"Error: CPU device is found when SYCL_DEVICE_TRIPLES sets level_zero"); | ||
} | ||
device d = ds.select_device(info::device_type::gpu, backend::level_zero); | ||
assert(d.is_gpu() && "Error: GPU device is not found by select_device."); | ||
} | ||
|
||
// CPU device should not be loaded if SYCL_DEVICE_TRIPLES does not | ||
// include 'opencl' string. | ||
if (pis && forcedPIs.find("opencl") == std::string::npos && | ||
forcedPIs.find("cpu") == std::string::npos && | ||
forcedPIs.find("*") == std::string::npos) { | ||
device d = ds.select_device(info::device_type::cpu); | ||
assert(!d.is_cpu() && "Error: CPU device is found when opencl is not | ||
loaded"); | ||
} | ||
*/ | ||
return 0; | ||
} |
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.
Why?
Will there be a dedicated test for windows platform?