Skip to content

Commit eab2969

Browse files
[SYCL] Throw exception for pipe extension on host (#6385)
The implementation of the pipes extension currently uses a failing assert when pipe operations are done on host. This commit changes these assertions into throwing a SYCL exception, both allowing for failure recovery and makes the failures independent on whether assertions are enabled. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 3f06cad commit eab2969

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

sycl/include/sycl/ext/intel/experimental/pipes.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ class pipe<_name, _dataT, _min_capacity, _propertiesT,
7575
#else
7676
(void)Success;
7777
(void)Properties;
78-
assert(!"Pipes are not supported on a host device!");
78+
throw sycl::exception(
79+
sycl::make_error_code(sycl::errc::feature_not_supported),
80+
"Pipes are not supported on a host device.");
7981
#endif // __SYCL_DEVICE_ONLY__
8082
}
8183

@@ -122,7 +124,9 @@ class pipe<_name, _dataT, _min_capacity, _propertiesT,
122124
(void)Success;
123125
(void)Data;
124126
(void)Properties;
125-
assert(!"Pipes are not supported on a host device!");
127+
throw sycl::exception(
128+
sycl::make_error_code(sycl::errc::feature_not_supported),
129+
"Pipes are not supported on a host device.");
126130
#endif // __SYCL_DEVICE_ONLY__
127131
}
128132

@@ -169,7 +173,9 @@ class pipe<_name, _dataT, _min_capacity, _propertiesT,
169173
return TempData;
170174
#else
171175
(void)Properties;
172-
assert(!"Pipes are not supported on a host device!");
176+
throw sycl::exception(
177+
sycl::make_error_code(sycl::errc::feature_not_supported),
178+
"Pipes are not supported on a host device.");
173179
#endif // __SYCL_DEVICE_ONLY__
174180
}
175181

@@ -212,7 +218,9 @@ class pipe<_name, _dataT, _min_capacity, _propertiesT,
212218
#else
213219
(void)Data;
214220
(void)Properties;
215-
assert(!"Pipes are not supported on a host device!");
221+
throw sycl::exception(
222+
sycl::make_error_code(sycl::errc::feature_not_supported),
223+
"Pipes are not supported on a host device.");
216224
#endif // __SYCL_DEVICE_ONLY__
217225
}
218226

sycl/include/sycl/ext/intel/pipes.hpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ template <class _name, class _dataT, int32_t _min_capacity = 0> class pipe {
3434
return TempData;
3535
#else
3636
(void)_Success;
37-
assert(!"Pipes are not supported on a host device!");
37+
throw sycl::exception(
38+
sycl::make_error_code(sycl::errc::feature_not_supported),
39+
"Pipes are not supported on a host device.");
3840
#endif // __SYCL_DEVICE_ONLY__
3941
}
4042

@@ -49,7 +51,9 @@ template <class _name, class _dataT, int32_t _min_capacity = 0> class pipe {
4951
#else
5052
(void)_Success;
5153
(void)_Data;
52-
assert(!"Pipes are not supported on a host device!");
54+
throw sycl::exception(
55+
sycl::make_error_code(sycl::errc::feature_not_supported),
56+
"Pipes are not supported on a host device.");
5357
#endif // __SYCL_DEVICE_ONLY__
5458
}
5559

@@ -64,7 +68,9 @@ template <class _name, class _dataT, int32_t _min_capacity = 0> class pipe {
6468
__spirv_ReadPipeBlockingINTEL(_RPipe, &TempData, m_Size, m_Alignment);
6569
return TempData;
6670
#else
67-
assert(!"Pipes are not supported on a host device!");
71+
throw sycl::exception(
72+
sycl::make_error_code(sycl::errc::feature_not_supported),
73+
"Pipes are not supported on a host device.");
6874
#endif // __SYCL_DEVICE_ONLY__
6975
}
7076

@@ -77,7 +83,9 @@ template <class _name, class _dataT, int32_t _min_capacity = 0> class pipe {
7783
__spirv_WritePipeBlockingINTEL(_WPipe, &_Data, m_Size, m_Alignment);
7884
#else
7985
(void)_Data;
80-
assert(!"Pipes are not supported on a host device!");
86+
throw sycl::exception(
87+
sycl::make_error_code(sycl::errc::feature_not_supported),
88+
"Pipes are not supported on a host device.");
8189
#endif // __SYCL_DEVICE_ONLY__
8290
}
8391

@@ -128,7 +136,9 @@ class kernel_readable_io_pipe {
128136
return TempData;
129137
#else
130138
(void)_Success;
131-
assert(!"Pipes are not supported on a host device!");
139+
throw sycl::exception(
140+
sycl::make_error_code(sycl::errc::feature_not_supported),
141+
"Pipes are not supported on a host device.");
132142
#endif // __SYCL_DEVICE_ONLY__
133143
}
134144

@@ -143,7 +153,9 @@ class kernel_readable_io_pipe {
143153
__spirv_ReadPipeBlockingINTEL(_RPipe, &TempData, m_Size, m_Alignment);
144154
return TempData;
145155
#else
146-
assert(!"Pipes are not supported on a host device!");
156+
throw sycl::exception(
157+
sycl::make_error_code(sycl::errc::feature_not_supported),
158+
"Pipes are not supported on a host device.");
147159
#endif // __SYCL_DEVICE_ONLY__
148160
}
149161

@@ -174,7 +186,9 @@ class kernel_writeable_io_pipe {
174186
#else
175187
(void)_Data;
176188
(void)_Success;
177-
assert(!"Pipes are not supported on a host device!");
189+
throw sycl::exception(
190+
sycl::make_error_code(sycl::errc::feature_not_supported),
191+
"Pipes are not supported on a host device.");
178192
#endif // __SYCL_DEVICE_ONLY__
179193
}
180194

@@ -188,7 +202,9 @@ class kernel_writeable_io_pipe {
188202
__spirv_WritePipeBlockingINTEL(_WPipe, &_Data, m_Size, m_Alignment);
189203
#else
190204
(void)_Data;
191-
assert(!"Pipes are not supported on a host device!");
205+
throw sycl::exception(
206+
sycl::make_error_code(sycl::errc::feature_not_supported),
207+
"Pipes are not supported on a host device.");
192208
#endif // __SYCL_DEVICE_ONLY__
193209
}
194210

0 commit comments

Comments
 (0)