5 From: hook@nas.nasa.gov (Edward C. Hook)
14 #define EXIT_SUCCESS 0
15 #define EXIT_FAILURE 1
18 int main( int argc, char *argv[] )
25 int status, gstatus, endstatus;
27 MPI_Init(&argc,&argv);
28 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
29 MPI_Comm_size(MPI_COMM_WORLD,&size);
31 for ( i=1 ; i < argc ; ++i ) {
32 if ( argv[i][0] != '-' )
36 chunk = atoi(argv[++i]);
39 fprintf(stderr,"Unrecognized argument %s\n",
41 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
47 SMPI addition : we want to test all three alltoall algorithms, thus we use three diffrent sizes
48 this is the code that handles these cases
49 if (sendsize < 200 && size > 12) {
51 smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype,
52 recvbuf, recvcount, recvtype,
54 } else if (sendsize < 3000) {
56 smpi_coll_tuned_alltoall_basic_linear(sendbuf, sendcount,
58 recvcount, recvtype, comm);
61 smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype,
62 recvbuf, recvcount, recvtype,
70 int sizes [3] ={ 4096, 64, 32};
71 for ( j=0 ; j < 3 ; j++ ) {
72 sb = (int *)malloc(size*sizes[j]*sizeof(int));
74 perror( "can't allocate send buffer" );
75 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
77 rb = (int *)malloc(size*sizes[j]*sizeof(int));
79 perror( "can't allocate recv buffer");
81 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
83 for ( i=0 ; i < size*sizes[j] ; ++i ) {
88 /* fputs("Before MPI_Alltoall\n",stdout); */
89 MPI_Barrier(MPI_COMM_WORLD );
90 /* This should really send MPI_CHAR, but since sb and rb were allocated
91 as chunk*size*sizeof(int), the buffers are large enough */
92 status = MPI_Alltoall(sb,sizes[j],MPI_INT,rb,sizes[j],MPI_INT,
95 /* fputs("Before MPI_Allreduce\n",stdout); */
96 MPI_Allreduce( &status, &gstatus, 1, MPI_INT, MPI_SUM,
99 MPI_Barrier(MPI_COMM_WORLD );
100 /* fputs("After MPI_Allreduce\n",stdout); */
101 if (rank == 0 && gstatus != 0) endstatus ++;
108 if (endstatus == 0) printf( " No Errors\n" );
110 printf("all_to_all returned %d erros\n",endstatus);
114 return(EXIT_SUCCESS);