Magma Kernel Distributed Parallelism
Introduction
In this section we discuss the way in which POSIX threads and distributed computation are used.
POSIX Threads
Recall that a process is a program that has been read into memory together with the various resources that it needs in order to be executed. This includes such things as registers, a stack, and a program counter. A thread is an independent stream of instructions taken from the compiled program which can be run by the operating system.
In the context of achieving efficient parallelism, threads have some advantages over processes. For example, all threads belonging to a particular process share the memory of their parent process and so can communicate with each other much faster than is the case with processes, each of which has its own private memory. Also context switching between threads is less expensive that is the case with processes.
For generating threads on machines running the UNIX operating system a standard programming interface has been defined by IEEE. Threads produced using this standard are known as POSIX threads or Pthreads.
When exploiting multiple cores of a compute node, Pthreads is generally more efficient than running the same number of processes. Consequently, we have used Pthreads to parallelise the enumeration of certain types of vectors in a lattice and the enumeration of words in a linear code. This parallelisation is restricted to the cores of a single compute node. To exploit multiple compute nodes distributed computation is used. Pthreads are used independently on each of the nodes while the tasks and inter-node communication is handled by the distributed computation machinery.
- SetNthreads(n): RngIntElt
Set the number of threads to be used in multi-threaded algorithms to be \(n\), if POSIX threads are enabled in this version of Magma.