Removed need for specific SPOTPY context.

这个提交包含在:
Craig Warren
2022-10-28 11:33:23 +01:00
父节点 ea576474fc
当前提交 f52f5a6252
共有 3 个文件被更改,包括 17 次插入37 次删除

查看文件

@@ -100,7 +100,7 @@ class ModelConfig:
Style.RESET_ALL) Style.RESET_ALL)
# Output file path and name for specific model # Output file path and name for specific model
self.appendmodelnumber = '' if sim_config.single_model else str(model_num + 1) # Indexed from 1 self.appendmodelnumber = '' if sim_config.args.n == 1 else str(model_num + 1) # Indexed from 1
self.set_output_file_path() self.set_output_file_path()
# Numerical dispersion analysis parameters # Numerical dispersion analysis parameters
@@ -286,7 +286,6 @@ class SimulationConfig:
self._get_byteorder() self._get_byteorder()
self._set_input_file_path() self._set_input_file_path()
self._set_model_start_end() self._set_model_start_end()
self._set_single_model()
def set_model_device(self, deviceID): def set_model_device(self, deviceID):
"""Specify pycuda/pyopencl object for model. """Specify pycuda/pyopencl object for model.
@@ -351,17 +350,11 @@ class SimulationConfig:
""" """
self.vtk_byteorder = 'LittleEndian' if sys.byteorder == 'little' else 'BigEndian' self.vtk_byteorder = 'LittleEndian' if sys.byteorder == 'little' else 'BigEndian'
def _set_single_model(self):
if self.model_end - self.model_start == 1:
self.single_model = True
else:
self.single_model = False
def _set_model_start_end(self): def _set_model_start_end(self):
"""Set range for number of models to run (internally 0 index).""" """Set range for number of models to run (internally 0 index)."""
if self.args.restart: if self.args.i:
modelstart = self.args.restart - 1 modelstart = self.args.i - 1
modelend = modelstart + self.args.n - 1 modelend = modelstart + self.args.n
else: else:
modelstart = 0 modelstart = 0
modelend = modelstart + self.args.n modelend = modelstart + self.args.n

查看文件

@@ -140,9 +140,11 @@ class MPIContext(Context):
if self.rank == 0: if self.rank == 0:
self.tsimstart = timer() self.tsimstart = timer()
self.print_logo_copyright() self.print_logo_copyright()
self.print_host_info() print_host_info(config.sim_config.hostinfo)
if config.sim_config.general['cuda']: if config.sim_config.general['solver'] == 'cuda':
self.print_gpu_info() print_cuda_info(config.sim_config.devices['devs'])
elif config.sim_config.general['solver'] == 'opencl':
print_opencl_info(config.sim_config.devices['devs'])
sys.stdout.flush() sys.stdout.flush()
# Contruct MPIExecutor # Contruct MPIExecutor

查看文件

