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

Fix physical domain for benchmark stencils #1772

Merged
merged 6 commits into from
Feb 24, 2025
Merged

Conversation

MarcelKoch
Copy link
Member

This PR changes the stencil generation for the benchmarks to always use the fixed physical domain $[0, 1]^d$. Before, the domain was scaling with the number of processes, as each process subdomain had to be a square/cube. Now, the shape of the subdomains (as in their number of degrees of freedom per dimension) is not square/cubic anymore, and can differ (slightly) between processes.

The subdomain sizes are chosen such that:

  • the global number of DOFs is the same in each dimension
  • the sum of all DOFs in one dimension over all subdomains in that dimension is equal to the global number of DOFs
  • the difference between of DOFs in one dimension of any subdomains is at most 1

Example: Consider a 2D equidistant grid with 81 DOFs in each direction. Given 2x2 processes, then the process at [0, 0] will have 41 x 41 DOFs, and the process [1, 0] will have 40 x 41 DOFs.

As a consequence of the variable subdomain size, the computed process local sizes have to be propagated up from the stencil creation.

@MarcelKoch MarcelKoch self-assigned this Jan 27, 2025
@ginkgo-bot ginkgo-bot added reg:testing This is related to testing. mod:core This is related to the core module. reg:benchmarking This is related to benchmarking. type:solver This is related to the solvers type:preconditioner This is related to the preconditioners labels Jan 27, 2025
@pratikvn pratikvn self-requested a review February 13, 2025 11:49
@thoasm thoasm requested review from thoasm and removed request for pratikvn February 13, 2025 11:49
@fritzgoebel fritzgoebel self-requested a review February 13, 2025 11:50
* @param positions The position of this subdomain with respect to each
* dimension.
* @param target_local_size The desired size of the subdomains. The actual size
* can deviate from this to accommodate the square
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-picking here, but shouldn't this be rectangular rather than square since we allow for different numbers of subdomains in each direction?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global domain is still square, so I reference that here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation speaks of the square size of the subdomains though, which is a bit weird in itself now that I think about it, shouldn't it be square / rectangular shape? But this is really not important.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I wasn't clear, I changed it to now read the square size of the global domain, which I hope is better to understand.

return is_in_box(i, discretization_points)
auto target_position = [&](const IndexType dim, const IndexType i,
const int position) {
return is_in_box(i, discretization_points[dim])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, since box is replaced with subdomain everywhere else, we could call this is_in_subdomain?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced it with range. I would consider the box here as something different from the subdomain, since the box is just the interval [0, n), but I thought that is_in_interval would be too long. So I'm now using is_in_range.

Copy link
Member

@thoasm thoasm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure what the additional size parameter of the generated matrices is doing. All I know is that it can be zeros, and other times, it is the local_size. I think some clarification would be helpful.
Additionally, the return value documentation of the generation functions needs to be updated.

* @param positions The position of this subdomain with respect to each
* dimension.
* @param target_local_size The desired size of the subdomains. The actual size
* can deviate from this to accommodate the square
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation speaks of the square size of the subdomains though, which is a bit weird in itself now that I think about it, shouldn't it be square / rectangular shape? But this is really not important.

Copy link
Member

@thoasm thoasm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

template <typename VectorType>
std::unique_ptr<VectorType> create_manufactured_rhs(
std::shared_ptr<const gko::Executor> exec, const gko::LinOp* system_matrix,
const VectorType* solution, bool normalize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is normalize ever false?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I will rename this function to create_normalized_manufactured_rhs.

@MarcelKoch MarcelKoch added the 1:ST:ready-to-merge This PR is ready to merge. label Feb 17, 2025
@MarcelKoch MarcelKoch force-pushed the stencil-rescaling branch 4 times, most recently from a491211 to 0e45798 Compare February 20, 2025 11:57
MarcelKoch and others added 6 commits February 20, 2025 17:24
This implies that the process subdomains will not be square/cube shaped anymore. Instead, they can have arbitrary shape `d_x * d_y (* d_z)`. The values `d_x, d_y, d_z` are process dependent, but they differ by at most 1 each.
- add documentation on empty dim
- fix documentation of return type
- rename `is_in_box` -> `is_in_range`
- rename manufactured rhs

Co-authored-by: Fritz Goebel <[email protected]>
Co-authored-by: Thomas Grützmacher <[email protected]>
Co-authored-by: Tobias Ribizel <[email protected]>
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.31%. Comparing base (2816a56) to head (3cc00bc).
Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
core/distributed/helpers.hpp 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1772      +/-   ##
===========================================
- Coverage    89.31%   89.31%   -0.01%     
===========================================
  Files          811      811              
  Lines        67506    67514       +8     
===========================================
+ Hits         60296    60301       +5     
- Misses        7210     7213       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MarcelKoch MarcelKoch merged commit ac0ffbd into develop Feb 24, 2025
13 of 14 checks passed
@MarcelKoch MarcelKoch deleted the stencil-rescaling branch February 24, 2025 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1:ST:ready-to-merge This PR is ready to merge. mod:core This is related to the core module. reg:benchmarking This is related to benchmarking. reg:testing This is related to testing. type:preconditioner This is related to the preconditioners type:solver This is related to the solvers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants