From dfd428ad9d429827fb7373250d22e3c099162b90 Mon Sep 17 00:00:00 2001 From: Mainak Jas Date: Fri, 20 Jan 2023 01:06:02 -0500 Subject: [PATCH] FIX for windows --- hnn_core/parallel_backends.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) 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):