-
Notifications
You must be signed in to change notification settings - Fork 10
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
Distributed Datawrangling macros #208
Conversation
This code using MPI
MPI.Init()
using ClimaOcean
@root begin
println("Hello from rank 0")
end
@onrank 1, println("Another Hello from rank 1")
@onrank 2, println("Yet another one from rank 2")
@root println()
@root println()
rank = ClimaOcean.mpi_rank()
a1 = []
a2 = []
for i in 1:10
push!(a1, i)
end
@distribute for i in 1:10
push!(a2, i)
end
@show rank a1 a2
@root println()
@root println()
@handshake @show rank a1 a2 ran with
I am wondering if maybe these functions could be more of an Oceananigans utility rather than a ClimaOcean one |
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.
This is epic.
A few comments:
- Should this be in Oceananigans
- Should everything take
comm
as an argument, which default toCOMM_WORLD
? - What happens if MPI is initialized but we are not distributed? I could see people leaving
MPI.Init()
in their scripts, lazily... - Can the macros also take
comm
as an argument, which defaults toCOMM_WORLD
?
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.
I mean, you could even contribute this to MPI.jl
and then we use it in either oceananigans or ClimaOcean
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.
I guess in the latter case, we should just merge it here and get used to using it, and then move it in the future
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.
Thanks, I also think this might go in Oceananigans. We probably have some use for it there.
I am thinking mostly of progress functions where we don't want all the ranks to spit out redundant information.
Regarding MPI.jl, I don't know if it would be needed there. Maybe, @simonbyrne, would you need macros like these in MPI.jl?
If not distributed but mpi is initialized then we are running on rank 0, so everything will work as if we are running a serial computation without having MPI initialized. The only difference is an hypothetical @onrank rank, exps...
, with rank > 0
, which executes if mpi is not initialized but will not execute anything if mpi is initialized with only one rank.
There are probably two different ways to reconcile this difference
- make
@onrank rank, exp...
execute always ifMPI.Comm_size() == 1
which allows serial computation but then the function is not really true to its name - enforce that
@onrank rank, exp...
executes only onrank
so only@onrank 0, exps...
(which is equivalent to@root
) executes something in a serial computation.
I'll try to figure out if I can pass communicators easily
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.
Regarding MPI.jl, I don't know if it would be needed there.
What do you mean by "needed"? These macros are completely independent of ocean modeling right?
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.
@simone-silvestri I suggest opening an issue on the MPI github to understand whether it is in scope for MPI.jl.
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.
I'm not sure about MPI.jl, but you could also put them in ClimaComms.jl?
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.
Thanks, we could migrate them there later on when we do the switch to ClimaComms.jl
I support merging this is as is and we can work out the kinks as we go |
sounds good! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 32 33 +1
Lines 1841 1828 -13
=====================================
+ Misses 1841 1828 -13 ☔ View full report in Codecov by Sentry. |
Ready to go |
Is there any way to add a few tests? |
Hmmm, we should add some MPI tests. Do we want to do it here? I can add some, otherwise we can move this to Oceananigans where probable we need |
I think we should really try to contribute this to MPI.jl. If MPI.jl doesn't want it, we may want to contribute it to some other small utility package. So I wouldn't put any effort into moving it to Oceananigans if we are just going to move it again. The tests should be portable, so I think its ok to put tests in here. |
This should be ready to merge |
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.
Awesome!
This PR is a proposal to partially solve #206 (in particular the redundant download part)
It introduces a couple of distributed macros:
We would have to find a way to test this since distributed tests are not in place yet.
A cleaner PR that substitutes #207