Skip to content

Commit 4aace67

Browse files
author
Arka
committed
Reorganized source tree, added CMake based build system and merged ATG project from
HardPkpMin2, which now will serve as a tutorial for Boost.Graph self learning
1 parent 217e7bd commit 4aace67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1375
-59
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ log
4141
*.swp
4242
*.svo
4343
*.svp
44+
/.vscode/
4445

4546
# Graph/tree visualization files
4647
*.dot
48+
49+
# Profile CSV datasets
50+
*.csv
51+
52+
# Build Products
53+
/build/
54+
55+
# Dump Datasets
56+
57+
# Graphviz visualizations
58+
*.dot
59+
*.pdf
60+
*.svg
61+
*.png
62+
*.jpeg

BoostGraph/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
cmake_minimum_required(VERSION 3.4.2)
2+
project(ptss-dse)
3+
4+
set(CMAKE_BUILD_TYPE Debug)
5+
set(PROJECT_DESCRIPTION "Malleable DAG scheduling with deadline for peak power minimization")
6+
set(PTSS_DSE_VERSION_MAJOR 1)
7+
set(PTSS_DSE_VERSION_MINOR 0)
8+
set(EXEC1 mDagPkpISLPED2019Ext)
9+
set(EXEC2 mDagPkpJansenBinSearch)
10+
11+
12+
## Targets (Convex Optimization+DGGD aka ISLPED extension)
13+
add_executable(${EXEC1} src/ATG.cpp src/testATG.cpp)
14+
target_include_directories(${EXEC1} PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR})
15+
target_compile_options(${EXEC1} PRIVATE -std=c++11 -Wall)
16+
target_link_libraries(${EXEC1} PUBLIC -lm -lecotools -lboost_graph)
17+
18+
## Targets (Tulika's suggestion dated 02/07/2019 aka Malleable-DAG scheduling + Binary search apprach)
19+
# add_executable(${EXEC2} src/Stats.cpp src/ATG.cpp src/KlausHuangLP.cpp src/KlausHuangListM.cpp src/testKlausHuangLP.cpp src/KHMBinSearch.cpp)
20+
# target_include_directories(${EXEC2} PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR} $ENV{GUROBI_HOME}/include)
21+
# target_compile_options(${EXEC2} PRIVATE -std=c++11 -Wall)
22+
# target_link_libraries(${EXEC2} PUBLIC -lm -lecotools -lgurobi_c++ -lgurobi81)

