Skip to content

Commit

Permalink
Merge pull request #9639 from stevengj/noaffinity
Browse files Browse the repository at this point in the history
do not set CPU affinity on Linux (see #3097)
  • Loading branch information
JeffBezanson committed Jan 6, 2015
2 parents 78e99a5 + 61e1563 commit 38d02bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
3 changes: 3 additions & 0 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ void __cdecl fpreset (void);
extern int needsSymRefreshModuleList;
extern BOOL (WINAPI *hSymRefreshModuleList)(HANDLE);
#endif
#if defined(__linux__)
//#define _GNU_SOURCE
#include <sched.h> // for setting CPU affinity
#endif

DLLEXPORT void jlbacktrace();
DLLEXPORT void gdbbacktrace();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 38d02bd

Please sign in to comment.