@@ -97,20 +97,16 @@ class Edge {
9797class BlkInfo {
9898 public:
9999 BlkInfo (int id, Block *blk, BlockType type = BlockType::kUnknow )
100- : id_(id),
101- blk_ (blk),
102- type_(type),
103- graph_ref_(0 ),
104- write_node_(nullptr ),
105- last_node_(nullptr ) {}
100+ : id_(id), blk_(blk), type_(type), graph_ref_(0 ), write_edge_(nullptr ) {}
106101
107102 // getters of BlkInfo
108103 int id () const { return id_; }
109104 Block *block () const { return blk_; }
110105 BlockType type () const { return type_; }
111106 int graph_ref () const { return graph_ref_; }
112- Node *write_node () const { return write_node_; }
113- Node *last_node () const { return last_node_; }
107+ Edge *write_edge () const { return write_edge_; }
108+ const NodeVec &used_nodes () const { return used_nodes_; }
109+ Node *used_node (const size_t idx) const ;
114110
115111 private:
116112 friend Graph;
@@ -119,8 +115,8 @@ class BlkInfo {
119115 Block *blk_;
120116 BlockType type_;
121117 int graph_ref_;
122- Node *write_node_ ; // last node that writes the block
123- Node *last_node_ ; // last node that uses the block
118+ Edge *write_edge_ ; // the edge of last node that writes data into blk
119+ NodeVec used_nodes_ ; // the nodes that use this block(in order of execution)
124120};
125121
126122class Graph {
@@ -165,8 +161,10 @@ class Graph {
165161 const BlockVec &free_blocks (const size_t idx) const ;
166162
167163 private:
168- void Analysis ();
164+ void Analyze ();
169165 void FreeLoop ();
166+ void AnalyzeNodes ();
167+ void AnalyzeEdges ();
170168 void AddSyncOp (function<void (Context *)> &&op);
171169
172170 // static void CUDART_CB Callback(cudaStream_t stream, cudaError_t status,
@@ -185,6 +183,7 @@ class Graph {
185183
186184 // Calculation graph analysis
187185 bool dirty_ = false ;
186+ bool in_serial_ = false ;
188187 NodeVec begin_nodes_;
189188 std::vector<NodeVec> next_nodes_;
190189 std::vector<BlockVec> free_blocks_;
0 commit comments