Skip to content

Commit 5b13d5b

Browse files
[SYCL] Make host device inaccessible through SYCL API (#6685)
This commit removes the host device from the device list and as such the host device will no longer be available in user code. The following changes are a result of this: * Device filters using 'host' as either backend or device type will cause a warning at runtime. Since there is no host device selectable for these filters, the resulting device list will not contain a host device. * is_host() on SYCL objects has been deprecated. Any use of them internally on a host device should cause an assertion to fail. * host_selector deprecation message has been changed to better reflect that there is no alternative. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
1 parent ed7cb4b commit 5b13d5b

Some content is hidden

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

53 files changed

+304
-692
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 = 0,
22+
host __SYCL2020_DEPRECATED("'host' backend is no longer supported") = 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class __SYCL_EXPORT context {
200200
/// Checks if this context is a SYCL host context.
201201
///
202202
/// \return true if this context is a SYCL host context.
203+
__SYCL2020_DEPRECATED(
204+
"is_host() is deprecated as the host device is no longer supported.")
203205
bool is_host() const;
204206

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

sycl/include/sycl/detail/device_filter.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class device_filter_list {
4646
bool backendCompatible(backend Backend);
4747
bool deviceTypeCompatible(info::device_type DeviceType);
4848
bool deviceNumberCompatible(int DeviceNum);
49-
bool containsHost();
5049
friend std::ostream &operator<<(std::ostream &Out,
5150
const device_filter_list &List);
5251
};

sycl/include/sycl/device.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class __SYCL_EXPORT device {
9999
/// Check if device is a host device
100100
///
101101
/// \return true if SYCL device is a host device
102+
__SYCL2020_DEPRECATED(
103+
"is_host() is deprecated as the host device is no longer supported.")
102104
bool is_host() const;
103105

104106
/// 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("Use a callable function instead.") host_selector
99+
__SYCL2020_DEPRECATED("Host device is no longer supported.") host_selector
100100
: public device_selector {
101101
public:
102102
int operator()(const device &dev) const override;

sycl/include/sycl/event.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class __SYCL_EXPORT event {
6767
/// Checks if this event is a SYCL host event.
6868
///
6969
/// \return true if this event is a SYCL host event.
70+
__SYCL2020_DEPRECATED(
71+
"is_host() is deprecated as the host device is no longer supported.")
7072
bool is_host() const;
7173

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

sycl/include/sycl/handler.hpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,6 @@ class __SYCL_EXPORT handler {
468468

469469
~handler() = default;
470470

471-
bool is_host() { return MIsHost; }
472-
473471
#ifdef __SYCL_DEVICE_ONLY__
474472
// In device compilation accessor isn't inherited from AccessorBaseHost, so
475473
// can't detect by it. Since we don't expect it to be ever called in device
@@ -543,18 +541,6 @@ class __SYCL_EXPORT handler {
543541
sizeof(sampler), ArgIndex);
544542
}
545543

546-
void verifyKernelInvoc(const kernel &Kernel) {
547-
if (is_host()) {
548-
throw invalid_object_error(
549-
"This kernel invocation method cannot be used on the host",
550-
PI_ERROR_INVALID_DEVICE);
551-
}
552-
if (Kernel.is_host()) {
553-
throw invalid_object_error("Invalid kernel type, OpenCL expected",
554-
PI_ERROR_INVALID_KERNEL);
555-
}
556-
}
557-
558544
/* The kernel passed to StoreLambda can take an id, an item or an nd_item as
559545
* its argument. Since esimd plugin directly invokes the kernel (doesn’t use
560546
* piKernelSetArg), the kernel argument type must be known to the plugin.
@@ -1066,7 +1052,6 @@ class __SYCL_EXPORT handler {
10661052
template <int Dims>
10671053
void parallel_for_impl(range<Dims> NumWorkItems, kernel Kernel) {
10681054
throwIfActionIsCreated();
1069-
verifyKernelInvoc(Kernel);
10701055
MKernel = detail::getSyclObjImpl(std::move(Kernel));
10711056
detail::checkValueRange<Dims>(NumWorkItems);
10721057
MNDRDesc.set(std::move(NumWorkItems));
@@ -1877,7 +1862,6 @@ class __SYCL_EXPORT handler {
18771862
/// \param Kernel is a SYCL kernel object.
18781863
void single_task(kernel Kernel) {
18791864
throwIfActionIsCreated();
1880-
verifyKernelInvoc(Kernel);
18811865
// Ignore any set kernel bundles and use the one associated with the kernel
18821866
setHandlerKernelBundle(Kernel);
18831867
// No need to check if range is out of INT_MAX limits as it's compile-time
@@ -1914,7 +1898,6 @@ class __SYCL_EXPORT handler {
19141898
void parallel_for(range<Dims> NumWorkItems, id<Dims> WorkItemOffset,
19151899
kernel Kernel) {
19161900
throwIfActionIsCreated();
1917-
verifyKernelInvoc(Kernel);
19181901
MKernel = detail::getSyclObjImpl(std::move(Kernel));
19191902
detail::checkValueRange<Dims>(NumWorkItems, WorkItemOffset);
19201903
MNDRDesc.set(std::move(NumWorkItems), std::move(WorkItemOffset));
@@ -1933,7 +1916,6 @@ class __SYCL_EXPORT handler {
19331916
/// \param Kernel is a SYCL kernel function.
19341917
template <int Dims> void parallel_for(nd_range<Dims> NDRange, kernel Kernel) {
19351918
throwIfActionIsCreated();
1936-
verifyKernelInvoc(Kernel);
19371919
MKernel = detail::getSyclObjImpl(std::move(Kernel));
19381920
detail::checkValueRange<Dims>(NDRange);
19391921
MNDRDesc.set(std::move(NDRange));

sycl/include/sycl/kernel.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class __SYCL_EXPORT kernel {
105105
/// Check if the associated SYCL context is a SYCL host context.
106106
///
107107
/// \return true if this SYCL kernel is a host kernel.
108+
__SYCL2020_DEPRECATED(
109+
"is_host() is deprecated as the host device is no longer supported.")
108110
bool is_host() const;
109111

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

sycl/include/sycl/platform.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ class __SYCL_EXPORT platform {
109109
/// Checks if this SYCL platform is a host platform.
110110
///
111111
/// \return true if this SYCL platform is a host platform.
112+
__SYCL2020_DEPRECATED(
113+
"is_host() is deprecated as the host device is no longer supported.")
112114
bool is_host() const;
113115

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

sycl/include/sycl/queue.hpp

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ class __SYCL_EXPORT queue {
278278
device get_device() const;
279279

280280
/// \return true if this queue is a SYCL host queue.
281+
__SYCL2020_DEPRECATED(
282+
"is_host() is deprecated as the host device is no longer supported.")
281283
bool is_host() const;
282284

283285
/// Queries SYCL queue for information.
@@ -302,28 +304,24 @@ class __SYCL_EXPORT queue {
302304
_CODELOCARG(&CodeLoc);
303305

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

329327
/// Submits a command group function object to the queue, in order to be
@@ -342,34 +340,27 @@ class __SYCL_EXPORT queue {
342340
_CODELOCARG(&CodeLoc);
343341

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

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

0 commit comments

Comments
 (0)