#define SEED 221238
#define sleep(x) smpi_sleep(x)
+#if _POSIX_TIMERS
+#define nanosleep(x,y) smpi_nanosleep(x,NULL)
+#endif
+#define usleep(x) smpi_usleep(x)
#include <smpi/smpi.h>
#include <xbt/sysdep.h>
#include <sys/time.h> /* Load it before the define next line to not mess with the system headers */
#define gettimeofday(x, y) smpi_gettimeofday(x, NULL)
-
+#if _POSIX_TIMERS
+#define clock_gettime(x, y) smpi_clock_gettime(x, y)
+#endif
#if HAVE_MC
#undef assert
#define assert(x) MC_assert(x)
#include <unistd.h>
#include <sys/time.h>
+#if _POSIX_TIMERS
+#include <time.h>
+#endif
#include <stddef.h>
#include <xbt/misc.h>
XBT_PUBLIC(double) smpi_get_host_consumed_energy(void);
XBT_PUBLIC(int) smpi_usleep(useconds_t usecs);
+#if _POSIX_TIMERS
+
+XBT_PUBLIC(int) smpi_nanosleep(struct timespec *tp, void* t);
+XBT_PUBLIC(int) smpi_clock_gettime(clockid_t clk_id, struct timespec *tp);
+#endif
XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs);
XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, void* tz);
XBT_PUBLIC(unsigned long long) smpi_rastro_resolution (void);
return static_cast<int>(private_sleep(static_cast<double>(usecs) / 1000000.0));
}
+#if _POSIX_TIMERS
+int smpi_nanosleep(struct timespec *tp, void* t)
+{
+ return static_cast<int>(private_sleep(static_cast<double>(tp->tv_sec + tp->tv_nsec / 1000000000.0)));
+}
+#endif
+
int smpi_gettimeofday(struct timeval *tv, void* tz)
{
double now;
return 0;
}
+#if _POSIX_TIMERS
+int smpi_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+ //there is only one time in SMPI, so clk_id is ignored.
+ double now;
+ smpi_bench_end();
+ now = SIMIX_get_clock();
+ if (tp) {
+ tp->tv_sec = static_cast<time_t>(now);
+ tp->tv_nsec = static_cast<long int>((now - tp->tv_sec) * 1e9);
+ }
+ smpi_bench_begin();
+ return 0;
+}
+#endif
+
extern double sg_surf_precision;
unsigned long long smpi_rastro_resolution (void)
{