Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thread pinning optimization #233

Open
wants to merge 2 commits into
base: scaling_archer2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion extra/weak_scaling/run_particleda.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
using ParticleDA
using TimerOutputs
using MPI
using ThreadPinning

# Initialise MPI
MPI.Init()
mpi_size = MPI.Comm_size(MPI.COMM_WORLD)
comm = MPI.COMM_WORLD
mpi_size = MPI.Comm_size(comm)
my_rank = MPI.Comm_rank(comm)

cores_per_numa = 16
threads_per_rank = Threads.nthreads()
ranks_per_numa = div(cores_per_numa, threads_per_rank)

# Pin threads so that threads of a MPI rank will be pinned to cores with
# contiguous IDs. This will ensure that
# - When running 16 or less threads per rank, all threads will be pinned to the same
# NUMA region as their master (sharing a memory controller within Infinity fabric)
# - When running 8 or less threads per rank, all threads will be pinned to the same
# Core Complex Die
# - When running 4 or less threads per rank, all threads will be pinned to the same
# Core Complex (sharing a L3 cache)

my_numa, my_id_in_numa = divrem(my_rank, ranks_per_numa) .+ (1, 0)
pinthreads( numa( my_numa, 1:Threads.nthreads() ) .+ threads_per_rank .* my_id_in_numa )
Comment on lines +8 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With ThreadPinning v0.7.3 you can use simply pinthreads(:affinitymask)


# Save some variables for later use
test_dir = joinpath(dirname(pathof(ParticleDA)), "..", "test")
Expand Down