Commit 3fe9b026 authored by Sridutt Bhalachandra's avatar Sridutt Bhalachandra
Browse files

Added power policy init and fixed TODOs in PPM

Added initialization of power policy using the manifest file and fixed
appropriate TODOs in `PowerPolicyManager` (PPM) Class using container
information (except adding new power policies)

See Issue #10
parent a04a4fad
......@@ -65,6 +65,7 @@ class ContainerManager(object):
container_powerpolicy['policy'] = "NONE"
container_powerpolicy['damper'] = None
container_powerpolicy['slowdown'] = None
container_powerpolicy['manager'] = None
# TODO: Application library to load must be set during configuration
applicationpreloadlibrary = ''
......@@ -3,6 +3,7 @@ from __future__ import print_function
from applications import ApplicationManager
from containers import ContainerManager
from controller import Controller, ApplicationActuator, PowerActuator
from powerpolicy import PowerPolicyManager
from functools import partial
import json
import logging
......@@ -80,6 +81,12 @@ class Daemon(object):"new container required: %r", msg)
container = self.container_manager.create(msg)
if container.powerpolicy['policy'] != "NONE":
container.powerpolicy['manager'] = PowerPolicyManager(
# TODO: obviously we need to send more info than that
update = {'type': 'container',
'event': 'start',
......@@ -28,19 +28,21 @@
for supported power contols and related information.
import ddcmpolicy
import logging
logger = logging.getLogger('nrm')
class PowerPolicyManager:
""" Used for power policy application """
def __init__(self, ncpus=0, policy='NONE', damper=0.1, slowdown=1.1):
def __init__(self, cpus=None, policy='NONE', damper=0.1, slowdown=1.1):
self.cpus = cpus
self.policy = policy
self.damper = damper
self.slowdown = slowdown
# TODO: Need to set this based on container configuration
self.ncpus = ncpus
# Intiliaze all power interfaces
self.ddcmpolicy = ddcmpolicy.DDCMPolicy()
......@@ -48,20 +50,23 @@ class PowerPolicyManager:
self.maxdclevel = self.ddcmpolicy.maxdclevel
# TODO: Need to set this value when DVFS policies are added
self.maxfreqlevel = -1
# TODO: Need to only allow power changes to cpus in container
self.dclevel = dict.fromkeys(range(0, self.ncpus), self.maxdclevel)
self.freqlevel = dict.fromkeys(range(0, self.ncpus), self.maxfreqlevel)
self.dclevel = dict.fromkeys(self.cpus, self.maxdclevel)
self.freqlevel = dict.fromkeys(self.cpus, self.maxfreqlevel)
# Book-keeping
self.damperexits = 0
self.slowdownexits = 0
self.prevtolalphasetime = 10000.0 # Random large value
self.prevtolalphasetime = 10000.0 # Any large value
def run_policy(self, cpu, startcompute, endcompute, startbarrier,
if cpu not in self.cpus:"Attempt to change power of cpu not in container : %r",
# Select and invoke appropriate power policy
# TODO: Need to add a better policy selection logic in addition to user
# specified
# specified using manifest file
ret, value = self.invoke_policy(cpu, self.policy, self.dclevel[cpu],
self.freqlevel[cpu], startcompute,
endcompute, startbarrier, endbarrier)
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