root/test/memchecker/irecv_init_check.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /*
   2  * Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
   3  *                         University of Stuttgart.  All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   9  */
  10 
  11 #include <stdio.h>
  12 #include "mpi.h"
  13 
  14 int main( int argc, char *argv[] )
  15 {
  16     int rank, size;
  17     int send_value[10],recv_value[10];
  18     int i;
  19     MPI_Status status;
  20     MPI_Request send_request;
  21     MPI_Request recv_request;
  22 
  23     MPI_Init( &argc, &argv );
  24 
  25     MPI_Comm_rank( MPI_COMM_WORLD, &rank );
  26     MPI_Comm_size( MPI_COMM_WORLD, &size );
  27 
  28     for(i=0; i < 10; i++) {
  29         send_value[i] = i;
  30         printf("\n%d:%d",i,send_value[i]);
  31     }
  32 
  33     /*
  34      * Only the last value of receive buffer is
  35      * initialized.
  36      */
  37     recv_value[9] = 100;
  38 
  39     if (size != 2) {
  40         fprintf (stderr, "Error: Need 2 processes\n");
  41         MPI_Finalize ();
  42     }
  43 
  44     /*
  45      * Now we only send 9 ints, but expect to receive 10.
  46      * Perfectly valid, but the receiver (in strict mode?) should not
  47      * depend on the data.
  48      */
  49     MPI_Isend (&send_value, 9, MPI_INT,
  50                (rank + 1) % size, 4711, MPI_COMM_WORLD, &send_request);
  51     MPI_Irecv (&recv_value, 10, MPI_INT,
  52                (rank + size - 1) % size, 4711, MPI_COMM_WORLD, &recv_request);
  53 
  54     MPI_Wait (&send_request, &status);
  55     MPI_Wait (&recv_request, &status);
  56 
  57     /*
  58      * In strict mode, this should return an error.
  59      */
  60     printf("\nError in strict mode: buf[9]:%d", recv_value[9]);
  61 
  62     MPI_Finalize ();
  63     return 0;
  64 }
  65 

/* [<][>][^][v][top][bottom][index][help] */