Skip to content

Commit 3756725

Browse files
EwanCmartygrant
authored andcommitted
Throw exception on unsupported entry-point
Describe in exception message the name of the unsupported entry-point.
1 parent 3244eb2 commit 3756725

File tree

3 files changed

+80
-24
lines changed

3 files changed

+80
-24
lines changed

sycl/doc/design/CommandGraph.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,14 @@ support.
266266
Due to the API mapping gaps documented in the following section, OpenCL as a
267267
SYCL backend cannot fully support the graphs API. Instead there are
268268
limitations in the types on nodes which a user can add to a graph, using
269-
an unsupported node type will cause an abort in graph finalization with the
270-
message
271-
`ur_die: Experimental Command-buffer entry point is not implemented for OpenCL adapter.`.
269+
an unsupported node type will cause a sycl exception to be throw in graph
270+
finalization with error code `sycl::errc::feature_not_support` and a message
271+
mentioning the unsupported command. For example,
272+
273+
```
274+
terminate called after throwing an instance of 'sycl::_V1::exception'
275+
what(): USM copy command not supported by graph backend
276+
```
272277

273278
The types of commands which are unsupported, and lead to this exception are:
274279
* `handler::copy(src, dest)` - Where `src` is an accessor and `dest` is a pointer.
@@ -312,6 +317,9 @@ adapter where there is matching support for each function in the list.
312317
| | clCommandSVMMemcpyKHR | No |
313318
| | clCommandSVMMemFillKHR | No |
314319

320+
We are looking to address these gaps in the future so that SYCL-Graphs can be
321+
fully supported on a `cl_khr_command_buffer` backend.
322+
315323
#### UR Command-Buffer Implementation
316324

317325
Many of the OpenCL functions take a `cl_command_queue` parameter which is not

sycl/plugins/unified_runtime/pi2ur.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static pi_result ur2piResult(ur_result_t urResult) {
101101
return PI_ERROR_LINK_PROGRAM_FAILURE;
102102
case UR_RESULT_ERROR_UNSUPPORTED_VERSION:
103103
case UR_RESULT_ERROR_UNSUPPORTED_FEATURE:
104+
return PI_ERROR_INVALID_OPERATION;
104105
case UR_RESULT_ERROR_INVALID_ARGUMENT:
105106
case UR_RESULT_ERROR_INVALID_NULL_HANDLE:
106107
case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE:

sycl/source/detail/memory_manager.cpp

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,10 +1518,20 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer(
15181518
}
15191519

15201520
if (1 == DimDst && 1 == DimSrc) {
1521-
Plugin->call<PiApiKind::piextCommandBufferMemBufferRead>(
1522-
CommandBuffer, sycl::detail::pi::cast<sycl::detail::pi::PiMem>(SrcMem),
1523-
SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes,
1524-
Deps.size(), Deps.data(), OutSyncPoint);
1521+
pi_result Result =
1522+
Plugin->call_nocheck<PiApiKind::piextCommandBufferMemBufferRead>(
1523+
CommandBuffer,
1524+
sycl::detail::pi::cast<sycl::detail::pi::PiMem>(SrcMem),
1525+
SrcXOffBytes, SrcAccessRangeWidthBytes, DstMem + DstXOffBytes,
1526+
Deps.size(), Deps.data(), OutSyncPoint);
1527+
1528+
if (Result == PI_ERROR_INVALID_OPERATION) {
1529+
throw sycl::exception(
1530+
sycl::make_error_code(sycl::errc::feature_not_supported),
1531+
"Device-to-host buffer copy command not supported by graph backend");
1532+
} else {
1533+
Plugin->checkPiResult(Result);
1534+
}
15251535
} else {
15261536
size_t BufferRowPitch = (1 == DimSrc) ? 0 : SrcSzWidthBytes;
15271537
size_t BufferSlicePitch =
@@ -1538,11 +1548,20 @@ void MemoryManager::ext_oneapi_copyD2H_cmd_buffer(
15381548
SrcAccessRange[SrcPos.YTerm],
15391549
SrcAccessRange[SrcPos.ZTerm]};
15401550

1541-
Plugin->call<PiApiKind::piextCommandBufferMemBufferReadRect>(
1542-
CommandBuffer, sycl::detail::pi::cast<sycl::detail::pi::PiMem>(SrcMem),
1543-
&BufferOffset, &HostOffset, &RectRegion, BufferRowPitch,
1544-
BufferSlicePitch, HostRowPitch, HostSlicePitch, DstMem, Deps.size(),
1545-
Deps.data(), OutSyncPoint);
1551+
pi_result Result =
1552+
Plugin->call_nocheck<PiApiKind::piextCommandBufferMemBufferReadRect>(
1553+
CommandBuffer,
1554+
sycl::detail::pi::cast<sycl::detail::pi::PiMem>(SrcMem),
1555+
&BufferOffset, &HostOffset, &RectRegion, BufferRowPitch,
1556+
BufferSlicePitch, HostRowPitch, HostSlicePitch, DstMem, Deps.size(),
1557+
Deps.data(), OutSyncPoint);
1558+
if (Result == PI_ERROR_INVALID_OPERATION) {
1559+
throw sycl::exception(
1560+
sycl::make_error_code(sycl::errc::feature_not_supported),
1561+
"Device-to-host buffer copy command not supported by graph backend");
1562+
} else {
1563+
Plugin->checkPiResult(Result);
1564+
}
15461565
}
15471566
}
15481567

