Skip to content

Commit d1907b8

Browse files
committed
Revert "[SYCL] Make host device inaccessible through SYCL API (intel#6685)"
This reverts commit 5b13d5b.
1 parent 24e36e8 commit d1907b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+939
-270
lines changed

sycl/include/sycl/backend_types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace sycl {
1919
__SYCL_INLINE_VER_NAMESPACE(_V1) {
2020

2121
enum class backend : char {
22-
host __SYCL2020_DEPRECATED("'host' backend is no longer supported") = 0,
22+
host = 0,
2323
opencl = 1,
2424
ext_oneapi_level_zero = 2,
2525
level_zero __SYCL2020_DEPRECATED("use 'ext_oneapi_level_zero' instead") =

sycl/include/sycl/context.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {
202202
/// Checks if this context is a SYCL host context.
203203
///
204204
/// \return true if this context is a SYCL host context.
205-
__SYCL2020_DEPRECATED(
206-
"is_host() is deprecated as the host device is no longer supported.")
207205
bool is_host() const;
208206

209207
/// Returns the backend associated with this context.

sycl/include/sycl/detail/device_filter.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class device_filter_list {
9393
bool backendCompatible(backend Backend);
9494
bool deviceTypeCompatible(info::device_type DeviceType);
9595
bool deviceNumberCompatible(int DeviceNum);
96+
bool containsHost();
9697
friend std::ostream &operator<<(std::ostream &Out,
9798
const device_filter_list &List);
9899
};

sycl/include/sycl/device.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
100100
/// Check if device is a host device
101101
///
102102
/// \return true if SYCL device is a host device
103-
__SYCL2020_DEPRECATED(
104-
"is_host() is deprecated as the host device is no longer supported.")
105103
bool is_host() const;
106104

107105
/// Check if device is a CPU device

sycl/include/sycl/device_selector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ __SYCL2020_DEPRECATED("Use the callable sycl::accelerator_selector_v instead.")
9696
///
9797
/// \ingroup sycl_api_dev_sel
9898
class __SYCL_EXPORT
99-
__SYCL2020_DEPRECATED("Host device is no longer supported.") host_selector
99+
__SYCL2020_DEPRECATED("Use a callable function instead.") host_selector
100100
: public device_selector {
101101
public:
102102
int operator()(const device &dev) const override;

sycl/include/sycl/event.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class __SYCL_EXPORT event : public detail::OwnerLessBase<event> {
6969
/// Checks if this event is a SYCL host event.
7070
///
7171
/// \return true if this event is a SYCL host event.
72-
__SYCL2020_DEPRECATED(
73-
"is_host() is deprecated as the host device is no longer supported.")
7472
bool is_host() const;
7573

7674
/// Return the list of events that this event waits for.

sycl/include/sycl/handler.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ class __SYCL_EXPORT handler {
411411

412412
~handler() = default;
413413

414-
// TODO: Private and unusued. Remove when ABI break is allowed.
415414
bool is_host() { return MIsHost; }
416415

417416
#ifdef __SYCL_DEVICE_ONLY__
@@ -500,10 +499,16 @@ class __SYCL_EXPORT handler {
500499
sizeof(sampler), ArgIndex);
501500
}
502501

503-
// TODO: Unusued. Remove when ABI break is allowed.
504502
void verifyKernelInvoc(const kernel &Kernel) {
505-
std::ignore = Kernel;
506-
return;
503+
if (is_host()) {
504+
throw invalid_object_error(
505+
"This kernel invocation method cannot be used on the host",
506+
PI_ERROR_INVALID_DEVICE);
507+
}
508+
if (Kernel.is_host()) {
509+
throw invalid_object_error("Invalid kernel type, OpenCL expected",
510+
PI_ERROR_INVALID_KERNEL);
511+
}
507512
}
508513

509514
/* The kernel passed to StoreLambda can take an id, an item or an nd_item as
@@ -1064,6 +1069,7 @@ class __SYCL_EXPORT handler {
10641069
template <int Dims>
10651070
void parallel_for_impl(range<Dims> NumWorkItems, kernel Kernel) {
10661071
throwIfActionIsCreated();
1072+
verifyKernelInvoc(Kernel);
10671073
MKernel = detail::getSyclObjImpl(std::move(Kernel));
10681074
detail::checkValueRange<Dims>(NumWorkItems);
10691075
MNDRDesc.set(std::move(NumWorkItems));
@@ -1682,6 +1688,7 @@ class __SYCL_EXPORT handler {
16821688
/// \param Kernel is a SYCL kernel object.
16831689
void single_task(kernel Kernel) {
16841690
throwIfActionIsCreated();
1691+
verifyKernelInvoc(Kernel);
16851692
// Ignore any set kernel bundles and use the one associated with the kernel
16861693
setHandlerKernelBundle(Kernel);
16871694
// No need to check if range is out of INT_MAX limits as it's compile-time
@@ -1718,6 +1725,7 @@ class __SYCL_EXPORT handler {
17181725
void parallel_for(range<Dims> NumWorkItems, id<Dims> WorkItemOffset,
17191726
kernel Kernel) {
17201727
throwIfActionIsCreated();
1728+
verifyKernelInvoc(Kernel);
17211729
MKernel = detail::getSyclObjImpl(std::move(Kernel));
17221730
detail::checkValueRange<Dims>(NumWorkItems, WorkItemOffset);
17231731
MNDRDesc.set(std::move(NumWorkItems), std::move(WorkItemOffset));
@@ -1736,6 +1744,7 @@ class __SYCL_EXPORT handler {
17361744
/// \param Kernel is a SYCL kernel function.
17371745
template <int Dims> void parallel_for(nd_range<Dims> NDRange, kernel Kernel) {
17381746
throwIfActionIsCreated();
1747+
verifyKernelInvoc(Kernel);
17391748
MKernel = detail::getSyclObjImpl(std::move(Kernel));
17401749
detail::checkValueRange<Dims>(NDRange);
17411750
MNDRDesc.set(std::move(NDRange));

sycl/include/sycl/kernel.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ class __SYCL_EXPORT kernel : public detail::OwnerLessBase<kernel> {
107107
/// Check if the associated SYCL context is a SYCL host context.
108108
///
109109
/// \return true if this SYCL kernel is a host kernel.
110-
__SYCL2020_DEPRECATED(
111-
"is_host() is deprecated as the host device is no longer supported.")
112110
bool is_host() const;
113111

114112
/// Get the context that this kernel is defined for.

sycl/include/sycl/platform.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
108108
/// Checks if this SYCL platform is a host platform.
109109
///
110110
/// \return true if this SYCL platform is a host platform.
111-
__SYCL2020_DEPRECATED(
112-
"is_host() is deprecated as the host device is no longer supported.")
113111
bool is_host() const;
114112

115113
/// Returns all SYCL devices associated with this platform.

sycl/include/sycl/queue.hpp

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,6 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
282282
device get_device() const;
283283

284284
/// \return true if this queue is a SYCL host queue.
285-
__SYCL2020_DEPRECATED(
286-
"is_host() is deprecated as the host device is no longer supported.")
287285
bool is_host() const;
288286

289287
/// Queries SYCL queue for information.
@@ -308,24 +306,28 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
308306
_CODELOCARG(&CodeLoc);
309307

310308
#if __SYCL_USE_FALLBACK_ASSERT
311-
auto PostProcess = [this, &CodeLoc](bool IsKernel, bool KernelUsesAssert,
312-
event &E) {
313-
if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) &&
314-
KernelUsesAssert && !device_has(aspect::accelerator)) {
315-
// __devicelib_assert_fail isn't supported by Device-side Runtime
316-
// Linking against fallback impl of __devicelib_assert_fail is
317-
// performed by program manager class
318-
// Fallback assert isn't supported for FPGA
319-
submitAssertCapture(*this, E, /* SecondaryQueue = */ nullptr, CodeLoc);
320-
}
321-
};
322-
323-
auto Event = submit_impl_and_postprocess(CGF, CodeLoc, PostProcess);
324-
return discard_or_return(Event);
325-
#else
326-
auto Event = submit_impl(CGF, CodeLoc);
327-
return discard_or_return(Event);
309+
if (!is_host()) {
310+
auto PostProcess = [this, &CodeLoc](bool IsKernel, bool KernelUsesAssert,
311+
event &E) {
312+
if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) &&
313+
KernelUsesAssert && !device_has(aspect::accelerator)) {
314+
// __devicelib_assert_fail isn't supported by Device-side Runtime
315+
// Linking against fallback impl of __devicelib_assert_fail is
316+
// performed by program manager class
317+
// Fallback assert isn't supported for FPGA
318+
submitAssertCapture(*this, E, /* SecondaryQueue = */ nullptr,
319+
CodeLoc);
320+
}
321+
};
322+
323+
auto Event = submit_impl_and_postprocess(CGF, CodeLoc, PostProcess);
324+
return discard_or_return(Event);
325+
} else
328326
#endif // __SYCL_USE_FALLBACK_ASSERT
327+
{
328+
auto Event = submit_impl(CGF, CodeLoc);
329+
return discard_or_return(Event);
330+
}
329331
}
330332

