While by default 'malloc' allocates memory on the same node as the calling process/thread ('numactl --show' shows 'preferred node: current', Linux kernel memory policy MPOL_DEFAULT), this can be changed. For instance, when running the program as follows, 'malloc' now prefers to allocate on the second node: numactl --preferred=1 ./myproc Thus, it seems to be sensible to provide a means to ensure the 'nearest' allocation. The MPOL_LOCAL policy does so, as provided by libnuma's numa_alloc_local. (Which is just wrapper around the syscalls mmap and mbind.) As with (lib)memkind, there is a run-time dlopen check for (lib)numa - and no numa*.h is required when bulding GCC. The patch assumes that yesterday's patch 'libgomp: Update OpenMP memory allocation doc, fix omp_high_bw_mem_space' https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624030.html has already been applied. (Which is mostly a .texi only patch, except for one 'return' -> 'break' change.) This patch has been bootstrapped and manually tested on x86-64. It also passed "make check". Comments, remarks, thoughts? [I really dislike committing patches without any feedback from others, but I still intent to do so, if no one comments. This applies to this patch and the other one.] Tobias PS: I have attached a testcase, but as it needs -lnuma, I do not intent to commit it. An alternative which could be to do the same as we do in the patch itself; namely, to use the dlopen handle to obtain the two libnuma library calls. - I am unsure whether I should do so or whether I should just leave out the testcase. Thoughts? ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955