aboutsummaryrefslogtreecommitdiff
blob: afde85585b06b67a9b9643a2e2643e30b333d455 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From 480e697681763cf31f015eb1ebad49a495f562c5 Mon Sep 17 00:00:00 2001
From: Martin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Date: Mon, 24 Jul 2017 16:17:50 +0200
Subject: [PATCH] Revert "Honor cgroup/cpuset limits when enumerating cpus"
 (#1246)

---
 driver/others/init.c   | 49 +++++--------------------------------------------
 driver/others/memory.c | 37 -------------------------------------
 2 files changed, 5 insertions(+), 81 deletions(-)

diff --git a/driver/others/init.c b/driver/others/init.c
index 4c75d72e4..3e6176967 100644
--- a/driver/others/init.c
+++ b/driver/others/init.c
@@ -778,11 +778,11 @@ static int initialized = 0;
 void gotoblas_affinity_init(void) {
 
   int cpu, num_avail;
-#ifndef USE_OPENMP	
+#ifndef USE_OPENMP
   cpu_set_t cpu_mask;
 #endif
   int i;
-	
+
   if (initialized) return;
 
   initialized = 1;
@@ -826,54 +826,15 @@ void gotoblas_affinity_init(void) {
   common -> shmid = pshmid;
 
   if (common -> magic != SH_MAGIC) {
-    cpu_set_t *cpusetp;
-    int nums;
-    int ret;
-
 #ifdef DEBUG
     fprintf(stderr, "Shared Memory Initialization.\n");
 #endif
 
     //returns the number of processors which are currently online
-
-    nums = sysconf(_SC_NPROCESSORS_CONF);
-     
-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 3)
-    common->num_procs = nums;
-#elif __GLIBC_PREREQ(2, 7)
-    cpusetp = CPU_ALLOC(nums);
-    if (cpusetp == NULL) {
-        common->num_procs = nums;
-    } else {
-        size_t size;
-        size = CPU_ALLOC_SIZE(nums);
-        ret = sched_getaffinity(0,size,cpusetp);
-        if (ret!=0) 
-            common->num_procs = nums;
-        else
-            common->num_procs = CPU_COUNT_S(size,cpusetp);
-    }
-    CPU_FREE(cpusetp);
-#else
-    ret = sched_getaffinity(0,sizeof(cpu_set_t), cpusetp);
-    if (ret!=0) {
-        common->num_procs = nums;
-    } else {
-#if !__GLIBC_PREREQ(2, 6)  
-    int i;
-    int n = 0;
-    for (i=0;i<nums;i++)
-        if (CPU_ISSET(i,cpusetp)) n++;
-    common->num_procs = n;
-    }
-#else
-    common->num_procs = CPU_COUNT(sizeof(cpu_set_t),cpusetp);
-#endif
-
-#endif 
+    common -> num_procs = sysconf(_SC_NPROCESSORS_CONF);;
 
     if(common -> num_procs > MAX_CPUS) {
-      fprintf(stderr, "\nOpenBLAS Warning : The number of CPU/Cores(%d) is beyond the limit(%d). Terminated.\n", common->num_procs, MAX_CPUS);
+      fprintf(stderr, "\nOpenBLAS Warining : The number of CPU/Cores(%d) is beyond the limit(%d). Terminated.\n", common->num_procs, MAX_CPUS);
       exit(1);
     }
 
@@ -886,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;
 
diff --git a/driver/others/memory.c b/driver/others/memory.c
index 38d063715..916950315 100644
--- a/driver/others/memory.c
+++ b/driver/others/memory.c
@@ -175,44 +175,7 @@ int get_num_procs(void);
 #else
 int get_num_procs(void) {
   static int nums = 0;
-cpu_set_t *cpusetp;
-size_t size;
-int ret;
-int i,n;
-
   if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF);
-#if !defined(OS_LINUX)
-     return nums;
-#endif
-     
-#if !defined(__GLIBC_PREREQ)
-   return nums;
-#endif   
-#if !__GLIBC_PREREQ(2, 3)
-   return nums;
-#endif   
-
-#if !__GLIBC_PREREQ(2, 7)
-  ret = sched_getaffinity(0,sizeof(cpu_set_t), cpusetp);
-  if (ret!=0) return nums;
-  n=0;
-#if !__GLIBC_PREREQ(2, 6)  
-  for (i=0;i<nums;i++)
-     if (CPU_ISSET(i,cpusetp)) n++;
-  nums=n;   
-#else
-  nums = CPU_COUNT(sizeof(cpu_set_t),cpusetp);
-#endif
-  return nums;
-#endif
-
-  cpusetp = CPU_ALLOC(nums);
-  if (cpusetp == NULL) return nums;
-  size = CPU_ALLOC_SIZE(nums);
-  ret = sched_getaffinity(0,size,cpusetp);
-  if (ret!=0) return nums;
-  nums = CPU_COUNT_S(size,cpusetp);
-  CPU_FREE(cpusetp);
   return nums;
 }
 #endif