Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove few tests which may never finish, and change one that used too much stack...
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / typecreate.c
1 #include <stdio.h>
2 #include "mpi.h"
3 #include "test.h"
4 #include <stdlib.h>
5
6 int main( int argc, char **argv )
7 {
8     int i, n, n_goal = 2048, rc, len;
9     MPI_Datatype *type_array;
10     char msg[MPI_MAX_ERROR_STRING];
11
12     MPI_Init( &argc, &argv );
13     MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
14
15     n = n_goal;
16
17     type_array = (MPI_Datatype *)malloc( n * sizeof(MPI_Datatype) );
18     
19     for (i=0; i<n; i++) {
20         int             blens[2];
21         MPI_Aint        displ[2];
22         MPI_Datatype    types[2];
23
24         blens[0] = 2;
25         blens[1] = 3;
26         displ[0] = 0;
27         displ[1] = (i+2) * sizeof(int);
28         types[0] = MPI_INT;
29         types[1] = MPI_DOUBLE;
30         rc = MPI_Type_struct( 2, blens, displ, types, type_array + i );
31         if (rc) {
32             fprintf( stderr, "Error when creating type number %d\n", i );
33             MPI_Error_string( rc, msg, &len );
34             fprintf( stderr, "%s\n", msg );
35             n = i + 1;
36             break;
37         }
38         rc = MPI_Type_commit( type_array + i );
39         if (rc) {
40             fprintf( stderr, "Error when commiting type number %d\n", i );
41             MPI_Error_string( rc, msg, &len );
42             fprintf( stderr, "%s\n", msg );
43             n = i + 1;
44             break;
45         }
46     }
47     for (i=0; i<n; i++) {
48         rc = MPI_Type_free( type_array + i );
49         if (rc) {
50             fprintf( stderr, "Error when freeing type number %d\n", i );
51             MPI_Error_string( rc, msg, &len );
52             fprintf( stderr, "%s\n", msg );
53             break;
54         }
55     }
56     free( type_array );
57     printf( "Completed test of %d type creations\n", n );
58     if (n != n_goal) {
59         printf (
60 "This MPI implementation limits the number of datatypes that can be created\n\
61 This is allowed by the standard and is not a bug, but is a limit on the\n\
62 implementation\n" );
63     }
64     MPI_Finalize( );
65     return 0;
66 }