From: jean-noel quintin Date: Wed, 10 Oct 2012 10:19:59 +0000 (+0100) Subject: [example,smpi,MM] remove the timer interface which is useless here X-Git-Tag: v3_8~93 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/29aece352b6242fed59d733f405a0c3df0839ca5 [example,smpi,MM] remove the timer interface which is useless here --- diff --git a/examples/smpi/MM/2.5D_MM.c b/examples/smpi/MM/2.5D_MM.c index 514ac43af2..b46902b663 100644 --- a/examples/smpi/MM/2.5D_MM.c +++ b/examples/smpi/MM/2.5D_MM.c @@ -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 #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); diff --git a/examples/smpi/MM/CMakeLists.txt b/examples/smpi/MM/CMakeLists.txt index a4a1c2f7a7..190a4c5eba 100644 --- a/examples/smpi/MM/CMakeLists.txt +++ b/examples/smpi/MM/CMakeLists.txt @@ -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) diff --git a/examples/smpi/MM/MM_mpi.c b/examples/smpi/MM/MM_mpi.c index 23d2e2be2a..6ff27c0b6e 100644 --- a/examples/smpi/MM/MM_mpi.c +++ b/examples/smpi/MM/MM_mpi.c @@ -1,7 +1,6 @@ /* * Block Matrix Multiplication example * - * Authors: Quintin Jean-Noël */ diff --git a/examples/smpi/MM/Summa.c b/examples/smpi/MM/Summa.c index 6b64619511..94588e54be 100644 --- a/examples/smpi/MM/Summa.c +++ b/examples/smpi/MM/Summa.c @@ -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); diff --git a/examples/smpi/MM/param.c b/examples/smpi/MM/param.c index a72e75c615..af39c21415 100644 --- a/examples/smpi/MM/param.c +++ b/examples/smpi/MM/param.c @@ -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 index a647f98712..0000000000 --- a/examples/smpi/MM/timer.c +++ /dev/null @@ -1,36 +0,0 @@ -# include "timer.h" -#include -#include -#include -#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 index bb4568714d..0000000000 --- a/examples/smpi/MM/timer.h +++ /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 - -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_*/ diff --git a/examples/smpi/MM/topo.c b/examples/smpi/MM/topo.c index e26a53b448..2c6d92a509 100644 --- a/examples/smpi/MM/topo.c +++ b/examples/smpi/MM/topo.c @@ -1,8 +1,6 @@ /*! * get the information of which thread are on the same node * - * - * Authors: Quintin Jean-Noël */ #include