Skip to content

Commit

Permalink
test: working example of halo exchange
Browse files Browse the repository at this point in the history
This test includes two examples for different grid layouts:

- 3 x 1 grid (3 procs)
- 2 x 2 grid (4 procs)

Makes use of the Slice functionality
  • Loading branch information
TomMelt committed Dec 20, 2024
1 parent aa15779 commit a989bb6
Show file tree
Hide file tree
Showing 4 changed files with 480 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/include/ModelArraySlice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ class ModelArraySlice {
}

ModelArray& copyToModelArray(ModelArray& target) const;
template <typename T> T& copyToBuffer(T& buffer)
template <typename T> T& copyToBuffer(T& buffer, size_t startIndex = 0)
{
// make no especial attempt at efficiency here
SliceIter thisIter(slice, data.dimensions());
auto biter = buffer.begin();
auto biter = std::next(buffer.begin(), startIndex);

while (!thisIter.isEnd()) {
// If the buffer ends before the slice, throw an exception
Expand Down
13 changes: 12 additions & 1 deletion core/src/include/Slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,18 @@ class Slice {
}
std::ostream& print(std::ostream& os) const
{
return os << start << ":" << stop << ":" << step;
// TODO remove me before merging into develop
// this is for debugging purposes only
if (start.isAll()) {
os << ":*:";
} else {
os << start << ":";
}
if (stop.isAll()) {
return os << "*:" << step;
} else {
return os << stop << ":" << step;
}
}
friend SliceIter;
};
Expand Down
22 changes: 22 additions & 0 deletions core/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ if(ENABLE_MPI)
)
target_link_libraries(testModelMetadata_MPI3 PRIVATE nextsimlib doctest::doctest)

# set(ModelArrayStructure "discontinuousgalerkin")
set(CoreDir "../../core/src/")

# set(MODEL_INCLUDE_DIR "./testmodelarraydetails")
add_executable(testHaloExchange_MPI4
"HaloExchange_test.cpp"
"MainMPI.cpp"
"../src/ModelArray.cpp"
"../src/ModelArraySlice.cpp"
"${MODEL_INCLUDE_DIR}/ModelArrayDetails.cpp"
)
target_compile_definitions(testHaloExchange_MPI4 PRIVATE USE_MPI)
target_include_directories(
testHaloExchange_MPI4 PRIVATE
"../src"
"../../dynamics/src"
${MODEL_INCLUDE_DIR}
)
target_link_libraries(testHaloExchange_MPI4 PRIVATE doctest::doctest Eigen3::Eigen)

set(MODEL_INCLUDE_DIR "../../core/src/discontinuousgalerkin")

add_executable(testParaGrid_MPI2 "ParaGrid_test.cpp" "MainMPI.cpp")
target_compile_definitions(
testParaGrid_MPI2
Expand Down
Loading

0 comments on commit a989bb6

Please # to comment.