summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kroeker <martin@ruby.chemie.uni-freiburg.de>2017-07-09 13:16:16 +0200
committerGitHub <noreply@github.com>2017-07-09 13:16:16 +0200
commit3db2adf87225bd1720a62c05a9b9296dbe8dace0 (patch)
tree84fdb73ae3563cf4a88cd1f428c33ae57f07f309
parentad2462811a4093153ea9898200ab73ef4aea6f23 (diff)
parentc1cf62d2c030b65d8fbf37b19ca1d88fa38f7709 (diff)
downloadopenblas-3db2adf87225bd1720a62c05a9b9296dbe8dace0.tar.gz
openblas-3db2adf87225bd1720a62c05a9b9296dbe8dace0.tar.bz2
openblas-3db2adf87225bd1720a62c05a9b9296dbe8dace0.zip
Merge pull request #1230 from martin-frbg/rhel5
Add sched_getcpu implementation for pre-2.6 glibc
-rw-r--r--driver/others/init.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/driver/others/init.c b/driver/others/init.c
index 9be6f52b0..3e6176967 100644
--- a/driver/others/init.c
+++ b/driver/others/init.c
@@ -354,6 +354,24 @@ static int numa_check(void) {
return common -> num_nodes;
}
+#if defined(__GLIBC_PREREQ)
+#if !__GLIBC_PREREQ(2, 6)
+int sched_getcpu(void)
+{
+int cpu;
+FILE *fp = NULL;
+if ( (fp = fopen("/proc/self/stat", "r")) == NULL)
+ return -1;
+if ( fscanf( fp, "%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%d", &cpu) != 1) {
+ fclose (fp);
+ return -1;
+ }
+ fclose (fp);
+ return(cpu);
+}
+#endif
+#endif
+
static void numa_mapping(void) {
int node, cpu, core;
@@ -808,7 +826,6 @@ void gotoblas_affinity_init(void) {
common -> shmid = pshmid;
if (common -> magic != SH_MAGIC) {
-
#ifdef DEBUG
fprintf(stderr, "Shared Memory Initialization.\n");
#endif
@@ -830,7 +847,7 @@ void gotoblas_affinity_init(void) {
if (common -> num_nodes > 1) numa_mapping();
common -> final_num_procs = 0;
- for(i = 0; i < common -> avail_count; i++) common -> final_num_procs += rcount(common -> avail[i]) + 1; //Make the max cpu number.
+ for(i = 0; i < common -> avail_count; i++) common -> final_num_procs += rcount(common -> avail[i]) + 1; //Make the max cpu number.
for (cpu = 0; cpu < common -> final_num_procs; cpu ++) common -> cpu_use[cpu] = 0;