Skip to content

Commit 139696b

Browse files
JeffBezansonKristofferC
authored andcommitted
fix #34415, remove affinity setting code (#34433)
This was removed before and added back apparently by mistake. (cherry picked from commit 5928786)
1 parent ea6f264 commit 139696b

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/init.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -698,18 +698,6 @@ void _julia_init(JL_IMAGE_SEARCH rel)
698698
}
699699
#endif
700700

701-
#if defined(__linux__)
702-
int ncores = jl_cpu_threads();
703-
if (ncores > 1) {
704-
cpu_set_t cpumask;
705-
CPU_ZERO(&cpumask);
706-
for(int i=0; i < ncores; i++) {
707-
CPU_SET(i, &cpumask);
708-
}
709-
sched_setaffinity(0, sizeof(cpu_set_t), &cpumask);
710-
}
711-
#endif
712-
713701
if ((jl_options.outputo || jl_options.outputbc) &&
714702
(jl_options.code_coverage || jl_options.malloc_log)) {
715703
jl_error("cannot generate code-coverage or track allocation information while generating a .o or .bc output file");

src/julia_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <uv.h>
99
#if !defined(_MSC_VER) && !defined(__MINGW32__)
1010
#include <unistd.h>
11-
#include <sched.h>
1211
#else
1312
#define sleep(x) Sleep(1000*x)
1413
#endif

test/threads.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads_exec
1313
error("threads test failed with nthreads == $other_nthreads")
1414
end
1515
end
16+
17+
# issue #34415 - make sure external affinity settings work
18+
if Sys.islinux() && Sys.CPU_THREADS > 1 && Sys.which("taskset") !== nothing
19+
run_with_affinity(spec) = readchomp(`taskset -c $spec $(Base.julia_cmd()) -e "run(\`taskset -p \$(getpid())\`)"`)
20+
@test endswith(run_with_affinity("1"), "2")
21+
@test endswith(run_with_affinity("0,1"), "3")
22+
end

0 commit comments

Comments
 (0)