.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto/plot_simulate_mpi_backend.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_howto_plot_simulate_mpi_backend.py: ======================================= 04. Use MPI backend for parallelization ======================================= This example demonstrates how to use the MPI backend for simulating dipoles using HNN-core. The MPI backend allows running the simulation in parallel across neurons in the network even with a single trial. For this, you will need the :ref:`MPI related software ` installed. Note that if you want to simulate in parallel across trials, the Joblib backend allows this without the need to install and configure MPI. .. GENERATED FROM PYTHON SOURCE LINES 15-19 .. code-block:: default # Authors: Mainak Jas # Blake Caldwell .. GENERATED FROM PYTHON SOURCE LINES 20-21 Let us import hnn_core .. GENERATED FROM PYTHON SOURCE LINES 21-26 .. code-block:: default import os.path as op import hnn_core from hnn_core import simulate_dipole, jones_2009_model .. GENERATED FROM PYTHON SOURCE LINES 27-34 Following :ref:`the alpha example `, we add a ~10 Hz "bursty" drive starting at 50 ms and continuing to the end of the simulation. Each burst consists of a pair (2) of spikes, spaced 10 ms apart. The occurrence of each burst is jittered by a random, normally distributed amount (20 ms standard deviation). We repeat the burst train 10 times, each time with unique randomization. .. GENERATED FROM PYTHON SOURCE LINES 34-42 .. code-block:: default net = jones_2009_model() weights_ampa = {'L2_pyramidal': 5.4e-5, 'L5_pyramidal': 5.4e-5} net.add_bursty_drive( 'bursty', tstart=50., burst_rate=10, burst_std=20., numspikes=2, spike_isi=10, n_drive_cells=10, location='distal', weights_ampa=weights_ampa, event_seed=278) .. GENERATED FROM PYTHON SOURCE LINES 43-48 Finally, to simulate we use the :class:`~hnn_core.parallel_backends.MPIBackend` class. This will start the simulation across the number of processors (cores) specified by ``n_procs`` using MPI. The ``'mpiexec'`` launcher is used from ``openmpi``, which must be installed on the system .. GENERATED FROM PYTHON SOURCE LINES 48-55 .. code-block:: default from hnn_core import MPIBackend with MPIBackend(n_procs=2, mpi_cmd='mpiexec'): dpls = simulate_dipole(net, tstop=310., n_trials=1) trial_idx = 0 dpls[trial_idx].plot() .. image-sg:: /auto_examples/howto/images/sphx_glr_plot_simulate_mpi_backend_001.png :alt: Aggregate (L2 + L5) :srcset: /auto_examples/howto/images/sphx_glr_plot_simulate_mpi_backend_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none MPI will run 1 trial(s) sequentially by distributing network neurons over 2 processes. numprocs=2 Loading custom mechanism files from /home/ryan/hnn-core/hnn_core/mod/x86_64/libnrnmech.so Building the NEURON model Loading custom mechanism files from /home/ryan/hnn-core/hnn_core/mod/x86_64/libnrnmech.so [Done] Trial 1: 0.03 ms... Trial 1: 10.0 ms... Trial 1: 20.0 ms... Trial 1: 30.0 ms... Trial 1: 40.0 ms... Trial 1: 50.0 ms... Trial 1: 60.0 ms... Trial 1: 70.0 ms... Trial 1: 80.0 ms... Trial 1: 90.0 ms... Trial 1: 100.0 ms... Trial 1: 110.0 ms... Trial 1: 120.0 ms... Trial 1: 130.0 ms... Trial 1: 140.0 ms... Trial 1: 150.0 ms... Trial 1: 160.0 ms... Trial 1: 170.0 ms... Trial 1: 180.0 ms... Trial 1: 190.0 ms... Trial 1: 200.0 ms... Trial 1: 210.0 ms... Trial 1: 220.0 ms... Trial 1: 230.0 ms... Trial 1: 240.0 ms... Trial 1: 250.0 ms... Trial 1: 260.0 ms... Trial 1: 270.0 ms... Trial 1: 280.0 ms... Trial 1: 290.0 ms... Trial 1: 300.0 ms...
.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 45.367 seconds) .. _sphx_glr_download_auto_examples_howto_plot_simulate_mpi_backend.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/jonescompneurolab/hnn-core/gh-pages?filepath=v0.3/notebooks/auto_examples/howto/plot_simulate_mpi_backend.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_simulate_mpi_backend.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_simulate_mpi_backend.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_