-
Notifications
You must be signed in to change notification settings - Fork 0
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
#56: implement parallel meshes as smaller instances of a global mesh #57
base: master
Are you sure you want to change the base?
#56: implement parallel meshes as smaller instances of a global mesh #57
Conversation
- User defined global mesh x and y decomposition still needs to be implemented - Mesh chunk border types aren't set properly
… size Parallel mesh sizes are now more equally distributed
- needs handling of cases where parallel mesh is of multiple current location types at once (e.g. domain mesh is divided in (1, 1), (2, 1), etc. parallel meshes) - needs usage of this type in order to correctly define mesh chunk borders
…nk creation - needs (2, 1) and (1, 2) number of parallel meshes case handling - needs further testing
- testing needed for validation
fixes #59: fix docker build failing
target_link_libraries(parallel_test MPI::MPI_CXX) | ||
target_link_libraries(allTests MPI::MPI_CXX) | ||
elseif(${USE_MPI} AND NOT MPI_FOUND) | ||
MESSAGE(WARNING "MPI not found. Disabling MPI.") |
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.
As long as MPI is marked as REQUIRED
, CMake should fail with adequate error in the find_package
step.
uint64_t n_c_x = 32; | ||
uint64_t n_c_y = 32; | ||
uint64_t n_parallel_meshes_x = 1; | ||
uint64_t n_parallel_meshes_y = 1; | ||
uint64_t n_colors_x = 1; | ||
uint64_t n_colors_y = 1; |
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.
Should these be printed as Input parameters
as well? (see below)
for(uint64_t ky = 0; ky < this->n_p_mesh_y; ky++){ | ||
n_y = n_cells_p_mesh_y; | ||
// correct parallel mesh size with remainder | ||
if(r_y > 0){ | ||
n_y++; | ||
r_y--; | ||
} | ||
|
||
// compute location type of current parallel mesh | ||
if(ky == 0){ | ||
p_mesh_border = static_cast<int>(LocationIndexEnum::VERT_BAR_BOT); | ||
} | ||
else if(ky == this->n_p_mesh_y - 1){ | ||
p_mesh_border = static_cast<int>(LocationIndexEnum::VERT_BAR_TOP); | ||
} | ||
else{ | ||
p_mesh_border = static_cast<int>(LocationIndexEnum::VERT_BAR_MID); | ||
} | ||
|
||
if(this->verbosity >= 2){ | ||
std::cout << "coordinates, pmesh border type: " | ||
<< "(0, " << ky << ")" | ||
<< " // " << static_cast<int>(p_mesh_border) << '\n'; | ||
} | ||
|
||
// construct current parallel mesh | ||
this->parallel_meshes.emplace | ||
(std::piecewise_construct, | ||
std::forward_as_tuple(std::array<uint64_t,2>{0, ky}), | ||
std::forward_as_tuple(n_cells_p_mesh_x, n_y, this->h, n_p, n_q, p_mesh_border, o_x, o_y)); | ||
|
||
o_y += n_y * this->h; | ||
} |
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.
Clarity / method length: extract this into a separate helper method. This will make the whole top-level code much more readable:
if()
if()
do_only_one_column_of_parallel_meshes(...);
elseif()
do_only_one_row_of_parallel_meshes(...);
else
do_something(...);
else
if()
do_parallel_mesh_is_unique(...);
...
...
...
for(uint64_t kx = 0; kx < this->n_p_mesh_x; kx++){ | ||
n_x = n_cells_p_mesh_x; | ||
// correct parallel mesh size with remainder | ||
if(r_x > 0){ | ||
n_x++; | ||
r_x--; | ||
} | ||
|
||
// compute location type of current parallel mesh | ||
if(kx == 0){ | ||
p_mesh_border = static_cast<int>(LocationIndexEnum::HORIZ_BAR_L); | ||
} | ||
else if(kx == this->n_p_mesh_x - 1){ | ||
p_mesh_border = static_cast<int>(LocationIndexEnum::HORIZ_BAR_R); | ||
} | ||
else{ | ||
p_mesh_border = static_cast<int>(LocationIndexEnum::HORIZ_BAR_MID); | ||
} | ||
|
||
if(this->verbosity >= 2){ | ||
std::cout << "coordinates, pmesh border type: " | ||
<< "( " << kx << ", 0)" | ||
<< " // " << static_cast<int>(p_mesh_border) << '\n'; | ||
} | ||
|
||
// construct current parallel mesh | ||
this->parallel_meshes.emplace | ||
(std::piecewise_construct, | ||
std::forward_as_tuple(std::array<uint64_t,2>{kx, 0}), | ||
std::forward_as_tuple(n_x, n_cells_p_mesh_y, this->h, n_p, n_q, p_mesh_border, o_x, o_y)); | ||
|
||
o_x += n_x * this->h; | ||
} |
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.
Same as above: extract into a helper method, do the same for the remaining cases below.
|
||
// compute location type of current parallel mesh | ||
if(ky == 0){ | ||
p_mesh_border = static_cast<int>(LocationIndexEnum::VERT_BAR_BOT); |
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.
Since p_mesh_border
is int8_t
:
p_mesh_border = static_cast<int>(LocationIndexEnum::VERT_BAR_BOT); | |
p_mesh_border = static_cast<int8_t>(LocationIndexEnum::VERT_BAR_BOT); |
here and everywhere below.
Latest Kokkos release is 3.6.01. cfd-mini-app/ubuntu-cpp.dockerfile Line 55 in 03e7615
Note: maybe this could be done in a separate issue? |
@@ -9,6 +9,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) | |||
|
|||
# Setting options | |||
option(OUTPUT_VTK_FILES "When OFF allows for a non-VTK build" OFF) | |||
option(USE_MPI "When OFF allows for a non-MPI build" OFF) |
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.
With this being OFF
by default, this feature will not get tested in CI.
Long-term it would be really good to have that configuration tested as well.
EDGE_2 = 6, | ||
EDGE_3 = 7, | ||
INTERIOR = 8 | ||
CORNER_0 = 0, // Bottom Left |
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.
Consider changing the names instead of adding comments.
@@ -28,6 +50,7 @@ class ParallelMesh | |||
uint64_t get_n_points_y() const { return this->n_cells_y + 1; } | |||
double get_cell_size() const { return this->h; } | |||
std::array<double,2> get_origin() const {return this->origin; } | |||
uint8_t get_location_type() const { return this->location_type; } |
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.
Return type does not match int8_t location_type
.
uint8_t get_location_type() const { return this->location_type; } | |
int8_t get_location_type() const { return this->location_type; } |
uint64_t n_cells_p_mesh_x = this->domain_size_x / this->n_p_mesh_x; | ||
uint64_t n_cells_p_mesh_y = this->domain_size_y / this->n_p_mesh_y; | ||
|
||
uint64_t remainder_x = this->domain_size_x % n_cells_p_mesh_x; | ||
uint64_t remainder_y = this->domain_size_y % n_cells_p_mesh_y; |
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.
Consider making this constexpr
getter methods.
// // Get the number of processes | ||
// int p; | ||
// MPI_Comm_size(MPI_COMM_WORLD, &p); | ||
// | ||
// // Get process rank | ||
// int world_rank; | ||
// MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); |
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.
Remove if this is not needed.
if(this->verbosity >= 1){ | ||
std::cout << "Assembling parallel meshes..." << std::endl; | ||
} |
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.
Encapsulate this with a helper method like:
void debug_print(const std::string& msg) {
if(this->verbosity >= 1){
std::cout << msg << std::endl;
}
}
so you can use:
debug_print("Assembling parallel meshes...");
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.
Various code quality comments posted. I have only briefly looked at the math / logic here, but I assume that part is OK.
Resolves #56