Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try harder to get useconds_t from unistd.h
[simgrid.git] / include / smpi / smpi.h
index 6cde539..a1ba3a0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -6,13 +6,15 @@
 #ifndef SMPI_H
 #define SMPI_H
 
+#define __USE_XOPEN /* pick useconds_t in unistd.h */
 #include <unistd.h>
+
 #include <sys/time.h>
 #if _POSIX_TIMERS
 #include <time.h>
 #endif
 
-#include <simgrid/datatypes.h>
+#include <simgrid/forward.h>
 #include <smpi/forward.hpp>
 #include <stddef.h>
 #include <xbt/misc.h>
@@ -914,13 +916,11 @@ XBT_PUBLIC(void) smpi_trace_set_call_location_(const char *file, int* line);
 /** Fortran binding + -fsecond-underscore **/
 XBT_PUBLIC(void) smpi_trace_set_call_location__(const char *file, int* line);
 
-#define SMPI_SAMPLE_LOCAL(iters,thres) for(smpi_sample_1(0, __FILE__, __LINE__, iters, thres); \
-                                           smpi_sample_2(0, __FILE__, __LINE__);      \
-                                           smpi_sample_3(0, __FILE__, __LINE__))
-
-#define SMPI_SAMPLE_GLOBAL(iters,thres) for(smpi_sample_1(1, __FILE__, __LINE__, iters, thres); \
-                                            smpi_sample_2(1, __FILE__, __LINE__);      \
-                                            smpi_sample_3(1, __FILE__, __LINE__))
+#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; )
@@ -944,7 +944,7 @@ XBT_PUBLIC(void*) smpi_shared_set_call(const char* func, const char* input, void
 /* Fortran specific stuff */
 
 XBT_PUBLIC(int) smpi_main(const char* program, int argc, char *argv[]);
-XBT_PUBLIC(int) smpi_process_index();
+XBT_ATTRIB_DEPRECATED_v322("Use Actor::self()->getPid(): v3.22 will turn this warning into an error.") XBT_PUBLIC(int) smpi_process_index();
 XBT_PUBLIC(void) smpi_process_init(int *argc, char ***argv);
 
 /* Trace replay specific stuff */
@@ -989,7 +989,7 @@ static void __attribute__((destructor)) __postfini_##name(void) { \
    name = NULL;                                                 \
 }
 
-#define SMPI_VARGET_GLOBAL(name) name[smpi_process_index()]
+#define SMPI_VARGET_GLOBAL(name) name[SIMIX_process_self()->pid]
 
 /**
  * This is used for the old privatization method, i.e., on old
@@ -1015,7 +1015,7 @@ if(!name) {                                         \
    smpi_register_static(name, xbt_free_f);          \
 }
 
-#define SMPI_VARGET_STATIC(name) name[smpi_process_index()]
+#define SMPI_VARGET_STATIC(name) name[SIMIX_process_self()->pid]
 
 
 SG_END_DECL()