diff --git a/src/init.c b/src/init.c index b8f668d023372..6b55e45ea4733 100644 --- a/src/init.c +++ b/src/init.c @@ -698,18 +698,6 @@ void _julia_init(JL_IMAGE_SEARCH rel) } #endif -#if defined(__linux__) - int ncores = jl_cpu_threads(); - 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 - if ((jl_options.outputo || jl_options.outputbc) && (jl_options.code_coverage || jl_options.malloc_log)) { jl_error("cannot generate code-coverage or track allocation information while generating a .o or .bc output file"); diff --git a/src/julia_internal.h b/src/julia_internal.h index fc0dd3096a8d9..057081c0e37ad 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -8,7 +8,6 @@ #include #if !defined(_MSC_VER) && !defined(__MINGW32__) #include -#include #else #define sleep(x) Sleep(1000*x) #endif diff --git a/test/threads.jl b/test/threads.jl index 4f2b3acdc014d..54e11c8df3f19 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -13,3 +13,10 @@ let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads_exec error("threads test failed with nthreads == $other_nthreads") end end + +# issue #34415 - make sure external affinity settings work +if Sys.islinux() && Sys.CPU_THREADS > 1 && Sys.which("taskset") !== nothing + run_with_affinity(spec) = readchomp(`taskset -c $spec $(Base.julia_cmd()) -e "run(\`taskset -p \$(getpid())\`)"`) + @test endswith(run_with_affinity("1"), "2") + @test endswith(run_with_affinity("0,1"), "3") +end