This globally shared gang is auto-initialised at startup and shared by all Repa computations.
In a data parallel setting, it does not help to have multiple gangs running at the same time. This is because a single data parallel computation should already be able to keep all threads busy. If we had multiple gangs running at the same time, then the system as a whole would run slower as the gangs would contend for cache and thrash the scheduler.
If, due to laziness or otherwise, you try to start multiple parallel Repa computations at the same time, then you will get the following warning on stderr at runtime:
Data.Array.Repa: Performing nested parallel computation sequentially. You've probably called the
copyfunction while another instance was already running. This can happen if the second version was suspended due to lazy evaluation. Use
deepSeqArrayto ensure that each array is fully evaluated before you
computethe next one.
Gang is a group of threads that execute arbitrary work requests.