-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Make host device and host platform always available, even when forcin… #992
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
Changes from all commits
47ddfee
7fbcc6a
441f118
6a4346f
fd977d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,18 @@ vector_class<device> device::get_devices(info::device_type deviceType) { | |
if (detail::match_types(deviceType, forced_type)) { | ||
detail::force_type(deviceType, forced_type); | ||
for (const auto &plt : platform::get_platforms()) { | ||
vector_class<device> found_devices(plt.get_devices(deviceType)); | ||
if (!found_devices.empty()) | ||
devices.insert(devices.end(), found_devices.begin(), | ||
found_devices.end()); | ||
// Host device must always be available. | ||
if (plt.is_host()) { | ||
vector_class<device> host_device( | ||
plt.get_devices(info::device_type::host)); | ||
if (!host_device.empty()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this if redundant? I think insert will correctly handle case when begin iterator == end iterator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - get_devices is supposed to only return devices of the passed type, hence the special casing for host devices. |
||
devices.insert(devices.end(), host_device.begin(), host_device.end()); | ||
} else { | ||
vector_class<device> found_devices(plt.get_devices(deviceType)); | ||
if (!found_devices.empty()) | ||
devices.insert(devices.end(), found_devices.begin(), | ||
found_devices.end()); | ||
} | ||
} | ||
} | ||
return devices; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clangxx -fsycl %s -o %t1.out | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t1.out | ||
vladimirlaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// RUN: %GPU_RUN_PLACEHOLDER %t1.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t1.out | ||
|
||
//==------ host_always_works.cpp - Host Device Availability 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> | ||
|
||
using namespace cl::sycl; | ||
|
||
int main() { | ||
device(host_selector{}); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clangxx -fsycl %s -o %t1.out | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t1.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t1.out | ||
vladimirlaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// RUN: %ACC_RUN_PLACEHOLDER %t1.out | ||
|
||
//==------ host_platform_avail.cpp - Host Platform Availability 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> | ||
|
||
using namespace cl::sycl; | ||
|
||
int main() { | ||
auto plats = platform::get_platforms(); | ||
bool found_host = false; | ||
|
||
// Look for a host platform | ||
for (const auto &plat : plats) { | ||
if (plat.is_host()) { | ||
found_host = true; | ||
} | ||
} | ||
|
||
// Fail if we didn't find a host platform | ||
return (!found_host); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.