-
Notifications
You must be signed in to change notification settings - Fork 82
Test for MPI.Irecv/MPI.Isend/MPI.Wait #518
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8988879
Setup MPI as an integration test
michel2323 8ba563d
Implement fix_ptr_lookup for raw fname
vchuravy ab9259d
Test MPI.Comm_size/Comm_rank under AD
vchuravy c8426e5
Test MPI.Recv/MPI.Send
vchuravy fab6f3e
Test for MPI.Irecv/MPI.Isend/MPI.Wait
michel2323 a1dc133
Merge branch 'main' into ms/mpi
vchuravy 4072817
Apply suggestion
giordano 7dda23d
Only run tests on 1.11
vchuravy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| using MPI | ||
| using Enzyme | ||
| using Test | ||
|
|
||
|
|
||
| function halo(x) | ||
| np = MPI.Comm_size(MPI.COMM_WORLD) | ||
| rank = MPI.Comm_rank(MPI.COMM_WORLD) | ||
| requests = Vector{MPI.Request}() | ||
| if rank != 0 | ||
| buf = @view x[1:1] | ||
| push!(requests, MPI.Isend(x[2:2], MPI.COMM_WORLD; dest = rank - 1, tag = 0)) | ||
| push!(requests, MPI.Irecv!(buf, MPI.COMM_WORLD; source = rank - 1, tag = 0)) | ||
| end | ||
| if rank != np - 1 | ||
| buf = @view x[end:end] | ||
| push!(requests, MPI.Isend(x[(end - 1):(end - 1)], MPI.COMM_WORLD; dest = rank + 1, tag = 0)) | ||
| push!(requests, MPI.Irecv!(buf, MPI.COMM_WORLD; source = rank + 1, tag = 0)) | ||
| end | ||
| for request in requests | ||
| MPI.Wait(request) | ||
| end | ||
| return nothing | ||
| end | ||
|
|
||
| MPI.Init() | ||
| np = MPI.Comm_size(MPI.COMM_WORLD) | ||
| rank = MPI.Comm_rank(MPI.COMM_WORLD) | ||
| nl = rank == 0 ? 0 : 2 | ||
| nr = rank == np - 1 ? 0 : 2 | ||
| nlocal = nr + nl + 1 | ||
|
|
||
| x = zeros(nlocal) | ||
| fill!(x, Float64(rank)) | ||
| halo(x) | ||
| MPI.Barrier(MPI.COMM_WORLD) | ||
|
|
||
| @test x[nl + 1] == Float64(rank) # Local | ||
| if rank != 0 | ||
| @test x[1] == Float64(rank - 1) # Recv | ||
| @test x[2] == Float64(rank) # Send | ||
| end | ||
| if rank != np - 1 | ||
| @test x[end] == Float64(rank + 1) # Recv | ||
| @test x[end - 1] == Float64(rank) # Send | ||
| end | ||
|
|
||
| dx = zeros(nlocal) | ||
| fill!(dx, Float64(rank)) | ||
| autodiff(Reverse, halo, Duplicated(x, dx)) | ||
| MPI.Barrier(MPI.COMM_WORLD) | ||
|
|
||
| @test dx[nl + 1] == Float64(rank) # Local -> no change | ||
| if rank != 0 | ||
| @test dx[1] == 0.0 # Recv -> Send & zero'd | ||
| @test dx[2] == Float64(rank + rank - 1) # Send -> += Recv | ||
| end | ||
| if rank != np - 1 | ||
| @test dx[end] == 0.0 # Recv -> Send & zero'd | ||
| @test dx[end - 1] == Float64(rank + rank + 1) # Send -> += Recv | ||
| end | ||
|
|
||
| fill!(dx, Float64(rank)) | ||
| autodiff(Forward, halo, Duplicated(x, dx)) | ||
| MPI.Barrier(MPI.COMM_WORLD) | ||
|
|
||
| @test dx[nl + 1] == Float64(rank) | ||
| if rank != 0 | ||
| @test dx[1] == Float64(rank - 1) | ||
| @test dx[2] == Float64(rank) | ||
| end | ||
| if rank != np - 1 | ||
| @test dx[end] == Float64(rank + 1) | ||
| @test dx[end - 1] == Float64(rank) | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 1.10 only: https://github.com/EnzymeAD/Enzyme.jl/actions/runs/19148197862/job/54731298414?pr=518#step:8:31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grrrml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EnzymeAD/Enzyme#2533