Commit 991894c8 authored by Valentin Reis's avatar Valentin Reis

[feature] energy,power,instrumentation reporting

parent 9fe8a58c
...@@ -22,7 +22,8 @@ class Application(object): ...@@ -22,7 +22,8 @@ class Application(object):
def __init__(self, uuid, container, progress, threads): def __init__(self, uuid, container, progress, threads):
self.uuid = uuid self.uuid = uuid
self.container_uuid = container self.container_uuid = container
self.progress = 1 self.progress = 0
self.hardwareprogress = 0
self.threads = threads self.threads = threads
self.thread_state = 'stable' self.thread_state = 'stable'
...@@ -57,11 +58,15 @@ class Application(object): ...@@ -57,11 +58,15 @@ class Application(object):
def update_progress(self, msg): def update_progress(self, msg):
"""Update the progress tracking.""" """Update the progress tracking."""
self.progress = self.progress + float(msg['payload'])/10000. if msg['event']=='progress':
self.progress = self.progress + float(msg['payload'])
elif msg['event']=='hardwareprogress':
self.hardwareprogress = self.hardwareprogress + float(msg['payload'])/10000.
def reset_progress(self): def reset_progress(self):
"""Update the progress tracking.""" """Update the progress tracking."""
self.progress = 0 self.progress = 0
self.hardwareprogress = 0
class ApplicationManager(object): class ApplicationManager(object):
......
...@@ -147,12 +147,13 @@ class BanditController(object): ...@@ -147,12 +147,13 @@ class BanditController(object):
self.enforce=enforce self.enforce=enforce
self.log_power=log_power self.log_power=log_power
if self.log_power is not None: if self.log_power is not None:
self.log_power.write("progress power loss a desc\n") self.log_power.write("hardwareprogress progress power loss a desc p_inst\n")
self.log_power.flush() self.log_power.flush()
def planify(self, target, machineinfo, applications): def planify(self, target, machineinfo, applications):
"""Plan the next action for the control loop.""" """Plan the next action for the control loop."""
current_e = float(machineinfo['energy']['energy']['cumulative']['package-0'])/(1000*1000) # in joules current_e = float(machineinfo['energy']['energy']['cumulative']['package-0'])/(1000*1000) # in joules
current_p = float(machineinfo['energy']['power']['p0'])/(1000*1000) # in joules
if self.last_e==0: if self.last_e==0:
self.last_e=current_e self.last_e=current_e
return([],[]) return([],[])
...@@ -169,6 +170,7 @@ class BanditController(object): ...@@ -169,6 +170,7 @@ class BanditController(object):
return([],[]) return([],[])
self.n=self.n+1 self.n=self.n+1
total_progress = sum([a.progress for a in applications.values()]) total_progress = sum([a.progress for a in applications.values()])
total_hardwareprogress = sum([a.hardwareprogress for a in applications.values()])
for a in applications.values(): for a in applications.values():
a.reset_progress() a.reset_progress()
logger.info("Controller: applications %r" %applications.values()) logger.info("Controller: applications %r" %applications.values())
...@@ -189,9 +191,9 @@ class BanditController(object): ...@@ -189,9 +191,9 @@ class BanditController(object):
logger.info("Controller: playing arm id %s (powercap '%s')." logger.info("Controller: playing arm id %s (powercap '%s')."
%(str(a),str([act.command for act in list(action)]))) %(str(a),str([act.command for act in list(action)])))
if self.log_power is not None: if self.log_power is not None:
self.log_power.write("%s %s %s %s %s\n" self.log_power.write("%s %s %s %s %s %s %s\n"
%(str(total_progress),str(total_power),str(loss), %(str(total_hardwareprogress),str(total_progress),str(total_power),str(loss),
str(a),str([act.command for act in list(action)]))) str(a),str([act.command for act in list(action)]),current_p))
self.log_power.flush() self.log_power.flush()
return(list(action),self.actuators) return(list(action),self.actuators)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment