Skip to content

Commit 17f819f

Browse files
authored
Merge pull request #89 from cesar-avalos3/update-to-python3
Update get-accel-sim-traces.py to support python 3
2 parents 8d1cf8e + 31fd8ec commit 17f819f

File tree

8 files changed

+61
-55
lines changed

8 files changed

+61
-55
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ AccelWattch microbenchmarks and AccelWattch validation set benchmarks are also i
104104
105105
2. **Accel-Sim SASS Frontend and Simulation Engine**: A simulator frontend that consumes SASS traces and feeds them into a performance model. The intial release of Accel-Sim coincides with the release of [GPGPU-Sim 4.0](https://github.com/accel-sim/accel-sim-framework/blob/dev/gpu-simulator/gpgpu-sim4.md), which acts as the detailed performance model. To build the Accel-Sim simulator that uses the traces, do the following:
106106
```bash
107+
pip3 install -r requirements.txt
107108
source ./gpu-simulator/setup_environment.sh
108109
make -j -C ./gpu-simulator/
109110
```
@@ -278,4 +279,4 @@ Note that *AccelWattch HW* and *AccelWattch HYBRID* configurations require hardw
278279

279280
5. **Microbenchmarks and Quadratic Optimization Solver**: The source code for the microbenchmarks used for AccelWattch dynamic power modeling are located [here](https://github.com/accel-sim/gpu-app-collection/tree/release-accelwattch/src/cuda/accelwattch-ubench) and can be compiled by following the README [here](https://github.com/accel-sim/gpu-app-collection/tree/release-accelwattch). The Quadratic Optimization Solver MATLAB script is located at `./util/accelwattch/quadprog_solver.m`.
280281

281-
6. **SASS to Power Component Mapping**: The header file `gpu-simulator/ISA_Def/accelwattch_component_mapping.h` contains the Accel-Sim instruction opcode to AccelWattch power component mapping and can be extended to support new SASS instructions for future architectures. Please look at the *opcode.h* files for respective GPU Architectures in the same directory `gpu-simulator/ISA_Def/` for SASS instruction to Accel-Sim opcode mapping.
282+
6. **SASS to Power Component Mapping**: The header file `gpu-simulator/ISA_Def/accelwattch_component_mapping.h` contains the Accel-Sim instruction opcode to AccelWattch power component mapping and can be extended to support new SASS instructions for future architectures. Please look at the *opcode.h* files for respective GPU Architectures in the same directory `gpu-simulator/ISA_Def/` for SASS instruction to Accel-Sim opcode mapping.

get-accel-sim-traces.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
from optparse import OptionParser
44
import re
@@ -49,7 +49,7 @@ def __init__(self, name):
4949

5050
def getTotalCompressed(self):
5151
total = 0.0
52-
for name,suite in self.suites.iteritems():
52+
for name,suite in self.suites.items():
5353
try:
5454
total += suite.compressedSize
5555
except TypeError:
@@ -58,13 +58,13 @@ def getTotalCompressed(self):
5858

5959
def getTotalUncompressed(self):
6060
total = 0.0
61-
for name,suite in self.suites.iteritems():
61+
for name,suite in self.suites.items():
6262
total += suite.uncompressedSize
6363
return total
6464

6565
def downloadTrace(cardName, suiteName):
6666
webFile = os.path.join(WEB_DIRECTORY, cardName, VERSION + ".latest", suiteName + ".tgz")
67-
print "\n\nDownloading {0}".format(webFile)
67+
print("\n\nDownloading {0}".format(webFile))
6868
wget = Popen(["wget " + webFile], stderr=STDOUT, shell=True)
6969
wget.communicate()
7070
if wget.returncode != 0:
@@ -121,13 +121,13 @@ def main():
121121
suite.uncompressedSize = getNumRaw(size)
122122

123123
# Infor the user what is available - ask them what they want to do
124-
print "\n\nCurrently Available Traces:"
125-
for cardName, card in sizeDict.iteritems():
126-
print "GPU Name: {0}. All Apps Compressed (Download size): {1}, All Apps Uncompressed (Size on disk when used): {2}"\
127-
.format(card.name, millify(card.getTotalCompressed()), millify(card.getTotalUncompressed()))
128-
for name, suite in card.suites.iteritems():
129-
print "\t{0}: Compressed = {1}, Uncompressed = {2}".format(suite.name,\
130-
millify(suite.compressedSize), millify(suite.uncompressedSize))
124+
print("\n\nCurrently Available Traces:")
125+
for cardName, card in sizeDict.items():
126+
print("GPU Name: {0}. All Apps Compressed (Download size): {1}, All Apps Uncompressed (Size on disk when used): {2}"\
127+
.format(card.name, millify(card.getTotalCompressed()), millify(card.getTotalUncompressed())))
128+
for name, suite in card.suites.items():
129+
print("\t{0}: Compressed = {1}, Uncompressed = {2}".format(suite.name,\
130+
millify(suite.compressedSize), millify(suite.uncompressedSize)))
131131

132132
selectionValid = False
133133
while not selectionValid:
@@ -144,29 +144,29 @@ def main():
144144
cardName = item.split(r"/")[0]
145145
suiteName = item.split(r"/")[1]
146146
if cardName == "all":
147-
for cardName, card in sizeDict.iteritems():
147+
for cardName, card in sizeDict.items():
148148
if suiteName == "all":
149-
for suiteName, suite in card.suites.iteritems():
149+
for suiteName, suite in card.suites.items():
150150
downloadTrace(cardName, suiteName)
151151
else:
152152
downloadTrace(cardName, suiteName)
153153
else:
154154
card = sizeDict[cardName]
155155
if suiteName == "all":
156-
for suiteName, suite in card.suites.iteritems():
156+
for suiteName, suite in card.suites.items():
157157
downloadTrace(cardName, suiteName)
158158
else:
159159
downloadTrace(cardName, suiteName)
160160

161161
selectionValid = True
162162
except Exception as e:
163163
selectionValid = False
164-
print "Invalid Input: {0}".format(e)
164+
print("Invalid Input: {0}".format(e))
165165
if options.apps != None:
166166
sys.exit(1)
167167

168-
print "\n\nDownload successful to {0}.\nFiles must be uncompressed with tar -xzvf <filename> to be usable by accel-sim"\
169-
.format(hw_run_dir)
168+
print("\n\nDownload successful to {0}.\nFiles must be uncompressed with tar -xzvf <filename> to be usable by accel-sim"\
169+
.format(hw_run_dir))
170170

171171
if __name__ == '__main__':
172172
main()

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pyyaml
2+
pandas
3+
plotly
4+
kaleido
5+
psutil

util/hw_stats/run_hw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Copyright (c) 2018-2021, Mahmoud Khairy, Vijay Kandiah, Timothy Rogers, Tor M. Aamodt, Nikos Hardavellas
44
# Northwestern University, Purdue University, The University of British Columbia
@@ -177,8 +177,8 @@
177177
if not options.norun:
178178
saved_dir = os.getcwd()
179179
os.chdir(this_run_dir)
180-
print "Running {0}".format(exe)
180+
print("Running {0}".format(exe))
181181

182182
if subprocess.call(["bash", "run.sh"]) != 0:
183-
print "Error invoking profiler on {0}".format(this_run_dir)
183+
print("Error invoking profiler on {0}".format(this_run_dir))
184184
os.chdir(saved_dir)

util/job_launching/monitor_func_test.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
from optparse import OptionParser
44
import re
@@ -37,21 +37,21 @@ def kill_all_running_jobs(jobstatus_out_filename):
3737
app = tokens[appCol].strip()
3838
appArgs = tokens[appArgsCol].strip()
3939
nodeName = tokens[nodeCol].strip()
40-
print "Calling qdel {0}: {1}/{2} ({3})".format(torqueID, app, appArgs, nodeName)
40+
print("Calling qdel {0}: {1}/{2} ({3})".format(torqueID, app, appArgs, nodeName))
4141
if subprocess.call( ["qdel" , torqueID] ) != 0:
42-
print "WARNING error calling qdel"
43-
print "Sleeping 30s to wait for the file system to calm down"
42+
print("WARNING error calling qdel")
43+
print("Sleeping 30s to wait for the file system to calm down")
4444
time.sleep(30)
4545
jobstatus_out_file.close()
4646

4747
def print_statsfile(options, this_directory):
4848
get_stats_out_file = open(options.statsfile, 'w+')
49-
print "Calling get_stats.py"
49+
print("Calling get_stats.py")
5050
if subprocess.call([os.path.join(this_directory, "get_stats.py") ,"-R" ,"-l", options.logfile, "-N", options.sim_name, "-A"],
5151
stdout=get_stats_out_file, stderr=get_stats_out_file) != 0:
52-
print "Error Launching get_stats.py"
52+
print("Error Launching get_stats.py")
5353
get_stats_out_file.seek(0)
54-
print get_stats_out_file.read()
54+
print(get_stats_out_file.read())
5555
get_stats_out_file.close()
5656

5757
def handle_exit(jobstatus_out_filename):
@@ -116,14 +116,14 @@ def handle_exit(jobstatus_out_filename):
116116
while True:
117117
jobstatus_out_file = open(jobstatus_out_filename, 'w+')
118118
if options.verbose:
119-
print "Calling job_status.py"
119+
print("Calling job_status.py")
120120
if subprocess.call([os.path.join(this_directory, "job_status.py"),\
121121
"-l", options.logfile, \
122122
"-N", options.sim_name, \
123123
"-j", job_manager],\
124124
stdout=jobstatus_out_file, stderr=jobstatus_out_file) != 0:
125125
jobstatus_out_file.seek(0)
126-
print jobstatus_out_file.read()
126+
print(jobstatus_out_file.read())
127127
exit("Error Launching job_status.py")
128128
else:
129129
jobstatus_out_file.seek(0)
@@ -135,7 +135,7 @@ def handle_exit(jobstatus_out_filename):
135135
num_no_err = 0
136136
for line in jobstatus_out_file.readlines():
137137
if options.verbose:
138-
print line.strip()
138+
print(line.strip())
139139
if jobStatusCol == None:
140140
jobStatusCol = getColId("(.*)JobStatus.*", line)
141141
else:
@@ -159,27 +159,27 @@ def handle_exit(jobstatus_out_filename):
159159
jobstatus_out_file.close()
160160

161161
total = num_passed + num_running + num_waiting + num_error + num_no_err
162-
print "Passed:{0}/{1}, No error:{2}/{1}, Failed/Error:{3}/{1}, Running:{4}/{1}, Waiting:{5}/{1}"\
163-
.format(num_passed, total, num_no_err, num_error, num_running, num_waiting)
162+
print("Passed:{0}/{1}, No error:{2}/{1}, Failed/Error:{3}/{1}, Running:{4}/{1}, Waiting:{5}/{1}"\
163+
.format(num_passed, total, num_no_err, num_error, num_running, num_waiting))
164164
if num_error > 0:
165-
print "Contents {0}:".format(failed_job_file)
165+
print("Contents {0}:".format(failed_job_file))
166166
if options.verbose and os.path.exists(failed_job_file):
167-
print open(failed_job_file).read()
167+
print(open(failed_job_file).read())
168168

169169
if num_running + num_waiting == 0:
170-
print "All {0} Tests Done.".format(total)
170+
print("All {0} Tests Done.".format(total))
171171
if num_error == 0:
172-
print "Congratulations! All Tests Pass!"
172+
print("Congratulations! All Tests Pass!")
173173
else:
174-
print "Something did not pass."
174+
print("Something did not pass.")
175175

176176
handle_exit(jobstatus_out_filename)
177177
else:
178-
print "Sleeping for {0}s".format(options.sleep_time)
178+
print("Sleeping for {0}s".format(options.sleep_time))
179179
time.sleep(int(options.sleep_time))
180180
options.timeout -= float(options.sleep_time)
181181
if options.timeout <= 0:
182-
print "Monitor has timed-out"
182+
print("Monitor has timed-out")
183183
if options.killwhentimedout:
184184
kill_all_running_jobs(jobstatus_out_filename)
185185
handle_exit(jobstatus_out_filename)

util/plotting/merge-stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
from __future__ import print_function
44
from optparse import OptionParser

util/plotting/plot-correlation.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
from __future__ import print_function
44
from optparse import OptionParser
@@ -58,12 +58,12 @@ def getAppData(kernels, x, y, xaxis_title, correlmap):
5858
# For rates, take the average across all the kernels in the app
5959
if correlmap.stattype == "rate":
6060
new_map = {}
61-
for k,v in app_map.iteritems():
61+
for k,v in app_map.items():
6262
x1,y1,numk = v
6363
new_map[k] = (x1 / numk, y1 / numk, numk)
6464
app_map = new_map
6565

66-
for k,v in app_map.iteritems():
66+
for k,v in app_map.items():
6767
apps.append(k)
6868
x1,y1,numk = v
6969
newx.append(x1)
@@ -480,7 +480,7 @@ def get_sim_csv_data(filepath, logger):
480480
count += 1
481481
for stat in stats_missing:
482482
appargs, num, current_stat = stat
483-
for cfg in all_kerns.iterkeys():
483+
for cfg in all_kerns.keys():
484484
del all_kerns[cfg][appargs][num][current_stat]
485485
return all_kerns
486486

@@ -614,18 +614,18 @@ def parse_hw_csv(csv_file, hw_data, appargs, kdata, logger):
614614

615615
def summarize_hw_data(hw_data, logger):
616616
print("-----------------------------------------------------------------")
617-
for device,appargslist in hw_data.iteritems():
617+
for device,appargslist in hw_data.items():
618618
print("All Card Summary:")
619619
print("HW Summary for {0} [Contains {1} Apps]:"
620620
.format(device,len(appargslist)))
621621
print("----------------------------------------------------------------\n\n")
622622

623623
# Print HW data summary
624-
for device,appargslist in hw_data.iteritems():
624+
for device,appargslist in hw_data.items():
625625
logger.logchan("-----------------------------------------------------------------","hwsummary")
626626
logger.logchan("HW Summary for {0} [Contains {1} Apps]:"
627627
.format(device,len(appargslist)), "hwsummary")
628-
for appargs,kdata in appargslist.iteritems():
628+
for appargs,kdata in appargslist.items():
629629
logger.logchan("\t{0}:".format(appargs), "hwsummary")
630630
logger.logchan("\t\tContatins {0} kernels:".format(len(kdata)), "hwsummary")
631631

@@ -763,13 +763,13 @@ def summarize_hw_data(hw_data, logger):
763763
exec(open(options.data_mappings,'r').read())
764764

765765
fig_data = {} # map of HW config to a list of scatters
766-
for cfg,sim_for_cfg in sim_data.iteritems():
766+
for cfg,sim_for_cfg in sim_data.items():
767767
if cfg.split('-')[0] not in config_maps:
768768
logger.log("cfg {0} not in config_maps:{1}.".format(cfg, config_maps))
769769
continue
770770

771771
hw_cfg = None
772-
for device in hw_data.iterkeys():
772+
for device in hw_data.keys():
773773
logger.log("Testing hw_cfg={0}".format(device))
774774
logger.log("\tcfg={0}, config_maps={1}".format(cfg,config_maps))
775775

@@ -804,14 +804,14 @@ def summarize_hw_data(hw_data, logger):
804804
num_under = 0
805805
num_over = 0
806806
errs = []
807-
sim_appargs_leftover = set(copy.deepcopy(sim_for_cfg.keys()))
808-
hw_appargs_leftover = set(copy.deepcopy(hw_data[hw_cfg].keys()))
807+
sim_appargs_leftover = set(copy.deepcopy(list(sim_for_cfg.keys())))
808+
hw_appargs_leftover = set(copy.deepcopy(list(hw_data[hw_cfg].keys())))
809809
max_axis_val = 0.0
810810
min_axis_val = 99999999999999999999999999999.9
811811
err_dropped_stats = 0
812812
hw_low_drop_stats = 0
813813
apps_included = {}
814-
for appargs,sim_klist in sim_for_cfg.iteritems():
814+
for appargs,sim_klist in sim_for_cfg.items():
815815
if appargs in hw_data[hw_cfg]:
816816
if (isAppBanned( appargs, blacklist )):
817817
continue
@@ -979,6 +979,6 @@ def summarize_hw_data(hw_data, logger):
979979

980980

981981
correl_outdir = os.path.join(this_directory, "correl-html")
982-
for (plotfile,hw_cfg), traces in fig_data.iteritems():
982+
for (plotfile,hw_cfg), traces in fig_data.items():
983983
make_submission_quality_image(options.image_type, traces, hw_cfg)
984984
print("Output Available at: file://{0}".format(correl_outdir))

util/tracer_nvbit/run_hw_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
sh_contents += "\nexport CUDA_VERSION=\"" + cuda_version + "\"; export CUDA_VISIBLE_DEVICES=\"" + options.device_num + "\" ; " +\
106106
"export TRACES_FOLDER="+ this_trace_folder + "; CUDA_INJECTION64_PATH=" + os.path.join(nvbit_tracer_path, "tracer_tool.so") + " " +\
107107
exec_path + " " + str(args) + " ; " + os.path.join(nvbit_tracer_path,"traces-processing", "post-traces-processing") + " " +\
108-
os.path.join(this_trace_folder, "kernelslist") #+ " ; rm -f " + this_trace_folder + "/*.trace ; rm -f " + this_trace_folder + "/kernelslist "
108+
os.path.join(this_trace_folder, "kernelslist") + " ; rm -f " + this_trace_folder + "/*.trace ; rm -f " + this_trace_folder + "/kernelslist "
109109

110110
open(os.path.join(this_run_dir,"run.sh"), "w").write(sh_contents)
111111
if subprocess.call(['chmod', 'u+x', os.path.join(this_run_dir,"run.sh")]) != 0:

0 commit comments

Comments
 (0)