331333
/// Submits a command group function object to the queue, in order to be
@@ -344,27 +346,34 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
344346
_CODELOCARG(&CodeLoc);
345347

346348
#if __SYCL_USE_FALLBACK_ASSERT
347-
auto PostProcess = [this, &SecondaryQueue, &CodeLoc](
348-
bool IsKernel, bool KernelUsesAssert, event &E) {
349-
if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) &&
350-
KernelUsesAssert && !device_has(aspect::accelerator)) {
351-
// Only secondary queues on devices need to be added to the assert
352-
// capture.
353-
// __devicelib_assert_fail isn't supported by Device-side Runtime
354-
// Linking against fallback impl of __devicelib_assert_fail is
355-
// performed by program manager class
356-
// Fallback assert isn't supported for FPGA
357-
submitAssertCapture(*this, E, &SecondaryQueue, CodeLoc);
358-
}
359-
};
360-
361-
auto Event =
362-
submit_impl_and_postprocess(CGF, SecondaryQueue, CodeLoc, PostProcess);
363-
return discard_or_return(Event);
364-
#else
365-
auto Event = submit_impl(CGF, SecondaryQueue, CodeLoc);
366-
return discard_or_return(Event);
349+
if (!is_host()) {
350+
auto PostProcess = [this, &SecondaryQueue, &CodeLoc](
351+
bool IsKernel, bool KernelUsesAssert, event &E) {
352+
if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) &&
353+
KernelUsesAssert && !device_has(aspect::accelerator)) {
354+
// Only secondary queues on devices need to be added to the assert
355+
// capture.
356+
// TODO: Handle case where primary queue is host but the secondary
357+
// queue is not.
358+
queue *DeviceSecondaryQueue =
359+
SecondaryQueue.is_host() ? nullptr : &SecondaryQueue;
360+
// __devicelib_assert_fail isn't supported by Device-side Runtime
361+
// Linking against fallback impl of __devicelib_assert_fail is
362+
// performed by program manager class
363+
// Fallback assert isn't supported for FPGA
364+
submitAssertCapture(*this, E, DeviceSecondaryQueue, CodeLoc);
365+
}
366+
};
367+
368+
auto Event = submit_impl_and_postprocess(CGF, SecondaryQueue, CodeLoc,
369+
PostProcess);
370+
return discard_or_return(Event);
371+
} else
367372
#endif // __SYCL_USE_FALLBACK_ASSERT
373+
{
374+
auto Event = submit_impl(CGF, SecondaryQueue, CodeLoc);
375+
return discard_or_return(Event);
376+
}
368377
}
369378

