parallel¶
Multi-threaded functions for parameter sweeps
Classes
|
Configuration variables for |
|
Default status reporter |
|
Produces |
|
Holds functions which hook into |
|
Keep track of progress while running |
Functions
|
Multi-threaded for loop |
|
Simple single-threaded for loop |
|
Do a multi-threaded n-dimensional parameter sweep |
|
Multi-threaded loop feed by the |
|
A decorator which creates factory functions for |
|
Do a multi-threaded parameter sweep |
- ndsweep(factory, plot=None, labels=None, tags=None, silent=False)¶
Do a multi-threaded n-dimensional parameter sweep
- Parameters:
- factory
Factory Factory function created with the
parallelize()decorator.- plotcallable
Plotting functions which takes a
NDSweepresult as its only argument.- labels, tagsdict
Forwarded to
NDSweepobject.- silentbool
Don’t print status messages.
- factory
- Returns:
- parallel_for(factory, make_result=None)¶
Multi-threaded loop feed by the
factoryfunction- Parameters:
- factory
Factory Factory function created with the
parallelize()decorator.- make_resultcallable, optional
Creates the final result from raw data. This result is also the final return value of
parallel_for().
- factory
- Returns:
- array_like
A result for each loop iteration.
Examples
@parallelize(x=np.linspace(0, 1, 10)) def factory(x): pb.Model(...) # depends on `x` kpm = pb.kpm(model) return kpm.deferred_ldos(...) # may also depend on `x` results = parallel_for(factory)
- parallelize(num_threads=num_cores, queue_size=num_cores, **kwargs)¶
A decorator which creates factory functions for
parallel_for()The decorated function must return a
Deferredcompute kernel.- Parameters:
- num_threadsint
Number of threads that will run in parallel. Defaults to the number of cores in the current machine.
- queue_sizeint
Number of
Deferredjobs to be queued up for consumption by the worker threads. The maximum number of jobs that will be kept in memory at any one time will bequeue_size+num_threads.- **kwargs
Variables which will be iterated over in
parallel_for()and passed to the decorated function. See example.
Examples
@parallelize(a=np.linspace(0, 1, 10), b=np.linspace(-2, 2, 10)) def factory(a, b): pb.Model(...) # depends on `a` and `b` kpm = pb.kpm(model) return kpm.deferred_ldos(...) # may also depend on `a` and `b` results = parallel_for(factory)
- sweep(factory, plot=<function <lambda>>, labels=None, tags=None, silent=False)¶
Do a multi-threaded parameter sweep
- Parameters:
- factory
Factory Factory function created with the
parallelize()decorator.- plotcallable
Plotting functions which takes a
Sweepresult as its only argument.- labels, tagsdict
Forwarded to
Sweepobject.- silentbool
Don’t print status messages.
- factory
- Returns: