MPI: reduction over task results limits datadeps concurrency to 2 tasks in total (hierarchical planner)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- julia
- Lĩnh vực
- distributed-systems
Hướng nghiên cứu
Run the supplied Julia/MPI reduction-tree script with hierarchical planning enabled and disabled, comparing task concurrency across ranks. Start by tracing the hierarchical planner's DFS behavior and populate_task_info! when a task argument is a DTask value. Done means the reduction tree reaches the available four-thread concurrency under MPI without regressing the independent-task case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Follow-up to #757 – thanks for the quick fix! With 0.22.6, independent tasks and the first example from the MPI docs now use all threads.
We still see low concurrency when tasks take other tasks' results as arguments, e.g. a reduction tree over partial results:
using Dagger, MPI
Dagger.accelerate!(:mpi)
work(n) = (s = 0.0; for i in 1:n; x = (i - 0.5) / n; s += 4.0 / (1.0 + x * x); end; s / n)
Dagger.spawn_datadeps() do
p = [Dagger.@spawn work(1 << 27) for _ in 1:16]
m = length(p)
while m > 1
for k in 1:m ÷ 2
p[k] = Dagger.@spawn +(p[2k - 1], p[2k])
end
m ÷= 2
end
p[1]
end
Only two work tasks run at the same time, also in total across ranks:
| 1 rank × 4 threads | 2 ranks × 2 threads | |
|---|---|---|
| independent tasks only | 0.30 s | 0.30 s |
| reduction tree | 0.60 s | 0.60 s |
reduction tree, hierarchical=false |
0.30 s | 0.31 s |
Without accelerate!(:mpi), the tree uses all four threads. Tested with Dagger 0.22.6, MPI.jl 0.20.27 (MPICH_jll), Julia 1.13.0 on macOS.
We are not sure about the cause, but it might be related to the hierarchical planner under MPI: it seems to plan in DFS order, where each + follows its two inputs, and planning a task with a DTask value argument may wait for that value (fetch in populate_task_info!). When we pass the partial results through In/InOut buffers instead of task values, all four threads are used.
Thanks a lot for looking into this, and for all your work on Dagger!
Full script with timing
using Dagger, MPI
const USE_MPI = get(ENV, "NO_MPI", "0") != "1"
USE_MPI ? Dagger.accelerate!(:mpi) : MPI.Init()
const TREE = get(ENV, "TREE", "1") == "1"
const HIERARCHICAL = get(ENV, "HIERARCHICAL", "1") == "1"
const rank = MPI.Comm_rank(MPI.COMM_WORLD)
const LOG = Tuple{Float64,Float64}[] # (start, end) of the work tasks on this rank
const LOG_LOCK = ReentrantLock()
function work(n)
t1 = time()
s = 0.0
for i in 1:n
x = (i - 0.5) / n
s += 4.0 / (1.0 + x * x)
end
lock(() -> push!(LOG, (t1, time())), LOG_LOCK)
return s / n
end
# maximum number of work tasks running at the same time
function max_concurrent(iv)
ev = sort!(vcat([(s, 1) for (s, _) in iv], [(e, -1) for (_, e) in iv]))
c = m = 0
for (_, d) in ev
c += d; m = max(m, c)
end
return m
end
for rep in 1:2
empty!(LOG)
t = @elapsed Dagger.spawn_datadeps(; hierarchical=HIERARCHICAL) do
p = [Dagger.@spawn work(1 << 27) for _ in 1:16]
if TREE
m = length(p)
while m > 1
for k in 1:m ÷ 2
p[k] = Dagger.@spawn +(p[2k - 1], p[2k])
end
m ÷= 2
end
end
p[1]
end
if rep == 2
USE_MPI && MPI.Barrier(MPI.COMM_WORLD)
print("rank $rank: $(round(t; digits=3)) s, $(length(LOG)) work tasks on this rank, " *
"max $(max_concurrent(LOG)) at a time\n")
end
end
mpiexec -n 1 julia --project=. --threads=4 script.jl # 0.60 s, max 2 at a time
HIERARCHICAL=0 mpiexec -n 1 julia --project=. --threads=4 script.jl # 0.30 s, max 4 at a time
- Ngôn ngữ chính
- Julia
- Star
- 734
- Fork
- 94
- Merge trung bình
- 4 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaParallel/Dagger.jl
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
JuliaParallel/Dagger.jl#786 · 1 bình luận ·
-
MPI: tasks with acceleration=DistributedAcceleration() go missing when ranks spawn them independentlyCó thể đã có người làm @AnnaLena77 đã nhận 39 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
JuliaParallel/Dagger.jl#778 · 1 bình luận ·
-
bug datadeps
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
JuliaParallel/Dagger.jl#665 · 3 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
JuliaParallel/Dagger.jl#661 · 1 bình luận ·
-
memory usage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
JuliaParallel/Dagger.jl#649 · 6 bình luận ·
Tất cả issue của JuliaParallel/Dagger.jl
Issue tương tự
-
docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
path: splitext treats directory references and leading dots as extensionsCó thể đã có người làm @Hiten0305l đã nhận hôm nay. Đang mở
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
JuliaRegistries/RegistryCI.jl#758 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JuliaParallel/Hwloc.jl#93 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày