-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsilo_bench.py
140 lines (120 loc) · 2.98 KB
/
silo_bench.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import math
import random
import subprocess
from subprocess import Popen, PIPE, call
import time
from datetime import datetime
import sys
import os
import getopt
import numpy as np
import itertools
import argparse
SERVER = "192.168.1.230"
ITR = 666
WTHRESH = 0
PTHRESH = 0
HTHRESH = 0
THRESHC = 0
DTXMXSZRQ = 0
DCA = 0
RSC_DELAY = 0
MAX_DESC = 0
BSIZEPKT = 0
BSIZEHDR = 0
RXRING = 0
TXRING = 0
RAPL = 136
ITRC = []
TYPE = 'etc'
TIME = 120
SEARCH = 0
VERBOSE = 0
'''
DVFS
0xc00 == 1.2GHz
0xd00 == 1.3GHz
.
.
.
.
0x1d00 == 2.9 GHz
'''
dvfs_dict = {
"1.2" : "0xc00",
"1.3" : "0xd00",
"1.4" : "0xe00",
"1.5" : "0xf00",
"1.6" : "0x1000",
"1.7" : "0x1100",
"1.8" : "0x1200",
"1.9" : "0x1300",
"2.0" : "0x1400",
"2.1" : "0x1500",
"2.2" : "0x1600",
"2.3" : "0x1700",
"2.4" : "0x1800",
"2.5" : "0x1900",
"2.6" : "0x1a00",
"2.7" : "0x1b00",
"2.8" : "0x1c00",
"2.9" : "0x1d00",
}
FREQ = dvfs_dict["2.9"]
def runLocalCommandOut(com):
#print(com)
p1 = Popen(list(filter(None, com.strip().split(' '))), stdout=PIPE)
p1.communicate()
#print("\t"+com, "->\n", p1.communicate()[0].strip())
def runRemoteCommandOut(com):
#print(com)
p1 = Popen(["ssh", SERVER, com], stdout=PIPE)
p1.communicate()
#print("\tssh "+SERVER, com, "->\n", p1.communicate()[0].strip())
def runLocalCommand(com):
#print(com)
p1 = Popen(list(filter(None, com.strip().split(' '))), stdout=PIPE)
def runRemoteCommand(com):
#print(com)
p1 = Popen(["ssh", SERVER, com])
def runRemoteCommands(com, server):
#print(com)
p1 = Popen(["ssh", server, com])
def runRemoteCommandGet(com):
#print(com)
p1 = Popen(["ssh", SERVER, com], stdout=PIPE)
return p1.communicate()[0].strip()
def init():
r = runRemoteCommandGet("ls /dev/shm/")
if len(r) == 0:
runRemoteCommandOut("cp ~/dbtest /dev/shm/")
def setRAPL(v):
global RAPL
p1 = Popen(["ssh", SERVER, "/root/uarch-configure/rapl-read/rapl-power-mod", v], stdout=PIPE, stderr=PIPE)
p1.communicate()
time.sleep(0.5)
RAPL = int(v)
def setDVFS(v):
global FREQ
p1 = Popen(["ssh", SERVER, "wrmsr -a 0x199", dvfs_dict[v]], stdout=PIPE, stderr=PIPE)
p1.communicate()
time.sleep(0.5)
FREQ = v
def runSilo():
output = runRemoteCommandGet("pkill dbtest")
output = runRemoteCommandGet("taskset -c 0-16 /dev/shm/dbtest --pmu --bench tpcc --runtime 30 --num-threads 15 --scale-factor 15")
print("*** RAPL:", RAPL, " FREQ:", FREQ, end=" ")
for l in str(output).split("\\n"):
print(str(l.strip()), end=" ")
print("\n")
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--rapl", help="Rapl power limit [46, 136]")
parser.add_argument("--dvfs", help="Cpu frequency [1.2, 2.9 GHz]")
args = parser.parse_args()
if args.rapl:
setRAPL(args.rapl)
if args.dvfs:
setDVFS(args.dvfs)
init()
runSilo()