你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Overhauled benchmarking mode.
这个提交包含在:
@@ -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))))
|
||||||
|
在新工单中引用
屏蔽一个用户