~ubuntu-branches/ubuntu/raring/simgrid/raring

« back to all changes in this revision

Viewing changes to teshsuite/smpi/mpich-test/pt2pt/hvec.c

  • Committer: Package Import Robot
  • Author(s): Martin Quinson
  • Date: 2013-01-31 00:24:51 UTC
  • mfrom: (10.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20130131002451-krejhf7w7h24lpsc
Tags: 3.9~rc1-1
* New upstream release: the "Grasgory" release. Major changes:
  - Gras was completely removed from this version.
  - Documentation reorganization to ease browsing it.
  - New default value for the TCP_gamma parameter: 4MiB

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "mpi.h"
 
2
#include "test.h"
 
3
#include <stdio.h>
 
4
 
 
5
/* The original version of this was sent by  
 
6
   empierce@tribble.llnl.gov (Elsie M. Pierce) 
 
7
   I've modified it to fit the automated tests requirements
 
8
 */
 
9
/* Prototypes for picky compilers */
 
10
int iinit ( int *, int, int );
 
11
int ilist1 ( int *, int, int, int );
 
12
void Build_vect ( MPI_Datatype * );
 
13
void Build_ctg ( int, MPI_Datatype *, MPI_Datatype * );
 
14
void Get_d5 ( int );
 
15
 
 
16
int iinit(a, value, l)
 
17
int *a, value, l;
 
18
{
 
19
  int i;
 
20
  
 
21
  for (i=0; i<l; i++)
 
22
    a[i] = value;
 
23
  return(0);
 
24
}
 
25
 
 
26
 
 
27
int ilist1(a, mype, pe_out, l)
 
28
int *a, mype, pe_out, l;
 
29
{
 
30
  int i;
 
31
  
 
32
  if (mype == pe_out){
 
33
    for (i=0; i<l; i++)
 
34
      printf("%d ",a[i]);
 
35
    printf("\n");
 
36
  }
 
37
  return(0);
 
38
}
 
39
 
 
40
 
 
41
void Build_vect(mess_ptr) 
 
42
MPI_Datatype* mess_ptr;
 
43
{
 
44
  int count, bllen, gap, str;
 
45
  
 
46
/*   Define an MPI type with two blocks of 3 integers each, separated */
 
47
/*   by one integer. */
 
48
  count = 2;
 
49
  bllen = 3;
 
50
  gap   = 1;
 
51
  str   = bllen + gap;
 
52
 
 
53
  MPI_Type_vector(count, bllen, str, MPI_INT, mess_ptr);
 
54
  MPI_Type_commit(mess_ptr);
 
55
  
 
56
}
 
57
 
 
58
 
 
59
void   Build_ctg(big_offset,messtyp, messtyp2)
 
60
int big_offset;
 
61
MPI_Datatype *messtyp, *messtyp2;
 
62
{
 
63
  int count;
 
64
  MPI_Aint ext;
 
65
    
 
66
  count=3;
 
67
  MPI_Type_extent(*messtyp, &ext);
 
68
  MPI_Type_hvector(count, 1, ext+big_offset, *messtyp, messtyp2);
 
69
  MPI_Type_commit(messtyp2);
 
70
  /*printf( "pack is:\n" );
 
71
  MPIR_PrintDatatypePack( stdout, 1, *messtyp2, 0, 0 );
 
72
  printf( "unpack is:\n" );
 
73
  MPIR_PrintDatatypeUnpack( stdout, 1, *messtyp2, 0, 0 ); */
 
74
}
 
75
  
 
76
 
 
77
 
 
78
void Get_d5(my_rank)
 
79
int my_rank;
 
80
{
 
81
  MPI_Datatype messtyp, messtyp2;
 
82
  int root=0;
 
83
  int count=1;
 
84
  int big_offset;
 
85
  int intlen;
 
86
#define DL 32
 
87
  
 
88
  int dar[DL];
 
89
     
 
90
  iinit(dar, my_rank, DL);
 
91
  Build_vect(&messtyp);
 
92
  MPI_Bcast(dar, count, messtyp, root, MPI_COMM_WORLD);
 
93
  if (my_rank==1)
 
94
    printf("  0 = Sent, 1 = Not Sent \n%s",
 
95
           "  Vector Type with Gap : \n");
 
96
  ilist1(dar, my_rank, 1, DL);
 
97
 
 
98
  intlen = sizeof(int);
 
99
  for (big_offset = -intlen; big_offset<=2*intlen; 
 
100
       big_offset += intlen){
 
101
    if (my_rank==1)
 
102
     printf("\n Three of above vector types combined, with offset = %i ints\n",
 
103
             big_offset/(int)sizeof(int));
 
104
    iinit(dar, my_rank, DL);
 
105
    Build_ctg(big_offset, &messtyp, &messtyp2);
 
106
    MPI_Bcast(dar, count, messtyp2, root, MPI_COMM_WORLD);
 
107
    MPI_Barrier(MPI_COMM_WORLD);
 
108
    MPI_Type_free(&messtyp2);
 
109
    ilist1(dar, my_rank, 1, DL);
 
110
  }
 
111
  MPI_Type_free( &messtyp );
 
112
}
 
113
 
 
114
 
 
115
 
 
116
int main( int argc, char *argv[]) 
 
117
{
 
118
  int my_rank;
 
119
    
 
120
  MPI_Init (&argc, &argv);
 
121
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
 
122
 
 
123
  Get_d5(my_rank);
 
124
  
 
125
  MPI_Finalize();
 
126
  return 0;
 
127
}