Is there a Scheme implementation that parallelizes?
Asked Answered
C

4

13

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.

Confluence answered 18/7, 2010 at 21:35 Comment(1)
Automatic parallelization is still rarely seen. If some FP enthusiast says FP language programs are 'better to parallelize', then he/she probably means by 'you', the programmer.Punctilio
Q
5

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?

Quincey answered 20/7, 2010 at 14:3 Comment(2)
I'm digging into it now. I don't know for sure yet, but it looks promising.Confluence
It does what I need for right now --- thanks! I've been wanting to try something that works this way.Confluence
F
3

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").

Furry answered 18/7, 2010 at 22:46 Comment(0)
T
3

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.

Twobit answered 19/7, 2010 at 23:59 Comment(0)
P
2

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.

Packet answered 18/7, 2010 at 22:5 Comment(2)
It confuses me that it claims to be a "dialect of Scheme and Common Lisp". Do they mean, "a dialect of Lisp"?Confluence
It does approach R5RS, though I had to dig through commit comments to find that out. Seriously underdocumented, as a whole, and it has a bus factor of 1, but it has potential.Confluence

© 2022 - 2024 — McMap. All rights reserved.