Overhauled benchmarking mode.

这个提交包含在:
Craig Warren
2017-03-13 13:53:04 +00:00
父节点 fa93f1f246
当前提交 d59bcc6021

查看文件

@@ -202,28 +202,44 @@ def run_benchmark_sim(args, inputfile, usernamespace):
hyperthreading = ', {} cores with Hyper-Threading'.format(hostinfo['logicalcores']) if hostinfo['hyperthreading'] else '' hyperthreading = ', {} cores with Hyper-Threading'.format(hostinfo['logicalcores']) if hostinfo['hyperthreading'] else ''
machineIDlong = '{}; {} x {} ({} cores{}); {} RAM; {}'.format(hostinfo['machineID'], hostinfo['sockets'], hostinfo['cpuID'], hostinfo['physicalcores'], hyperthreading, human_size(hostinfo['ram'], a_kilobyte_is_1024_bytes=True), hostinfo['osversion']) machineIDlong = '{}; {} x {} ({} cores{}); {} RAM; {}'.format(hostinfo['machineID'], hostinfo['sockets'], hostinfo['cpuID'], hostinfo['physicalcores'], hyperthreading, human_size(hostinfo['ram'], a_kilobyte_is_1024_bytes=True), hostinfo['osversion'])
# Number of CPU threads to test - start from single thread and double threads until maximum number of physical cores # Number of CPU threads to benchmark - start from single thread and double threads until maximum number of physical cores
minthreads = 1 threads = 1
maxthreads = hostinfo['physicalcores'] maxthreads = hostinfo['physicalcores']
threads = [] maxthreadspersocket = hostinfo['physicalcores'] / hostinfo['sockets']
while minthreads < maxthreads: cputhreads = np.array([], dtype=np.int32)
threads.append(int(minthreads)) while threads < maxthreadspersocket:
minthreads *= 2 cputhreads = np.append(cputhreads, int(threads))
threads.append(int(maxthreads)) threads *= 2
threads.reverse() # Check for system with only single thread
if cputhreads.size == 0:
benchtimes = np.zeros(len(threads)) cputhreads = np.append(cputhreads, threads)
numbermodelruns = len(threads) # Add maxthreadspersocket and maxthreads if necessary
if cputhreads[-1] != maxthreadspersocket:
cputhreads = np.append(cputhreads, int(maxthreadspersocket))
if cputhreads[-1] != maxthreads:
cputhreads = np.append(cputhreads, int(maxthreads))
cputhreads = cputhreads[::-1]
cputimes = np.zeros(len(cputhreads))
numbermodelruns = len(cputhreads)
usernamespace['number_model_runs'] = numbermodelruns usernamespace['number_model_runs'] = numbermodelruns
for currentmodelrun in range(1, numbermodelruns + 1): for currentmodelrun in range(1, numbermodelruns + 1):
os.environ['OMP_NUM_THREADS'] = str(threads[currentmodelrun - 1]) os.environ['OMP_NUM_THREADS'] = str(cputhreads[currentmodelrun - 1])
tsolve = run_model(args, currentmodelrun, numbermodelruns, inputfile, usernamespace) cputimes[currentmodelrun - 1] = run_model(args, currentmodelrun, numbermodelruns, inputfile, usernamespace)
benchtimes[currentmodelrun - 1] = tsolve
# Get model size (in cells) and number of iterations
if currentmodelrun == 1:
if numbermodelruns == 1:
outputfile = os.path.splitext(args.inputfile)[0] + '.out'
else:
outputfile = os.path.splitext(args.inputfile)[0] + str(currentmodelrun) + '.out'
f = h5py.File(outputfile, 'r')
iterations = f.attrs['Iterations']
numcells = f.attrs['nx, ny, nz']
# Save number of threads and benchmarking times to NumPy archive # Save number of threads and benchmarking times to NumPy archive
threads = np.array(threads) np.savez(os.path.splitext(inputfile.name)[0], machineID=machineIDlong, cputhreads=cputhreads, cputimes=cputimes, iterations=iterations, numcells=numcells, version=__version__)
np.savez(os.path.splitext(inputfile.name)[0], threads=threads, benchtimes=benchtimes, machineID=machineIDlong, version=__version__)
simcompletestr = '\n=== Simulation completed' simcompletestr = '\n=== Simulation completed'
print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_width() - 1 - len(simcompletestr)))) print('{} {}\n'.format(simcompletestr, '=' * (get_terminal_width() - 1 - len(simcompletestr))))