#include "mpi.h" #include "mpix.h" #include #include #include #include #include using namespace std; int main( int argc, char* argv[] ) { MPI_Init( &argc, &argv ); // Extract the total number of processes int p; MPI_Comm_size( MPI_COMM_WORLD, &p ); // Create custom BG/P 4D torus communicator int torus_rank; int result; MPI_Comm torus_comm; MPIX_Cart_comm_create( &torus_comm ); MPI_Comm_rank( torus_comm, &torus_rank ); result = 0; MPIX_Get_property(torus_comm, MPIDO_RECT_COMM, &result); if (torus_rank == 0) { if(result) fprintf(stderr, "Get_property: world is a rect. comm\n"); } // Set up the MatrixCol communicator // (Recall that MPIX_Cart_comm_create orders [T,Z,Y,X]) int remainingDimensions[4]; remainingDimensions[0] = true; // keep T remainingDimensions[1] = true; // keep Z remainingDimensions[2] = false; remainingDimensions[3] = false; int r; int matrix_col_rank; MPI_Comm matrix_col_comm; MPI_Cart_sub( torus_comm, remainingDimensions, &matrix_col_comm ); MPI_Comm_rank( matrix_col_comm, &matrix_col_rank ); MPI_Comm_size( matrix_col_comm, &r ); result = 0; MPIX_Get_property(matrix_col_comm, MPIDO_RECT_COMM, &result); if (matrix_col_rank == 0) { if(result) fprintf(stderr, "Get_property: matrix_col_comm is a rect. sub. comm\n"); } // Set up the MatrixRow communicator remainingDimensions[0] = false; remainingDimensions[1] = false; remainingDimensions[2] = true; // keep Y remainingDimensions[3] = true; // keep X int c; int matrix_row_rank; MPI_Comm matrix_row_comm; MPI_Cart_sub( torus_comm, remainingDimensions, &matrix_row_comm ); MPI_Comm_rank( matrix_row_comm, &matrix_row_rank ); MPI_Comm_size( matrix_row_comm, &c ); MPIX_Get_property(matrix_row_comm, MPIDO_RECT_COMM, &result); if (matrix_row_rank == 0) { if(result) fprintf(stderr, "Get_property: matrix_row_comm is a rect. sub. comm\n"); } if( torus_rank == 0 ) { ostringstream msg; msg << "Using " << r << " x " << c << " grid." << endl; cout << msg.str(); } // We will simulate an Allgather of a column panel of size 40,000 x 64 int m = 40000; int b = 64; int num_tests = 20; vector local_data; vector gathered_data; double start_time, stop_time, average_time, bandwidth; /* #define MPIDO_USE_ABCAST_ALLGATHER 26 #define MPIDO_USE_ABINOM_BCAST_ALLGATHER 27 #define MPIDO_USE_ALLTOALL_ALLGATHER 28 #define MPIDO_USE_ARECT_BCAST_ALLGATHER 29 #define MPIDO_USE_ALLREDUCE_ALLGATHER 30 #define MPIDO_USE_BCAST_ALLGATHER 31 #define MPIDO_USE_BINOM_BCAST_ALLGATHER 32 #define MPIDO_USE_RECT_BCAST_ALLGATHER 33 #define MPIDO_USE_RECT_DPUT_ALLGATHER 34 #define MPIDO_USE_MPICH_ALLGATHER 35 */ vector allgather_codes(10); for( unsigned i=0; i allgather_props(allgather_codes.size()); for( unsigned i=0; i avail_props(0); for( unsigned i=0; i