Skip to main content

Module parallel

Module parallel 

Source
Expand description

Parallel batch processing utilities.

Provides Python-facing functions that run Rayon-based parallel computations while releasing the Python GIL so that Python threads are not blocked.

§Example (Python)

import scirs2

# Compute means of multiple float arrays in parallel.
arrays = [[1.0, 2.0, 3.0], [4.0, 5.0], [6.0, 7.0, 8.0, 9.0]]
means = scirs2.parallel_map_mean(arrays)
# means == [2.0, 4.5, 7.5]

# Parallel batch matrix-vector multiply.
mats = [[1.0, 0.0, 0.0, 1.0], [2.0, 0.0, 0.0, 2.0]]
vecs = [[3.0, 4.0], [3.0, 4.0]]
results = scirs2.parallel_batch_matvec(mats, vecs, 2, 2)
# results == [[3.0, 4.0], [6.0, 8.0]]

Functions§

parallel_batch_matvec
Perform a batch of matrix-vector multiplications in parallel.
parallel_map_mean
Compute the arithmetic mean of each sub-array in parallel.
register_parallel_module
Register parallel batch-processing functions into a PyO3 module.