Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
generalize previous change to other MPI predefined globals.
[simgrid.git] / include / smpi / sampi.h
1 /* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SAMPI_H_
7 #define SAMPI_H_
8
9 #define SMPI_NO_OVERRIDE_MALLOC
10 #include <stdlib.h>
11 #include <smpi/smpi.h>
12
13 #define AMPI_CALL(type, name, args)                                                                                    \
14   type _XBT_CONCAT(A, name) args __attribute__((weak));                                                                \
15   type _XBT_CONCAT(AP, name) args;
16
17 #ifndef HAVE_SMPI
18 #undef malloc
19 #undef calloc
20 #undef free
21 // Internally disable these overrides (HAVE_SMPI is only defined when building the library)
22 #define malloc(nbytes) _sampi_malloc(nbytes)
23 #define calloc(n_elm, elm_size) _sampi_calloc((n_elm), (elm_size))
24 #define realloc(ptr, nbytes) _sampi_realloc((ptr), (nbytes))
25 #define free(ptr) _sampi_free(ptr)
26 #endif
27
28 SG_BEGIN_DECL
29
30 XBT_PUBLIC void* _sampi_malloc(size_t size);
31 XBT_PUBLIC void* _sampi_calloc(size_t n_elm, size_t elm_size);
32 XBT_PUBLIC void* _sampi_realloc(void *ptr, size_t size);
33 XBT_PUBLIC void _sampi_free(void* ptr);
34
35 AMPI_CALL(XBT_PUBLIC int, MPI_Iteration_in, (MPI_Comm comm))
36 AMPI_CALL(XBT_PUBLIC int, MPI_Iteration_out, (MPI_Comm comm))
37 AMPI_CALL(XBT_PUBLIC void, MPI_Migrate, (MPI_Comm comm))
38
39 SG_END_DECL
40
41 #endif