diff --git a/neurodamus/commands.py b/neurodamus/commands.py index 611df78a..632216e9 100644 --- a/neurodamus/commands.py +++ b/neurodamus/commands.py @@ -58,7 +58,8 @@ def neurodamus(args=None): --model-stats Show model stats in CoreNEURON simulations [default: False] --dry-run Dry-run simulation to estimate memory usage [default: False] --num-target-ranks= Number of ranks to target for dry-run load balancing - --skip-write-model Run CoreNeuron in direct mode, without writing model data to disk + --coreneuron-direct-mode Run CoreNeuron in direct memory mode transfered from Neuron, + without writing model data to disk. """ options = docopt_sanitize(docopt(neurodamus.__doc__, args)) config_file = options.pop("ConfigFile") diff --git a/neurodamus/core/configuration.py b/neurodamus/core/configuration.py index e29fae88..40ae6d20 100644 --- a/neurodamus/core/configuration.py +++ b/neurodamus/core/configuration.py @@ -75,11 +75,8 @@ class CliOptions(ConfigT): model_stats = False simulator = None dry_run = False -<<<<<<< HEAD num_target_ranks = None -======= - skip_write_model = False ->>>>>>> a8a10a6... Cli option + coreneuron_direct_mode = False # Restricted Functionality support, mostly for testing @@ -240,11 +237,8 @@ class _SimConfig(object): spike_location = "soma" spike_threshold = -30 dry_run = False -<<<<<<< HEAD num_target_ranks = None -======= - skip_write_model = False ->>>>>>> a8a10a6... Cli option + coreneuron_direct_mode = False _validators = [] _requisitors = [] @@ -280,11 +274,8 @@ def init(cls, config_file, cli_options): cls.modifications = compat.Map(cls._config_parser.parsedModifications or {}) cls.cli_options = CliOptions(**(cli_options or {})) cls.dry_run = cls.cli_options.dry_run -<<<<<<< HEAD cls.num_target_ranks = cls.cli_options.num_target_ranks -======= - cls.skip_write_model = cls.cli_options.skip_write_model ->>>>>>> a8a10a6... Cli option + cls.coreneuron_direct_mode = cls.cli_options.coreneuron_direct_mode # change simulator by request before validator and init hoc config if cls.cli_options.simulator: cls._parsed_run["Simulator"] = cls.cli_options.simulator @@ -1020,15 +1011,13 @@ def _spikes_sort_order(config: _SimConfig, run_conf): @SimConfig.validator -def _skip_write_coreneuron_model(config: _SimConfig, run_conf): - if config.skip_write_model: +def _coreneuron_direct_mode(config: _SimConfig, run_conf): + if config.coreneuron_direct_mode: if config.use_coreneuron: logging.info("Run CORENEURON without writing model data to disk") - # config.use_neuron = True - # config.use_coreneuron = False else: - logging.warning("--skip-write-model not valid for NEURON, continue as usual") - config.skip_write_model = False + logging.warning("--coreneuron-direct-mode not valid for NEURON, continue with NEURON") + config.coreneuron_direct_mode = False def get_debug_cell_gid(cli_options): diff --git a/neurodamus/core/coreneuron_configuration.py b/neurodamus/core/coreneuron_configuration.py index 33a6b04f..4e8d37f7 100644 --- a/neurodamus/core/coreneuron_configuration.py +++ b/neurodamus/core/coreneuron_configuration.py @@ -3,7 +3,6 @@ from pathlib import Path from ._utils import run_only_rank0 from . import NeurodamusCore as Nd -from ..utils.logging import log_verbose class CompartmentMapping: @@ -207,25 +206,21 @@ def write_spike_filename(self, filename): fp.write(filename) fp.write("\n") - def psolve_core(self, save_path=None, restore_path=None, skip_write_model=False): + def psolve_core(self, save_path=None, restore_path=None, coreneuron_direct_mode=False): from neuron import coreneuron from . import NeurodamusCore as Nd Nd.cvode.cache_efficient(1) coreneuron.enable = True - if not skip_write_model: - coreneuron.file_mode = True - coreneuron.sim_config = f"{self.output_root}/{self.sim_config_file}" - if save_path: - coreneuron.save_path = save_path - if restore_path: - coreneuron.restore_path = restore_path - # Model is already written to disk by calling pc.nrncore_write() - coreneuron.skip_write_model_to_disk = True - coreneuron.model_path = f"{self.datadir}" - else: - log_verbose("Run CORENEURON direct mode") - coreneuron.sim_config = f"{self.output_root}/{self.sim_config_file}" + coreneuron.file_mode = not coreneuron_direct_mode + coreneuron.sim_config = f"{self.output_root}/{self.sim_config_file}" + if save_path: + coreneuron.save_path = save_path + if restore_path: + coreneuron.restore_path = restore_path + # Model is already written to disk by calling pc.nrncore_write() + coreneuron.skip_write_model_to_disk = True + coreneuron.model_path = f"{self.datadir}" Nd.pc.psolve(Nd.tstop) diff --git a/neurodamus/node.py b/neurodamus/node.py index 2d18fd75..681a6daa 100644 --- a/neurodamus/node.py +++ b/neurodamus/node.py @@ -282,7 +282,7 @@ def __init__(self, config_file, options=None): self._run_conf = SimConfig.run_conf self._target_manager = TargetManager(self._run_conf) self._target_spec = TargetSpec(self._run_conf.get("CircuitTarget")) - if SimConfig.use_neuron or SimConfig.skip_write_model: + if SimConfig.use_neuron or SimConfig.coreneuron_direct_mode: self._sonatareport_helper = Nd.SonataReportHelper(Nd.dt, True) self._base_circuit: CircuitConfig = SimConfig.base_circuit self._extra_circuits = SimConfig.extra_circuits @@ -772,7 +772,7 @@ def _enable_replay(self, source, target, stim_conf, tshift=.0, delay=.0, logging.info("=> Population pathway %s -> %s. Source offset: %d", src_pop_str, dst_pop_str, src_pop_offset) - if SimConfig.use_coreneuron and not SimConfig.skip_write_model: + if SimConfig.use_coreneuron and not SimConfig.coreneuron_direct_mode: self._coreneuron_replay_append(spike_manager, src_pop_offset) else: conn_manager.replay(spike_manager, source, target, delay) @@ -1092,7 +1092,7 @@ def sim_init(self, corenrn_gen=None, **sim_opts): if corenrn_gen: self._sim_corenrn_write_config() - if SimConfig.use_neuron or SimConfig.skip_write_model: + if SimConfig.use_neuron or SimConfig.coreneuron_direct_mode: self._sim_init_neuron() if ospath.isfile("debug_gids.txt"): @@ -1276,11 +1276,11 @@ def _sim_corenrn_write_config(self, corenrn_restore=False): if not corenrn_restore: CompartmentMapping(self._circuits.global_manager).register_mapping() - if not SimConfig.skip_write_model: + if not SimConfig.coreneuron_direct_mode: with self._coreneuron_ensure_all_ranks_have_gids(CoreConfig.datadir): self._pc.nrnbbcore_write(CoreConfig.datadir) MPI.barrier() # wait for all ranks to finish corenrn data generation - + CoreConfig.write_sim_config( Nd.tstop, Nd.dt, @@ -1311,10 +1311,10 @@ def run_all(self): self.sonata_spikes() if SimConfig.use_coreneuron: print_mem_usage() - if not SimConfig.skip_write_model: + if not SimConfig.coreneuron_direct_mode: self.clear_model(avoid_clearing_queues=False) self._run_coreneuron() - if SimConfig.skip_write_model: + if SimConfig.coreneuron_direct_mode: self.sonata_spikes() return timings @@ -1332,7 +1332,7 @@ def _run_coreneuron(self): CoreConfig.psolve_core( getattr(SimConfig, "save", None), getattr(SimConfig, "restore", None), - SimConfig.skip_write_model + SimConfig.coreneuron_direct_mode ) # diff --git a/tests/integration-e2e/test_coreneuron_directmode.py b/tests/integration-e2e/test_coreneuron_directmode.py index 8c376c92..0d960083 100644 --- a/tests/integration-e2e/test_coreneuron_directmode.py +++ b/tests/integration-e2e/test_coreneuron_directmode.py @@ -10,7 +10,7 @@ def test_coreneuron_no_write_model(USECASE3): nd = Neurodamus( str(USECASE3 / "simulation_sonata_coreneuron.json"), keep_build=True, - skip_write_model=True + coreneuron_direct_mode=True ) nd.run() coreneuron_data = SimConfig.coreneuron_datadir