idk
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user