rparallel : Racket in parallel
License: LGPL-3.0-or-later
(require rparallel) | package: rparallel |
1 Introduction
This package provides high-level parallel forms.
The implementation relies on Racket futures. Due to coordination overhead the library is only useful to parallelize computationally instensive code. For instance, consider the following:
(parallel-map sqrt (range 1000000))
Here the parallel form creates several futures whose overhead vastly prevails over the relatively cheap sqrt operation. This leads to a much slower computation than the respective serial map call. To take advantage from multiple processor, larger chunks of computation needs to be distributed over fewer futures, for instance:
(parallel-let ((x (map sqrt (range 1000))) (y (map sqrt (range 1000) (range 1000000)))) (append x y))
See Parallelism with Futures for further subtleties related to the use of futures.
2 Interface
syntax
(parallel-values v ...)
procedure
(parallel-for-each proc lst ...+) → void?
proc : procedure? lst : list?
syntax
(parallel-let ([id val-expr] ...) body ...+)
procedure
(parallel-map proc lst ...+) → list?
proc : procedure? lst : list?
See pmap : Parallel map for alternative parallel map procedures that leverage both Racket futures and places forms of parallelism.