Now committed as r14-2462-g450b05ce54d3f0. Changes to the patch in previous email: * I fixed some issues found on the way, * The wording in the .texi has been improved/expanded, and * I included two testcases to exercise the two libraries (or the default allocator when it is not available at runtime). Given that the default allocation already works fine (nearest) and the normal "malloc" is more economic in terms of memory handling (not multiples of page size or requesting a fixed pool size), I was wondering whether this patch is really needed. But at the end: default can be changed (cf. below) and given the user the choice makes sense. The manual states what GCC does which should help to make a conscious choice. * * * I did experiment with the testcase attached to previous email plus using dlopen to obtain the functions from libnuma if available. It was also using: /* { dg-do run { target { dlopen } } } */ /* { dg-additional-options "-ldl" } */ However, the Linux kernel too often placed the allocated memory on the "wrong" node to be usable as a testcase. I did get be 0 to 15 misplaced allocations, depending on the run. Hence, there is no such testcase. Using numactrl --preferred=1 I could force the normal allocation to (mostly) use node 1 for allocations such that the difference between partiton = default/environment vs. partition = nearest was clearly visible. Hence it does work. Otherwise, the same applies as I wrote the yesterday: On 11.07.23 12:35, Tobias Burnus wrote: > 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. ----------------- 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