Skip to content

Commit

Permalink
fix #34415, remove affinity setting code (#34433)
Browse files Browse the repository at this point in the history
This was removed before and added back apparently by mistake.
  • Loading branch information
JeffBezanson authored and KristofferC committed Jan 20, 2020
1 parent 0d99f4c commit 5928786
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 0 additions & 12 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <uv.h>
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#include <sched.h>
#else
#define sleep(x) Sleep(1000*x)
#endif
Expand Down
7 changes: 7 additions & 0 deletions test/threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5928786

Please sign in to comment.