How to do multi core programming in F#

1.7k views Asked by At

How do I program I F# that utilize multi cores CPU? Say instead of multithread or async? In python language, they have multiprocessing module but what is the equivalent for F#?

3

There are 3 answers

0
Anton Schwaighofer On

Adding a couple of pointers to what has already been mentioned in the comments:

0
Maxim Kitsenko On

There are several approaches for parallelization in F#

  1. F# uses CLR and CTS so it is possible to use usual .NET constructions like you do it in C#. For example: Thread, BackgroundWorker, AutoResetEvent etc. Details
  2. F# has a built-in construct called "asynchronous workflows" Details
  3. There are some frameworks which allow you to choose appropriate parallelisation model. For example Hopac
0
Grzegorz SÅ‚awecki On

If You're intereseted in GPU programming (which is strongly related to multicore, or even manycore) in F#, take a look into Alea GPU which allows You to easily use F# for technologies like CUDA.

For list other GPU programming options in F#, look here.

You can also try to employ the actor model. Akka.NET has some nice F# API.

There's also an incoming book that as a whole can be considered an answer to the question (didn't read it yet).