X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/29aece352b6242fed59d733f405a0c3df0839ca5..c2ba0183f433a0786347f3010f43217ac8145389:/examples/smpi/MM/Summa.c diff --git a/examples/smpi/MM/Summa.c b/examples/smpi/MM/Summa.c index 94588e54be..cb51445097 100644 --- a/examples/smpi/MM/Summa.c +++ b/examples/smpi/MM/Summa.c @@ -1,3 +1,9 @@ +/* Copyright (c) 2012-2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + /*! * Classical Block Matrix Multiplication example * @@ -6,25 +12,29 @@ #include "Matrix_init.h" #include "Summa.h" #include "xbt/log.h" +#include + XBT_LOG_NEW_DEFAULT_CATEGORY(MM_Summa, "Messages specific for this msg example"); -inline double Summa( - double *a, double *b, double *c, - size_t lda, size_t ldb, size_t ldc, - size_t m, size_t k_a, size_t k_b, size_t n, - size_t Block_size, size_t start, size_t end, - size_t row, size_t col, size_t size_row, size_t size_col, - double *a_local, double *b_local, - MPI_Datatype Block_a, MPI_Datatype Block_a_local, - MPI_Datatype Block_b, - MPI_Comm row_comm, MPI_Comm col_comm, int subs) +double Summa(double *a, double *b, double *c, + size_t lda, size_t ldb, size_t ldc, + size_t m, size_t k_a, size_t k_b, size_t n, + size_t Block_size, size_t start, size_t end, + size_t row, size_t col, size_t size_row, size_t size_col, + double *a_local, double *b_local, + MPI_Datatype Block_a, MPI_Datatype Block_a_local, + MPI_Datatype Block_b, + MPI_Comm row_comm, MPI_Comm col_comm, int subs) { double *B_a , *B_b ; //matrix blocks size_t err; //double alpha = 1, beta = 1; //C := alpha * a * b + beta * c - size_t B_proc_col, B_proc_row; // Number of bloc(row or col) on one processor + size_t B_proc_row; // Number of bloc(row or col) on one processor +#ifndef CYCLIC + size_t B_proc_col; B_proc_col = k_b / Block_size; // Number of block on one processor +#endif B_proc_row = k_a / Block_size; // Number of block on one processor //size_t lda = k_a, ldb = n, ldc = n; @@ -73,8 +83,8 @@ inline double Summa( XBT_DEBUG( "pivot: %zu, iter: %zu, B_proc_col: %zu, " "size_col:%zu, size_row: %zu\n", pivot_row, iter, B_proc_row,size_col,size_row); - MPI_Barrier(row_comm); - MPI_Barrier(col_comm); +/* MPI_Barrier(row_comm);*/ +/* MPI_Barrier(col_comm);*/ start_time_intern = MPI_Wtime(); //Broadcast the row @@ -122,10 +132,10 @@ inline double Summa( XBT_DEBUG("position of B_b: %zu \n", pos_b); } end_time_intern = MPI_Wtime(); - communication_time += start_time_intern - end_time_intern; + communication_time += end_time_intern - start_time_intern; - MPI_Barrier(row_comm); - MPI_Barrier(col_comm); +/* MPI_Barrier(row_comm);*/ +/* MPI_Barrier(col_comm);*/ start_time_intern = MPI_Wtime(); XBT_DEBUG("execute Gemm number: %zu\n", iter); //We have recieved a line of block and a colomn @@ -139,16 +149,16 @@ inline double Summa( c[i*ldc+j] += B_a[i*lda_local+k]*B_b[k*ldb_local+j]; end_time_intern = MPI_Wtime(); - computation_time += start_time_intern - end_time_intern; + computation_time += end_time_intern - start_time_intern; } MPI_Barrier(row_comm); MPI_Barrier(col_comm); end_time = MPI_Wtime(); - time = start_time - end_time; - printf("communication time: %le nanoseconds, " - "computation time: %le nanoseconds\n", + time = end_time - start_time ; + printf("communication time: %e seconds, " + "computation time: %e seconds\n", communication_time, computation_time);