-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdef.ml
More file actions
73 lines (62 loc) · 2.14 KB
/
def.ml
File metadata and controls
73 lines (62 loc) · 2.14 KB
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
open Format
(* DEFINITION TYPE TASKS *)
type task = {
id : int;
w : float; (* work *)
c : float; (* checkpoint time *)
r : float; (* recovery time *)
}
(* DEFINITION TYPE (DIRECTED) EDGES *)
type edge = {
id1 : int;
id2 : int;
}
(* DEFINITION TYPE DAG *)
type dag = {
tabTask : task array;
sources : int list; (* list of the sources of the DAG *)
tabParents : int list array; (* tabParents.(i) is the list of the index in tabTask of the parents of tabTask.(i) *)
tabChildren : int list array; (* tabChildren.(i) is the list of the index in tabTask of the children of tabTask.(i) *)
weightSucc : float array; (* weightSucc.(i) is the sum of the weight of all successors of tabTask.(i) *)
}
(** Type of the specification of a DAG. Can be almost converted to [dag] *)
type spec = task list * (int * int) list
type spec_tree = task list * (int * int) list * int
let computeWS dag =
let ntasks = Array.length (dag.tabTask) in
let wSucc = Array.make ntasks 0. in
let tasksDone = Array.make ntasks false in
let rec auxcomputeWS taskId =
if tasksDone.(taskId) then ()
else
begin
tasksDone.(taskId) <- true;
let f x =
auxcomputeWS x ;
(* Printf.printf "task %d went from %f to %f\n" taskId wSucc.(x) (wSucc.(taskId) +. wSucc.(x)+. dag.tabTask.(x).w);*)
wSucc.(taskId) <- wSucc.(taskId) +. wSucc.(x) +. dag.tabTask.(x).w
in
List.iter f dag.tabChildren.(taskId)
end
in
List.iter auxcomputeWS dag.sources;
{
tabTask = dag.tabTask;
sources = dag.sources;
tabParents = dag.tabParents;
tabChildren = dag.tabChildren;
weightSucc = wSucc;
}
(* DEFINITION TYPE LINEAR WORKFLOW *)
type linearWorkflow = {
order : (int * bool) array; (* "int" is the index of the task in dag.tabTask; "bool" is whether or not that task is checkpointed *)
sched : (int * bool) array; (* sched.(i) is "j,true" if there exists j and order.(j) = (i,_) (meaning task i has already been scheduled.)*)
}
type param = {
lambda : float;
d : float;
ntasks : int;
expe_number : int; (* What we want to plot *)
c_number : int; (* How we want to generate checkpointing time *)
r_number : int; (* How we want to generate recovery time *)
}