From f52f5a6252d39ea848922fdbc02e30a4f64a1e4a Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Fri, 28 Oct 2022 11:33:23 +0100 Subject: [PATCH] Removed need for specific SPOTPY context. --- gprMax/config.py | 15 ++++----------- gprMax/contexts.py | 8 +++++--- gprMax/gprMax.py | 31 ++++++++----------------------- 3 files changed, 17 insertions(+), 37 deletions(-) diff --git a/gprMax/config.py b/gprMax/config.py index e7bb3ff3..3f430675 100644 --- a/gprMax/config.py +++ b/gprMax/config.py @@ -100,7 +100,7 @@ class ModelConfig: Style.RESET_ALL) # 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() # Numerical dispersion analysis parameters @@ -286,7 +286,6 @@ class SimulationConfig: self._get_byteorder() self._set_input_file_path() self._set_model_start_end() - self._set_single_model() def set_model_device(self, deviceID): """Specify pycuda/pyopencl object for model. @@ -351,17 +350,11 @@ class SimulationConfig: """ 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): """Set range for number of models to run (internally 0 index).""" - if self.args.restart: - modelstart = self.args.restart - 1 - modelend = modelstart + self.args.n - 1 + if self.args.i: + modelstart = self.args.i - 1 + modelend = modelstart + self.args.n else: modelstart = 0 modelend = modelstart + self.args.n diff --git a/gprMax/contexts.py b/gprMax/contexts.py index 545d4471..099b7fb7 100644 --- a/gprMax/contexts.py +++ b/gprMax/contexts.py @@ -140,9 +140,11 @@ class MPIContext(Context): if self.rank == 0: self.tsimstart = timer() self.print_logo_copyright() - self.print_host_info() - if config.sim_config.general['cuda']: - self.print_gpu_info() + print_host_info(config.sim_config.hostinfo) + if config.sim_config.general['solver'] == 'cuda': + 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() # Contruct MPIExecutor diff --git a/gprMax/gprMax.py b/gprMax/gprMax.py index 0c2b600b..32edf66d 100644 --- a/gprMax/gprMax.py +++ b/gprMax/gprMax.py @@ -20,7 +20,7 @@ import argparse import gprMax.config as config -from .contexts import Context, MPIContext, SPOTPYContext +from .contexts import Context, MPIContext from .utilities.logging import logging_config # Arguments (used for API) and their default values (used for API and CLI) @@ -28,8 +28,7 @@ args_defaults = {'scenes': None, 'inputfile': None, 'outputfile': None, 'n': 1, - 'task': None, - 'restart': None, + 'i': None, 'mpi': False, 'gpu': None, 'opencl': None, @@ -38,7 +37,7 @@ args_defaults = {'scenes': None, 'geometry_only': False, 'geometry_fixed': False, 'write_processed': False, - 'log_level': 20, + 'log_level': 20, # Level DEBUG = 10; INFO = 20; BASIC = 25 'log_file': False} # 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.', 'outputfile': '(str, opt): File path to the output data file.', 'n': '(int, req): Number of required simulation runs.', - 'task': '(int, opt): Task identifier (model number) when running ' - '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 ' + 'i': '(int, opt): Model number to start/restart simulation ' 'from. It would typically be used to restart a series of ' 'models from a specific model number, with the n argument, ' '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'], outputfile=args_defaults['outputfile'], n=args_defaults['n'], - task=args_defaults['task'], - restart=args_defaults['restart'], + i=args_defaults['i'], mpi=args_defaults['mpi'], gpu=args_defaults['gpu'], opencl=args_defaults['opencl'], @@ -112,8 +105,7 @@ def run(scenes=args_defaults['scenes'], 'inputfile': inputfile, 'outputfile': outputfile, 'n': n, - 'task': task, - 'restart': restart, + 'i': i, 'mpi': mpi, 'gpu': gpu, 'opencl': opencl, @@ -138,8 +130,7 @@ def cli(): formatter_class=argparse.ArgumentDefaultsHelpFormatter) 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('-task', type=int, help=help_msg['task']) - parser.add_argument('-r', '--restart', type=int, help=help_msg['restart']) + parser.add_argument('-i', type=int, help=help_msg['i']) parser.add_argument('-mpi', action='store_true', default=args_defaults['mpi'], help=help_msg['mpi']) parser.add_argument('-gpu', type=int, action='append', nargs='*', @@ -177,14 +168,8 @@ def run_main(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) - elif config.sim_config.args.mpi: + if config.sim_config.args.mpi: context = MPIContext() context.run() # Standard running (OpenMP/CUDA/OpenCL)