#ifndef SMPI_H
#define SMPI_H
#include <unistd.h>
#include <sys/time.h>
#if _POSIX_TIMERS
#include <time.h>
#endif
#include <stddef.h>
#ifdef _WIN32
#define MPI_CALL(type,name,args) \
type name args; \
type P##name args
#else
#define MPI_CALL(type,name,args) \
type name args __attribute__((weak)); \
type P##name args
#endif
#define MPI_THREAD_SINGLE 0
#define MPI_THREAD_FUNNELED 1
#define MPI_THREAD_SERIALIZED 2
#define MPI_THREAD_MULTIPLE 3
#define MPI_MAX_PROCESSOR_NAME 100
#define MPI_MAX_NAME_STRING 100
#define MPI_MAX_ERROR_STRING 100
#define MPI_MAX_DATAREP_STRIN 100
#define MPI_MAX_INFO_KEY 100
#define MPI_MAX_INFO_VAL 100
#define MPI_MAX_OBJECT_NAME 100
#define MPI_MAX_PORT_NAME 100
#define MPI_MAX_LIBRARY_VERSION_STRING 100
#define SMPI_RAND_SEED 5
#define MPI_ANY_SOURCE -555
#define MPI_BOTTOM (void *)-111
#define MPI_PROC_NULL -666
#define MPI_ANY_TAG -444
#define MPI_UNDEFINED -333
#define MPI_IN_PLACE (void *)-222
#define MPI_SUCCESS 0
#define MPI_ERR_COMM 1
#define MPI_ERR_ARG 2
#define MPI_ERR_TYPE 3
#define MPI_ERR_REQUEST 4
#define MPI_ERR_INTERN 5
#define MPI_ERR_COUNT 6
#define MPI_ERR_RANK 7
#define MPI_ERR_TAG 8
#define MPI_ERR_TRUNCATE 9
#define MPI_ERR_GROUP 10
#define MPI_ERR_OP 11
#define MPI_ERR_OTHER 12
#define MPI_ERR_IN_STATUS 13
#define MPI_ERR_PENDING 14
#define MPI_ERR_BUFFER 15
#define MPI_ERR_NAME 16
#define MPI_ERR_DIMS 17
#define MPI_ERR_TOPOLOGY 18
#define MPI_ERR_NO_MEM 19
#define MPI_ERR_WIN 20
#define MPI_ERR_INFO_VALUE 21
#define MPI_ERR_INFO_KEY 22
#define MPI_ERR_INFO_NOKEY 23
#define MPI_ERR_ROOT 24
#define MPI_ERR_UNKNOWN 25
#define MPI_ERR_KEYVAL 26
#define MPI_ERR_BASE 27
#define MPI_ERR_SPAWN 28
#define MPI_ERR_PORT 29
#define MPI_ERR_SERVICE 30
#define MPI_ERR_SIZE 31
#define MPI_ERR_DISP 32
#define MPI_ERR_INFO 33
#define MPI_ERR_LOCKTYPE 34
#define MPI_ERR_ASSERT 35
#define MPI_RMA_CONFLICT 36
#define MPI_RMA_SYNC 37
#define MPI_ERR_FILE 38
#define MPI_ERR_NOT_SAME 39
#define MPI_ERR_AMODE 40
#define MPI_ERR_UNSUPPORTED_DATAREP 41
#define MPI_ERR_UNSUPPORTED_OPERATION 42
#define MPI_ERR_NO_SUCH_FILE 43
#define MPI_ERR_FILE_EXISTS 44
#define MPI_ERR_BAD_FILE 45
#define MPI_ERR_ACCESS 46
#define MPI_ERR_NO_SPACE 47
#define MPI_ERR_QUOTA 48
#define MPI_ERR_READ_ONLY 49
#define MPI_ERR_FILE_IN_USE 50
#define MPI_ERR_DUP_DATAREP 51
#define MPI_ERR_CONVERSION 52
#define MPI_ERR_IO 53
#define MPI_ERR_RMA_ATTACH 54
#define MPI_ERR_RMA_CONFLICT 55
#define MPI_ERR_RMA_RANGE 56
#define MPI_ERR_RMA_SHARED 57
#define MPI_ERR_RMA_SYNC 58
#define MPI_ERR_RMA_FLAVOR 59
#define MPI_T_ERR_CANNOT_INIT 60
#define MPI_T_ERR_NOT_INITIALIZED 61
#define MPI_T_ERR_MEMORY 62
#define MPI_T_ERR_INVALID_INDEX 63
#define MPI_T_ERR_INVALID_ITEM 64
#define MPI_T_ERR_INVALID_SESSION 65
#define MPI_T_ERR_INVALID_HANDLE 66
#define MPI_T_ERR_OUT_OF_HANDLES 67
#define MPI_T_ERR_OUT_OF_SESSIONS 68
#define MPI_T_ERR_CVAR_SET_NOT_NOW 69
#define MPI_T_ERR_CVAR_SET_NEVER 70
#define MPI_T_ERR_PVAR_NO_WRITE 71
#define MPI_T_ERR_PVAR_NO_STARTSTOP 72
#define MPI_T_ERR_PVAR_NO_ATOMIC 73
#define MPI_ERRCODES_IGNORE (int *)0
#define MPI_IDENT 0
#define MPI_SIMILAR 1
#define MPI_UNEQUAL 2
#define MPI_CONGRUENT 3
#define MPI_BSEND_OVERHEAD 0
#define MPI_IO -1
#define MPI_HOST -2
#define MPI_WTIME_IS_GLOBAL -3
#define MPI_APPNUM -4
#define MPI_TAG_UB -5
#define MPI_TAG_LB -6
#define MPI_UNIVERSE_SIZE -7
#define MPI_LASTUSEDCODE -8
#define MPI_MODE_NOSTORE 0x1
#define MPI_MODE_NOPUT 0x2
#define MPI_MODE_NOPRECEDE 0x4
#define MPI_MODE_NOSUCCEED 0x8
#define MPI_MODE_NOCHECK 0x10
#define MPI_KEYVAL_INVALID 0
#define MPI_NULL_COPY_FN NULL
#define MPI_NULL_DELETE_FN NULL
#define MPI_ERR_LASTCODE 74
#define MPI_CXX_BOOL MPI_DATATYPE_NULL
#define MPI_CXX_FLOAT_COMPLEX MPI_DATATYPE_NULL
#define MPI_CXX_DOUBLE_COMPLEX MPI_DATATYPE_NULL
#define MPI_CXX_LONG_DOUBLE_COMPLEX MPI_DATATYPE_NULL
#define MPI_DISTRIBUTE_BLOCK 0
#define MPI_DISTRIBUTE_NONE 1
#define MPI_DISTRIBUTE_CYCLIC 2
#define MPI_DISTRIBUTE_DFLT_DARG 3
#define MPI_ORDER_C 1
#define MPI_ORDER_FORTRAN 0
#define MPI_TYPECLASS_REAL 0
#define MPI_TYPECLASS_INTEGER 1
#define MPI_TYPECLASS_COMPLEX 2
#define MPI_ROOT 0
#define MPI_INFO_NULL ((MPI_Info)NULL)
#define MPI_COMM_TYPE_SHARED 1
#define MPI_WIN_NULL ((MPI_Win)NULL)
#define MPI_VERSION 2
#define MPI_SUBVERSION 2
#define MPI_UNWEIGHTED (int *)0
#define MPI_ARGV_NULL (char **)0
#define MPI_ARGVS_NULL (char ***)0
#define MPI_LOCK_EXCLUSIVE 1
#define MPI_LOCK_SHARED 2
#define MPI_MODE_RDONLY 2
#define MPI_MODE_RDWR 8
#define MPI_MODE_WRONLY 4
#define MPI_MODE_CREATE 1
#define MPI_MODE_EXCL 64
#define MPI_MODE_DELETE_ON_CLOSE 16
#define MPI_MODE_UNIQUE_OPEN 32
#define MPI_MODE_APPEND 128
#define MPI_MODE_SEQUENTIAL 256
#define MPI_FILE_NULL ((MPI_File) 0)
#define MPI_DISPLACEMENT_CURRENT -54278278
#define MPI_SEEK_SET 600
#define MPI_SEEK_CUR 602
#define MPI_SEEK_END 604
#define MPI_MAX_DATAREP_STRING 128
#define MPI_WIN_BASE -1
#define MPI_WIN_SIZE -2
#define MPI_WIN_DISP_UNIT -3
struct s_MPI_File;
typedef struct {
int MPI_SOURCE;
int MPI_TAG;
int MPI_ERROR;
#define MPI_STATUS_IGNORE ((MPI_Status*)NULL)
#define MPI_STATUSES_IGNORE ((MPI_Status*)NULL)
#define MPI_DATATYPE_NULL ((const MPI_Datatype)NULL)
#define MPI_LONG_LONG_INT MPI_LONG_LONG
#define MPI_C_COMPLEX MPI_C_FLOAT_COMPLEX
#define MPI_Count int
#define MPI_COUNT MPI_INT
#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
#define MPI_INTEGER MPI_INT
#define MPI_2INTEGER MPI_2INT
#define MPI_LOGICAL MPI_INT
#else
#define MPI_INTEGER MPI_LONG
#define MPI_2INTEGER MPI_2LONG
#define MPI_LOGICAL MPI_LONG
#endif
#define MPI_Fint int
#define MPI_COMPLEX MPI_C_FLOAT_COMPLEX
#define MPI_DOUBLE_COMPLEX MPI_C_DOUBLE_COMPLEX
#define MPI_LOGICAL1 MPI_UINT8_T
#define MPI_LOGICAL2 MPI_UINT16_T
#define MPI_LOGICAL4 MPI_UINT32_T
#define MPI_LOGICAL8 MPI_UINT64_T
#define MPI_2REAL MPI_2FLOAT
#define MPI_CHARACTER MPI_CHAR
#define MPI_DOUBLE_PRECISION MPI_DOUBLE
#define MPI_2DOUBLE_PRECISION MPI_2DOUBLE
#define MPI_OP_NULL ((MPI_Op)NULL)
#define MPI_GROUP_NULL ((MPI_Group)NULL)
#define MPI_COMM_NULL ((MPI_Comm)NULL)
#define MPI_COMM_SELF smpi_process_comm_self()
#define MPIO_Request MPI_Request
#define MPI_REQUEST_NULL ((MPI_Request)NULL)
#define MPI_FORTRAN_REQUEST_NULL -1
void* attribute_val_out,
int*
flag);
#define MPI_Comm_copy_attr_function MPI_Copy_function
#define MPI_Comm_delete_attr_function MPI_Delete_function
void* attribute_val_out,
int*
flag);
void* attribute_val_out,
int*
flag);
#define MPI_COMM_NULL_COPY_FN ((MPI_Comm_copy_attr_function*)0)
#define MPI_COMM_NULL_DELETE_FN ((MPI_Comm_delete_attr_function*)0)
#define MPI_TYPE_NULL_COPY_FN ((MPI_Type_copy_attr_function*)0)
#define MPI_TYPE_NULL_DELETE_FN ((MPI_Type_delete_attr_function*)0)
#define MPI_WIN_NULL_COPY_FN ((MPI_Win_copy_attr_function*)0)
#define MPI_WIN_NULL_DELETE_FN ((MPI_Win_delete_attr_function*)0)
MPI_Datatype* old_types, MPI_Datatype*
newtype));
MPI_Datatype* old_types, MPI_Datatype*
newtype));
int *ranks2));
#define MPI_DUP_FN MPI_Comm_dup
#define MPI_WIN_DUP_FN ((MPI_Win_copy_attr_function*)MPI_DUP_FN)
#define MPI_TYPE_DUP_FN ((MPI_Type_copy_attr_function*)MPI_DUP_FN)
#define MPI_COMM_DUP_FN ((MPI_Comm_copy_attr_function *)MPI_DUP_FN)
#define MPI_INFO_ENV 1
MPI_Comm* comm_graph));
int *num_datatypes, int *combiner));
void *
recvbuf,
int *recvcnts,
int *rdispls, MPI_Datatype *recvtypes, MPI_Comm
comm));
#if _POSIX_TIMERS > 0
XBT_PUBLIC(
int) smpi_nanosleep(
const struct timespec *tp,
struct timespec * t);
XBT_PUBLIC(
int) smpi_clock_gettime(clockid_t clk_id,
struct timespec *tp);
#endif
#define SMPI_SAMPLE_LOOP(global, iters, thres) \
for (smpi_sample_1(global, __FILE__, __LINE__, iters, thres); smpi_sample_2(global, __FILE__, __LINE__); \
smpi_sample_3(global, __FILE__, __LINE__))
#define SMPI_SAMPLE_LOCAL(iters, thres) SMPI_SAMPLE_LOOP(0, iters, thres)
#define SMPI_SAMPLE_GLOBAL(iters, thres) SMPI_SAMPLE_LOOP(1, iters, thres)
#define SMPI_SAMPLE_DELAY(duration) for(smpi_execute(duration); 0; )
#define SMPI_SAMPLE_FLOPS(flops) for(smpi_execute_flops(flops); 0; )
#define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__)
#define SMPI_PARTIAL_SHARED_MALLOC(size, shared_block_offsets, nb_shared_blocks) \
smpi_shared_malloc_partial(size, shared_block_offsets, nb_shared_blocks)
#define SMPI_SHARED_FREE(data) smpi_shared_free(data)
#define SMPI_SHARED_CALL(func, input, ...) \
(smpi_shared_known_call(#func, input) ? smpi_shared_get_call(#func, input) \
: smpi_shared_set_call(#func, input, (func(__VA_ARGS__))))
#define SMPI_VARINIT_GLOBAL(name,type) \
type *name = NULL; \
static void __attribute__((constructor)) __preinit_##name(void) { \
if(!name) \
name = (type*)calloc(smpi_global_size(), sizeof(type)); \
} \
static void __attribute__((destructor)) __postfini_##name(void) { \
free(name); \
name = NULL; \
}
#define SMPI_VARINIT_GLOBAL_AND_SET(name,type,expr) \
type *name = NULL; \
static void __attribute__((constructor)) __preinit_##name(void) { \
size_t size = smpi_global_size(); \
size_t i; \
type value = expr; \
if(!name) { \
name = (type*)malloc(size * sizeof(type)); \
for(i = 0; i < size; i++) { \
name[i] = value; \
} \
} \
} \
static void __attribute__((destructor)) __postfini_##name(void) { \
free(name); \
name = NULL; \
}
#define SMPI_VARGET_GLOBAL(name) name[smpi_process_index()]
#define SMPI_VARINIT_STATIC(name,type) \
static type *name = NULL; \
if(!name) { \
name = (type*)calloc(smpi_global_size(), sizeof(type)); \
smpi_register_static(name, xbt_free_f); \
}
#define SMPI_VARINIT_STATIC_AND_SET(name,type,expr) \
static type *name = NULL; \
if(!name) { \
size_t size = smpi_global_size(); \
size_t i; \
type value = expr; \
name = (type*)malloc(size * sizeof(type)); \
for(i = 0; i < size; i++) { \
name[i] = value; \
} \
smpi_register_static(name, xbt_free_f); \
}
#define SMPI_VARGET_STATIC(name) name[smpi_process_index()]
#ifdef __cplusplus
#include <vector>
size_t offset,
size_t buff_size);
std::vector<std::pair<size_t, size_t>>
dst);
#endif
#endif