Skip to content

Commit

Permalink
added mpi_test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilo9999 committed Jun 17, 2024
1 parent be91556 commit 21f0f75
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
26 changes: 19 additions & 7 deletions .github/workflows/linux_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,30 @@ jobs:
shell: bash -el {0}
run: |
python -m pip install --verbose '.[opt, parallel, test, gui]'
- name: Lint with flake8
- name: Run MPI application
shell: bash -el {0}
run: |
mpiexec -np 2 python ./hnn_core/mpi_test.py
- name: Verify NEURON installation
shell: bash -el {0}
run: |
nrniv -python -nobanner -mpi python "from neuron import h; print(h)"
- name: Run MPI application with NEURON
shell: bash -el {0}
run: |
flake8 --count hnn_core
mpiexec -np 2 -verbose nrniv -python -mpi -nobanner python ./hnn_core/mpi_test.py
# - name: Lint with flake8
# shell: bash -el {0}
# run: |
# flake8 --count hnn_core

- name: Test with pytest
shell: bash -el {0}
run: |
python -m pytest ./hnn_core/tests/test_parallel_backends.py --cov=hnn_core --cov-report=xml
- name: Upload coverage to Codecov
shell: bash -el {0}
run: |
bash <(curl -s https://codecov.io/bash) -f ./coverage.xml
# - name: Upload coverage to Codecov
# shell: bash -el {0}
# run: |
# bash <(curl -s https://codecov.io/bash) -f ./coverage.xml
27 changes: 27 additions & 0 deletions hnn_core/mpi_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from mpi4py import MPI
import logging
from neuron import h
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()

logger.info(f"Process {rank} out of {size} processors")
# Initialize NEURON with MPI support
h('''
objref pc
pc = new ParallelContext()
''')

# Check if NEURON MPI is enabled
is_mpi_enabled = int(h.pc.nhost() > 1)

if is_mpi_enabled:
logger.info(f"NEURON MPI is enabled. Running on {int(h.pc.nhost())} processes")
else:
logger.info("NEURON MPI is not enabled.")

if rank == 0:
print("NEURON MPI test completed")

0 comments on commit 21f0f75

Please sign in to comment.