3
votes

In Haskell, I'm able to enable parallel evaluation of lists using:

map expensiveFunction list `using` parList rdeepseq

Adding only the `using` parList rdeepseq enables the pure parallel computation and runs 4 times faster on my quad-core processor.

Is there a similar capability using SBCL?

1

1 Answers

8
votes

Common Lisp doesn't have a standard facility to do this, but there is a library designed to do exactly this that is well supported on most CL implementations: Lparallel

With lparallel you can do the following:

(let ((number-sets '((1 2 3) (4 5 6) (10 11 12 13 14) (100 200 300))))
  (lparallel:pmap 'list (lambda (v) (apply #'+ v)) number-sets))

This will perform the individual summations in parallel, but otherwise return the same result as if one had used plain map.