Skip to content

Commit cdc2272

Browse files
[SYCL][Graph] Add missing exception for USM memset (#11945)
Throws a invalid exception when memset queue shortcut is used during graph recording since memset is not supported by the current graph implementation. Adds a unitest checking that the exception is correctly thrown. Addresses issue #11940
1 parent 1e1801d commit cdc2272

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

sycl/source/detail/queue_impl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ event queue_impl::memset(const std::shared_ptr<detail::queue_impl> &Self,
8585
// Emit a begin/end scope for this call
8686
PrepareNotify.scopedNotify((uint16_t)xpti::trace_point_type_t::task_begin);
8787
#endif
88+
if (MGraph.lock()) {
89+
throw sycl::exception(make_error_code(errc::invalid),
90+
"The memset feature is not yet available "
91+
"for use with the SYCL Graph extension.");
92+
}
93+
8894
if (MHasDiscardEventsSupport) {
8995
MemoryManager::fill_usm(Ptr, Self, Count, Value,
9096
getOrWaitEvents(DepEvents, MContext), nullptr);

sycl/unittests/Extensions/CommandGraph.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,25 @@ TEST_F(CommandGraphTest, KernelPropertiesExceptionCheck) {
17201720
KernelFunction);
17211721
}
17221722

1723+
TEST_F(CommandGraphTest, USMMemsetShortcutExceptionCheck) {
1724+
1725+
const size_t N = 10;
1726+
unsigned char *Arr = malloc_device<unsigned char>(N, Queue);
1727+
int Value = 77;
1728+
1729+
Graph.begin_recording(Queue);
1730+
1731+
std::error_code ExceptionCode = make_error_code(sycl::errc::success);
1732+
try {
1733+
Queue.memset(Arr, Value, N);
1734+
} catch (exception &Exception) {
1735+
ExceptionCode = Exception.code();
1736+
}
1737+
ASSERT_EQ(ExceptionCode, sycl::errc::invalid);
1738+
1739+
Graph.end_recording(Queue);
1740+
}
1741+
17231742
TEST_F(CommandGraphTest, Memcpy2DExceptionCheck) {
17241743
constexpr size_t RECT_WIDTH = 30;
17251744
constexpr size_t RECT_HEIGHT = 21;

0 commit comments

Comments
 (0)