/*!
* 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
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;
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) {
}
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);
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);
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);
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)
/*
* Block Matrix Multiplication example
*
- * Authors: Quintin Jean-Noël
*/
/*!
* 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");
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;
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;
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,
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);
/*!
* get the parameter specific to the process from a file
*
- *
- * Authors: Quintin Jean-Noël
*/
#include "topo.h"
+++ /dev/null
-# 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);
-}
+++ /dev/null
-#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_*/
/*!
* get the information of which thread are on the same node
*
- *
- * Authors: Quintin Jean-Noël
*/
#include <stdlib.h>