diff options
author | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-03 10:46:04 +0000 |
---|---|---|
committer | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-03 10:46:04 +0000 |
commit | 737efd9985336b9897361b6e0beab77fc214476e (patch) | |
tree | 0e7d2a27bf466c8bf3dea438e99068bf00c01d1c /libgomp | |
parent | e50494f3f8e79a68434cd2a37a163fb7bc5baa66 (diff) | |
download | gcc-737efd9985336b9897361b6e0beab77fc214476e.tar.gz |
* config/linux/proc.h: New.
* config/linux/proc.c: Include "proc.h". Do not include <sched.h>.
(gomp_cpuset_popcount): Rename from cpuset_popcount. No more static.
(gomp_init_num_threads): Update call to cpuset_popcount.
(get_num_procs): Ditto.
* config/linux/affinity.c (gomp_init_affinity): Call
gomp_cpuset_popcount.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177265 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 10 | ||||
-rw-r--r-- | libgomp/config/linux/affinity.c | 4 | ||||
-rw-r--r-- | libgomp/config/linux/proc.c | 10 | ||||
-rw-r--r-- | libgomp/config/linux/proc.h | 34 |
4 files changed, 51 insertions, 7 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index b26dcd54cd6..df3cf60992c 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,13 @@ +2011-08-03 Uros Bizjak <ubizjak@gmail.com> + + * config/linux/proc.h: New. + * config/linux/proc.c: Include "proc.h". Do not include <sched.h>. + (gomp_cpuset_popcount): Rename from cpuset_popcount. No more static. + (gomp_init_num_threads): Update call to cpuset_popcount. + (get_num_procs): Ditto. + * config/linux/affinity.c (gomp_init_affinity): Call + gomp_cpuset_popcount. + 2011-08-02 Jakub Jelinek <jakub@redhat.com> PR fortran/42041 diff --git a/libgomp/config/linux/affinity.c b/libgomp/config/linux/affinity.c index d8d575628ff..8896a6f8ba7 100644 --- a/libgomp/config/linux/affinity.c +++ b/libgomp/config/linux/affinity.c @@ -29,7 +29,7 @@ #define _GNU_SOURCE 1 #endif #include "libgomp.h" -#include <sched.h> +#include "proc.h" #include <stdlib.h> #include <unistd.h> @@ -56,7 +56,7 @@ gomp_init_affinity (void) CPU_ZERO (&cpusetnew); if (gomp_cpu_affinity_len == 0) { - unsigned long count = CPU_COUNT (&cpuset); + unsigned long count = gomp_cpuset_popcount (&cpuset); if (count >= 65536) count = 65536; gomp_cpu_affinity = malloc (count * sizeof (unsigned short)); diff --git a/libgomp/config/linux/proc.c b/libgomp/config/linux/proc.c index 01f51dfa193..8d9cfb599ba 100644 --- a/libgomp/config/linux/proc.c +++ b/libgomp/config/linux/proc.c @@ -30,7 +30,7 @@ #define _GNU_SOURCE 1 #endif #include "libgomp.h" -#include <sched.h> +#include "proc.h" #include <stdlib.h> #include <unistd.h> #ifdef HAVE_GETLOADAVG @@ -40,8 +40,8 @@ #endif #ifdef HAVE_PTHREAD_AFFINITY_NP -static unsigned long -cpuset_popcount (cpu_set_t *cpusetp) +unsigned long +gomp_cpuset_popcount (cpu_set_t *cpusetp) { #ifdef CPU_COUNT /* glibc 2.6 and above provide a macro for this. */ @@ -76,7 +76,7 @@ gomp_init_num_threads (void) if (pthread_getaffinity_np (pthread_self (), sizeof (cpuset), &cpuset) == 0) { /* Count only the CPUs this process can use. */ - gomp_global_icv.nthreads_var = cpuset_popcount (&cpuset); + gomp_global_icv.nthreads_var = gomp_cpuset_popcount (&cpuset); if (gomp_global_icv.nthreads_var == 0) gomp_global_icv.nthreads_var = 1; return; @@ -99,7 +99,7 @@ get_num_procs (void) if (pthread_getaffinity_np (pthread_self (), sizeof (cpuset), &cpuset) == 0) { - int ret = cpuset_popcount (&cpuset); + int ret = gomp_cpuset_popcount (&cpuset); return ret != 0 ? ret : 1; } } diff --git a/libgomp/config/linux/proc.h b/libgomp/config/linux/proc.h new file mode 100644 index 00000000000..f9e311088ba --- /dev/null +++ b/libgomp/config/linux/proc.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + Contributed by Uros Bizjak <ubizjak@gmail.com> + + This file is part of the GNU OpenMP Library (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef GOMP_PROC_H +#define GOMP_PROC_H 1 + +#include <sched.h> + +#ifdef HAVE_PTHREAD_AFFINITY_NP +extern unsigned long gomp_cpuset_popcount (cpu_set_t *); +#endif + +#endif /* GOMP_PROC_H */ |