Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid into...
[simgrid.git] / examples / smpi / NAS / MPI_dummy / mpi_dummy.c
1 #include <stdlib.h>
2 #include "mpi.h"
3 #include "wtime.h"
4
5 void  mpi_error( void )
6 {
7     printf( "mpi_error called\n" );
8     abort();
9 }
10
11
12
13
14 int   MPI_Irecv( void         *buf,
15                  int          count,
16                  MPI_Datatype datatype,
17                  int          source,
18                  int          tag,
19                  MPI_Comm     comm,
20                  MPI_Request  *request )
21 {
22     mpi_error();
23     return( MPI_ERR_OTHER );
24 }
25
26
27
28
29 int   MPI_Recv( void         *buf,
30                 int          count,
31                 MPI_Datatype datatype,
32                 int          source,
33                 int          tag,
34                 MPI_Comm     comm,
35                 MPI_Status   *status )
36 {
37     mpi_error();
38     return( MPI_ERR_OTHER );
39 }
40
41
42
43
44 int   MPI_Send( void         *buf,
45                 int          count,
46                 MPI_Datatype datatype,
47                 int          dest,
48                 int          tag,
49                 MPI_Comm     comm )
50 {
51     mpi_error();
52     return( MPI_ERR_OTHER );
53 }
54
55
56
57
58 int   MPI_Wait( MPI_Request *request,
59                 MPI_Status  *status )
60 {
61     mpi_error();
62     return( MPI_ERR_OTHER );
63 }
64
65
66
67
68 int   MPI_Init( int  *argc,
69                 char ***argv )
70 {
71     return( MPI_SUCCESS );
72 }
73
74
75
76
77 int   MPI_Comm_rank( MPI_Comm comm, 
78                      int      *rank )
79 {
80     *rank = 0;
81     return( MPI_SUCCESS );
82 }
83
84
85
86
87 int   MPI_Comm_size( MPI_Comm comm, 
88                      int      *size )
89 {
90     *size = 1;
91     return( MPI_SUCCESS );
92 }
93
94
95
96
97 double MPI_Wtime( void )
98 {
99     void wtime();
100
101     double t;
102     wtime( &t );
103     return( t );
104 }
105
106
107
108
109 int  MPI_Barrier( MPI_Comm comm )
110 {
111     return( MPI_SUCCESS );
112 }
113
114
115
116
117 int  MPI_Finalize( void )
118 {
119     return( MPI_SUCCESS );
120 }
121
122
123
124
125 int  MPI_Allreduce( void         *sendbuf,
126                     void         *recvbuf,
127                     int          nitems,
128                     MPI_Datatype type,
129                     MPI_Op       op,
130                     MPI_Comm     comm )
131 {
132     int i;
133     if( type == MPI_INT )
134     {
135         int *pd_sendbuf, *pd_recvbuf;
136         pd_sendbuf = (int *) sendbuf;    
137         pd_recvbuf = (int *) recvbuf;    
138         for( i=0; i<nitems; i++ )
139             *(pd_recvbuf+i) = *(pd_sendbuf+i);
140     }
141     if( type == MPI_LONG )
142     {
143         long *pd_sendbuf, *pd_recvbuf;
144         pd_sendbuf = (long *) sendbuf;    
145         pd_recvbuf = (long *) recvbuf;    
146         for( i=0; i<nitems; i++ )
147             *(pd_recvbuf+i) = *(pd_sendbuf+i);
148     }
149     if( type == MPI_DOUBLE )
150     {
151         double *pd_sendbuf, *pd_recvbuf;
152         pd_sendbuf = (double *) sendbuf;    
153         pd_recvbuf = (double *) recvbuf;    
154         for( i=0; i<nitems; i++ )
155             *(pd_recvbuf+i) = *(pd_sendbuf+i);
156     }
157     return( MPI_SUCCESS );
158 }
159   
160
161
162
163 int  MPI_Reduce( void         *sendbuf,
164                  void         *recvbuf,
165                  int          nitems,
166                  MPI_Datatype type,
167                  MPI_Op       op,
168                  int          root,
169                  MPI_Comm     comm )
170 {
171     int i;
172     if( type == MPI_INT )
173     {
174         int *pi_sendbuf, *pi_recvbuf;
175         pi_sendbuf = (int *) sendbuf;    
176         pi_recvbuf = (int *) recvbuf;    
177         for( i=0; i<nitems; i++ )
178             *(pi_recvbuf+i) = *(pi_sendbuf+i);
179     }
180     if( type == MPI_LONG )
181     {
182         long *pi_sendbuf, *pi_recvbuf;
183         pi_sendbuf = (long *) sendbuf;    
184         pi_recvbuf = (long *) recvbuf;    
185         for( i=0; i<nitems; i++ )
186             *(pi_recvbuf+i) = *(pi_sendbuf+i);
187     }
188     if( type == MPI_DOUBLE )
189     {
190         double *pd_sendbuf, *pd_recvbuf;
191         pd_sendbuf = (double *) sendbuf;    
192         pd_recvbuf = (double *) recvbuf;    
193         for( i=0; i<nitems; i++ )
194             *(pd_recvbuf+i) = *(pd_sendbuf+i);
195     }
196     return( MPI_SUCCESS );
197 }
198   
199
200
201
202 int  MPI_Alltoall( void         *sendbuf,
203                    int          sendcount,
204                    MPI_Datatype sendtype,
205                    void         *recvbuf,
206                    int          recvcount,
207                    MPI_Datatype recvtype,
208                    MPI_Comm     comm )
209 {
210     int i;
211     if( recvtype == MPI_INT )
212     {
213         int *pd_sendbuf, *pd_recvbuf;
214         pd_sendbuf = (int *) sendbuf;    
215         pd_recvbuf = (int *) recvbuf;    
216         for( i=0; i<sendcount; i++ )
217             *(pd_recvbuf+i) = *(pd_sendbuf+i);
218     }
219     if( recvtype == MPI_LONG )
220     {
221         long *pd_sendbuf, *pd_recvbuf;
222         pd_sendbuf = (long *) sendbuf;    
223         pd_recvbuf = (long *) recvbuf;    
224         for( i=0; i<sendcount; i++ )
225             *(pd_recvbuf+i) = *(pd_sendbuf+i);
226     }
227     return( MPI_SUCCESS );
228 }
229   
230
231
232
233 int  MPI_Alltoallv( void         *sendbuf,
234                     int          *sendcounts,
235                     int          *senddispl,
236                     MPI_Datatype sendtype,
237                     void         *recvbuf,
238                     int          *recvcounts,
239                     int          *recvdispl,
240                     MPI_Datatype recvtype,
241                     MPI_Comm     comm )
242 {
243     int i;
244     if( recvtype == MPI_INT )
245     {
246         int *pd_sendbuf, *pd_recvbuf;
247         pd_sendbuf = (int *) sendbuf;    
248         pd_recvbuf = (int *) recvbuf;    
249         for( i=0; i<sendcounts[0]; i++ )
250             *(pd_recvbuf+i+recvdispl[0]) = *(pd_sendbuf+i+senddispl[0]);
251     }
252     if( recvtype == MPI_LONG )
253     {
254         long *pd_sendbuf, *pd_recvbuf;
255         pd_sendbuf = (long *) sendbuf;    
256         pd_recvbuf = (long *) recvbuf;    
257         for( i=0; i<sendcounts[0]; i++ )
258             *(pd_recvbuf+i+recvdispl[0]) = *(pd_sendbuf+i+senddispl[0]);
259     }
260     return( MPI_SUCCESS );
261 }
262   
263
264
265