-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][Graph] Command Graph PoC #7627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
1acf57e
Inital version of sycl graph prototype
reble d286c71
Adding initial sycl graph doc
reble 656f5c3
Adding lazy execution property to queue
reble 0bad787
fix merge
reble a8b5b32
Update pi_level_zero.cpp
reble 2b50af4
update extension proposal started to incorporate feedback
reble 047839b
typo
reble f957996
fix typos and syntax issues
reble 0d8a5f4
Apply suggestions from code review
reble 50d49a1
Propagate lazy queue property
julianmi 9b46c4b
fix formatting issues
reble 7d81618
fix issue introd. by recent merge
reble 7917086
fix formatting
reble a3164de
update API to recent proposal
reble 8850b18
fix rebase issue
reble 446ac53
revert changes to level-zero plugin
reble fa7494d
starting to rework lazy execution logic
reble 7581915
bugfix
reble 38da3c6
add basic tests
reble fa58aa3
renaming macro and bugfix
reble 4478390
clang-format
reble 383459c
Renaming variables
reble f71ea49
Common changes from record & replay API (#32)
EwanC df971e5
[SYCL] Minor graph classes refactor (#36)
Bensuo 2cf9d0f
Cosmetic changes
reble 9f127d7
[SYCL] Repro for reduction fail
EwanC 578692f
[SYCL] PIMPL refactor
EwanC 7bb11ce
[SYCL] Use handler to execute graph
EwanC 3073cfc
[SYCL] Clean-up lazy queue PI changes
EwanC c99bdca
[SYCL] Fix reductions not working inside graph
Bensuo 1448cb5
[SYCL] Enable submitting sub-graphs
Bensuo fb28d59
[SYCL] Rename exec_graph to ext_oneapi_graph
Bensuo 4a306ed
[SYCL] Add unit tests for command graph POC
Bensuo 1249fbc
[SYCL] Pass property_list to APIs
EwanC 0ac7a7e
Adding new example using make edge function (#63)
reble 06c588f
Apply suggestions from code review
reble d4c1ed3
[SYCL] Record & Replay Implementation
EwanC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
//==--------- graph.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 | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include <sycl/detail/common.hpp> | ||
#include <sycl/detail/defines_elementary.hpp> | ||
#include <sycl/property_list.hpp> | ||
|
||
namespace sycl { | ||
__SYCL_INLINE_VER_NAMESPACE(_V1) { | ||
|
||
class handler; | ||
class queue; | ||
namespace ext { | ||
namespace oneapi { | ||
namespace experimental { | ||
|
||
namespace detail { | ||
struct node_impl; | ||
struct graph_impl; | ||
|
||
using node_ptr = std::shared_ptr<node_impl>; | ||
using graph_ptr = std::shared_ptr<graph_impl>; | ||
} // namespace detail | ||
|
||
enum class graph_state { | ||
modifiable, | ||
executable, | ||
}; | ||
|
||
class __SYCL_EXPORT node { | ||
private: | ||
node(detail::node_ptr Impl) : impl(Impl) {} | ||
|
||
template <class Obj> | ||
friend decltype(Obj::impl) | ||
sycl::detail::getSyclObjImpl(const Obj &SyclObject); | ||
template <class T> | ||
friend T sycl::detail::createSyclObjFromImpl(decltype(T::impl) ImplObj); | ||
|
||
detail::node_ptr impl; | ||
detail::graph_ptr MGraph; | ||
}; | ||
|
||
template <graph_state State = graph_state::modifiable> | ||
class __SYCL_EXPORT command_graph { | ||
public: | ||
command_graph(const property_list &propList = {}); | ||
|
||
// Adding empty node with [0..n] predecessors: | ||
node add(const std::vector<node> &dep = {}); | ||
|
||
// Adding device node: | ||
template <typename T> node add(T cgf, const std::vector<node> &dep = {}) { | ||
return add_impl(cgf, dep); | ||
} | ||
|
||
// Adding dependency between two nodes. | ||
void make_edge(node sender, node receiver); | ||
|
||
command_graph<graph_state::executable> | ||
finalize(const sycl::context &syclContext, | ||
const property_list &propList = {}) const; | ||
|
||
/// Change the state of a queue to be recording and associate this graph with | ||
/// it. | ||
/// @param recordingQueue The queue to change state on and associate this | ||
/// graph with. | ||
/// @return True if the queue had its state changed from executing to | ||
/// recording. | ||
bool begin_recording(queue recordingQueue); | ||
|
||
/// Change the state of multiple queues to be recording and associate this | ||
/// graph with each of them. | ||
/// @param recordingQueues The queues to change state on and associate this | ||
/// graph with. | ||
/// @return True if any queue had its state changed from executing to | ||
/// recording. | ||
bool begin_recording(const std::vector<queue> &recordingQueues); | ||
|
||
/// Set all queues currently recording to this graph to the executing state. | ||
/// @return True if any queue had its state changed from recording to | ||
/// executing. | ||
bool end_recording(); | ||
|
||
/// Set a queues currently recording to this graph to the executing state. | ||
/// @param recordingQueue The queue to change state on. | ||
/// @return True if the queue had its state changed from recording to | ||
/// executing. | ||
bool end_recording(queue recordingQueue); | ||
|
||
/// Set multiple queues currently recording to this graph to the executing | ||
/// state. | ||
/// @param recordingQueue The queues to change state on. | ||
/// @return True if any queue had its state changed from recording to | ||
/// executing. | ||
bool end_recording(const std::vector<queue> &recordingQueues); | ||
|
||
private: | ||
command_graph(detail::graph_ptr Impl) : impl(Impl) {} | ||
|
||
// Template-less implementation of add() | ||
node add_impl(std::function<void(handler &)> cgf, | ||
const std::vector<node> &dep); | ||
|
||
template <class Obj> | ||
friend decltype(Obj::impl) | ||
sycl::detail::getSyclObjImpl(const Obj &SyclObject); | ||
template <class T> | ||
friend T sycl::detail::createSyclObjFromImpl(decltype(T::impl) ImplObj); | ||
|
||
detail::graph_ptr impl; | ||
}; | ||
|
||
template <> class __SYCL_EXPORT command_graph<graph_state::executable> { | ||
public: | ||
command_graph() = delete; | ||
|
||
command_graph(detail::graph_ptr g, const sycl::context &ctx) | ||
: MTag(rand()), MCtx(ctx), impl(g) {} | ||
|
||
private: | ||
template <class Obj> | ||
friend decltype(Obj::impl) | ||
sycl::detail::getSyclObjImpl(const Obj &SyclObject); | ||
|
||
int MTag; | ||
const sycl::context &MCtx; | ||
detail::graph_ptr impl; | ||
}; | ||
} // namespace experimental | ||
} // namespace oneapi | ||
} // namespace ext | ||
} // __SYCL_INLINE_VER_NAMESPACE(_V1) | ||
} // namespace sycl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is not intended for use by the user, is there a reason to expose it as a feature?