370379
/// Prevents any commands submitted afterward to this queue from executing

sycl/source/context.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ context::context(const std::vector<device> &DeviceList,
5959
PI_ERROR_INVALID_VALUE);
6060
}
6161
auto NonHostDeviceIter = std::find_if_not(
62-
DeviceList.begin(), DeviceList.end(), [&](const device &CurrentDevice) {
63-
return detail::getSyclObjImpl(CurrentDevice)->is_host();
64-
});
62+
DeviceList.begin(), DeviceList.end(),
63+
[&](const device &CurrentDevice) { return CurrentDevice.is_host(); });
6564
if (NonHostDeviceIter == DeviceList.end())
6665
impl = std::make_shared<detail::context_impl>(DeviceList[0], AsyncHandler,
6766
PropList);
@@ -72,7 +71,7 @@ context::context(const std::vector<device> &DeviceList,
7271
if (std::any_of(DeviceList.begin(), DeviceList.end(),
7372
[&](const device &CurrentDevice) {
7473
return (
75-
detail::getSyclObjImpl(CurrentDevice)->is_host() ||
74+
CurrentDevice.is_host() ||
7675
(detail::getSyclObjImpl(CurrentDevice.get_platform())
7776
->getHandleRef() != NonHostPlatform));
7877
}))
@@ -124,11 +123,7 @@ context::get_info() const {
124123

125124
cl_context context::get() const { return impl->get(); }
126125

127-
bool context::is_host() const {
128-
bool IsHost = impl->is_host();
129-
assert(!IsHost && "context::is_host should not be called in implementation.");
130-
return IsHost;
131-
}
126+
bool context::is_host() const { return impl->is_host(); }
132127

133128
backend context::get_backend() const noexcept { return getImplBackend(impl); }
134129

sycl/source/detail/backend_impl.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
//===----------------------------------------------------------------------===//
88

99
#pragma once
10-
#include <cassert>
1110
#include <sycl/backend_types.hpp>
1211

1312
namespace sycl {
1413
__SYCL_INLINE_VER_NAMESPACE(_V1) {
1514
namespace detail {
1615

1716
template <class T> backend getImplBackend(const T &Impl) {
18-
assert(!Impl->is_host() && "Cannot get the backend for host.");
19-
return Impl->getPlugin().getBackend();
17+
backend Result;
18+
if (Impl->is_host())
19+
Result = backend::host;
20+
else
21+
Result = Impl->getPlugin().getBackend();
22+
23+
return Result;
2024
}
2125

2226
} // namespace detail

sycl/source/detail/context_impl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ namespace detail {
3030
context_impl::context_impl(const device &Device, async_handler AsyncHandler,
3131
const property_list &PropList)
3232
: MAsyncHandler(AsyncHandler), MDevices(1, Device), MContext(nullptr),
33-
MPlatform(), MPropList(PropList),
34-
MHostContext(detail::getSyclObjImpl(Device)->is_host()),
33+
MPlatform(), MPropList(PropList), MHostContext(Device.is_host()),
3534
MSupportBufferLocationByDevices(NotChecked) {
3635
MKernelProgramCache.setContextPtr(this);
3736
}

sycl/source/detail/device_filter.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,6 @@ device_filter::device_filter(const std::string &FilterString) {
299299
else {
300300
Backend = It->second;
301301
TripleValueID++;
302-
303-
if (Backend == backend::host)
304-
std::cerr << "WARNING: The 'host' backend type is no longer supported in "
305-
"device filter."
306-
<< std::endl;
307302
}
308303

309304
// Handle the optional 2nd field of the filter - device type.
@@ -320,11 +315,6 @@ device_filter::device_filter(const std::string &FilterString) {
320315
else {
321316
DeviceType = Iter->second;
322317
TripleValueID++;
323-
324-
if (DeviceType == info::device_type::host)
325-
std::cerr << "WARNING: The 'host' device type is no longer supported "
326-
"in device filter."
327-
<< std::endl;
328318
}
329319
}
330320

@@ -338,8 +328,8 @@ device_filter::device_filter(const std::string &FilterString) {
338328
std::string Message =
339329
std::string("Invalid device filter: ") + FilterString +
340330
"\nPossible backend values are "
341-
"{opencl,level_zero,cuda,hip,esimd_emulator,*}.\n"
342-
"Possible device types are {cpu,gpu,acc,*}.\n"
331+
"{host,opencl,level_zero,cuda,hip,esimd_emulator,*}.\n"
332+
"Possible device types are {host,cpu,gpu,acc,*}.\n"
343333
"Device number should be an non-negative integer.\n";
344334
throw sycl::invalid_parameter_error(Message, PI_ERROR_INVALID_VALUE);
345335
}
@@ -402,6 +392,19 @@ bool device_filter_list::deviceNumberCompatible(int DeviceNum) {
402392
});
403393
}
404394

395+
bool device_filter_list::containsHost() {
396+
for (const device_filter &Filter : FilterList) {
397+
if (Filter.Backend == backend::host || Filter.Backend == backend::all)
398+
if (Filter.DeviceType == info::device_type::host ||
399+
Filter.DeviceType == info::device_type::all)
400+
// SYCL RT never creates more than one HOST device.
401+
// All device numbers other than 0 are rejected.
402+
if (!Filter.DeviceNum || Filter.DeviceNum == 0)
403+
return true;
404+
}
405+
return false;
406+
}
407+
405408
} // namespace detail
406409
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
407410
} // namespace sycl

0 commit comments

Comments
 (0)