Logo AND Algorithmique Numérique Distribuée

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