This commit is contained in:
kai
2025-06-15 16:24:26 +02:00
parent a121a42bbf
commit e5dc2649f8
2 changed files with 28 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
#define SUPER_GRID_H
#include "matrix.h"
#include <cstdio>
#include <mpi.h>
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

View File

@@ -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<int, 2> 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; }