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
48 three different sizes. This is the code that handles these cases:
50 if (sendsize < 200 && size > 12) {
52 smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype,
53 recvbuf, recvcount, recvtype,
55 } else if (sendsize < 3000) {
57 smpi_coll_tuned_alltoall_basic_linear(sendbuf, sendcount,
59 recvcount, recvtype, comm);
62 smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype,
63 recvbuf, recvcount, recvtype,
69 int sizes [3] ={ 4096, 64, 32};
70 for ( j=0 ; j < 3 ; j++ ) {
71 sb = (int *)malloc(size*sizes[j]*sizeof(int));
73 perror( "can't allocate send buffer" );
74 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
76 rb = (int *)malloc(size*sizes[j]*sizeof(int));
78 perror( "can't allocate recv buffer");
80 MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
82 for ( i=0 ; i < size*sizes[j] ; ++i ) {
87 /* fputs("Before MPI_Alltoall\n",stdout); */
88 MPI_Barrier(MPI_COMM_WORLD );
89 /* This should really send MPI_CHAR, but since sb and rb were allocated
90 as chunk*size*sizeof(int), the buffers are large enough */
91 status = MPI_Alltoall(sb,sizes[j],MPI_INT,rb,sizes[j],MPI_INT,
94 /* fputs("Before MPI_Allreduce\n",stdout); */
95 MPI_Allreduce( &status, &gstatus, 1, MPI_INT, MPI_SUM,
98 MPI_Barrier(MPI_COMM_WORLD );
99 /* fputs("After MPI_Allreduce\n",stdout); */
100 if (rank == 0 && gstatus != 0) endstatus ++;
107 if (endstatus == 0) printf( " No Errors\n" );
109 printf("all_to_all returned %d erros\n",endstatus);
113 return(EXIT_SUCCESS);