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[] )
24 int status, gstatus, endstatus;
26 MPI_Init(&argc,&argv);
27 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
28 MPI_Comm_size(MPI_COMM_WORLD,&size);
30 for ( i=1 ; i < argc ; ++i ) {
31 if ( argv[i][0] != '-' )
35 fprintf(stderr,"Unrecognized argument %s\n",
37 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
43 SMPI addition: we want to test all three alltoall algorithms, thus we use
44 three different sizes. This is the code that handles these cases:
46 if (sendsize < 200 && size > 12) {
48 smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype,
49 recvbuf, recvcount, recvtype,
51 } else if (sendsize < 3000) {
53 smpi_coll_tuned_alltoall_basic_linear(sendbuf, sendcount,
55 recvcount, recvtype, comm);
58 smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype,
59 recvbuf, recvcount, recvtype,
65 int sizes [3] ={ 4096, 64, 32};
66 for ( j=0 ; j < 3 ; j++ ) {
67 sb = (int *)malloc(size*sizes[j]*sizeof(int));
69 perror( "can't allocate send buffer" );
70 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
72 rb = (int *)malloc(size*sizes[j]*sizeof(int));
74 perror( "can't allocate recv buffer");
76 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
78 for ( i=0 ; i < size*sizes[j] ; ++i ) {
83 /* fputs("Before MPI_Alltoall\n",stdout); */
84 MPI_Barrier(MPI_COMM_WORLD );
85 /* This should really send MPI_CHAR, but since sb and rb were allocated
86 as chunk*size*sizeof(int), the buffers are large enough */
87 status = MPI_Alltoall(sb,sizes[j],MPI_INT,rb,sizes[j],MPI_INT,
90 /* fputs("Before MPI_Allreduce\n",stdout); */
91 MPI_Allreduce( &status, &gstatus, 1, MPI_INT, MPI_SUM,
94 MPI_Barrier(MPI_COMM_WORLD );
95 /* fputs("After MPI_Allreduce\n",stdout); */
96 if (rank == 0 && gstatus != 0) endstatus ++;
103 if (endstatus == 0) printf( " No Errors\n" );
105 printf("all_to_all returned %d erros\n",endstatus);
109 return(EXIT_SUCCESS);