- Infos im HLRS Wiki sind nicht rechtsverbindlich und ohne Gewähr -
NEC Cluster NUMA Tuning
The Nehalem architecture is the first intel platform following a NUMA (=non uniform memory access) design pattern. The memory controller is located within the CPU chip, and therefor, a system with two CPU sockets as the HLRS/NEC installation has two distinct memory controllers, each responsible for 1/2 of the memory.
To achieve maximum performance, this has to be taken into consideration, as data is best accessed by processes nearby the data - or in other words, for best performance, the data has to be distributed over the two memory controllers, or NUMA nodes, in a pattern that matches the accesses from the processes or thread.
The linux kernel us NUMA aware, and does it's best to place data at a good (=near) memory location. This is achieved by following a first touch policy. A memory page is allocated - if possible - nearby the process touching it first.
Important: First touch, not allocate!
MPI programs with one process per core tend to do things right, data is accessed from the process allocating and first touching the data. Only extreme inbalance, like one rank using so much memory on one NUMA node that other ranks memory does not fit into the local node. In such a case, performance could suffer as memory accesses have to be done to remote memory on the further node.
For OpenMP programs, care has to be taken that the nodes are used in a balanced way, and that processes touch the memory multithreaded, and in the same way as the data is accessed later, if possible.
Here is simple example to demonstrate the impact of wrong initialization of data.
If this code is compiled using
and run using
one gets a runtime of about 0.443941 seconds. (we use 8 threads and use intel compilers openmp runtime option to pin threads to cores for most consistent performance and NUMA placement)
If compiled with
the runtime is 0.230432 seconds, which is x1.9 better than the initial result.
The initialization of the data within a parallel loop makes sure the data is for each thread on the local node, and therefor nearly doubles the performance. As the data is small enough to fit into one node, if no care is taken, all data resides behind one of the two memory controllers, and one half of the available memory bandwidth is wasted.
If a hybrid MPI-OpenMP approach is used, it can make perfect sense to run one MPI process per numa node, so on the Nehalem cluster, 2 per node, and use 4 threads per MPI process.
See the MPI section for a wrapper script allowing numa placement of the MPI processes and thread pinning of the OpenMP threads for best results.