omp_get_num_procs() not working on macintosh?

2008-02-17 Thread CSights
Hi,
I'm not able to detect the number of processors using 
omp_get_num_procs()  on 
a macintosh.
I've installed gcc/g++ v4.3 from hpc.sourceforge.net (the "Tiger" 
version)
[Url 1 below].  (Installed = extracted to /)
$ g++ --version
g++ (GCC) 4.3.0 20080125 (experimental)
I compile the code below with no problems.
$ g++ -fopenmp main.cpp -o openmpTest
When the code executes omp_get_num_procs() detects 1 processor.
$ ./openmpTest
num procs 1
thread 0  i: 0
thread 0  i: 1
thread 0  i: 2
thread 0  i: 3
thread 0  i: 4
thread 0  i: 5
thread 0  i: 6
thread 0  i: 7
thread 0  i: 8
thread 0  i: 9

This macintosh has two physical chips and 2 cores per chip.
$ sysctl hw 
[...]
hw.ncpu: 4
hw.activecpu: 4
[...]

Does anybody know why omp_get_num_procs() is returning 1 on this 
machine?  
Let me know if you need more info!

Thanks,
C.


[1]http://prdownloads.sourceforge.net/hpc/gcc-intel-bin.tar.gz?download


-
// "g++ -fopenmp  main.cpp -o openmpTest"
#include 

#ifdef _OPENMP  // defined at compile time by -fopenmp
#include 
#endif

using namespace std;

int main (int argc, char **argv) {
int n_iters = 10;

#ifdef OMP_H// defined in header omp.h
cout<<"num procs "<

Re: omp_get_num_procs() not working on macintosh?

2008-02-18 Thread CSights
> > Perhaps Darwin doesn't define _SC_NPROCESSORS_ONLN
>
> It is defined on Darwin9:
>
> [ibook-dhum] f90/bug% grep _SC_NPROCESSORS_ONLN /usr/include/*
> /usr/include/unistd.h:#define   _SC_NPROCESSORS_ONLN            58
>
> but apparently not for Darwin8.
>
> Dominique

Yep, I'm having trouble with Darwin v 8.

$ uname -v
Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; 
root:xnu-792.25.20~1/RELEASE_I386