diff --git a/hnn_core/parallel_backends.py b/hnn_core/parallel_backends.py index b022e59652..d216fba5e6 100644 --- a/hnn_core/parallel_backends.py +++ b/hnn_core/parallel_backends.py @@ -4,6 +4,9 @@ # Mainak Jas import os +import platform +import os.path as op + import sys import re import multiprocessing @@ -633,24 +636,23 @@ def __init__(self, n_procs=None, mpi_cmd='mpiexec'): self.mpi_cmd = mpi_cmd - if hyperthreading: - self.mpi_cmd += ' --use-hwthread-cpus' - - if oversubscribe: - self.mpi_cmd += ' --oversubscribe' + if platform.system() == 'Windows': + self.mpi_cmd += f' /np {self.n_procs}' + use_posix = True + else: + if hyperthreading: + self.mpi_cmd += ' --use-hwthread-cpus' + if oversubscribe: + self.mpi_cmd += ' --oversubscribe' - self.mpi_cmd += ' -np ' + str(self.n_procs) + self.mpi_cmd += f' -np {self.n_procs}' + use_posix = False - self.mpi_cmd += ' nrniv -python -mpi -nobanner ' + \ - sys.executable + ' ' + \ - os.path.join(os.path.dirname(sys.modules[__name__].__file__), - 'mpi_child.py') + mpi_child_fname = op.join(op.dirname(__file__), 'mpi_child.py') + self.mpi_cmd += (' nrniv -python -mpi -nobanner' + f' python {mpi_child_fname}') # Split the command into shell arguments for passing to Popen - if 'win' in sys.platform: - use_posix = True - else: - use_posix = False self.mpi_cmd = shlex.split(self.mpi_cmd, posix=use_posix) def __enter__(self):