Skip to content

Commit e54259e

Browse files
committed
Add thread pinning optimization
1 parent 6f4efbe commit e54259e

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

extra/weak_scaling/run_particleda.jl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
11
using ParticleDA
22
using TimerOutputs
33
using MPI
4+
using ThreadPinning
45

56
# Initialise MPI
67
MPI.Init()
7-
mpi_size = MPI.Comm_size(MPI.COMM_WORLD)
8+
comm = MPI.COMM_WORLD
9+
mpi_size = MPI.Comm_size(comm)
10+
my_rank = MPI.Comm_rank(comm)
11+
12+
cores_per_numa = 16
13+
threads_per_rank = Threads.nthreads()
14+
ranks_per_numa = div(cores_per_numa, threads_per_rank)
15+
16+
# Pin threads so that threads of a MPI rank will be pinned to cores with
17+
# contiguous IDs. This will ensure that
18+
# - When running 16 or less threads per rank, all threads will be pinned to the same
19+
# NUMA region as their master (sharing a memory controller within Infinity fabric)
20+
# - When running 8 or less threads per rank, all threads will be pinned to the same
21+
# Core Complex Die
22+
# - When running 4 or less threads per rank, all threads will be pinned to the same
23+
# Core Complex (sharing a L3 cache)
24+
25+
my_numa, my_id_in_numa = divrem(my_rank, ranks_per_numa) .+ (1, 0)
26+
pinthreads( numa( my_numa, 1:Threads.nthreads() ) .+ threads_per_rank .* my_id_in_numa )
827

928
# Save some variables for later use
1029
test_dir = joinpath(dirname(pathof(ParticleDA)), "..", "test")
1130
llw2d_src = joinpath(test_dir, "models", "llw2d.jl")
12-
observation_file = "observations.h5"
31+
observation_file = "test_observations.h5"
1332

1433
# Instantiate the test environment
1534
using Pkg

test/Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ GaussianRandomFields = "e4b2fa32-6e09-5554-b718-106ed5adafe9"
77
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
10+
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
1011
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1112
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
1213
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1314
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1415
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
1516
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1617
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
18+
ThreadPinning = "811555cd-349b-4f26-b7bc-1f208b848042"
1719
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
1820

1921
[compat]
2022
Distributions = "0.22, 0.23, 0.24, 0.25"
2123
GaussianRandomFields = "2.1.1"
2224
HDF5 = "0.14, 0.15, 0.16"
23-
MPI = "0.19"
25+
MPI = "0.20"
2426
StableRNGs = "1"
2527
YAML = "0.4"
26-
julia = "1.7"
28+
julia = "1.7"

0 commit comments

Comments
 (0)