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

Allow uniform_partition to have arbitrarily many ghost layers #173

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

Joroks
Copy link
Contributor

@Joroks Joroks commented Sep 22, 2024

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.

@Joroks Joroks changed the title Nghosts Allow uniform_partition to have arbitrarily many ghost layers Sep 22, 2024
@fverdugo
Copy link
Owner

@Joroks Thanks for this PR. I will need some time to review this. I will come back to you.

@fverdugo fverdugo self-requested a review September 23, 2024 14:52
Copy link
Owner

@fverdugo fverdugo left a 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
Copy link
Owner

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.

Copy link
Contributor Author

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

Copy link
Owner

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.

Copy link
Owner

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.

Copy link
Contributor Author

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))
Copy link
Owner

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?

Copy link
Contributor Author

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)
Copy link
Owner

@fverdugo fverdugo Sep 29, 2024

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?

Copy link
Contributor Author

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
Copy link
Owner

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!

@fverdugo
Copy link
Owner

fverdugo commented Oct 7, 2024

@Joroks thanks for the last changes. Let's wait for the checks to pass.

@fverdugo
Copy link
Owner

fverdugo commented Oct 7, 2024

@Joroks out of curiosity: Is there a way I can find your personal webpage / google scholar?

@Joroks
Copy link
Contributor Author

Joroks commented Oct 7, 2024

@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/

@fverdugo fverdugo merged commit a948ae4 into fverdugo:master Oct 7, 2024
4 checks passed
@fverdugo
Copy link
Owner

fverdugo commented Oct 7, 2024

@Joroks thanks for the link!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants