From c701bf2a98e6416dd5cbdf84ddc79c76dd629b5d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 11 Jan 2023 17:29:07 +0100 Subject: init: replace custom cpu count detection with sysconf Drop now-unnecessary assembly support. --- init.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'init.c') diff --git a/init.c b/init.c index f112ce7..07a00d8 100644 --- a/init.c +++ b/init.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -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; -- cgit v1.2.3