-
- while (MTestGetIntracommGeneral( &comm, 2, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- if (size < 3) continue;
-
- /* Create and load the arguments to alltoallv */
- sendcounts = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
- rdispls = (int *)malloc( size * sizeof(int) );
- sdispls = (int *)malloc( size * sizeof(int) );
- if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
- fprintf( stderr, "Could not allocate arg items!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Get the neighbors */
- left = (rank - 1 + size) % size;
- right = (rank + 1) % size;
-
- /* Set the defaults */
- for (i=0; i<size; i++) {
- sendcounts[i] = 0;
- recvcounts[i] = 0;
- rdispls[i] = 0;
- sdispls[i] = 0;
- }
-
- for (length=1; length < 66000; length = length*2+1 ) {
- /* Get the buffers */
- sbuf = (int *)malloc( 2 * length * sizeof(int) );
- rbuf = (int *)malloc( 2 * length * sizeof(int) );
- if (!sbuf || !rbuf) {
- fprintf( stderr, "Could not allocate buffers!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Load up the buffers */
- for (i=0; i<length; i++) {
- sbuf[i] = i + 100000*rank;
- sbuf[i+length] = i + 100000*rank;
- rbuf[i] = -i;
- rbuf[i+length] = -i-length;
- }
- sendcounts[left] = length;
- sendcounts[right] = length;
- recvcounts[left] = length;
- recvcounts[right] = length;
- rdispls[left] = 0;
- rdispls[right] = length;
- sdispls[left] = 0;
- sdispls[right] = length;
-
- MPI_Alltoallv( sbuf, sendcounts, sdispls, MPI_INT,
- rbuf, recvcounts, rdispls, MPI_INT, comm );
-
- /* Check rbuf */
- p = rbuf; /* left */
-
- for (i=0; i<length; i++) {
- if (p[i] != i + 100000 * left) {
- if (err < 10) {
- fprintf( stderr, "[%d from %d] got %d expected %d for %dth\n",
- rank, left, p[i], i + 100000 * left, i );
- }
- err++;
- }
- }
-
- p = rbuf + length; /* right */
- for (i=0; i<length; i++) {
- if (p[i] != i + 100000 * right) {
- if (err < 10) {
- fprintf( stderr, "[%d from %d] got %d expected %d for %dth\n",
- rank, right, p[i], i + 100000 * right, i );
- }
- err++;
- }
- }
-
- free( rbuf );
- free( sbuf );
- }
-
- free( sdispls );
- free( rdispls );
- free( recvcounts );
- free( sendcounts );
- MTestFreeComm( &comm );
+
+ while (MTestGetIntracommGeneral(&comm, 2, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+
+ if (size < 3)
+ continue;
+
+ /* Create and load the arguments to alltoallv */
+ sendcounts = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
+ rdispls = (int *) malloc(size * sizeof(int));
+ sdispls = (int *) malloc(size * sizeof(int));
+ if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
+ fprintf(stderr, "Could not allocate arg items!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Get the neighbors */
+ left = (rank - 1 + size) % size;
+ right = (rank + 1) % size;
+
+ /* Set the defaults */
+ for (i = 0; i < size; i++) {
+ sendcounts[i] = 0;
+ recvcounts[i] = 0;
+ rdispls[i] = 0;
+ sdispls[i] = 0;
+ }
+
+ for (length = 1; length < 66000; length = length * 2 + 1) {
+ /* Get the buffers */
+ sbuf = (int *) malloc(2 * length * sizeof(int));
+ rbuf = (int *) malloc(2 * length * sizeof(int));
+ if (!sbuf || !rbuf) {
+ fprintf(stderr, "Could not allocate buffers!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Load up the buffers */
+ for (i = 0; i < length; i++) {
+ sbuf[i] = i + 100000 * rank;
+ sbuf[i + length] = i + 100000 * rank;
+ rbuf[i] = -i;
+ rbuf[i + length] = -i - length;
+ }
+ sendcounts[left] = length;
+ sendcounts[right] = length;
+ recvcounts[left] = length;
+ recvcounts[right] = length;
+ rdispls[left] = 0;
+ rdispls[right] = length;
+ sdispls[left] = 0;
+ sdispls[right] = length;
+
+ MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT,
+ rbuf, recvcounts, rdispls, MPI_INT, comm);
+
+ /* Check rbuf */
+ p = rbuf; /* left */
+
+ for (i = 0; i < length; i++) {
+ if (p[i] != i + 100000 * left) {
+ if (err < 10) {
+ fprintf(stderr, "[%d from %d] got %d expected %d for %dth\n",
+ rank, left, p[i], i + 100000 * left, i);
+ }
+ err++;
+ }
+ }
+
+ p = rbuf + length; /* right */
+ for (i = 0; i < length; i++) {
+ if (p[i] != i + 100000 * right) {
+ if (err < 10) {
+ fprintf(stderr, "[%d from %d] got %d expected %d for %dth\n",
+ rank, right, p[i], i + 100000 * right, i);
+ }
+ err++;
+ }
+ }
+
+ free(rbuf);
+ free(sbuf);
+ }
+
+ free(sdispls);
+ free(rdispls);
+ free(recvcounts);
+ free(sendcounts);
+ MTestFreeComm(&comm);