Skip to content

Commit dddba62

Browse files
authored
improve perf test (ROCm#213)
* added full test suite in perf test
1 parent 674836f commit dddba62

File tree

1 file changed

+84
-15
lines changed

1 file changed

+84
-15
lines changed

scripts/perf/rocfft_perf_test_suite.py

+84-15
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
import subprocess
2727
import os
2828
import datetime
29+
import json
2930

3031
from timeit import default_timer as timer
3132

3233
#Todo:
33-
# -- implement full test suite
34+
# -- support testing plannar format
35+
# -- support plot GFLOPS or time
3436
# -- update short test suite
3537
# -- add option to run with float or double
3638
# -- timeout for plotting
@@ -40,7 +42,7 @@
4042
FULL_SUITE_FLOAT_TEST_NUM=9
4143
FULL_SUITE_DOUBLE_TEST_NUM=9
4244

43-
SHORT_SUITE_FLOAT_TEST_NUM=7
45+
SHORT_SUITE_FLOAT_TEST_NUM=8
4446
SHORT_SUITE_DOUBLE_TEST_NUM=5
4547

4648
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
7173
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
7274

7375

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+
74110
def plot_test_suite(plot_cmd, table_file_list, ref_file_list):
75111

76112
append_options = " -x x -y gflops "
@@ -99,26 +135,58 @@ def plot_test_suite(plot_cmd, table_file_list, ref_file_list):
99135
parser.add_argument('-w', '--work-dir',
100136
dest='work_dir', default='./',
101137
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')
103139
parser.add_argument('-p', '--plot', action="store_true", help='plot the results to png')
104140
parser.add_argument('-m','--mute', action="store_true", help='no print')
105141
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)')
108144

109145
args = parser.parse_args()
110146

111147
elapsed_time = timer()
112148

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+
113171
measure_cmd = "python measurePerformance.py"
114172
plot_cmd = "python plotPerformance.py"
115173

116-
file_name_index_list = ['f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'd0', 'd1', 'd2', 'd3', 'd4']
117-
118174
append_options = ""
119175

120176
table_file_list = []
121177
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))
122190

123191
args.ref_dir = os.path.join(args.ref_dir, '')
124192
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):
130198

131199
# backup first
132200
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'
134202
if os.path.isfile(file):
135203
os.rename(file, file+".bak");
136204
table_file_list.append(file)
137205

138-
label = " --label short_ref "
206+
label = " --label " + args.type + "_ref "
139207

140208
else:
141209

142210
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'
145213

146214
if not os.path.isfile(ref_file):
147215
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):
151219
if not os.path.exists(args.work_dir):
152220
os.mkdir( args.work_dir, 0755 )
153221

154-
label = " --label short "
222+
label = " --label " + args.type + " "
155223

156224
append_options += label + ' --client-prefix ' + args.client_prefix
157225
if args.mute:
158226
append_options += ' --mute '
159227

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)
161232
if args.plot:
162233
plot_test_suite(plot_cmd, table_file_list, ref_file_list)
163234

164235
elapsed_time = timer() - elapsed_time
165236

166237
print "Elapsed time: " + str(datetime.timedelta(seconds=elapsed_time))
167-
168-

0 commit comments

Comments
 (0)