@@ -1576,10 +1595,20 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer(
15761595
}
15771596

15781597
if (1 == DimDst && 1 == DimSrc) {
1579-
Plugin->call<PiApiKind::piextCommandBufferMemBufferWrite>(
1580-
CommandBuffer, sycl::detail::pi::cast<sycl::detail::pi::PiMem>(DstMem),
1581-
DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes,
1582-
Deps.size(), Deps.data(), OutSyncPoint);
1598+
pi_result Result =
1599+
Plugin->call_nocheck<PiApiKind::piextCommandBufferMemBufferWrite>(
1600+
CommandBuffer,
1601+
sycl::detail::pi::cast<sycl::detail::pi::PiMem>(DstMem),
1602+
DstXOffBytes, DstAccessRangeWidthBytes, SrcMem + SrcXOffBytes,
1603+
Deps.size(), Deps.data(), OutSyncPoint);
1604+
1605+
if (Result == PI_ERROR_INVALID_OPERATION) {
1606+
throw sycl::exception(
1607+
sycl::make_error_code(sycl::errc::feature_not_supported),
1608+
"Host-to-device buffer copy command not supported by graph backend");
1609+
} else {
1610+
Plugin->checkPiResult(Result);
1611+
}
15831612
} else {
15841613
size_t BufferRowPitch = (1 == DimDst) ? 0 : DstSzWidthBytes;
15851614
size_t BufferSlicePitch =
@@ -1596,11 +1625,21 @@ void MemoryManager::ext_oneapi_copyH2D_cmd_buffer(
15961625
DstAccessRange[DstPos.YTerm],
15971626
DstAccessRange[DstPos.ZTerm]};
15981627

1599-
Plugin->call<PiApiKind::piextCommandBufferMemBufferWriteRect>(
1600-
CommandBuffer, sycl::detail::pi::cast<sycl::detail::pi::PiMem>(DstMem),
1601-
&BufferOffset, &HostOffset, &RectRegion, BufferRowPitch,
1602-
BufferSlicePitch, HostRowPitch, HostSlicePitch, SrcMem, Deps.size(),
1603-
Deps.data(), OutSyncPoint);
1628+
pi_result Result =
1629+
Plugin->call_nocheck<PiApiKind::piextCommandBufferMemBufferWriteRect>(
1630+
CommandBuffer,
1631+
sycl::detail::pi::cast<sycl::detail::pi::PiMem>(DstMem),
1632+
&BufferOffset, &HostOffset, &RectRegion, BufferRowPitch,
1633+
BufferSlicePitch, HostRowPitch, HostSlicePitch, SrcMem, Deps.size(),
1634+
Deps.data(), OutSyncPoint);
1635+
1636+
if (Result == PI_ERROR_INVALID_OPERATION) {
1637+
throw sycl::exception(
1638+
sycl::make_error_code(sycl::errc::feature_not_supported),
1639+
"Host-to-device buffer copy command not supported by graph backend");
1640+
} else {
1641+
Plugin->checkPiResult(Result);
1642+
}
16041643
}
16051644
}
16061645

@@ -1614,9 +1653,17 @@ void MemoryManager::ext_oneapi_copy_usm_cmd_buffer(
16141653
PI_ERROR_INVALID_VALUE);
16151654

16161655
const PluginPtr &Plugin = Context->getPlugin();
1617-
Plugin->call<PiApiKind::piextCommandBufferMemcpyUSM>(
1618-
CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(),
1619-
OutSyncPoint);
1656+
pi_result Result =
1657+
Plugin->call_nocheck<PiApiKind::piextCommandBufferMemcpyUSM>(
1658+
CommandBuffer, DstMem, SrcMem, Len, Deps.size(), Deps.data(),
1659+
OutSyncPoint);
1660+
if (Result == PI_ERROR_INVALID_OPERATION) {
1661+
throw sycl::exception(
1662+
sycl::make_error_code(sycl::errc::feature_not_supported),
1663+
"USM copy command not supported by graph backend");
1664+
} else {
1665+
Plugin->checkPiResult(Result);
1666+
}
16201667
}
16211668

16221669
void MemoryManager::copy_image_bindless(

0 commit comments

Comments
 (0)