This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: omp_get_num_procs() not working on macintosh?
- From: Jakub Jelinek <jakub at redhat dot com>
- To: CSights <csights at fastmail dot fm>
- Cc: gcc at gcc dot gnu dot org
- Date: Sun, 17 Feb 2008 22:18:08 +0100
- Subject: Re: omp_get_num_procs() not working on macintosh?
- References: <200802171200.51764.csights@fastmail.fm>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sun, Feb 17, 2008 at 12:00:51PM -0500, CSights wrote:
> 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!
Perhaps Darwin doesn't define _SC_NPROCESSORS_ONLN or
sysconf (_SC_NPROCESSORS_ONLN) doesn't work properly on Darwin?
If so, someone familiar with Darwin needs to provide (a tested) darwin specific
proc.c implementation which can be added to libgomp/config/darwin/proc.c
to replace the libgomp/config/posix/proc.c version.
Jakub