你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 04:56:51 +08:00
Added setting of some environment variable for OpenMP for better performance.
这个提交包含在:
@@ -60,7 +60,10 @@ def process_singlecmds(singlecmds, G):
|
|||||||
|
|
||||||
# Number of processors to run on (OpenMP)
|
# Number of processors to run on (OpenMP)
|
||||||
cmd = '#num_threads'
|
cmd = '#num_threads'
|
||||||
ompthreads = os.environ.get('OMP_NUM_THREADS')
|
os.environ['OMP_WAIT_POLICY'] = 'active'
|
||||||
|
os.environ['OMP_DYNAMIC'] = 'false'
|
||||||
|
os.environ['OMP_PROC_BIND'] = '1'
|
||||||
|
|
||||||
if singlecmds[cmd] != 'None':
|
if singlecmds[cmd] != 'None':
|
||||||
tmp = tuple(int(x) for x in singlecmds[cmd].split())
|
tmp = tuple(int(x) for x in singlecmds[cmd].split())
|
||||||
if len(tmp) != 1:
|
if len(tmp) != 1:
|
||||||
@@ -68,15 +71,18 @@ def process_singlecmds(singlecmds, G):
|
|||||||
if tmp[0] < 1:
|
if tmp[0] < 1:
|
||||||
raise CmdInputError(cmd + ' requires the value to be an integer not less than one')
|
raise CmdInputError(cmd + ' requires the value to be an integer not less than one')
|
||||||
G.nthreads = tmp[0]
|
G.nthreads = tmp[0]
|
||||||
elif ompthreads:
|
os.environ['OMP_NUM_THREADS'] = str(G.nthreads)
|
||||||
G.nthreads = int(ompthreads)
|
elif os.environ.get('OMP_NUM_THREADS'):
|
||||||
|
G.nthreads = int(os.environ.get('OMP_NUM_THREADS'))
|
||||||
else:
|
else:
|
||||||
# Set number of threads to number of physical CPU cores, i.e. avoid hyperthreading with OpenMP
|
# Set number of threads to number of physical CPU cores, i.e. avoid hyperthreading with OpenMP
|
||||||
G.nthreads = psutil.cpu_count(logical=False)
|
G.nthreads = psutil.cpu_count(logical=False)
|
||||||
if G.nthreads > psutil.cpu_count(logical=False):
|
os.environ['OMP_NUM_THREADS'] = str(G.nthreads)
|
||||||
print('\nWARNING: You have specified more threads ({}) than available physical CPU cores ({}). This may lead to degraded performance.'.format(G.nthreads, psutil.cpu_count(logical=False)))
|
|
||||||
if G.messages:
|
if G.messages:
|
||||||
print('Number of threads: {}'.format(G.nthreads))
|
print('Number of threads: {}'.format(G.nthreads))
|
||||||
|
if G.nthreads > psutil.cpu_count(logical=False):
|
||||||
|
print('\nWARNING: You have specified more threads ({}) than available physical CPU cores ({}). This may lead to degraded performance.'.format(G.nthreads, psutil.cpu_count(logical=False)))
|
||||||
|
|
||||||
|
|
||||||
# Spatial discretisation
|
# Spatial discretisation
|
||||||
|
在新工单中引用
屏蔽一个用户