From 21f0f7557846f34e3b3d9611e8e640df5a08a29e Mon Sep 17 00:00:00 2001 From: Camilo Diaz Date: Mon, 17 Jun 2024 10:38:20 -0400 Subject: [PATCH] added mpi_test.py --- .github/workflows/linux_unit_test.yml | 26 +++++++++++++++++++------- hnn_core/mpi_test.py | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 hnn_core/mpi_test.py diff --git a/.github/workflows/linux_unit_test.yml b/.github/workflows/linux_unit_test.yml index b65c104f7..18b2bd275 100644 --- a/.github/workflows/linux_unit_test.yml +++ b/.github/workflows/linux_unit_test.yml @@ -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 \ No newline at end of file + # - name: Upload coverage to Codecov + # shell: bash -el {0} + # run: | + # bash <(curl -s https://codecov.io/bash) -f ./coverage.xml \ No newline at end of file diff --git a/hnn_core/mpi_test.py b/hnn_core/mpi_test.py new file mode 100644 index 000000000..203290732 --- /dev/null +++ b/hnn_core/mpi_test.py @@ -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") \ No newline at end of file