Parallelization control¶
This module defines the singleton class Parallelism
to govern the
parallelization of computations in some specific topics. It allows the user to
set the number of processes to be used for parallelization.
Some examples of use are provided in the documentation of
sage.tensor.modules.comp.Components.contract()
.
AUTHORS:
- Marco Mancini, Eric Gourgoulhon, Michal Bejger (2015): initial version
-
sage.parallel.parallelism.
Parallelism
¶ Singleton class for managing the number of processes used in parallel computations involved in various fields.
EXAMPLES:
The number of processes is initialized to 1 (no parallelization) for each field (only tensor computations are implemented at the moment):
sage: Parallelism() Number of processes for parallelization: - tensor computations: 1
Using 4 processes to parallelize tensor computations:
sage: Parallelism().set('tensor', nproc=4) sage: Parallelism() Number of processes for parallelization: - tensor computations: 4 sage: Parallelism().get('tensor') 4
Using 6 processes to parallelize all types of computations:
sage: Parallelism().set(nproc=6) sage: Parallelism() Number of processes for parallelization: - tensor computations: 6
Using all the cores available on the computer to parallelize tensor computations:
sage: Parallelism().set('tensor') sage: Parallelism() # random (depends on the computer) Number of processes for parallelization: - tensor computations: 8
Using all the cores available on the computer to parallelize all types of computations:
sage: Parallelism().set() sage: Parallelism() # random (depends on the computer) Number of processes for parallelization: - tensor computations: 8
Switching off all parallelizations:
sage: Parallelism().set(nproc=1)