-
Notifications
You must be signed in to change notification settings - Fork 16
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
Allow uniform_partition to have arbitrarily many ghost layers #173
Conversation
@Joroks Thanks for this PR. I will need some time to review this. I will come back to you. |
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.
@Joroks Thanks for this PR! Please see my comments.
src/p_range.jl
Outdated
@@ -552,7 +552,7 @@ interface. | |||
- `periodic::NTuple{N}=ntuple(i->false,N)`: Use or not periodic boundaries per direction. | |||
|
|||
For convenience, one can also provide scalar inputs instead tuples | |||
to create 1D block partitions. In this case, the argument `np` can be omitted | |||
to create 1D block partitions. In this case, the argument `np` is omitted |
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 looks like a breaking change. Is it really needed? Please keep the current option of not omitting np.
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 had to remove this option because this would otherwise result i a duplicate function signature.
uniform_partition(rank,n::Integer,ghost::Integer,periodic::Bool=false)
would be the same as
uniform_partition(rank,np::Integer,n::Integer)
if periodic is not specified.
I'm open to other ideas on how to handle this problem
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.
Hi @Joroks,
good point. I see the problem.
Maybe we can add a new method in which the optional arguments are key-word arguments:
function uniform_partition(ranks,np::Tuple,n::Tuple;
ghost=map(i->false,np),periodic=map(i->false,np))
end
This one should not interfere with any of the existing methods, I would say.
And for the moment build the thick ghost layer only using always tuples, also in the 1d case.
In the next breaking release, we can polish all these methods.
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.
The reason for this is that I don't want to introduce breaking changes at this moment.
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.
Hi @fverdugo,
the original type signature doesn't restrict the ghost argument to be a tuple of booleans.
I don't think it's necessary to use the key-word arguments to avoid breaking changes.
I've updated to documentation and reverted the function signature to reflect that.
lis = CircularArray(LinearIndices(n)) | ||
local_cis = CartesianIndices(local_ranges) | ||
owner_lis = CircularArray(LinearIndices(np)) |
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 think this was the only place where we used CircularArrays (please confirm). If so, can you remove it as a dependence?
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.
There is still another place where CircularArrays are used (two lines above actually).
@@ -809,39 +800,32 @@ function renumber_partition(partition_in;renumber_local_indices=true) | |||
end | |||
|
|||
function local_range(p,np,n,ghost=false,periodic=false) |
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.
Is the new version of this function equivalent to the previous one? In the previous, we distribute the reminder by giving an extra item to the first parts (or the last parts, now not I don't remember). Can you please include (by replying this comment) the output of this new version for some illustrative input values?
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.
The logic on how to distribute the remainder hasn't changed as offset
is still calculated exactly the same way. I just simplified the function a bit and made it work with more than one layer of ghost atoms.
julia> [PartitionedArrays.local_range(i, 5, 17) for i in 1:5]'
1×5 adjoint(::Vector{UnitRange{Int64}}) with eltype LinearAlgebra.Adjoint{Int64, UnitRange{Int64}}:
[1 2 3] [4 5 6] [7 8 9] [10 11 12 13] [14 15 16 17]
julia> [PartitionedArrays.local_range(i, 5, 17, true) for i in 1:5]'
1×5 adjoint(::Vector{UnitRange{Int64}}) with eltype LinearAlgebra.Adjoint{Int64, UnitRange{Int64}}:
[1 2 3 4] [3 4 … 6 7] [6 7 … 9 10] [9 10 … 13 14] [13 14 … 16 17]
julia> [PartitionedArrays.local_range(i, 5, 17, true, true) for i in 1:5]'
1×5 adjoint(::Vector{UnitRange{Int64}}) with eltype LinearAlgebra.Adjoint{Int64, UnitRange{Int64}}:
[0 1 … 3 4] [3 4 … 6 7] [6 7 … 9 10] [9 10 … 13 14] [13 14 … 17 18]
@@ -51,6 +51,22 @@ function p_range_tests(distribute) | |||
periodic = (true,true) | |||
uniform_partition(rank,np,n,ghost,periodic) | |||
|
|||
# uniform Cartesian partition with two layers of ghosts |
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.
Good to add tests. Thanks!
@Joroks thanks for the last changes. Let's wait for the checks to pass. |
@Joroks out of curiosity: Is there a way I can find your personal webpage / google scholar? |
@fverdugo I unfortunately don't have any because im currently still only a bachelor student. I'm currently in the process of finishing my bachelors thesis which is related to running simulations on HPC clusters which has gotten me interested large scale parallel programms through the use of MPI and julia. I was the person suggesting to migrate the simulation code from matlab to julia, which is the topic of my thesis, alongside some mathematical improvements i discovered along the way. I can however point you to the research group I'm writing my bachelors thesis for: https://www.capriccio.research.fau.eu/ |
@Joroks thanks for the link! |
I've modified
uniform_partition
such that it now works with arbitrarily thick ghost layers. This would be a first step towards #97.On my machine, it passes all the tests.