diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp index ec7eceb183813..a5f00b90518c1 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/graph.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/graph.hpp @@ -9,11 +9,17 @@ #pragma once #include +#include + +#include "graph_defines.hpp" #include #include namespace sycl { +__SYCL_INLINE_VER_NAMESPACE(_V1) { +class queue; + namespace ext { namespace oneapi { namespace experimental { @@ -142,8 +148,6 @@ struct node { void set_root() { MGraph->add_root(MNode); } }; -enum class graph_state { modifiable, executable }; - template class command_graph { public: // Adding empty node with [0..n] predecessors: @@ -219,5 +223,6 @@ void command_graph::exec_and_wait(sycl::queue q) { } // namespace experimental } // namespace oneapi } // namespace ext +} // __SYCL_INLINE_VER_NAMESPACE(_V1) } // namespace sycl diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph_defines.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph_defines.hpp new file mode 100644 index 0000000000000..f5eb4162c0284 --- /dev/null +++ b/sycl/include/sycl/ext/oneapi/experimental/graph_defines.hpp @@ -0,0 +1,28 @@ +//==--------- graph_defines.hpp --- SYCL graph extension +//---------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#pragma once + +namespace sycl { +__SYCL_INLINE_VER_NAMESPACE(_V1) { +namespace ext { +namespace oneapi { +namespace experimental { +enum class graph_state { + modifiable, + executable, +}; + +/// Forward declaration for command_graph +template class command_graph; +} +} // namespace oneapi +} // namespace ext +} // __SYCL_INLINE_VER_NAMESPACE(_V1) +} // namespace sycl diff --git a/sycl/include/sycl/queue.hpp b/sycl/include/sycl/queue.hpp index fd2cf7736dc3a..a2036a40490ff 100644 --- a/sycl/include/sycl/queue.hpp +++ b/sycl/include/sycl/queue.hpp @@ -23,6 +23,8 @@ #include #include +#include + // Explicitly request format macros #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS 1 @@ -1068,6 +1070,14 @@ class __SYCL_EXPORT queue { /// \return the backend associated with this queue. backend get_backend() const noexcept; +public: + /// Submits an executable command_graph for execution on this queue + /// + /// \return an event representing the execution of the command_graph + event submit(ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::executable> + graph); + private: pi_native_handle getNative() const; diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index 47cdc71c70f9c..41d5b15903860 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -15,6 +15,8 @@ #include #include +#include + #include namespace sycl { @@ -212,5 +214,12 @@ bool queue::device_has(aspect Aspect) const { // avoid creating sycl object from impl return impl->getDeviceImplPtr()->has(Aspect); } + +event queue::submit(ext::oneapi::experimental::command_graph< + ext::oneapi::experimental::graph_state::executable> + graph) { + graph.exec_and_wait(*this); + return {}; +} } // __SYCL_INLINE_VER_NAMESPACE(_V1) } // namespace sycl