cpu_unordered_parallel#
- class brainpy.running.cpu_unordered_parallel(func, arguments, num_process=None, num_task=None, **tqdm_kwargs)[source]#
Performs a parallel unordered map with a progress bar.
Examples
>>> import brainpy as bp >>> import brainpy.math as bm >>> import numpy as np >>> >>> def simulate(inp): >>> inp = bm.as_jax(inp) >>> hh = bp.neurons.HH(1) >>> runner = bp.DSRunner(hh, inputs=['input', inp], >>> monitors=['V', 'spike'], >>> progress_bar=False) >>> runner.run(100) >>> bm.clear_buffer_memory() # clear all cached data and functions >>> return runner.mon.spike.sum() >>> >>> if __name__ == '__main__': # This is important! >>> results = bp.running.cpu_unordered_parallel(simulate, [np.arange(1, 10, 100)], num_process=10) >>> print(results)
- Parameters:
func (callable, function) – The function to apply to each element of the given Iterables.
arguments (sequence of Iterable, dict) – One or more Iterables containing the data to be mapped.
num_process (int, float) – Number of threads used for parallel running. If int, it is the number of threads to be used; if float, it is the fraction of total threads to be used for running.
num_task (int) – The total number of tasks in this parallel running.
tqdm_kwargs (Any) – The setting for the progress bar.
- Returns:
results – A list which will apply the function to each element of the given tasks.
- Return type: