Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does gcc, icc, or Microsoft's C/C++ compiler support or know anything about NUMA?

Tags:

linux

gcc

g++

icc

numa

If I have a multi-processor board that has cache-coherent non-uniform memory access ( NUMA ), i.e. separate "northbridges" with separate RAM for each processor, does any compiler know how to automatically spread the data across the different memory systems such that processes working on local threads are mostly retrieving their data from the RAM associated with the processor the thread is running on?

I have a setup where 1 GB is attached to processor 0, 1 GB is attached to processor 1, et c. up to 4 processors. In the coherent memory space the physical memory for the RAM on the 1st processor is addresses 0 to 1GB-1. For the second processor it is 1GB to 2GB-1, and so on.

Will any compilers, or perhaps malloc specifically, associate new memory alloc'd by a process on a specific core to the physical RAM associated with that core?

like image 814
Ross Rogers Avatar asked Jan 26 '10 19:01

Ross Rogers


People also ask

Can G ++ compile C code?

gcc is used to compile C program. g++ can compile any . c or . cpp files but they will be treated as C++ files only.

Is C ++ 20 supported?

GCC has experimental support for the latest revision of the C++ standard, which was published in 2020. C++20 features are available since GCC 8.


2 Answers

Linux kernel knows about NUMA and will try to give your process pages from memory local to the current CPU (source: U. Drepper, "What Every Programmer Should Know About Memory".)

like image 155
Nikolai Fetissov Avatar answered Sep 28 '22 05:09

Nikolai Fetissov


NUMA-aware memory allocation is not done at compile time. Making assumptions like this would be bad for portability.

On Linux, this is a kernel function, though you can control this at runtime with numactl or set_mempolicy or with libnuma.

like image 34
Eric Seppanen Avatar answered Sep 28 '22 05:09

Eric Seppanen