Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[smpi,example] an example of matrix multiplication with non contignous memory
[simgrid.git] / examples / smpi / MM / timer.c
1 # include "timer.h"
2 #include <mpi.h>
3 #include <math.h>
4 #include <stdio.h>
5 #include "xbt/log.h"
6  XBT_LOG_NEW_DEFAULT_CATEGORY(MM_timer,
7                              "Messages specific for this msg example");
8
9 /* this could be specific for some processors
10  * the default solution seems to be accurate enough
11 #define CLOCK_TIMER CLOCK_MONOTONIC_RAW
12  */
13
14 inline double get_microsecond(struct timespec *res){
15   return (res->tv_sec*1000000 + res->tv_nsec/1000);
16 }
17 inline double get_nanosecond(struct timespec *res){
18   return (res->tv_sec*1000000000 + res->tv_nsec);
19 }
20 inline double get_second(struct timespec *res){
21   return (res->tv_sec + res->tv_nsec/1000000000);
22 }
23
24 inline int get_time(struct timespec *tp){
25   double time = MPI_Wtime();
26   time_t value = (time_t)floor(time);
27   time -= (double) value;
28   time = time * 1000000000;
29   tp->tv_nsec = (long) time;
30   tp->tv_sec = value ;
31 }
32
33 double get_timediff(struct timespec *start, struct timespec *end){
34         return (double)(-start->tv_sec - ((double)start->tv_nsec)/1000000000 + end->tv_sec + ((double)end->tv_nsec)/1000000000);
35 }