Question

Is there a R5RS-or-higher Scheme implementation that does parallelization? For example, if I say to do:

(map (lambda (x) 
        (pure-functional-stuff x))
     '(1 3 5 7 11 13))

it will process 1, 3, 5, and 7 simultaneously if the machine can do it? That's supposed to be one of the big advantages of functional programming, but I can't find a maintained, up-to-date Scheme that does it. I'd be fine with one that wouldn't parallelize it unless I assert that the function doesn't have side-effects.

Was it helpful?

Solution

I'm a developer of Schemik and I think that it is the Scheme you are looking for. The project is still developed and maintained. Early this year, I released a version which improves compatibility with R5RS. Unfortunately, Schemik is a research project focused on the process of expression evaluation, thus, its standard library is still relatively small. Is there any particular functionality you miss in Schemik?

OTHER TIPS

Racket has futures that do something very similar to this, and will also have a second approach for parallelism in the near future (which will be called "places").

It turns out that you don't really want the compiler to try to parallelize everything because then you end up wasting time coordinating efforts even when doing something simple like,

(map add1 '(1 2 3))

that would be faster to just do on one thread. However, many functional languages these days make it easy for you to make this parallel when "add1" is actually "really-long-computation". Each language has its own approach, but I'd recommend taking advantage of multiple cores in Racket using futures.

While the compiler deciding things automatically for you is nice, it's not a bad tradeoff to change a "map" to a "pmap" where you think it might help rather than deal with slowdowns in other places because the compiler was too ambitious.

Something as basic as

(define (pmap f xs)
  (map touch (map (λ(x) (future (λ() (f x)))) xs)))

can get you pretty far when used judiciously, but you should experiment with chunking up your data to feed to parallel threads.

I just found Schemik

http://schemik.sourceforge.net/

which seems to be maintained to at least 2009, though I don't know if it's R5RS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top