Skip to content

Commit

Permalink
[SYCL][Graph][HIP] Add HIP backend support to SYCL-Graph (#12230)
Browse files Browse the repository at this point in the history
Tests HIP Support for Graph from
oneapi-src/unified-runtime#1254 and updates
documentation.

Depends on #12753.

---------

Co-authored-by: Andrey Alekseenko <andrey.alekseenko@scilifelab.se>
Co-authored-by: Ewan Crawford <ewan@codeplay.com>
  • Loading branch information
3 people authored Mar 1, 2024
1 parent be8ad8f commit 897b270
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 14 deletions.
23 changes: 22 additions & 1 deletion sycl/doc/design/CommandGraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Implementation of UR command-buffers
for each of the supported SYCL 2020 backends.

Backends which are implemented currently are: [Level Zero](#level-zero),
[CUDA](#cuda), and partial support for [OpenCL](#opencl).
[CUDA](#cuda), [HIP](#hip) and partial support for [OpenCL](#opencl).

### Level Zero

Expand Down Expand Up @@ -351,6 +351,27 @@ An executable CUDA Graph, which contains all commands and synchronization
information, is saved in the UR command-buffer to allow for efficient
graph resubmission.

### HIP

The HIP backend offers a Graph managemenet API very similar to CUDA Graph
feature for batching series of operations.
The SYCL Graph HIP backend implementation is therefore very similar to that of CUDA.

UR commands (e.g. kernels) are mapped as graph nodes using the
[HIP Management API](https://docs.amd.com/projects/HIP/en/docs-5.5.0/doxygen/html/group___graph.html).
Synchronization between commands (UR sync-points) is implemented
using graph dependencies.
Executable HIP Graphs can be submitted to a HIP stream
in the same way as regular kernels.
The HIP backend enables enqueuing events to wait for into a stream.
It also allows signaling the completion of a submission with an event.
Therefore, submitting a UR command-buffer consists only of submitting to a stream
the executable HIP Graph that represent this series of operations.

An executable HIP Graph, which contains all commands and synchronization
information, is saved in the UR command-buffer to allow for efficient
graph resubmission.

### OpenCL

SYCL-Graph is only enabled for an OpenCL backend when the
Expand Down
2 changes: 1 addition & 1 deletion sycl/doc/design/images/SYCL-Graph-Architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions sycl/plugins/unified_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT)
include(FetchContent)

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
# commit 9b936b5748a8da86123f3f148d1cfa84e52531c4
# Merge: 91c6068b 767cfd1a
# Author: Piotr Balcer <piotr.balcer@intel.com>
# Date: Mon Feb 26 10:46:55 2024 +0100
# Merge pull request #1354 from AllanZyne/sanitizer-device-global
# [DeviceSanitizer] Support detecting out-of-bounds error on DeviceGlobals
set(UNIFIED_RUNTIME_TAG 9b936b5748a8da86123f3f148d1cfa84e52531c4)

# commit a2757b2931daa2f8d7c9dd51b0fc846be1fd49a7
# Merge: 9b936b5 + f78d369
# Author: Kenneth Benzie (Benie) <k.benzie@codeplay.com>
# Date: Tue Feb 27 11:34:58 2024 +0000
# Merge pull request #1254 from Bensuo/cmdbuf-support-hip
# [EXP][CMDBUF] HIP adapter support for command buffers
set(UNIFIED_RUNTIME_TAG a2757b2931daa2f8d7c9dd51b0fc846be1fd49a7 )

if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO)
set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}")
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/Graph/Explicit/enqueue_ordering.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: aspect-usm_shared_allocations
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG
Expand Down
3 changes: 1 addition & 2 deletions sycl/test-e2e/Graph/Explicit/work_group_size_prop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
// should. So the Sycl graph support cannot correctly catch the error and throw
// the approriate exception for negative test. An issue has been reported
// https://github.com/bashbaug/SimpleOpenCLSamples/issues/95
// XFAIL: cuda
// XFAIL: cuda, hip
// UNSUPPORTED: opencl
// Note: failing negative test with HIP in the original test
// TODO: disable hip when HIP backend will be supported by Graph

#define GRAPH_E2E_EXPLICIT

Expand Down
3 changes: 1 addition & 2 deletions sycl/test-e2e/Graph/RecordReplay/work_group_size_prop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
// should. So the Sycl graph support cannot correctly catch the error and throw
// the approriate exception for negative test. An issue has been reported
// https://github.com/bashbaug/SimpleOpenCLSamples/issues/95
// XFAIL: cuda
// XFAIL: cuda, hip
// UNSUPPORTED: opencl
// Note: failing negative test with HIP in the original test
// TODO: disable hip when HIP backend will be supported by Graph

#define GRAPH_E2E_RECORD_REPLAY

Expand Down
3 changes: 2 additions & 1 deletion sycl/test-e2e/Graph/device_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ int main() {
auto Backend = Device.get_backend();

if ((Backend == backend::ext_oneapi_level_zero) ||
(Backend == backend::ext_oneapi_cuda)) {
(Backend == backend::ext_oneapi_cuda) ||
(Backend == backend::ext_oneapi_hip)) {
assert(SupportsGraphs == exp_ext::graph_support_level::native);
} else if (Backend == backend::opencl) {
// OpenCL backend support is conditional on the cl_khr_command_buffer
Expand Down

0 comments on commit 897b270

Please sign in to comment.