snake.core.parallel
#
Utilities for running parallel computations with processes and shared memory.
Module Contents#
Classes#
Properties of an array stored in shared memory. |
|
Wrapper for function to be call with parallel shared memory. |
Functions#
Run a function in parallel with shared memory. |
|
Get arrays from shared memory. |
|
Move an array to shared memory. |
Data#
API#
- class snake.core.parallel.ArrayProps[source]#
Bases:
typing.NamedTuple
Properties of an array stored in shared memory.
- dtype: numpy.typing.DTypeLike = None#
- class snake.core.parallel.SHM_Wrapper(func: collections.abc.Callable)[source]#
Wrapper for function to be call with parallel shared memory.
- Parameters:
func (Callable) β Function to be called with shared memory arrays.
Initialization
- __call__(input_props: snake.core.parallel.ArrayProps, output_props: snake.core.parallel.ArrayProps, *args: Any, **kwargs: Any) None [source]#
Run in parallel with shared memory.
- snake.core.parallel.run_parallel(func: collections.abc.Callable, input_array: numpy.typing.NDArray, output_array: numpy.typing.NDArray, n_jobs: int = -1, parallel_axis: int = 0, *args: Any, **kwargs: Any) numpy.typing.NDArray [source]#
Run a function in parallel with shared memory.
- snake.core.parallel.array_from_shm(*array_props: snake.core.parallel.ArrayProps) collections.abc.Generator[list[numpy.typing.NDArray], None, None] [source]#
Get arrays from shared memory.
- snake.core.parallel.array_to_shm(array: numpy.typing.NDArray, smm: multiprocessing.managers.SharedMemoryManager) tuple[snake.core.parallel.ArrayProps, numpy.typing.NDArray, multiprocessing.shared_memory.SharedMemory] [source]#
Move an array to shared memory.