File tree Expand file tree Collapse file tree 4 files changed +69
-6
lines changed Expand file tree Collapse file tree 4 files changed +69
-6
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,8 @@ vector_class<platform> platform_impl::get_platforms() {
41
41
}
42
42
}
43
43
44
- if (ForcedType == info::device_type:: host || ForcedType == info::device_type::all)
45
- Platforms.emplace_back (platform ());
44
+ // The host platform should always be available.
45
+ Platforms.emplace_back (platform ());
46
46
47
47
return Platforms;
48
48
}
Original file line number Diff line number Diff line change @@ -41,10 +41,18 @@ vector_class<device> device::get_devices(info::device_type deviceType) {
41
41
if (detail::match_types (deviceType, forced_type)) {
42
42
detail::force_type (deviceType, forced_type);
43
43
for (const auto &plt : platform::get_platforms ()) {
44
- vector_class<device> found_devices (plt.get_devices (deviceType));
45
- if (!found_devices.empty ())
46
- devices.insert (devices.end (), found_devices.begin (),
47
- found_devices.end ());
44
+ // Host device must always be available.
45
+ if (plt.is_host ()) {
46
+ vector_class<device> host_device (
47
+ plt.get_devices (info::device_type::host));
48
+ if (!host_device.empty ())
49
+ devices.insert (devices.end (), host_device.begin (), host_device.end ());
50
+ } else {
51
+ vector_class<device> found_devices (plt.get_devices (deviceType));
52
+ if (!found_devices.empty ())
53
+ devices.insert (devices.end (), found_devices.begin (),
54
+ found_devices.end ());
55
+ }
48
56
}
49
57
}
50
58
return devices;
Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx -fsycl %s -o %t1.out
2
+ // RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
3
+ // RUN: %CPU_RUN_PLACEHOLDER %t1.out
4
+ // RUN: %GPU_RUN_PLACEHOLDER %t1.out
5
+ // RUN: %ACC_RUN_PLACEHOLDER %t1.out
6
+
7
+ // ==------ host_always_works.cpp - Host Device Availability test -----------==//
8
+ //
9
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
10
+ // See https://llvm.org/LICENSE.txt for license information.
11
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
12
+ //
13
+ // ===----------------------------------------------------------------------===//
14
+
15
+ #include < CL/sycl.hpp>
16
+
17
+ using namespace cl ::sycl;
18
+
19
+ int main () {
20
+ device (host_selector{});
21
+
22
+ return 0 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx -fsycl %s -o %t1.out
2
+ // RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
3
+ // RUN: %CPU_RUN_PLACEHOLDER %t1.out
4
+ // RUN: %GPU_RUN_PLACEHOLDER %t1.out
5
+ // RUN: %ACC_RUN_PLACEHOLDER %t1.out
6
+
7
+ // ==------ host_platform_avail.cpp - Host Platform Availability test -------==//
8
+ //
9
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
10
+ // See https://llvm.org/LICENSE.txt for license information.
11
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
12
+ //
13
+ // ===----------------------------------------------------------------------===//
14
+
15
+ #include < CL/sycl.hpp>
16
+
17
+ using namespace cl ::sycl;
18
+
19
+ int main () {
20
+ auto plats = platform::get_platforms ();
21
+ bool found_host = false ;
22
+
23
+ // Look for a host platform
24
+ for (const auto &plat : plats) {
25
+ if (plat.is_host ()) {
26
+ found_host = true ;
27
+ }
28
+ }
29
+
30
+ // Fail if we didn't find a host platform
31
+ return (!found_host);
32
+ }
You can’t perform that action at this time.
0 commit comments