aboutsummaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-01-11 17:29:07 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-11 17:29:07 +0100
commitc701bf2a98e6416dd5cbdf84ddc79c76dd629b5d (patch)
tree9913cbf9b5a1819a0cf060420d5a658a3c7dbc30 /init.c
parent3f6fe366cc0a1c965389b30c7c74f5539e7a04c3 (diff)
init: replace custom cpu count detection with sysconf
Drop now-unnecessary assembly support.
Diffstat (limited to 'init.c')
-rw-r--r--init.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/init.c b/init.c
index f112ce7..07a00d8 100644
--- a/init.c
+++ b/init.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <unistd.h>
#include <cblas.h>
@@ -30,7 +31,6 @@
#include "basis.h"
#include "common.h"
-#include "cpu.h"
#include "internal.h"
#include "log.h"
#include "nlsolve.h"
@@ -55,9 +55,16 @@ static int teukolsky_init_check_options(TDContext *td)
int ret;
if (!td->nb_threads) {
- td->nb_threads = tdi_cpu_count();
- if (!td->nb_threads)
- td->nb_threads = 1;
+ long val = 0;
+
+#ifdef _SC_NPROCESSORS_ONLN
+ val = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+
+ if (val <= 0)
+ val = 1;
+
+ td->nb_threads = val;
}
ret = tp_init(&s->tp, td->nb_threads);
@@ -327,7 +334,7 @@ TDContext *td_context_alloc(void)
if (!td)
return NULL;
- td->nb_threads = 1;
+ td->nb_threads = 0;
td->family = TD_FAMILY_TIME_ANTISYM_CUBIC;
td->solution_branch = 0;