Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check return code, and report errors.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 6 Mar 2013 12:18:39 +0000 (13:18 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 6 Mar 2013 12:31:27 +0000 (13:31 +0100)
Avoids to call MPI_Get_count with an invalid status.

teshsuite/smpi/mpich-test/pt2pt/sndrcvrep.c

index 87b5999..b4955aa 100644 (file)
@@ -50,12 +50,17 @@ int main( int argc, char **argv )
     count   = 0;
     sendtag = 1;
     recvtag = 1;
-    MPI_Sendrecv_replace( buf, count, dtype, dest, 
-                         sendtag, source, recvtag, MPI_COMM_WORLD, &status );
-    MPI_Get_count( &status, dtype, &len );
-    if (len != 0) {
-       errcnt ++;
-       fprintf( stderr, "Computed %d for count, should be %d\n", len, 0 );
+    rc = MPI_Sendrecv_replace( buf, count, dtype, dest,
+                              sendtag, source, recvtag, MPI_COMM_WORLD, &status );
+    if (rc) {
+       errcnt++;
+       fprintf( stderr, "Failed with non-contiguous datatype (error = %d)\n", rc);
+    } else {
+       MPI_Get_count( &status, dtype, &len );
+       if (len != 0) {
+           errcnt ++;
+           fprintf( stderr, "Computed %d for count, should be %d\n", len, 0 );
+       }
     }
     
     MPI_Type_free( &dtype );