From c3ddf90084b535a2957ca03405107c8c1c6f6f68 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Tue, 6 Jan 2015 11:11:04 -0500 Subject: [PATCH 1/2] do not set CPU affinity on Linux (see #3097) --- src/init.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/init.c b/src/init.c index c222bf63da4eb..ea12598a93d14 100644 --- a/src/init.c +++ b/src/init.c @@ -77,10 +77,6 @@ void __cdecl fpreset (void); extern int needsSymRefreshModuleList; extern BOOL (WINAPI *hSymRefreshModuleList)(HANDLE); #endif -#if defined(__linux__) -//#define _GNU_SOURCE -#include // for setting CPU affinity -#endif DLLEXPORT void jlbacktrace(); DLLEXPORT void gdbbacktrace(); @@ -974,18 +970,6 @@ void _julia_init(JL_IMAGE_SEARCH rel) } #endif -#if defined(__linux__) - int ncores = jl_cpu_cores(); - if (ncores > 1) { - cpu_set_t cpumask; - CPU_ZERO(&cpumask); - for(int i=0; i < ncores; i++) { - CPU_SET(i, &cpumask); - } - sched_setaffinity(0, sizeof(cpu_set_t), &cpumask); - } -#endif - #ifdef JL_GC_MARKSWEEP jl_gc_init(); jl_gc_disable(); From 61e156321e9e6642603a21c3389d131ec3a4e549 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Tue, 6 Jan 2015 14:38:38 -0500 Subject: [PATCH 2/2] set OPENBLAS_MAIN_FREE=1 to ensure that OpenBLAS does not set CPU affinity --- base/client.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/client.jl b/base/client.jl index fb0a71e980792..f3975cf6dbc55 100644 --- a/base/client.jl +++ b/base/client.jl @@ -370,6 +370,9 @@ end function early_init() global const JULIA_HOME = ccall(:jl_get_julia_home, Any, ()) + # make sure OpenBLAS does not set CPU affinity (#1070, #9639) + ENV["OPENBLAS_MAIN_FREE"] = get(ENV, "OPENBLAS_MAIN_FREE", + get(ENV, "GOTOBLAS_MAIN_FREE", "1")) Sys.init_sysinfo() if CPU_CORES > 8 && !("OPENBLAS_NUM_THREADS" in keys(ENV)) && !("OMP_NUM_THREADS" in keys(ENV)) # Prevent openblas from stating to many threads, unless/until specifically requested