From edd325e3385841edca25fe92531b86a4e3c9f279 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 22 Dec 2015 10:33:08 -0800 Subject: [PATCH] Round the number of threads to use down to a power of 2 Since other calculations depend on this being true --- geojson.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/geojson.c b/geojson.c index 6248b57..f968cfc 100644 --- a/geojson.c +++ b/geojson.c @@ -70,6 +70,9 @@ void init_cpus() { CPUS = 1; } + // Round down to a power of 2 + CPUS = 1 << (int) (log(CPUS) / log(2)); + TEMP_FILES = 64; struct rlimit rl; if (getrlimit(RLIMIT_NOFILE, &rl) != 0) {