Racket 7 multi core support

295 views
Skip to first unread message

Piyush Katariya

unread,
May 21, 2018, 10:31:24 AM5/21/18
to Racket Users
Will Racket 7 support utilizing multi-core CPUs in one process instance ?

George Neuner

unread,
May 21, 2018, 11:31:45 AM5/21/18
to Piyush Katariya, racket users

On 5/21/2018 10:31 AM, Piyush Katariya wrote:
> Will Racket 7 support utilizing multi-core CPUs in one process instance ?

Sort of.  The Racket VM implements userspace threads on a single core. 
However a single OS process can host multiple instances of the VM which
can communicate with each other by message passing.

See "places":
https://docs.racket-lang.org/guide/parallelism.html?q=places#%28part._effective-places%29
    https://docs.racket-lang.org/reference/places.html?q=places
https://docs.racket-lang.org/guide/parallelism.html?q=places#%28part._distributed-places%29
https://docs.racket-lang.org/distributed-places/index.html?q=places

George

Sam Tobin-Hochstadt

unread,
May 21, 2018, 11:38:28 AM5/21/18
to George Neuner, Piyush Katariya, racket users
Additionally, the `racket/future` library provides (somewhat limited)
support for shared memory parallelism.

Sam
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Piyush Katariya

unread,
May 21, 2018, 12:00:12 PM5/21/18
to Racket Users
what if i dont wish to juggle between Threads and Places to leverage all CPU cores ?

Just use Thread abstraction.

Chez Scheme page says it can possible run on multi core, so I believe it must be possible for Racket 7 to do so ???

George Neuner

unread,
May 21, 2018, 11:31:06 PM5/21/18
to Piyush Katariya, racket users
Not necessarily.   Chez uses kernel threads on most platforms, but it's threads don't have the same semantics as Racket's threads.  So far, I have heard nothing definitive about whether Chez-Racket will try to use Chez threads directly, or continue with the Racket user-space thread model.


You also should note the caution in Chez's documentation:
One restriction should be observed when one of multiple threads creates or loads compiled code, however, which is that only that thread or subsequently created children, or children of subsequently created children, etc., should run the code. This is because multiple-processor systems upon which threaded code may run might not guarantee that the data and instruction caches are synchronized across processors.
I'm not familiar with the internals of Chez threads, but this wording makes me wonder.  It's possible that the initial program thread might be started on any core, but other threads it creates are restricted to running on the same core as the parent  [most OS allow doing this].  Forking another process may be the only way to (guarantee to) use multiple cores.

Also note that Chez's thread API provides no way to change thread affinity.

George

Sam Tobin-Hochstadt

unread,
May 21, 2018, 11:42:45 PM5/21/18
to George Neuner, Piyush Katariya, racket users
First, the default build of Racket 7 (according to the plan Matthew
posted to the racket-dev list on Feb 20) will have the new in-Racket
expander, but the default will not be to use Chez Scheme's runtime.

Second, the "cs" variant of Racket will map Racket futures onto Chez
pthreads, and many more operations are future-safe in that variant.
However, Racket threads still do not run in parallel in the "cs"
variant -- you need to use futures or places to make use of more than
one hardware core from Racket.

Sam

George Neuner

unread,
May 21, 2018, 11:50:24 PM5/21/18
to Sam Tobin-Hochstadt, Piyush Katariya, racket users
Hi Sam,

On 5/21/2018 11:42 PM, Sam Tobin-Hochstadt wrote:
> First, the default build of Racket 7 (according to the plan Matthew
> posted to the racket-dev list on Feb 20) will have the new in-Racket
> expander, but the default will not be to use Chez Scheme's runtime.
>
> Second, the "cs" variant of Racket will map Racket futures onto Chez
> pthreads, and many more operations are future-safe in that variant.
> However, Racket threads still do not run in parallel in the "cs"
> variant -- you need to use futures or places to make use of more than
> one hardware core from Racket.
>
> Sam

Thanks for the clarification.  I'm not on the developer list - I've just
read the blog entries.  I have pretty much suspected all along that
Racket would not rush to adopt kernel threads (other than internally to
implement places).

George

Piyush Katariya

unread,
May 22, 2018, 2:39:05 AM5/22/18
to Racket Users
Thanks Sam.

When you say Racket 7's "cs" variant can use Future and Places to leverage multiple CPU cores, is it one OS process or multiple ? 

Sam Tobin-Hochstadt

unread,
May 22, 2018, 6:54:14 AM5/22/18
to Piyush Katariya, racket users list
Just like with current Racket, both futures and places run in a single process.

Sam

On Tue, May 22, 2018, 2:39 AM Piyush Katariya <corporat...@gmail.com> wrote:
Thanks Sam.

When you say Racket 7's "cs" variant can use Future and Places to leverage multiple CPU cores, is it one OS process or multiple ? 

--
Reply all
Reply to author
Forward
0 new messages