Parallel Computing

48 views
Skip to first unread message

Guillaume Jounel

unread,
Aug 7, 2022, 8:28:10 PM8/7/22
to gonum-dev
Hello,

In Intro to Gonum, the author claims that "Gonum code can often be made to run in parallel by setting a flag".

Does this refer to GOMAXPROCS or is there anything else behind this? Also, "often" is ambiguous, do we know what operations can be made to run in parallel? Usually I would expect such parallelisation to be explicitly written with Goroutines in for-loops for operations such as matrix multiplications (as some do), but my understanding is that Gonum uses bindings to C-backed BLAS/LAPACK packages, so how can I ensure operations are running in parallel?

Thank you,
Guillaume

Dan Kortschak

unread,
Aug 8, 2022, 6:06:40 AM8/8/22
to gonu...@googlegroups.com
I don't recall exactly what was intended with that comment. I don't
think that it refers to GOMAXPROCS since that is an env var. I suspect
that it is referring to the more general idea that parallelising a code
can often be as simple as adding a small amount of logic, bearing in
mind that the article is written at least part as a comparison with
python and MATLAB where doing this is much harder.

The second question is easier; for the most part, parallelisation is
under the control of the user. There are some packages where the
functions do do work in parallel. The generalised matrix multiply is an
example of this. Routines in diff/fd, integrate/quad and optimize all
do work concurrently, given a possibility for parts to be done in
parallel.

It is not the case that Gonum always uses bindings to a C-backed
BLAS/LAPACK, although this can be done. By default all Gonum code is
pure Go/ASM. If you do choose to use the OpenBLAS implementations for
BLAS and LAPACK, then you will get that package's parallelisation.

Dan

Reply all
Reply to author
Forward
0 new messages