Skip to content

Commit

Permalink
FIX for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmainak committed Jan 20, 2023
1 parent e59cfbd commit dfd428a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions hnn_core/parallel_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# Mainak Jas <[email protected]>

import os
import platform
import os.path as op

import sys
import re
import multiprocessing
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit dfd428a

Please sign in to comment.