parallel-processingcommon-lisp

Is there a way to execute forms in parallel in Common Lisp? Something like a parallel PROGN?


I have a sequence of array assignments:

...
(incf (aref res 1) formula1)
(incf (aref res 2) formula2)
...

The formulai is some complicated auto-generated code, and it's very different for each i. This code is generated at compile time - it's an algebraic expression, not a macro or function.

What I want is to wrap these statements in something like a "parallel progn", so that the assignments are partitioned onto different worker threads. The order of execution doesn't matter since each index is assigned exactly once.

I can't see how to fit this problem into lparallel's abstractions, but maybe I'm missing something. It seems that neither pmap, plet, nor futures are a good fit for this problem.


Solution

  • Turns out there is such a package available. Investigating the ones listed by (ql:system-apropos "parallel") led me to simple-parallel-tasks, which includes a pprogn form, documented as

    Evaluate forms in parallel and return the result of the evaluation of the last form.

    (There's also a pprog1 which returns the first form).