-
Notifications
You must be signed in to change notification settings - Fork 0
/
DAGScheduler.h
77 lines (64 loc) · 1.94 KB
/
DAGScheduler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef DAGSCHEDULER_H
#define DAGSCHEDULER_H
#include <set>
#include <utility>
#include <vector>
#include <map>
/// The high-performance DAG scheduler. Visits the DAG obeying the dependencies.
///
/// @author Mario Valle - Swiss National Supercomputing Centre (CSCS)
/// @date 2012-05-14 (initial version)
/// @version 1.1
///
class DAGScheduler {
public:
/// Constructor.
///
DAGScheduler() {}
/// Destructor.
///
~DAGScheduler() {}
/// Clean everything
///
void clear(void);
/// Add a piece of DAG
///
/// @param[in] aCopyId The current copy of the forest in which the dependency
/// should be recorded
/// @param[in] aDependsOn The object on which aDependant depends
/// @param[in] aDependant The object to be computed only when aDependsOn is
/// ready
///
void loadDependency(unsigned int aCopyId, const void *aDependsOn,
const void *aDependant);
/// Signals dependencies load has finished.
///
/// @param[in] aNumCodonSets Number of DAG copies (one for each codon classes)
///
void endLoadDependencies(unsigned int aNumCodonSets = 1);
/// Get next item to process.
///
/// @return The next object with all dependencies satisfied. Return NULL if no
/// more objects to be executed.
///
void *getNext(void);
/// Signals finished execution on aItem.
///
/// @param[in] aItem Object on which execution has ended.
///
void setDone(const void *aItem);
/// Reset all dependencies to initial state
///
void resetDependencies(void);
/// Dump DAG in textual form
///
void dumpDAG(std::ostream &aOut) const;
private:
std::set<const void *> mNodes; ///< Load the distinct node addresses
std::vector<std::pair<const void *, const void *> >
mEdges; ///< Load the edges
std::map<const void *, int> mRefCounter; ///< Reference counter
std::map<const void *, int>
mRefCounterSave; ///< Save the reference counter map
};
#endif