Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dc2d81af99561b337e3665c2ea41a6a4134bc813
[simgrid.git] / teshsuite / smpi / mpich-test / coll / bcastbug.c
1 #include "mpi.h"
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include "test.h"
5
6 int main( int argc, char **argv )
7 {
8   char *buf;
9   int rank, size, i;
10   MPI_Request req[10];
11   MPI_Status  stat[10];
12   MPI_Status  status;
13
14   buf = (char *)malloc(32*1024);
15   MPI_Init(&argc, &argv);
16   MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
17   MPI_Comm_size ( MPI_COMM_WORLD, &size );
18
19   if (size > 10) return 1;
20   
21   if (rank == 0) {
22     for ( i = 1; i < size; i++ )
23       MPI_Isend(buf,1024,MPI_BYTE,i,0,MPI_COMM_WORLD,&req[i]);
24     MPI_Waitall(size-1, &req[1], &stat[1]); /* Core dumps here! */
25   }
26   else 
27     MPI_Recv(buf,1024,MPI_BYTE,0,0,MPI_COMM_WORLD,&status);
28
29     Test_Waitforall( );
30   MPI_Finalize();
31   return 0;
32 }
33
34 #if 0
35 int MPIND_Waitall(count, array_of_requests, array_of_statuses )
36 int         count;
37 MPI_Request array_of_requests[];
38 MPI_Status  array_of_statuses[];
39 {
40   int i;
41   MPIR_BOOL completed;
42   
43   for (i = 0; i < count; i++) {
44     if (!array_of_requests[i]) continue;
45     MPID_complete_send(&array_of_requests[i]->shandle, 
46                        &(array_of_statuses[i]) );
47     
48     MPIND_Request_free( &array_of_requests[i] ); /* Core dumps here! */
49     array_of_requests[i]    = NULL;
50   }
51   return MPI_SUCCESS;
52 }
53
54
55 #define MPID_ND_free_send_handle( a )  if ((a)->buffer) {FREE((a)->buffer);}
56
57 int MPIND_Request_free( request )
58 MPI_Request *request;
59 {
60   int errno = MPI_SUCCESS;
61  
62   printf("Should be core dumping here (buffer = %d)...\n",
63          (&((*request)->shandle.dev_shandle))->buffer);
64   MPID_ND_free_send_handle(&((*request)->shandle.dev_shandle));
65   printf("and not reaching here!\n");
66   SBfree( MPIR_shandles, *request );
67
68   return MPI_SUCCESS;
69 }
70 #endif