BoostGraph/DAGGen/tutorialnx.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Created on Tue Jul 2 11:20:05 2019
5+
6+
@author: amaity
7+
"""
8+
import numpy as np
9+
import networkx as nx
10+
import os
11+
from networkx.drawing.nx_agraph import write_dot
12+
13+
def main():
14+
G = nx.gnp_random_graph(4,0.5,directed=True)
15+
H = nx.DiGraph([(u,v,{'weight':np.random.randint(0,5)}) for (u,v) in G.edges() if u<v])
16+
if nx.is_directed_acyclic_graph(H):
17+
write_dot(H, 'fileD.dot')
18+
os.system('neato -Tpdf fileD.dot >fileD.pdf')
19+
write_dot(G, 'fileG.dot')
20+
os.system('neato -Tpdf fileG.dot >fileG.pdf')
21+
22+
if __name__=="__main__":
23+
main()

BoostGraph/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Boost.Graph
2+
Tutorial on Boost Graphs and their uses.

BoostGraph/include/ATG.hpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#ifndef DEF_ATG_H
2+
#define DEF_ATG_H
3+
4+
#include <iostream>
5+
#include <vector>
6+
#include <algorithm>
7+
#include <set>
8+
#include <queue>
9+
#include <boost/graph/adjacency_list.hpp>
10+
11+
void testATG(int N, double p);
12+
void randDAGGen();
13+
std::ostream& operator<<(std::ostream &os, const NodeType &et);
14+
15+
class AppTaskGraph {
16+
private:
17+
DAGType gSS;
18+
std::vector<DAGVertexType> vdMap; /* Node identifier set, vdMap[N-1] is a sink */
19+
std::map<DAGVertexType,std::vector<DAGVertexType>> predVdMap; /* Map of predecessors */
20+
std::map<DAGVertexType,std::vector<DAGVertexType>> succVdMap; /* Map of successors */
21+
bool initialized;
22+
bool scheduled;
23+
double t; /* Execution time spent */
24+
int util; /* Number of processors used */
25+
int finishCounter;
26+
double wC; /* Worst case makespan */
27+
double deadline;
28+
void computeNbdMap();
29+
int execute(int M_X, double delta);
30+
int KlausHuangLP(int M_X, double rho, int mu);
31+
double KlausHuangListM(int M_X, double delta);
32+
void computeHeight(bool schedule);
33+
void reset(); /* Reset the schedules and status */
34+
public:
35+
AppTaskGraph(int N, double p);
36+
AppTaskGraph(std::string dotFile); /* Read a dot file */
37+
AppTaskGraph();
38+
void writeDot(int iter);
39+
std::vector<DAGVertexType> getPreds(int jid) { return this->predVdMap[this->vdMap[jid]]; };
40+
std::vector<DAGVertexType> getPreds(DAGVertexType vptr) { return this->predVdMap[vptr]; };
41+
std::vector<DAGVertexType> getSuccs(int jid) { return this->succVdMap[this->vdMap[jid]]; };
42+
std::vector<DAGVertexType> getSuccs(DAGVertexType vptr) { return this->succVdMap[vptr]; };
43+
NodeType getNode(int jid) { return this->gSS[this->vdMap[jid]]; };
44+
NodeType getNode(DAGVertexType vptr) { return this->gSS[vptr]; };
45+
double tau_j(int jid, int l);
46+
int getSize() { return this->vdMap.size(); };
47+
double KlausHuangMethodSched(int M_X);
48+
void KHMBinSearch(int K); /* Minimum peak power scheduling */
49+
void genStats();
50+
};
51+
#endif

BoostGraph/include/DataTypes.hpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#ifndef DEF_DATATYPES_H
2+
#define DEF_DATATYPES_H
3+
4+
#include <iostream>
5+
#include <iomanip>
6+
#include <vector>
7+
#include <boost/graph/adjacency_list.hpp>
8+
9+
#define M 32 // Maximum number of cores
10+
#define NMax 20000 // Maximum supported taskset size
11+
#define FIXED_FLOAT(x) std::fixed<<std::setprecision(2)<<(x)
12+
#define DEBUG
13+
14+
/*
15+
* 1. NotReady - Predecessors not yet finished, cannot execute
16+
* 2. Ready - Predecessors finished, but not enough resources
17+
* 3. Active - Execution under progress
18+
* 4. Finished - Completed execution already
19+
*/
20+
enum StatusType {NotReady,Ready,Finished,Active};
21+
22+
struct NodeType {
23+
StatusType status;
24+
double estart; /* Earliest possible start time that satisfies the precedence constraints */
25+
26+
/* Execution type characteristics (static)
27+
* execution time is modelled \tau_j(m) = \tau_j(1) * m^(-d_{j}).
28+
* where 0 < d_{j} < 1
29+
*/
30+
double dj; /* Exponent 0 < dj < 1 */
31+
double tau1;
32+
int id;
33+
34+
/* Execution type characteristics (Dynamic)
35+
* mainly start and finish time in the schedule
36+
*/
37+
int alloc;
38+
double start_time;
39+
double stop_time;
40+
double C; /* computation requirement, uninitialized value = -1 */
41+
};
42+
43+
/* Only used for dependency modelling */
44+
struct EdgeType {
45+
int edgeNum;
46+
};
47+
48+
/* Event types for statistics collection and display */
49+
enum EventType {Stop=1,Start=0};
50+
51+
/* <time stamp, EeventType, alloc, id> */
52+
typedef std::tuple<double,EventType,int,int> Events;
53+
54+
typedef boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS,NodeType,EdgeType> DAGType;
55+
typedef boost::graph_traits<DAGType>::vertex_descriptor DAGVertexType;
56+
typedef boost::graph_traits<DAGType>::edge_descriptor DAGEdgeType;
57+
typedef boost::graph_traits<DAGType>::out_edge_iterator DAGOutEdgeIterator;
58+
typedef boost::graph_traits<DAGType>::in_edge_iterator DAGInEdgeIterator;
59+
typedef boost::graph_traits<DAGType>::vertex_iterator DAGVertexIterator;
60+
typedef boost::graph_traits<DAGType>::degree_size_type DAGDegSizeType;
61+
62+
class DAGVertexPW {
63+
public:
64+
DAGVertexPW(DAGType& g) : myGraph(g) {}
65+
template <class VertexOrEdge>
66+
void operator()(std::ostream& os, const VertexOrEdge& v) const {
67+
os << "[status=\"{";
68+
switch(myGraph[v].status) {
69+
case NotReady : os << "NotReady,"; break;
70+
case Ready : os << "Ready,"; break;
71+
case Finished : os << "Finished,"; break;
72+
case Active : os << "Active"; break;
73+
}
74+
os << "id:" << myGraph[v].id;
75+
// os << ",estart:" << FIXED_FLOAT(myGraph[v].estart);
76+
// os << ",alloc:" << myGraph[v].alloc;
77+
// os << ",start:" << FIXED_FLOAT(myGraph[v].start_time);
78+
// os << ",stop:" << FIXED_FLOAT(myGraph[v].stop_time);
79+
// os << ",C:" << FIXED_FLOAT(myGraph[v].C);
80+
os << ",dj:" << FIXED_FLOAT(myGraph[v].dj);
81+
os << ",tau1:" << FIXED_FLOAT(myGraph[v].tau1);
82+
os << "}\"]";
83+
}
84+
private:
85+
DAGType& myGraph;
86+
};
87+
88+
class DAGEdgePW {
89+
public:
90+
DAGEdgePW(DAGType& g) : myGraph(g) {}
91+
template <class VertexOrEdge>
92+
void operator()(std::ostream& os, const VertexOrEdge& e) const {
93+
}
94+
private:
95+
DAGType& myGraph;
96+
};
97+
98+
#endif

0 commit comments

Comments
 (0)