Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[example,smpi,MM] remove the timer interface which is useless here
authorjean-noel quintin <jnquintin@dhcp-892b9b4c.ucd.ie>
Wed, 10 Oct 2012 10:19:59 +0000 (11:19 +0100)
committerjean-noel quintin <jnquintin@dhcp-892b9b4c.ucd.ie>
Wed, 10 Oct 2012 10:19:59 +0000 (11:19 +0100)
examples/smpi/MM/2.5D_MM.c
examples/smpi/MM/CMakeLists.txt
examples/smpi/MM/MM_mpi.c
examples/smpi/MM/Summa.c
examples/smpi/MM/param.c
examples/smpi/MM/timer.c [deleted file]
examples/smpi/MM/timer.h [deleted file]
examples/smpi/MM/topo.c

index 514ac43..b46902b 100644 (file)
@@ -1,13 +1,11 @@
 /*!
  * 2.5D Block Matrix Multiplication example
  *
- * Authors: Quintin Jean-Noël
  */
 
 #include "Matrix_init.h"
 #include "Summa.h"
 #include "2.5D_MM.h"
-#include "timer.h"
 #include <stdlib.h>
 #include "xbt/log.h"
 #define CHECK_25D 1
@@ -30,9 +28,9 @@ double two_dot_five(
 
 
   double time, communication_time = 0;
-  struct timespec start_time, end_time; //time mesure
-  struct timespec end_time_intern; //time mesure
-  struct timespec start_time_reduce, end_time_reduce; //time mesure
+  double start_time, end_time; //time mesure
+  double end_time_intern; //time mesure
+  double start_time_reduce, end_time_reduce; //time mesure
 
   MPI_Comm my_world;
 
@@ -181,7 +179,7 @@ double two_dot_five(
 
 
   MPI_Barrier(my_world);
-  get_time(&start_time);
+  start_time = MPI_Wtime();
   if( NB_groups > 1 ) {
     err = MPI_Bcast(a, m*k_a, MPI_DOUBLE, 0, group_line);
     if (err != MPI_SUCCESS) {
@@ -195,8 +193,8 @@ double two_dot_five(
     }
     MPI_Barrier(my_world);
   }
-  get_time(&end_time_intern);
-  communication_time += get_timediff(&start_time,&end_time_intern);
+  end_time_intern = MPI_Wtime();
+  communication_time += start_time - end_time_intern;
 
   XBT_INFO( "group %zu NB_block: %zu, NB_groups %zu\n"
               ,group,NB_Block, NB_groups);
@@ -220,7 +218,7 @@ double two_dot_five(
   MPI_Comm_rank(group_line, &myrank);
 
   MPI_Barrier(my_world);
-  get_time(&start_time_reduce);
+  start_time_reduce = MPI_Wtime();
   if( NB_groups > 1 ) {
     // a gather is better?
     err = MPI_Reduce(c, res, m*n, MPI_DOUBLE, MPI_SUM, 0, group_line);
@@ -234,12 +232,12 @@ double two_dot_five(
     res=swap;
   }
   MPI_Barrier(my_world);
-  get_time(&end_time_reduce);
+  end_time_reduce = MPI_Wtime();
 
   MPI_Barrier(my_world);
-  get_time(&end_time);
-  time = get_timediff(&start_time,&end_time);
-  double reduce_time = get_timediff(&start_time_reduce,&end_time_reduce);
+  end_time = MPI_Wtime();
+  time = start_time - end_time;
+  double reduce_time = start_time_reduce - end_time_reduce;
   printf("communication time: %le reduce time: %le nanoseconds, "
          "total time: %le nanoseconds\n",communication_time,reduce_time,time);
   MPI_Barrier(my_world);
index a4a1c2f..190a4c5 100644 (file)
@@ -7,7 +7,7 @@ if(enable_smpi)
 
   include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi")
 
-add_executable(MM_mpi MM_mpi.c 2.5D_MM.c Summa.c timer.c topo.c param.c Matrix_init.c)
+add_executable(MM_mpi MM_mpi.c 2.5D_MM.c Summa.c topo.c param.c Matrix_init.c)
 
 ### Add definitions for compile
 if(NOT WIN32)
index 23d2e2b..6ff27c0 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * Block Matrix Multiplication example
  *
- * Authors: Quintin Jean-Noël
  */
 
 
index 6b64619..94588e5 100644 (file)
@@ -1,11 +1,10 @@
 /*!
  * Classical Block Matrix Multiplication example
  *
- * Authors: Quintin Jean-Noël
  */
+
 #include "Matrix_init.h"
 #include "Summa.h"
-#include "timer.h"
 #include "xbt/log.h"
  XBT_LOG_NEW_DEFAULT_CATEGORY(MM_Summa,
                              "Messages specific for this msg example");
@@ -34,13 +33,13 @@ inline double Summa(
 
 
   double time, computation_time = 0, communication_time = 0;
-  struct timespec start_time, end_time; //time mesure
-  struct timespec start_time_intern, end_time_intern; //time mesure
+  double start_time, end_time; //time mesure
+  double start_time_intern, end_time_intern; //time mesure
 
 
 
 
-  get_time(&start_time);
+  start_time = MPI_Wtime();
 
   /*-------------Distributed Matrix Multiplication algorithm-----------------*/
   size_t iter;
@@ -77,7 +76,7 @@ inline double Summa(
     MPI_Barrier(row_comm);
     MPI_Barrier(col_comm);
 
-    get_time(&start_time_intern);
+    start_time_intern = MPI_Wtime();
     //Broadcast the row
     if(size_row > 1){
       MPI_Datatype * Block;
@@ -122,12 +121,12 @@ inline double Summa(
       B_b = b + pos_b;
       XBT_DEBUG("position of B_b: %zu \n", pos_b);
     }
-    get_time(&end_time_intern);
-    communication_time += get_timediff(&start_time_intern,&end_time_intern);
+    end_time_intern = MPI_Wtime();
+    communication_time += start_time_intern - end_time_intern;
 
     MPI_Barrier(row_comm);
     MPI_Barrier(col_comm);
-    get_time(&start_time_intern);
+    start_time_intern = MPI_Wtime();
     XBT_DEBUG("execute Gemm number: %zu\n", iter);
     //We have recieved a line of block and a colomn
    //              cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans,
@@ -139,15 +138,15 @@ inline double Summa(
         for(k = 0; k < Block_size; k++)
           c[i*ldc+j] += B_a[i*lda_local+k]*B_b[k*ldb_local+j];
 
-    get_time(&end_time_intern);
-    computation_time += get_timediff(&start_time_intern,&end_time_intern);
+    end_time_intern = MPI_Wtime();
+    computation_time += start_time_intern - end_time_intern;
 
   }
   MPI_Barrier(row_comm);
   MPI_Barrier(col_comm);
 
-  get_time(&end_time);
-  time = get_timediff(&start_time,&end_time);
+  end_time = MPI_Wtime();
+  time = start_time - end_time;
   printf("communication time: %le nanoseconds, "
          "computation time: %le nanoseconds\n",
          communication_time, computation_time);
index a72e75c..af39c21 100644 (file)
@@ -1,8 +1,6 @@
 /*!
  * get the parameter specific to the process from a file
  *
- *
- * Authors: Quintin Jean-Noël
  */
 
 #include "topo.h"
diff --git a/examples/smpi/MM/timer.c b/examples/smpi/MM/timer.c
deleted file mode 100644 (file)
index a647f98..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# include "timer.h"
-#include <mpi.h>
-#include <math.h>
-#include <stdio.h>
-#include "xbt/log.h"
- XBT_LOG_NEW_DEFAULT_CATEGORY(MM_timer,
-                             "Messages specific for this msg example");
-
-/* this could be specific for some processors
- * the default solution seems to be accurate enough
-#define CLOCK_TIMER CLOCK_MONOTONIC_RAW
- */
-
-inline double get_microsecond(struct timespec *res){
-  return (res->tv_sec*1000000 + res->tv_nsec/1000);
-}
-inline double get_nanosecond(struct timespec *res){
-  return (res->tv_sec*1000000000 + res->tv_nsec);
-}
-inline double get_second(struct timespec *res){
-  return (res->tv_sec + res->tv_nsec/1000000000);
-}
-
-inline int get_time(struct timespec *tp){
-  double time = MPI_Wtime();
-  time_t value = (time_t)floor(time);
-  time -= (double) value;
-  time = time * 1000000000;
-  tp->tv_nsec = (long) time;
-  tp->tv_sec = value ;
-  return 0;
-}
-
-double get_timediff(struct timespec *start, struct timespec *end){
-       return (double)(-start->tv_sec - ((double)start->tv_nsec)/1000000000 + end->tv_sec + ((double)end->tv_nsec)/1000000000);
-}
diff --git a/examples/smpi/MM/timer.h b/examples/smpi/MM/timer.h
deleted file mode 100644 (file)
index bb45687..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef timer_H_
-#define timer_H_
-/*!
- * \defgroup timer.h
- * here, we provides a generic interface to time some parts of the code
- */
-# include <sys/time.h>
-
-inline double get_second(struct timespec *res);
-inline double get_microsecond(struct timespec *res);
-inline double get_nanosecond(struct timespec *res);
-
-
-
-int get_time(struct timespec *tp);
-double get_timediff(struct timespec *start, struct timespec * end);
-#endif /*timer_H_*/
index e26a53b..2c6d92a 100644 (file)
@@ -1,8 +1,6 @@
 /*!
  * get the information of which thread are on the same node
  *
- *
- * Authors: Quintin Jean-Noël
  */
 
 #include <stdlib.h>