omp_set_num_threads error

Hello,

I am porting some OpenMP code to a 4P AMD Opteron box which we bought the PGI compilers for. The code runs fine on our Sun box. When I call omp_set_num_threads( int ) routine, it causes an error. It turns out that if I set the number of threads to anything other than 1, it fails (which is obviously not useful)

omp_get_num_procs returns 4, but omp_get_max_threads returns 1. I tried setting OMP_NUM_THREADS, and I get similar results. Is there something I need to do on the compile line other than -mp? Is there something I should set with the OS? (SuSE 9.x)?

Thanks,
Jim

Turns out that the Sun platform has 4 dual core processors, and the nubmer of threads was being set to 8 somewhere I hadn’t checked. When I back then number of threads down to 4, things seemed to work. I know setting the number of threads > num procs is bad, but I thought it would let you do it anyways. Is this a bug or is there some way to have it just warn me about this problem?

Thanks,
Jim

Hi Jim,

Settting the environment variable “MP_WARN” to “no” will disable the warning message you get when you try to run more threads then you have processors. Though with or without the warning, the number of threads you set is the number of threads that would be run.

What you may be encountering is that the basic PGI Workstation license restricts you a max of 4 sockets (a dual-core CPU is considered a single socket). Which type of product do you have, Workstation, Server, or CDK? Are the Opterons dual-core?

Thanks,
Mat

Mat,

I checked with our admin and we do have the Workstation license, and our Opterons are of the single core variety. I am also using C++, so I guess what is happening is that omp_set_num_threads() is throwing an exception that I’m not catching. I can do some experimentation with this at some point to see if that’s what’s really happening.