-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
657 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains 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,92 @@ | ||
#pragma once | ||
|
||
#include "Neon/core/core.h" | ||
#include "Neon/core/types/digraph.h" | ||
|
||
#include "Neon/set/ContainerTools/GraphDependency.h" | ||
#include "Neon/set/ContainerTools/GraphNode.h" | ||
|
||
namespace Neon::set::container { | ||
|
||
struct Graph | ||
{ | ||
using Uid = GraphNodeOrganization::Uid; | ||
using Index = GraphNodeOrganization::Index; | ||
|
||
public: | ||
Graph(); | ||
|
||
/** | ||
* Get a reference to the begin node | ||
*/ | ||
auto getBeginNode() const -> const GraphNode&; | ||
|
||
/** | ||
* Get a reference to the end node of the graph | ||
*/ | ||
auto getEndNode() const -> const GraphNode&; | ||
|
||
/** | ||
* add a node between the begin and end nodes | ||
*/ | ||
auto addNode(Container& container) -> GraphNode&; | ||
|
||
/** | ||
* Remove Node | ||
*/ | ||
auto removeNode(GraphNode& gn) -> GraphNode; | ||
|
||
/** | ||
* Add node between two other nodes | ||
*/ | ||
auto addNodeInBetween(const GraphNode& nodeA, | ||
Container& containerB, | ||
const GraphNode& nodeC) -> GraphNode&; | ||
|
||
auto addNodeInBetween(const GraphNode& nodeA, | ||
Container& containerB, | ||
const GraphNode& nodeC, | ||
GraphDependency& ab, | ||
GraphDependency& bc) -> GraphNode&; | ||
/** | ||
* Add a dependency between two nodes of the graph | ||
*/ | ||
auto addDependency(const GraphNode& source, | ||
const GraphNode& destination, | ||
GraphDependencyType graphDependencyType = GraphDependencyType::USER) -> GraphDependency&; | ||
|
||
/** | ||
* Clone a node and return a reference to the new clone. | ||
* The cloning process connects the clone the the same nodes of the original | ||
* | ||
* @param graphNode | ||
* @return | ||
*/ | ||
auto clone(const GraphNode& graphNode) -> GraphNode&; | ||
|
||
/** | ||
* Returns all proceeding graph nodes. | ||
* The begin node is excluded | ||
*/ | ||
auto getProceedingGraphNodes() -> std::vector<GraphNode*>; | ||
|
||
/** | ||
* Returns all subsequent graph nodes. | ||
* The end node is excluded | ||
*/ | ||
auto getSubsequentGraphNodes() -> std::vector<GraphNode*>; | ||
|
||
/** | ||
* Execute the scheduling operation associated to the node | ||
*/ | ||
auto execute() -> void; | ||
|
||
auto computeScheduling() -> void; | ||
|
||
private: | ||
using RawGraph = DiGraph<GraphNode, GraphDependency>; | ||
Uid mUidCounter; | ||
RawGraph mRawGraph; | ||
}; | ||
|
||
} // namespace Neon::set::container |
21 changes: 21 additions & 0 deletions
21
libNeonSet/include/Neon/set/ContainerTools/GraphDependency.h
This file contains 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,21 @@ | ||
#pragma once | ||
|
||
#include "Neon/set/ContainerTools/GraphDependencyType.h" | ||
|
||
namespace Neon::set::container { | ||
|
||
struct GraphDependency | ||
{ | ||
public: | ||
GraphDependency(); | ||
GraphDependency(GraphDependencyType type); | ||
|
||
auto setType(GraphDependencyType type) -> void; | ||
auto getType() -> GraphDependencyType; | ||
|
||
private: | ||
GraphDependencyType mType; | ||
// TODO - add information for data and Scheduling dependency | ||
}; | ||
|
||
} // namespace Neon::set::container |
52 changes: 52 additions & 0 deletions
52
libNeonSet/include/Neon/set/ContainerTools/GraphDependencyType.h
This file contains 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,52 @@ | ||
#pragma once | ||
#include <array> | ||
#include <string> | ||
|
||
namespace Neon { | ||
|
||
enum struct GraphDependencyType | ||
{ | ||
DATA = 0 /** dependency generated by analyzing data dependency */, | ||
SCHEDULING = 1 /** hints for scheduling **/, | ||
USER = 2 /** Uer defined scheduling */ | ||
}; | ||
|
||
/** | ||
* Set of utilities for GraphDependencyType options. | ||
*/ | ||
struct GraphDependencyTypeUtil | ||
{ | ||
/** | ||
* Number of configurations for the enum | ||
*/ | ||
static const int nConfig{static_cast<int>(3)}; | ||
|
||
/** | ||
* Convert enum value to string | ||
* | ||
* @param dataView | ||
*/ | ||
static auto toString(GraphDependencyType dataView) -> std::string; | ||
|
||
/** | ||
* Returns all valid configuration for GraphDependencyType | ||
*/ | ||
static auto validOptions() -> std::array<Neon::GraphDependencyType, GraphDependencyTypeUtil::nConfig>; | ||
|
||
/** | ||
* Convert an integer to a GraphDependencyType | ||
*/ | ||
static auto fromInt(int val) -> GraphDependencyType; | ||
|
||
/** | ||
* Convert a GraphDependencyType to an integer | ||
*/ | ||
static auto toInt(GraphDependencyType dataView) -> int; | ||
}; | ||
|
||
|
||
/** | ||
* operator<< | ||
*/ | ||
std::ostream& operator<<(std::ostream& os, Neon::GraphDependencyType const& m); | ||
} // namespace Neon |
This file contains 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,47 @@ | ||
#pragma once | ||
|
||
#include "Neon/set/ContainerTools/GraphNodeOrganization.h" | ||
#include "Neon/set/ContainerTools/GraphNodeScheduling.h" | ||
|
||
#include "Neon/set/Containter.h" | ||
|
||
namespace Neon::set::container { | ||
|
||
struct GraphNode | ||
{ | ||
public: | ||
GraphNode(); | ||
GraphNode(const Container& container, | ||
GraphNodeOrganization::Uid uid); | ||
|
||
/** | ||
* Factory method to generate a begin node | ||
*/ | ||
static auto getBeginNode() -> GraphNode; | ||
|
||
/** | ||
* Factory method to generate a end node | ||
*/ | ||
static auto getEndNode() -> GraphNode; | ||
|
||
/** | ||
* Execute the scheduling operation associated to the node | ||
*/ | ||
auto execute() -> void; | ||
|
||
auto getOrganization() -> GraphNodeOrganization&; | ||
auto getOrganization() const -> const GraphNodeOrganization&; | ||
|
||
auto getScheduling() -> GraphNodeScheduling&; | ||
auto getScheduling() const -> const GraphNodeScheduling&; | ||
|
||
auto getContianer() -> Container&; | ||
auto getContianer() const -> const Container&; | ||
|
||
private: | ||
Container mContainer /**< Any Neon container */; | ||
GraphNodeScheduling mGraphNodeScheduling /**< Scheduling information for the node */; | ||
GraphNodeOrganization mGraphNodeOrganization /**< Information to organize the node w.r.t. the rest of the graph */; | ||
}; | ||
|
||
} // namespace Neon::set::container |
33 changes: 33 additions & 0 deletions
33
libNeonSet/include/Neon/set/ContainerTools/GraphNodeOrganization.h
This file contains 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,33 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include "vector" | ||
|
||
namespace Neon::set::container { | ||
|
||
class GraphNodeOrganization | ||
{ | ||
public: | ||
using Uid = uint32_t; | ||
using Index = uint32_t; | ||
|
||
constexpr static Uid notSet = 0; | ||
constexpr static Uid beginUid = 1; | ||
constexpr static Uid endUid = 2; | ||
constexpr static Uid firstInternal = 3; | ||
|
||
GraphNodeOrganization(); | ||
GraphNodeOrganization(int uid); | ||
|
||
auto setUid(Uid uid) -> void; | ||
auto setIndex(Index index) -> void; | ||
|
||
auto getUid() const -> Uid; | ||
auto getIndex() const -> Index; | ||
|
||
private: | ||
Uid mUid /** unique identifier for the node */; | ||
Index mIndex /** relative index w.r.t the completed graph. This value may change during the life of the graph */; | ||
}; | ||
|
||
} // namespace Neon::set::container |
56 changes: 56 additions & 0 deletions
56
libNeonSet/include/Neon/set/ContainerTools/GraphNodeScheduling.h
This file contains 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,56 @@ | ||
#pragma once | ||
|
||
#include "Neon/core/types/DataView.h" | ||
#include "vector" | ||
|
||
namespace Neon::set::container { | ||
|
||
class GraphNodeScheduling | ||
{ | ||
|
||
/** | ||
* Get the stream to execute the Container | ||
*/ | ||
auto getStream() const | ||
-> int; | ||
|
||
/** | ||
* Get the event to asynchronously signal that the execution of the Container is completed. | ||
*/ | ||
auto getEvent() const | ||
-> int; | ||
|
||
/** | ||
* Get list of events to wait the completion of. | ||
*/ | ||
auto getDependentEvents() const | ||
-> const std::vector<int>&; | ||
|
||
/** | ||
* Set the stream for the Container execution | ||
*/ | ||
auto setStream(int stream /**< stream for the Container execution */) -> void; | ||
|
||
/** | ||
* Set the event to asynchronously signal the completion of the Container. | ||
*/ | ||
auto setEvent(int event /**< Event to be used to signal the completion of the Container */) -> void; | ||
|
||
/** | ||
* Set the list of events that needed to be waited for before running the Container. | ||
*/ | ||
auto setDependentEvents(const std::vector<int>&) -> void; | ||
|
||
auto setDataView(Neon::DataView dataView) -> void; | ||
|
||
public: | ||
GraphNodeScheduling(); | ||
|
||
private: | ||
int mStream /**< Stream for each operation for the node */; | ||
int mEvent /**< Event to be used to signal the completion of the node container */; | ||
std::vector<int> mDependentEvents /**< Events to be waited for before running the Container */; | ||
Neon::DataView mDataView; | ||
}; | ||
|
||
} // namespace Neon::set::container |
Oops, something went wrong.