-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtools.ml
49 lines (37 loc) · 1.09 KB
/
tools.ml
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
open Format
open Printf
open Def
let isCkptWF workflow i = (* Returns whether ith task of the workflow is checkpointed. *)
snd (workflow.order.(i))
let isSchedDAG workflow i = (* Returns whether task i is checkpointed. *)
if not (snd workflow.sched.(i)) then failwith "the task is not scheduled"
else
snd (workflow.order.(fst workflow.sched.(i)))
let indTaskWF2DAG workflow i =
fst workflow.order.(i)
let indTaskDAG2WF workflow i =
if not (snd workflow.sched.(i)) then failwith "the task is not scheduled"
else
fst workflow.sched.(i)
let total_weight dag =
let ntasks = Array.length dag.tabTask in
let weight = ref 0. in
for i = 0 to ntasks -1 do
weight := !weight +. dag.tabTask.(i).w
done;
!weight
(* DEBUG TOOLS *)
let print_workflow_expect workflow eXi =
let ntasks = Array.length workflow.order in
for i = 0 to ntasks -1 do
printf "%d: %d -> %f\n" i (fst workflow.order.(i)) (eXi.(i))
done
let print_matrix tab =
let n = Array.length tab in
let m = Array.length tab.(0) in
for i = 0 to n-1 do
for j = 0 to m-1 do
printf "%f\t" tab.(i).(j)
done;
printf "\n"
done