typedef enum MPIR_Topo_type {
MPI_GRAPH=1,
MPI_CART=2,
- MPI_DIST_GRAPH=3
+ MPI_DIST_GRAPH=3,
+ MPI_INVALID_TOPO=-1
} MPIR_Topo_type;
typedef ptrdiff_t MPI_Aint;
XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void);
XBT_PUBLIC(void*) smpi_process_get_user_data(void);
XBT_PUBLIC(void) smpi_process_set_user_data(void *);
-/*
-XBT_PUBLIC(void) smpi_exit(int);
-*/
XBT_PUBLIC(void) smpi_execute_flops(double flops);
XBT_PUBLIC(void) smpi_execute(double duration);
XBT_PUBLIC(void) SMPI_init(void);
XBT_PUBLIC(void) SMPI_finalize(void);
-
-
+/* Manual global privatization fallback */
+XBT_PUBLIC(void) smpi_register_static(void* arg, void_f_pvoid_t free_fn);
+XBT_PUBLIC(void) smpi_free_static(void);
+
+#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()]
SG_END_DECL()
#endif