Skip to content

Commit 6fe60a4

Browse files
committed
Update to ThreadPinning v1
1 parent 0cb6e0a commit 6fe60a4

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ Logging = "1"
2727
Parameters = "0.12, 0.13"
2828
Pkg = "1"
2929
Sockets = "1"
30-
ThreadPinning = "0.7.22, 1"
30+
ThreadPinning = "1"
3131
julia = "1.10"

ext/ParallelProcessingToolsThreadPinningExt.jl

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ import LinearAlgebra
55
import Distributed
66
import ThreadPinning
77

8-
# ThreadPinning.jl does not support all operating systems, currently:
9-
const _threadpinning_supported = isdefined(ThreadPinning, :affinitymask2cpuids)
8+
9+
# ThreadPinning.jl does not fully support all operating systems, currently:
10+
const _threadpinning_supported = try
11+
@assert convert(Int, ThreadPinning.getcpuid()) isa Int
12+
true
13+
catch err
14+
false
15+
end
16+
1017

1118
@static if _threadpinning_supported
1219

13-
1420
function ParallelProcessingTools._pinthreads_auto_impl(::Val{true})
1521
pid = Distributed.myid()
1622
if Distributed.myid() == 1
@@ -22,7 +28,7 @@ function ParallelProcessingTools._pinthreads_auto_impl(::Val{true})
2228
end
2329
else
2430
@debug "On process $pid, pinning threads according to affinity mask"
25-
let available_cpus = ThreadPinning.affinitymask2cpuids(ThreadPinning.get_affinity_mask())
31+
let available_cpus = _ThreadPinning.Utility.affinitymask2cpuids(ThreadPinning.getaffinity())
2632
ThreadPinning.pinthreads(:affinitymask)
2733
LinearAlgebra.BLAS.set_num_threads(length(available_cpus))
2834
end
@@ -32,7 +38,6 @@ end
3238

3339
ParallelProcessingTools._getcpuids_impl(::Val{true}) = ThreadPinning.getcpuids()
3440

35-
3641
end # if _threadpinning_supported
3742

3843
end # module ChangesOfVariablesInverseFunctionsExt

test/runtests.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import Test
44

55
import ThreadPinning
6-
ThreadPinning.Prefs.set_os_warning(false)
6+
7+
if isdefined(ThreadPinning, :Prefs)
8+
ThreadPinning.Prefs.set_os_warning(false)
9+
end
710

811
Test.@testset "Package ParallelProcessingTools" begin
912
@info "Testing with $(Base.Threads.nthreads()) Julia threads."
@@ -21,6 +24,7 @@ Test.@testset "Package ParallelProcessingTools" begin
2124
include("test_procinit.jl")
2225
include("test_workerpool.jl")
2326
include("test_onworkers.jl")
27+
include("test_ext_threadpinning.jl")
2428
include("test_deprecated.jl")
2529
include("test_docs.jl")
2630
end # testset

test/test_ext_threadpinning.jl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file is a part of ParallelProcessingTools.jl, licensed under the MIT License (MIT).
2+
3+
using ParallelProcessingTools
4+
using Test
5+
6+
import ThreadPinning
7+
8+
@testset "ext_threadpinning" begin
9+
ParallelProcessingToolsThreadPinningExt = Base.get_extension(ParallelProcessingTools, :ParallelProcessingToolsThreadPinningExt)
10+
@test ParallelProcessingToolsThreadPinningExt isa Module
11+
12+
@test pinthreads_auto() isa Nothing
13+
end

0 commit comments

Comments
 (0)