How does one compile numa code in PGI 11 and newer?

Here’s another problem we’ve run into. This code should query the numa system but we cannot get it to work.

#include <numa>
#include <stdio>

int main(){

   int max;

   max = numa_max_node();
   printf("Max nodes: %d\n", max);

   if (numa_available() < 0) {
      printf("Your system DOES NOT support the NUMA API.\n");
   } else {
      printf("Your system DOES support the NUMA API.\n");
   }
   return 0;
}

Compiled with

 pgcc -o numa_test numa_test.c -lnuma

Whether we put the “-lnuma” option in or not, the output of the program is always

Max nodes: 6451072
Your system DOES NOT support the NUMA API.

More info about this problem (the forum software wouldn’t let me add this to the original post without really screwing up the format).


$ ldd numa_test
linux-vdso.so.1 => (0x00007fff3e393000)
libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x00002b10d878d000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b10d8996000)
libm.so.6 => /lib64/libm.so.6 (0x00002b10d8bb2000)
libc.so.6 => /lib64/libc.so.6 (0x00002b10d8e36000)
/lib64/ld-linux-x86-64.so.2 (0x00002b10d856b000)
[/code]

This happens on all of the versions of PGI we have > 11. So PGI 11.10, 12.1 and 12.4.

This is on many of our systems, the newest being a RHEL 6.2 system, base gcc 4.4.6 and glibc-2.12-1.47.

Hi David,

Starting with 11.x compilers, the PGI drivers will link by default with the PGI OpenMP libraries. For non-OpenMP codes, this includes linking with a NUMA stub object “nonuma.o”. So what’s happening here is that “numa_available:” is being resolved by the stub version not the library version.

You can work around this issue by adding to the link the flag “-mp” or “-nomp -lnuma”. The default is to use the “-mp=nonuma” option.

Hope this helps,
Mat

% pgcpp numa.o -V12.4 ; a.out
Max nodes: 0
Your system DOES NOT support the NUMA API.

% pgcpp numa.o -V12.4 -mp ; a.out
Max nodes: 0
Your system DOES support the NUMA API.

% pgcpp numa.o -V12.4 -nomp -lnuma ; a.out
Max nodes: 0
Your system DOES support the NUMA API.

And where has this been documented?

PGI 2011 release notes under Chapter 2 “New or Modified Features”.

  • Mat

This is what I am reading: http://www.pgroup.com/doc/pgiwsrn.pdf

It isn’t there anywhere.

Furthermore, if I follow a link to the latest 2011 release notes, for 11.10, I get a page not found error:
http://www.pgroup.com/doc/pgiwsrn1110.pdf