Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions sycl/include/sycl/ext/oneapi/experimental/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
#pragma once

#include <sycl/detail/defines_elementary.hpp>
#include <sycl/queue.hpp>

#include "graph_defines.hpp"

#include <list>
#include <set>

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
class queue;

namespace ext {
namespace oneapi {
namespace experimental {
Expand Down Expand Up @@ -142,8 +148,6 @@ struct node {
void set_root() { MGraph->add_root(MNode); }
};

enum class graph_state { modifiable, executable };

template <graph_state State = graph_state::modifiable> class command_graph {
public:
// Adding empty node with [0..n] predecessors:
Expand Down Expand Up @@ -219,5 +223,6 @@ void command_graph<graph_state::executable>::exec_and_wait(sycl::queue q) {
} // namespace experimental
} // namespace oneapi
} // namespace ext
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl

28 changes: 28 additions & 0 deletions sycl/include/sycl/ext/oneapi/experimental/graph_defines.hpp
Original file line number Diff line number Diff line change
@@ -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 <graph_state State> class command_graph;
}
} // namespace oneapi
} // namespace ext
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl
10 changes: 10 additions & 0 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <sycl/property_list.hpp>
#include <sycl/stl.hpp>

#include <sycl/ext/oneapi/experimental/graph_defines.hpp>

// Explicitly request format macros
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 9 additions & 0 deletions sycl/source/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <sycl/queue.hpp>
#include <sycl/stl.hpp>

#include <sycl/ext/oneapi/experimental/graph.hpp>

#include <algorithm>

namespace sycl {
Expand Down Expand Up @@ -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