From e5dc2649f878499323faf361467f89bf5e4dba99 Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 15 Jun 2025 16:24:26 +0200 Subject: [PATCH] idk --- lab11/game_of_life/super_grid.h | 10 ++++++++++ lab11/game_of_life/test.cpp | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lab11/game_of_life/super_grid.h b/lab11/game_of_life/super_grid.h index 65485ca..e6fb784 100644 --- a/lab11/game_of_life/super_grid.h +++ b/lab11/game_of_life/super_grid.h @@ -2,6 +2,7 @@ #define SUPER_GRID_H #include "matrix.h" +#include #include class SuperGrid { @@ -75,4 +76,13 @@ inline void SuperGrid::set_communicator(MPI_Comm communicator) { this->comm_ = communicator; } +inline void SuperGrid::find_neighbors() { + int left, right; + int top, bottom; + MPI_Cart_shift(this->comm_, 0, 1, &left, &right); + MPI_Cart_shift(this->comm_, 0, 1, &top, &bottom); + + printf("left: %d, right: %d \ntop: %d, bottom: %d", left, right, top, bottom); +} + #endif // SUPER_GRID_H diff --git a/lab11/game_of_life/test.cpp b/lab11/game_of_life/test.cpp index ac8e6ba..a313d6e 100644 --- a/lab11/game_of_life/test.cpp +++ b/lab11/game_of_life/test.cpp @@ -72,4 +72,21 @@ TEST(test_super_grid) { check(su_grid.cols(), 10); } -int main() { return 0; } +TEST(test_find_neighbors) { + int a; + char *b[10]; + MPI_Init(&a, nullptr); + + MPI_Comm comm_; + MPIGridSize mpiProcs = {0, 0}; + + std::array periods = {1, 1}; + MPI_Cart_create(MPI_COMM_WORLD, 2, mpiProcs.data(), periods.data(), true, + &comm_); + + SuperGrid su_grid = SuperGrid::zeros(10, 10, nullptr); + su_grid.find_neighbors(); + MPI_Finalize(); +} + +int main(int argc, char *argv[]) { return 0; }