@@ -20,7 +20,7 @@ import argparse
import gprMax.config as config import gprMax.config as config
from .contexts import Context, MPIContext, SPOTPYContext from .contexts import Context, MPIContext
from .utilities.logging import logging_config from .utilities.logging import logging_config
# Arguments (used for API) and their default values (used for API and CLI) # Arguments (used for API) and their default values (used for API and CLI)
@@ -28,8 +28,7 @@ args_defaults = {'scenes': None,
'inputfile': None, 'inputfile': None,
'outputfile': None, 'outputfile': None,
'n': 1, 'n': 1,
'task': None, 'i': None,
'restart': None,
'mpi': False, 'mpi': False,
'gpu': None, 'gpu': None,
'opencl': None, 'opencl': None,
@@ -38,7 +37,7 @@ args_defaults = {'scenes': None,
'geometry_only': False, 'geometry_only': False,
'geometry_fixed': False, 'geometry_fixed': False,
'write_processed': False, 'write_processed': False,
'log_level': 20, 'log_level': 20, # Level DEBUG = 10; INFO = 20; BASIC = 25
'log_file': False} 'log_file': False}
# Argument help messages (used for CLI argparse) # Argument help messages (used for CLI argparse)
@@ -50,12 +49,7 @@ help_msg = {'scenes': '(list, opt): List of the scenes to run the model. '
'by providing an input file.', 'by providing an input file.',
'outputfile': '(str, opt): File path to the output data file.', 'outputfile': '(str, opt): File path to the output data file.',
'n': '(int, req): Number of required simulation runs.', 'n': '(int, req): Number of required simulation runs.',
'task': '(int, opt): Task identifier (model number) when running ' 'i': '(int, opt): Model number to start/restart simulation '
'simulation as a job array on Open Grid Scheduler/Grid '
'Engine (http://gridscheduler.sourceforge.net/index.html). '
'For further details see the parallel performance '
'section of the User Guide.',
'restart': '(int, opt): Model number to start/restart simulation '
'from. It would typically be used to restart a series of ' 'from. It would typically be used to restart a series of '
'models from a specific model number, with the n argument, ' 'models from a specific model number, with the n argument, '
'e.g. to restart from A-scan 45 when creating a B-scan ' 'e.g. to restart from A-scan 45 when creating a B-scan '
@@ -91,8 +85,7 @@ def run(scenes=args_defaults['scenes'],
inputfile=args_defaults['inputfile'], inputfile=args_defaults['inputfile'],
outputfile=args_defaults['outputfile'], outputfile=args_defaults['outputfile'],
n=args_defaults['n'], n=args_defaults['n'],
task=args_defaults['task'], i=args_defaults['i'],
restart=args_defaults['restart'],
mpi=args_defaults['mpi'], mpi=args_defaults['mpi'],
gpu=args_defaults['gpu'], gpu=args_defaults['gpu'],
opencl=args_defaults['opencl'], opencl=args_defaults['opencl'],
@@ -112,8 +105,7 @@ def run(scenes=args_defaults['scenes'],
'inputfile': inputfile, 'inputfile': inputfile,
'outputfile': outputfile, 'outputfile': outputfile,
'n': n, 'n': n,
'task': task, 'i': i,
'restart': restart,
'mpi': mpi, 'mpi': mpi,
'gpu': gpu, 'gpu': gpu,
'opencl': opencl, 'opencl': opencl,
@@ -138,8 +130,7 @@ def cli():
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('inputfile', help=help_msg['inputfile']) parser.add_argument('inputfile', help=help_msg['inputfile'])
parser.add_argument('-n', default=args_defaults['n'], type=int, help=help_msg['n']) parser.add_argument('-n', default=args_defaults['n'], type=int, help=help_msg['n'])
parser.add_argument('-task', type=int, help=help_msg['task']) parser.add_argument('-i', type=int, help=help_msg['i'])
parser.add_argument('-r', '--restart', type=int, help=help_msg['restart'])
parser.add_argument('-mpi', action='store_true', default=args_defaults['mpi'], parser.add_argument('-mpi', action='store_true', default=args_defaults['mpi'],
help=help_msg['mpi']) help=help_msg['mpi'])
parser.add_argument('-gpu', type=int, action='append', nargs='*', parser.add_argument('-gpu', type=int, action='append', nargs='*',
@@ -177,14 +168,8 @@ def run_main(args):
config.sim_config = config.SimulationConfig(args) config.sim_config = config.SimulationConfig(args)
# If integrating with SPOTPY (https://github.com/thouska/spotpy) - extra
# 'spotpy' attribute is added to args when called by SPOTPY
if hasattr(args, 'spotpy'):
if args.spotpy:
context = SPOTPYContext()
context.run(args.i)
# MPI running with (OpenMP/CUDA/OpenCL) # MPI running with (OpenMP/CUDA/OpenCL)
elif config.sim_config.args.mpi: if config.sim_config.args.mpi:
context = MPIContext() context = MPIContext()
context.run() context.run()
# Standard running (OpenMP/CUDA/OpenCL) # Standard running (OpenMP/CUDA/OpenCL)