AdjoinableMPI
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
support.c
Go to the documentation of this file.
1 /*
2 ##########################################################
3 # This file is part of the AdjoinableMPI library #
4 # released under the MIT License. #
5 # The full COPYRIGHT notice can be found in the top #
6 # level directory of the AdjoinableMPI distribution. #
7 ##########################################################
8 */
9 #include <stdlib.h>
10 #include <assert.h>
11 #include <stdio.h>
12 #include "ampi/adTool/support.h"
13 
15 
16 int AMPI_Init_NT(int* argc,
17  char*** argv) {
18  int rc;
19  rc=MPI_Init(argc,
20  argv);
85 #ifdef AMPI_FORTRANCOMPATIBLE
86  ourADTOOL_AMPI_FPCollection.fortransetuptypes__fp=&adtool_ampi_fortransetuptypes_;
87  ourADTOOL_AMPI_FPCollection.fortrancleanuptypes__fp=&adtool_ampi_fortrancleanuptypes_;
88 #endif
92  return rc;
93 }
94 
96  int count,
97  MPI_Datatype datatype,
98  int root,
99  MPI_Comm comm) {
100 }
101 
103  int* count,
104  MPI_Datatype* datatype,
105  int* root,
106  MPI_Comm* comm,
107  void **idx) {
108 }
109 
111  int count) {
112 }
113 
115  int* count) {
116 }
117 
119  void* rbuf,
120  void* resultData,
121  int pushResultData, /* push resultData if true */
122  int count,
123  MPI_Datatype datatype,
124  MPI_Op op,
125  int root,
126  MPI_Comm comm) {
127 }
129  MPI_Datatype* datatype) {
130 }
131 
132 void ADTOOL_AMPI_popReduceInfo(void** sbuf,
133  void** rbuf,
134  void** prevData,
135  void** resultData,
136  int* count,
137  MPI_Op* op,
138  int* root,
139  MPI_Comm* comm,
140  void **idx) {
141 }
142 
144  int count,
145  MPI_Datatype datatype,
146  int src,
147  int tag,
149  MPI_Comm comm) {
150 }
151 
153  int* count,
154  MPI_Datatype* datatype,
155  int* src,
156  int* tag,
158  MPI_Comm* comm,
159  void **idx) {
160 }
161 
163  int count,
164  MPI_Datatype datatype,
165  int src,
166  int tag,
168  MPI_Comm comm) {
169 }
170 
172  int* count,
173  MPI_Datatype* datatype,
174  int* src,
175  int* tag,
177  MPI_Comm* comm,
178  void **idx) {
179 }
180 
181 void ADTOOL_AMPI_pushGSinfo(int commSizeForRootOrNull,
182  void *rbuf,
183  int rcnt,
184  MPI_Datatype rtype,
185  void *buf,
186  int count,
187  MPI_Datatype type,
188  int root,
189  MPI_Comm comm) {
190 }
191 
192 void ADTOOL_AMPI_popGScommSizeForRootOrNull(int *commSizeForRootOrNull) {
193 }
194 
195 void ADTOOL_AMPI_popGSinfo(int commSizeForRootOrNull,
196  void **rbuf,
197  int *rcnt,
198  MPI_Datatype *rtype,
199  void **buf,
200  int *count,
201  MPI_Datatype *type,
202  int *root,
203  MPI_Comm *comm) {
204 }
205 
206 void ADTOOL_AMPI_pushGSVinfo(int commSizeForRootOrNull,
207  void *rbuf,
208  int *rcnts,
209  int *displs,
210  MPI_Datatype rtype,
211  void *buf,
212  int count,
213  MPI_Datatype type,
214  int root,
215  MPI_Comm comm) {
216 }
217 
218 void ADTOOL_AMPI_popGSVinfo(int commSizeForRootOrNull,
219  void **rbuf,
220  int *rcnts,
221  int *displs,
222  MPI_Datatype *rtype,
223  void **buf,
224  int *count,
225  MPI_Datatype *type,
226  int *root,
227  MPI_Comm *comm) {
228 }
229 
231 }
232 
234 }
235 
236 void ADTOOL_AMPI_push_AMPI_Request(struct AMPI_Request_S *ampiRequest) {
237 }
238 
239 void ADTOOL_AMPI_pop_AMPI_Request(struct AMPI_Request_S *ampiRequest) {
240 }
241 
243 }
244 
246 }
247 
248 void ADTOOL_AMPI_push_request(MPI_Request request) {
249 }
250 
251 MPI_Request ADTOOL_AMPI_pop_request() {
252  return 0;
253 }
254 
256 }
257 
259 }
260 
261 void ADTOOL_AMPI_push_comm(MPI_Comm comm) {
262 }
263 
265  return 0;
266 }
267 
268 void* ADTOOL_AMPI_rawData(void* activeData, int *size) {
269  return activeData;
270 }
271 
272 void* ADTOOL_AMPI_rawDataV(void* activeData, int commSize, int *counts, int* displs) {
273  return activeData;
274 }
275 void * ADTOOL_AMPI_packDType(void* indata, void* outdata, int count, int idx) {
276  return indata;
277 }
278 void * ADTOOL_AMPI_unpackDType(void* indata, void* outdata, int count, int idx) {
279  return indata;
280 }
281 
282 void * ADTOOL_AMPI_rawAdjointData(void* activeData) {
283  return activeData;
284 }
285 
287  void* buf) {
288 }
289 
290 void ADTOOL_AMPI_Turn(void* buf, void* adjointBuf) {}
291 
293  void* buf) {
294  /* do nothing */
295 }
296 
298  MPI_Datatype datatype) {
299 }
300 
301 void ADTOOL_AMPI_setAdjointCount(struct AMPI_Request_S *ampiRequest) {
302  /* for now we keep the count as is but for example in vector mode one would have to multiply by vector length */
303 }
305  ADTOOL_AMPI_setAdjointCount(ampiRequest);
306  ampiRequest->adjointTempBuf =
308  ampiRequest->datatype,
309  ampiRequest->comm) ;
310  assert(ampiRequest->adjointTempBuf);
311 }
312 
314 }
315 
317  ADTOOL_AMPI_setWinAdjointCount(winRequest);
318  assert(winRequest->adjointTempBuf);
319 }
320 
322 }
323 
324 void* ADTOOL_AMPI_allocateTempBuf(int adjointCount, MPI_Datatype datatype, MPI_Comm comm) {
325  size_t s=0;
326  int dt_idx = derivedTypeIdx(datatype);
327  if (datatype==MPI_DOUBLE)
328  s=sizeof(double);
329  else if (datatype==MPI_FLOAT)
330  s=sizeof(float);
331  else if (isDerivedType(dt_idx))
332  s = getDTypeData()->p_extents[dt_idx];
333  else
334  MPI_Abort(comm, MPI_ERR_TYPE);
335  return (void*)malloc(adjointCount*s);
336 }
337 
338 void ADTOOL_AMPI_releaseAdjointTempBuf(void *tempBuf) {
339  free(tempBuf) ;
340 }
341 
343  MPI_Datatype datatype,
344  MPI_Comm comm) {
345  void* ptr = NULL;
346  if (datatype==MPI_DOUBLE)
347  ptr = malloc(count*sizeof(MPI_DOUBLE));
348  else if (datatype==MPI_FLOAT)
349  ptr = malloc(count*sizeof(MPI_FLOAT));
350  assert(ptr);
351  return ptr;
352 }
353 
355  int count,
356  MPI_Datatype datatype) {
357  free(buf);
358 }
359 
360 void * ADTOOL_AMPI_copyActiveBuf(void* source,
361  void* target,
362  int count,
363  MPI_Datatype datatype,
364  MPI_Comm comm) {
365  return source;
366 }
367 
369 void ADTOOL_AMPI_adjointMultiply(int count, MPI_Datatype datatype, MPI_Comm comm,
370  void *source, void *adjointSource,
371  void* target, void* adjointTarget) {
372 }
373 
375 void ADTOOL_AMPI_adjointMin(int count, MPI_Datatype datatype, MPI_Comm comm,
376  void *source, void *adjointSource,
377  void* target, void* adjointTarget) {
378 }
379 
381 void ADTOOL_AMPI_adjointMax(int count, MPI_Datatype datatype, MPI_Comm comm,
382  void *source, void *adjointSource,
383  void* target, void* adjointTarget) {
384 }
385 
386 void ADTOOL_AMPI_incrementAdjoint(int adjointCount, MPI_Datatype datatype, MPI_Comm comm, void* target, void *source, void *idx) {
387 }
388 
389 void ADTOOL_AMPI_multiplyAdjoint(int adjointCount, MPI_Datatype datatype, MPI_Comm comm, void* target, void *source, void *idx) {
390 }
391 
392 void ADTOOL_AMPI_divideAdjoint(int adjointCount, MPI_Datatype datatype, MPI_Comm comm, void* target, void *source, void *idx) {
393 }
394 
395 void ADTOOL_AMPI_equalAdjoints(int adjointCount, MPI_Datatype datatype, MPI_Comm comm, void* target, void *source1, void *source2, void *idx) {
396 }
397 
398 void ADTOOL_AMPI_nullifyAdjoint(int adjointCount, MPI_Datatype datatype, MPI_Comm comm, void* target) {
399 }
400 
404 void ADTOOL_AMPI_pushBuffer(int count, MPI_Datatype datatype, MPI_Comm comm,
405  void* buffer) {
406  printf("Please provide implementation of ADTOOL_AMPI_pushBuffer()\n") ;
407 }
408 
412 void ADTOOL_AMPI_popBuffer(int count, MPI_Datatype datatype, MPI_Comm comm,
413  void* buffer) {
414  printf("Please provide implementation of ADTOOL_AMPI_popBuffer()\n") ;
415 }
416 
417 void ADTOOL_AMPI_writeData(void *buf,int *count) { }
418 
419 void ADTOOL_AMPI_writeDataV(void* activeData, int *counts, int* displs) {}
420 
422  return AMPI_PASSIVE;
423 }
424 
425 void *ADTOOL_AMPI_createWinMap(void *active_buf, MPI_Aint size){
426  return NULL;
427 }
428 
429 void ADTOOL_AMPI_writeWinData(void *map, void *buf, MPI_Aint size){
430 }
431 
432 MPI_Aint ADTOOL_AMPI_getWinSize(MPI_Aint size) {
433  return 0;
434 }
435 
436 #ifdef AMPI_FORTRANCOMPATIBLE
437  void adtool_ampi_fortransetuptypes_(MPI_Fint* adouble,MPI_Fint* areal) {
438  }
439 #endif
440 
442 #ifdef AMPI_FORTRANCOMPATIBLE
443  MPI_Fint adouble;
444  MPI_Fint areal;
445 #endif
446  /* Change AMPI_ADOUBLE to something else? Need AMPI_ADOUBLE!=MPI_DOUBLE for derived types. */
447  AMPI_ADOUBLE=MPI_DOUBLE;
448  AMPI_AFLOAT=MPI_FLOAT;
449 #ifdef AMPI_FORTRANCOMPATIBLE
450  adtool_ampi_fortransetuptypes_(&adouble, &areal);
451  AMPI_ADOUBLE_PRECISION=MPI_Type_f2c(adouble);
452  AMPI_AREAL=MPI_Type_f2c(areal);
453 #endif
454 }
455 
456 #ifdef AMPI_FORTRANCOMPATIBLE
457  void adtool_ampi_fortrancleanuptypes_(MPI_Fint* adouble,MPI_Fint* areal) {
458  }
459 #endif
460 
462 }
463 
464 MPI_Datatype ADTOOL_AMPI_FW_rawType(MPI_Datatype datatype) {
465  return datatype;
466 }
467 
468 MPI_Datatype ADTOOL_AMPI_BW_rawType(MPI_Datatype datatype) {
469  return datatype;
470 }