Now retrieving path to rapl throttle script by reading value of an environment variable. Also, stored the RAPL_PKG_Throttle.py script in a directory called scripts/. The location of this needs to be stored in an environment variable named RAPL_PKG_THROTTLE_LOCATION.

This commit is contained in:
Pradyumna Kaushik 2017-09-28 14:59:31 -04:00
parent dcf67661e9
commit c2b42c2662
3 changed files with 41 additions and 3 deletions

View file

@ -0,0 +1,35 @@
#!/usr/bin/python3
import sys
import os
import math
def main():
POWER_CAP_DIR = "/sys/class/powercap/"
if not len(sys.argv) == 2:
print(sys.argv[0] + " <throttle percent>")
exit(-1)
if not os.path.exists(POWER_CAP_DIR):
print("Powercap framework not installed exist")
exit(-1)
throttle_percent = float(sys.argv[1])/100.0
if throttle_percent > 1.0 or throttle_percent < 0:
print("Percent must be between 0 and 100")
exit(-1)
# print(throttle_percent)
for directory in os.listdir(POWER_CAP_DIR):
if len(directory.split(':')) == 2:
max_watts = open(POWER_CAP_DIR + directory + '/constraint_0_max_power_uw', 'r')
rapl_cap_watts = open(POWER_CAP_DIR + directory + '/constraint_0_power_limit_uw', 'w') #0=longer window, 1=shorter window
rapl_cap_watts.write(str(math.ceil(float(max_watts.read())*throttle_percent)))
main()