.. _parallel:

PARALLEL
###########

An optionally section to run |popy| in parallel to increase the speed of the program by separating tasks amongst the different nodes of a computer.

You can add the |parallel| section to the following scripts:-

* :ref:`tut_script`
* :ref:`gen_script`
* :ref:`fit_script`
* :ref:`sim_script`
* :ref:`comp_script`
* :ref:`mtut_script`
* :ref:`mgen_script`
* :ref:`mfit_script`
* :ref:`msim_script`
* :ref:`mcomp_script`
* :ref:`grph_script`
* :ref:`vpc_script`

|ie| Any script that does a significant amount of processing over all individuals in the population.

If you leave out the parallel section then the script will be executed in serial, |ie| using one processor.

.. _example_parallel:

Example PARALLEL section
=========================

You can make your |popy| script use parallel processing by adding the following:-

.. code-block:: pyml
    
    PARALLEL:
        MPI_WORKERS:
            n_workers: 4
                   
This section invokes the 'MPI_WORKERS' parallel method, that uses :term:`mpi` to process individuals in parallel where possible.

The 'n_workers' parameter requests 4 separate processors. You can also use:-

.. code-block:: pyml

    PARALLEL:
        MPI_WORKERS:
            n_workers: auto
            
To utilise all processors on a given machine.

Note if you leave out the the 'PARALLEL' section from your script, this is equivalent to using the following:-

.. code-block:: pyml

    PARALLEL: {SINGLE: {}}
    
That requests using a single processor.
 
                   


