-
Notifications
You must be signed in to change notification settings - Fork 1
/
Optimizations.py
93 lines (70 loc) · 2.34 KB
/
Optimizations.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
__author__ = "Alex Hoffman"
__copyright__ = "Copyright 2019, Alex Hoffman"
__license__ = "GPL"
__version__ = "1.0"
__maintainer__ = "Alex Hoffman"
__email__ = "[email protected]"
__status__ = "Beta"
from enum import Enum
optimization_ID = 0
class OptimizationInfoType(Enum):
NONE = 0
B2L_REALLOC = 0b1
DVFS = 0b10
SAME_CLUSTER_REALLOC = 0b100
DVFS_AFTER_REALLOC = 0b1000
def __str__(self):
return "%s" % self.name
class OptimizationInfo:
def __init__(self,
graph_node,
optim_type=OptimizationInfoType.NONE.value,
message=""):
self.ID = 0
self.graph_node = graph_node
self.optim_type = optim_type
self.message = message
def __str__(self):
ret = ""
if self.optim_type & OptimizationInfoType.DVFS.value:
if ret != "":
ret += ", "
ret += "DVFS"
if self.optim_type & OptimizationInfoType.B2L_REALLOC.value:
if ret != "":
ret += ", "
ret += "Task Reallocation"
if self.optim_type & OptimizationInfoType.SAME_CLUSTER_REALLOC.value:
if ret != "":
ret += ", "
ret += "Reallocated within cluster"
if self.optim_type & OptimizationInfoType.DVFS_AFTER_REALLOC.value:
if ret != "":
ret += ", "
ret += "DVFS possible after reallocation"
return ret
def set_message(self, message):
self.message = message
def add_optim_type(self, optim_type):
global optimization_ID
if self.ID == 0:
self.ID = optimization_ID
optimization_ID += 1
self.optim_type |= optim_type.value
def dvfs_possible(self):
if self.optim_type & OptimizationInfoType.DVFS.value:
return True
return False
def realloc_possible(self):
if self.optim_type & OptimizationInfoType.B2L_REALLOC.value:
return True
return False
def cluster_realloc_possible(self):
if self.optim_type & OptimizationInfoType.SAME_CLUSTER_REALLOC.value:
return True
return False
def dvfs_after_realloc_possible(self):
if self.optim_type & OptimizationInfoType.DVFS_AFTER_REALLOC.value:
return True
return False