dorado.parallel_routing

Parallel functionality using the native Python multiprocessing library.

Parallel functionality using multiprocessing (included with Python). For local parallelization using CPU cores.

Project Homepage: https://github.com/passaH2O/dorado

dorado.parallel_routing.combine_result(par_result)[source]

Combine results from each core.

Take the parallel resulting list and combine the entries so that a single dictionary with the beginning/end indices and travel times for all particles is returned as opposed to a list with one dictionary per parallel process

Inputs :

par_resultlist

List of length(num_cores) with a dictionary of the beg/end indices and travel times for each particle computed by that process/core

Outputs :

single_resultlist

Nested list that matches ‘all_walk_data’

class dorado.parallel_routing.parallel_obj[source]

Empty class to hold parallel parameters.

This is an internal class used by parallel_routing that never needs to be defined outside of that function.

__init__()[source]

Initialize attributes.

__weakref__

list of weak references to the object (if defined)

dorado.parallel_routing.parallel_routing(particles, num_iter, Np_tracer, seed_xloc, seed_yloc, num_cores)[source]

Do the parallel routing of particles.

Function to do parallel routing of particles. Does this by duplicating the call to Particle.run_iteration() across different processes.

Inputs :

particledorado.particle_track.Particles

An initialized particle_track.Particles object with some generated particles.

num_iterint

Number of iterations to route particles for

Np_tracerint

Number of particles to generate.

seed_xloclist

List of x-coordinates over which to initially distribute the particles.

seed_yloclist

List of y-coordinates over which to initially distribute the particles.

num_coresint

Number of processors/cores to use for parallel part

Outputs :

par_resultlist

List of length(num_cores) with a dictionary of the beg/end indices and travel times for each particle computed by that process/core

dorado.parallel_routing.run_iter(pobj)[source]

Wrapper run script for the particle iterations.

This is an internal function that should not be called directly. Rather it is wrapped by the parallel_routing function and mapped to the CPU cores to allow for particle routing in parallel. Uses a small parallel_obj class to hold a bunch of attributes and do the particle generation and routing.

Inputs :

pobjparallel_obj

Special parallel object.

Outputs :

all_walk_datalist

Nested list of all x and y locations and travel times, with details same as input previous_walk_data