26
26
import subprocess
27
27
import os
28
28
import datetime
29
+ import json
29
30
30
31
from timeit import default_timer as timer
31
32
32
33
#Todo:
33
- # -- implement full test suite
34
+ # -- support testing plannar format
35
+ # -- support plot GFLOPS or time
34
36
# -- update short test suite
35
37
# -- add option to run with float or double
36
38
# -- timeout for plotting
40
42
FULL_SUITE_FLOAT_TEST_NUM = 9
41
43
FULL_SUITE_DOUBLE_TEST_NUM = 9
42
44
43
- SHORT_SUITE_FLOAT_TEST_NUM = 7
45
+ SHORT_SUITE_FLOAT_TEST_NUM = 8
44
46
SHORT_SUITE_DOUBLE_TEST_NUM = 5
45
47
46
48
def load_short_test_suite (measure_cmd , table_file_list , ref_file_list , append_options ):
@@ -71,6 +73,40 @@ def load_short_test_suite(measure_cmd, table_file_list, ref_file_list, append_op
71
73
subprocess .check_call (measure_cmd + " -x 256-4194304 -b 50 -prime_factor 2 -r double -i 2 -o 3 " + file_list [12 ] + append_options , shell = True ) # TODO: test with "-b adapt" after fixing real fft
72
74
73
75
76
+ def load_full_test_suite (measure_cmd , table_file_list , ref_file_list , append_options ):
77
+
78
+ file_list = []
79
+ if not ref_file_list :
80
+ for f in table_file_list :
81
+ file_list .append (" --tablefile " + f )
82
+ else :
83
+ for i in range (len (table_file_list )):
84
+ file_list .append (" --tablefile " + table_file_list [i ] + " --ref-file " + ref_file_list [i ])
85
+
86
+ subprocess .check_call (measure_cmd + " -x 2-16777216 -b adapt -prime_factor 2 " + file_list [ 0 ] + append_options , shell = True )
87
+ subprocess .check_call (measure_cmd + " -x 2-4096 -y 2-4096 -b adapt -prime_factor 2 " + file_list [ 1 ] + append_options , shell = True )
88
+ subprocess .check_call (measure_cmd + " -x 2-256 -y 2-256 -z 2-256 -b adapt -prime_factor 2 " + file_list [ 2 ] + append_options , shell = True )
89
+
90
+ subprocess .check_call (measure_cmd + " -x 2-16777216 -b adapt -prime_factor 2 --placeness out" + file_list [ 3 ] + append_options , shell = True )
91
+ subprocess .check_call (measure_cmd + " -x 3-14348907 -b adapt -prime_factor 3 " + file_list [ 4 ] + append_options , shell = True )
92
+ subprocess .check_call (measure_cmd + " -x 5-9765625 -b adapt -prime_factor 5 " + file_list [ 5 ] + append_options , shell = True )
93
+
94
+ subprocess .check_call (measure_cmd + " -x 128-4194304 -prime_factor 2 -i 2 -o 3 " + file_list [ 6 ] + append_options , shell = True ) # TODO: test with "-x 128-4194304 -b adapt" after fixing real fft
95
+ subprocess .check_call (measure_cmd + " -x 128-4194304 -prime_factor 2 -i 3 -o 2 " + file_list [ 7 ] + append_options , shell = True ) # TODO: test with "-x 128-4194304 -b adapt" after fixing real fft
96
+ subprocess .check_call (measure_cmd + " -x 2-4096 -y 2-4096 -b 20 -prime_factor 2 -i 3 -o 2 --placeness out" + file_list [ 8 ] + append_options , shell = True ) # TODO: test with "-b adapt" after fixing real fft
97
+
98
+ subprocess .check_call (measure_cmd + " -x 2-16777216 -b adapt -prime_factor 2 -r double " + file_list [ 9 ] + append_options , shell = True )
99
+ subprocess .check_call (measure_cmd + " -x 2-4096 -y 2-4096 -b adapt -prime_factor 2 -r double " + file_list [10 ] + append_options , shell = True )
100
+ subprocess .check_call (measure_cmd + " -x 2-256 -y 2-256 -z 2-256 -b adapt -prime_factor 2 -r double " + file_list [11 ] + append_options , shell = True )
101
+
102
+ subprocess .check_call (measure_cmd + " -x 2-16777216 -b adapt -prime_factor 2 --placeness out -r double " + file_list [12 ] + append_options , shell = True )
103
+ subprocess .check_call (measure_cmd + " -x 3-14348907 -b adapt -prime_factor 3 -r double " + file_list [13 ] + append_options , shell = True )
104
+ subprocess .check_call (measure_cmd + " -x 5-9765625 -b adapt -prime_factor 5 -r double " + file_list [14 ] + append_options , shell = True )
105
+
106
+ subprocess .check_call (measure_cmd + " -x 128-4194304 -prime_factor 2 -i 2 -o 3 -r double " + file_list [15 ] + append_options , shell = True ) # TODO: test with "-x 128-4194304 -b adapt" after fixing real fft
107
+ subprocess .check_call (measure_cmd + " -x 128-4194304 -prime_factor 2 -i 3 -o 2 -r double " + file_list [16 ] + append_options , shell = True ) # TODO: test with "-x 128-4194304 -b adapt" after fixing real fft
108
+ subprocess .check_call (measure_cmd + " -x 2-4096 -y 2-4096 -b 20 -prime_factor 2 -i 3 -o 2 --placeness out -r double " + file_list [17 ] + append_options , shell = True ) # TODO: test with "-b adapt" after fixing real fft
109
+
74
110
def plot_test_suite (plot_cmd , table_file_list , ref_file_list ):
75
111
76
112
append_options = " -x x -y gflops "
@@ -99,26 +135,58 @@ def plot_test_suite(plot_cmd, table_file_list, ref_file_list):
99
135
parser .add_argument ('-w' , '--work-dir' ,
100
136
dest = 'work_dir' , default = './' ,
101
137
help = 'specify the current working results dirctory(default ./)' )
102
- parser .add_argument ('-g' , '--gen-ref' , action = "store_true" , help = 'generate reference' )
138
+ parser .add_argument ('-g' , '--gen-ref' , dest = 'gen_ref' , action = "store_true" , help = 'generate reference' )
103
139
parser .add_argument ('-p' , '--plot' , action = "store_true" , help = 'plot the results to png' )
104
140
parser .add_argument ('-m' ,'--mute' , action = "store_true" , help = 'no print' )
105
141
parser .add_argument ('--client-prefix' ,
106
- dest = 'client_prefix' , default = './' ,
107
- help = 'Path where the library client is located (default current directory)' )
142
+ dest = 'client_prefix' , default = '../../build/release/clients/staging /' ,
143
+ help = 'Path where the library client is located (default current build release directory)' )
108
144
109
145
args = parser .parse_args ()
110
146
111
147
elapsed_time = timer ()
112
148
149
+ if args .gen_ref :
150
+ print "Generate reference in ref directory" , args .ref_dir
151
+ else :
152
+ print "Ref directory" , args .ref_dir
153
+ print "Work directory" , args .work_dir
154
+
155
+ config_info = "Check config info with rocm-smi and hipcc\n "
156
+ try :
157
+ config_info += subprocess .check_output (['/opt/rocm/bin/rocm-smi' , '--showdriverversion' , '--showvbios' , '--showfwinfo' , '-s' , '-i' , '-d' , args .device ])
158
+ except subprocess .CalledProcessError as e :
159
+ config_info += "Can not find or run /opt/rocm/bin/rocm-smi properly.\n "
160
+
161
+ try :
162
+ config_info += subprocess .check_output (['/opt/rocm/bin/hipcc' , '--version' ])
163
+ except subprocess .CalledProcessError as e :
164
+ config_info += "Can not find or run /opt/rocm/bin/hipcc --version properly.\n "
165
+
166
+ if not os .path .exists ('perfLog' ):
167
+ os .makedirs ('perfLog' )
168
+ with open ("perfLog/config_info.txt" , "w" ) as config_info_file :
169
+ config_info_file .write (config_info )
170
+
113
171
measure_cmd = "python measurePerformance.py"
114
172
plot_cmd = "python plotPerformance.py"
115
173
116
- file_name_index_list = ['f0' , 'f1' , 'f2' , 'f3' , 'f4' , 'f5' , 'f6' , 'f7' , 'd0' , 'd1' , 'd2' , 'd3' , 'd4' ]
117
-
118
174
append_options = ""
119
175
120
176
table_file_list = []
121
177
ref_file_list = []
178
+ file_name_index_list = []
179
+
180
+ if args .type == "short" :
181
+ for i in range (SHORT_SUITE_FLOAT_TEST_NUM ):
182
+ file_name_index_list .append ('f' + str (i ))
183
+ for i in range (SHORT_SUITE_DOUBLE_TEST_NUM ):
184
+ file_name_index_list .append ('d' + str (i ))
185
+ else :
186
+ for i in range (FULL_SUITE_FLOAT_TEST_NUM ):
187
+ file_name_index_list .append ('f' + str (i ))
188
+ for i in range (FULL_SUITE_DOUBLE_TEST_NUM ):
189
+ file_name_index_list .append ('d' + str (i ))
122
190
123
191
args .ref_dir = os .path .join (args .ref_dir , '' )
124
192
args .work_dir = os .path .join (args .work_dir , '' )
@@ -130,18 +198,18 @@ def plot_test_suite(plot_cmd, table_file_list, ref_file_list):
130
198
131
199
# backup first
132
200
for file_name_index in file_name_index_list :
133
- file = args .ref_dir + 'short_ '+ file_name_index + '_ref.csv'
201
+ file = args .ref_dir + args . type + '_ '+ file_name_index + '_ref.csv'
134
202
if os .path .isfile (file ):
135
203
os .rename (file , file + ".bak" );
136
204
table_file_list .append (file )
137
205
138
- label = " --label short_ref "
206
+ label = " --label " + args . type + "_ref "
139
207
140
208
else :
141
209
142
210
for file_name_index in file_name_index_list :
143
- file = args .work_dir + 'short_ '+ file_name_index + '.csv'
144
- ref_file = args .ref_dir + 'short_ '+ file_name_index + '_ref.csv'
211
+ file = args .work_dir + args . type + '_ '+ file_name_index + '.csv'
212
+ ref_file = args .ref_dir + args . type + '_ '+ file_name_index + '_ref.csv'
145
213
146
214
if not os .path .isfile (ref_file ):
147
215
sys .exit ('Error! Can not find ref file ' + ref_file )
@@ -151,18 +219,19 @@ def plot_test_suite(plot_cmd, table_file_list, ref_file_list):
151
219
if not os .path .exists (args .work_dir ):
152
220
os .mkdir ( args .work_dir , 0755 )
153
221
154
- label = " --label short "
222
+ label = " --label " + args . type + " "
155
223
156
224
append_options += label + ' --client-prefix ' + args .client_prefix
157
225
if args .mute :
158
226
append_options += ' --mute '
159
227
160
- load_short_test_suite (measure_cmd , table_file_list , ref_file_list , append_options )
228
+ if args .type == "short" :
229
+ load_short_test_suite (measure_cmd , table_file_list , ref_file_list , append_options )
230
+ else :
231
+ load_full_test_suite (measure_cmd , table_file_list , ref_file_list , append_options )
161
232
if args .plot :
162
233
plot_test_suite (plot_cmd , table_file_list , ref_file_list )
163
234
164
235
elapsed_time = timer () - elapsed_time
165
236
166
237
print "Elapsed time: " + str (datetime .timedelta (seconds = elapsed_time ))
167
-
168
-
0 commit comments