Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 14:16:29 +0000 (15:16 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 14:16:29 +0000 (15:16 +0100)
13 files changed:
examples/smpi/MM/2.5D_MM.c [deleted file]
examples/smpi/MM/2.5D_MM.h [deleted file]
examples/smpi/MM/CMakeLists.txt
examples/smpi/MM/MM_mpi.c
examples/smpi/MM/Matrix_init.c
examples/smpi/MM/Summa.c
examples/smpi/MM/Summa.h
examples/smpi/MM/command_exemple [deleted file]
examples/smpi/bcbench.c
examples/smpi/mvmul.c
examples/smpi/replay_multiple/replay_multiple.c
examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c
tools/internal/check_dist_archive.exclude

diff --git a/examples/smpi/MM/2.5D_MM.c b/examples/smpi/MM/2.5D_MM.c
deleted file mode 100644 (file)
index 041342e..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-/* 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. */
-
-/*!
- * 2.5D Block Matrix Multiplication example
- *
- */
-
-#include "Matrix_init.h"
-#include "Summa.h"
-#include "2.5D_MM.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include "xbt/log.h"
-#define CHECK_25D 1
-
- XBT_LOG_NEW_DEFAULT_CATEGORY(25D_MM,
-                             "Messages specific for this msg example");
-
-double two_dot_five(
-                    size_t m, size_t k, size_t n,
-                    size_t Block_size, size_t group, size_t key,
-                    size_t size_row, size_t size_col, size_t NB_groups ){
-  double *a,  *b,  *c;
-  double *res = NULL;
-  /* Split the communicator into groups */
-
-  /* Find out my identity in the default communicator */
-  int myrank;
-  int NB_proc;
-  int err;
-  int useless = 0;
-
-
-  double time, communication_time = 0;
-  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;
-
-  if ( group >= NB_groups ){
-    XBT_DEBUG(
-                "Not enough group NB_groups : %zu my group id : %zu\n",
-                NB_groups, group);
-    MPI_Comm_split(MPI_COMM_WORLD, 0, key, &my_world);
-    return -1;
-  }else{
-    MPI_Comm_split(MPI_COMM_WORLD, 1, key, &my_world);
-  }
-
-  MPI_Comm_size (my_world, &NB_proc);
-
-  if ( NB_proc < (int)(size_row*size_col*NB_groups) ){
-    XBT_INFO(
-                "Not enough processors NB_proc : %d required : %zu\n",
-                NB_proc, size_row*size_col*NB_groups);
-    return -1;
-  }
-
-
-
-  MPI_Comm group_comm;
-  MPI_Comm_split(my_world, group, key, &group_comm);
-
-  MPI_Comm_rank(group_comm, &myrank);
-  MPI_Comm_size (group_comm, &NB_proc);
-  /* for each group start the execution of his */
-
-
-  NB_proc=size_row*size_col;
-  size_t row = myrank / size_row;
-  size_t col = myrank % size_row;
-
-
-
-
-  /*-------------------------Check some mandatory conditions------------------*/
-  size_t NB_Block = k / Block_size;
-  if ( k % Block_size != 0 ){
-    XBT_INFO(
-                "The matrix size has to be proportionnal to the number\
-                of blocks: %zu\n", NB_Block);
-    return -1;
-  }
-
-  if ( size_row > NB_Block || size_col > NB_Block ){
-    XBT_INFO(
-                "Number of blocks is too small compare to the number of"
-                " processors (%zu,%zu) in a row or a col (%zu)\n",
-                size_col, size_row, NB_Block);
-    return -1;
-  }
-
-  if ( NB_Block % size_row != 0 || NB_Block % size_col != 0){
-    XBT_INFO("The number of Block by processor is not an %s",
-                "integer\n");
-    return -1;
-  }
-
-
-
-  if(row >= size_col || col >= size_row){
-    XBT_INFO( "I'm useless bye!!! col: %zu row: %zu, "
-                "size_col: %zu , size_row: %zu \n",
-                col,row,size_col,size_row);
-    useless = 1;
-  }
-
-
-  if(useless == 1){
-    /*----------------------Prepare the Communication Layer-------------------*/
-    /* add useless processor on a new color to execute the matrix
-     * multiplication with the other processors*/
-
-    /* Split comm size_to row and column comms */
-    MPI_Comm row_comm, col_comm, group_line;
-    MPI_Comm_split(my_world, myrank, MPI_UNDEFINED, &group_line);
-    /* color by row, rank by column */
-    MPI_Comm_split(group_comm, size_row, MPI_UNDEFINED, &row_comm);
-    /* color by column, rank by row */
-    MPI_Comm_split(group_comm, size_col, MPI_UNDEFINED, &col_comm);
-    /*------------------------Communication Layer can be used-----------------*/
-
-    return 0;
-  }
-  XBT_DEBUG( "I'm initialized col: %zu row: %zu, "
-              "size_col: %zu , size_row: %zu, my rank: %d \n"
-              ,col,row,size_col,size_row, myrank);
-
-
-
-  /*------------------------Initialize the matrices---------------------------*/
-
-  /* think about a common interface
-   *  int pdgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans,
-   *                 m, n, k, alpha, a, ia, ja, lda, b, ib, jb, ldb,
-   *                 beta, c, ldc, Comm, rank );
-   */
-
-  /*------------------------Prepare the Communication Layer-------------------*/
-  /* Split comm size_to row and column comms */
-  MPI_Comm row_comm, col_comm, group_line;
-  MPI_Comm_split(my_world, myrank, group, &group_line);
-  /* color by row, rank by column */
-  MPI_Comm_split(group_comm, row, col, &row_comm);
-  /* color by column, rank by row */
-  MPI_Comm_split(group_comm, col, row, &col_comm);
-  /*-------------------------Communication Layer can be used------------------*/
-
-  // matrix sizes
-  m   = m   / size_col;
-  n   = n   / size_row;
-  size_t k_a = k / size_row;
-  size_t k_b = k / size_col;
-
-
-
-  /*only on the group 0*/
-  if( group == 0 ) {
-    matrices_initialisation(&a, &b, &c, m, k_a, k_b, n, row, col);
-    if( NB_groups > 1 ) res = malloc( sizeof(double)*m*n );
-  } else matrices_allocation(&a, &b, &c, m, k_a, k_b, n);
-
-
-  /*-------------------Configuration for Summa algorihtm--------------------*/
-  /*--------------------Allocation of matrices block-------------------------*/
-  double *a_Summa, *b_Summa;
-  blocks_initialisation(&a_Summa, &b_Summa, m, Block_size, n);
-
-  /*--------------------Communication types for MPI--------------------------*/
-  MPI_Datatype Block_a;
-  MPI_Datatype Block_a_local;
-  MPI_Datatype Block_b;
-  MPI_Type_vector(m , Block_size, k_a, MPI_DOUBLE, &Block_a);
-  MPI_Type_vector(m , Block_size, Block_size, MPI_DOUBLE, &Block_a_local);
-  MPI_Type_vector(Block_size, n, n, MPI_DOUBLE, &Block_b);
-  MPI_Type_commit(&Block_a);
-  MPI_Type_commit(&Block_a_local);
-  MPI_Type_commit(&Block_b);
-  /*-------------Communication types for MPI are configured------------------*/
-
-
-
-
-  MPI_Barrier(my_world);
-  start_time = MPI_Wtime();
-  if( NB_groups > 1 ) {
-    err = MPI_Bcast(a, m*k_a, MPI_DOUBLE, 0, group_line);
-    if (err != MPI_SUCCESS) {
-      perror("Error Bcast A\n");
-      return -1;
-    }
-    err = MPI_Bcast(b, n*k_b, MPI_DOUBLE, 0, group_line);
-    if (err != MPI_SUCCESS) {
-      perror("Error Bcast B\n");
-      return -1;
-    }
-    MPI_Barrier(my_world);
-  }
-  end_time_intern = MPI_Wtime();
-  communication_time += end_time_intern - start_time;
-
-  XBT_INFO( "group %zu NB_block: %zu, NB_groups %zu\n"
-              ,group,NB_Block, NB_groups);
-  XBT_INFO(
-              "m %zu,  k_a %zu,  k_b %zu,  n %zu,  Block_size %zu, "
-              "group*NB_Block/NB_groups %zu, "
-              "(group+1)*NB_Block/NB_groups %zu, row %zu,  col %zu,"
-              "size_row %zu,  size_col %zu\n" ,
-              m, k_a, k_b, n, Block_size,
-              group*NB_Block/NB_groups, (group+1)*NB_Block/NB_groups,
-              row, col, size_row, size_col);
-
-
-  Summa( a, b, c, k_a, n, n, m, k_a, k_b, n, Block_size,
-          group*NB_Block/NB_groups, (group+1)*NB_Block/NB_groups,
-          row, col, size_row, size_col, a_Summa, b_Summa, Block_a,
-          Block_a_local, Block_b, row_comm, col_comm, 0);
-
-  /*-------------------------End Summa algorihtm-----------------------------*/
-
-  MPI_Comm_rank(group_line, &myrank);
-
-  MPI_Barrier(my_world);
-  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);
-    if (err != MPI_SUCCESS) {
-      perror("Error Bcast A\n");
-      return -1;
-    }
-  }else{
-    double *swap= c;
-    c = res;
-    res=swap;
-  }
-  MPI_Barrier(my_world);
-  end_time_reduce = MPI_Wtime();
-
-  MPI_Barrier(my_world);
-  end_time = MPI_Wtime();
-  time = end_time - start_time;
-  double reduce_time = end_time_reduce - start_time_reduce;
-  printf("communication time: %e reduce time: %e seconds, "
-         "total time: %e seconds\n",communication_time,reduce_time,time);
-  MPI_Barrier(my_world);
-
-#if CHECK_25D
-  if(myrank == 0)
-    check_result(res, a, b, m, n, k_a, k_b, row, col, size_row, size_col);
-#endif
-
-  // close properly the pragram
-
-  MPI_Type_free(&Block_a);
-  MPI_Type_free(&Block_a_local);
-  MPI_Type_free(&Block_b);
-
-  free(a_Summa);
-  free(b_Summa);
-
-
-  free( a );
-  free( b );
-  if( NB_groups > 1 ) {
-    free( c );
-  }
-  free(res);
-
-  MPI_Barrier(MPI_COMM_WORLD);
-  MPI_Comm_free(&my_world);
-  MPI_Comm_free(&group_comm);
-  MPI_Comm_free(&group_line);
-  MPI_Comm_free(&row_comm);
-  MPI_Comm_free(&col_comm);
-  return 0;
-}
-
-
-
diff --git a/examples/smpi/MM/2.5D_MM.h b/examples/smpi/MM/2.5D_MM.h
deleted file mode 100644 (file)
index 3415d6b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* 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. */
-
-#include <mpi.h>
-double two_dot_five(
-                    size_t m, size_t k, size_t n,
-                    size_t Block_size, size_t group, size_t key,
-                    size_t size_row, size_t size_col, size_t NB_groups );
-
index 4438eec..02819ba 100644 (file)
@@ -3,21 +3,16 @@ if(enable_smpi)
   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
 
   if(NOT WIN32)
-    add_executable       (MM_mpi MM_mpi.c 2.5D_MM.c Summa.c Matrix_init.c)
+    add_executable       (MM_mpi MM_mpi.c Summa.c Matrix_init.c)
     target_link_libraries(MM_mpi simgrid)
   endif()
 endif()
 
-set(tesh_files
-  ${tesh_files}
-  PARENT_SCOPE)
 set(examples_src
   ${examples_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/MM_mpi.c
-  ${CMAKE_CURRENT_SOURCE_DIR}/2.5D_MM.c
   ${CMAKE_CURRENT_SOURCE_DIR}/Summa.c
   ${CMAKE_CURRENT_SOURCE_DIR}/Matrix_init.c
-  ${CMAKE_CURRENT_SOURCE_DIR}/2.5D_MM.h
   ${CMAKE_CURRENT_SOURCE_DIR}/Summa.h
   ${CMAKE_CURRENT_SOURCE_DIR}/Matrix_init.h
   PARENT_SCOPE)
index ecaab74..70974a3 100644 (file)
 /* 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. */
 
-/*
- * Block Matrix Multiplication example
- *
- */
+/* Block Matrix Multiplication example */
 
 #include "Matrix_init.h"
-#include "2.5D_MM.h"
+#include "Summa.h"
 #include "xbt/log.h"
 #include <xbt/str.h>
 
-/*int sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
-  int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
- */
 #include <stdio.h>
 #include <string.h>
 #include <mpi.h>
 #include <math.h>
 #include <getopt.h>
 
- XBT_LOG_NEW_DEFAULT_CATEGORY(MM_mpi,
-                             "Messages specific for this msg example");
+#define CHECK_25D 1
 
+XBT_LOG_NEW_DEFAULT_CATEGORY(MM_mpi, "Messages specific for this msg example");
 
+static double two_dot_five(size_t m, size_t k, size_t n, size_t Block_size, size_t group, size_t key, size_t size_row,
+                           size_t size_col, size_t NB_groups ){
+  double *a,  *b,  *c;
+  double *res = NULL;
+  /* Split the communicator into groups */
+
+  /* Find out my identity in the default communicator */
+  int myrank;
+  int NB_proc;
+  int err;
+  int useless = 0;
+
+  double time, communication_time = 0;
+  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;
+
+  if ( group >= NB_groups ){
+    XBT_DEBUG("Not enough group NB_groups : %zu my group id : %zu\n", NB_groups, group);
+    MPI_Comm_split(MPI_COMM_WORLD, 0, key, &my_world);
+    return -1;
+  }else{
+    MPI_Comm_split(MPI_COMM_WORLD, 1, key, &my_world);
+  }
+
+  MPI_Comm_size (my_world, &NB_proc);
+
+  if ( NB_proc < (int)(size_row*size_col*NB_groups) ){
+    XBT_INFO("Not enough processors NB_proc : %d required : %zu\n", NB_proc, size_row*size_col*NB_groups);
+    return -1;
+  }
+
+  MPI_Comm group_comm;
+  MPI_Comm_split(my_world, group, key, &group_comm);
+
+  MPI_Comm_rank(group_comm, &myrank);
+  MPI_Comm_size (group_comm, &NB_proc);
+  /* for each group start the execution of his */
+
+  NB_proc=size_row*size_col;
+  size_t row = myrank / size_row;
+  size_t col = myrank % size_row;
+
+  /*-------------------------Check some mandatory conditions------------------*/
+  size_t NB_Block = k / Block_size;
+  if ( k % Block_size != 0 ){
+    XBT_INFO("The matrix size has to be proportionnal to the number of blocks: %zu\n", NB_Block);
+    return -1;
+  }
+
+  if ( size_row > NB_Block || size_col > NB_Block ){
+    XBT_INFO("Number of blocks is too small compare to the number of processors (%zu,%zu) in a row or a col (%zu)\n",
+             size_col, size_row, NB_Block);
+    return -1;
+  }
+
+  if ( NB_Block % size_row != 0 || NB_Block % size_col != 0){
+    XBT_INFO("The number of Block by processor is not an integer\n");
+    return -1;
+  }
+
+  if(row >= size_col || col >= size_row){
+    XBT_INFO( "I'm useless bye!!! col: %zu row: %zu, size_col: %zu , size_row: %zu \n", col,row,size_col,size_row);
+    useless = 1;
+  }
+
+  if(useless == 1){
+    /*----------------------Prepare the Communication Layer-------------------*/
+    /* add useless processor on a new color to execute the matrix
+     * multiplication with the other processors*/
+
+    /* Split comm size_to row and column comms */
+    MPI_Comm row_comm, col_comm, group_line;
+    MPI_Comm_split(my_world, myrank, MPI_UNDEFINED, &group_line);
+    /* color by row, rank by column */
+    MPI_Comm_split(group_comm, size_row, MPI_UNDEFINED, &row_comm);
+    /* color by column, rank by row */
+    MPI_Comm_split(group_comm, size_col, MPI_UNDEFINED, &col_comm);
+    /*------------------------Communication Layer can be used-----------------*/
+
+    return 0;
+  }
+  XBT_DEBUG("I'm initialized col: %zu row: %zu, size_col: %zu , size_row: %zu, my rank: %d \n", col,row,size_col,
+            size_row, myrank);
+
+  /*------------------------Initialize the matrices---------------------------*/
+  /* think about a common interface
+   *  int pdgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, alpha, a, ia, ja, lda, b, ib, jb, ldb,
+   *              beta, c, ldc, Comm, rank );
+   */
+
+  /*------------------------Prepare the Communication Layer-------------------*/
+  /* Split comm size_to row and column comms */
+  MPI_Comm row_comm, col_comm, group_line;
+  MPI_Comm_split(my_world, myrank, group, &group_line);
+  /* color by row, rank by column */
+  MPI_Comm_split(group_comm, row, col, &row_comm);
+  /* color by column, rank by row */
+  MPI_Comm_split(group_comm, col, row, &col_comm);
+  /*-------------------------Communication Layer can be used------------------*/
+
+  // matrix sizes
+  m   = m   / size_col;
+  n   = n   / size_row;
+  size_t k_a = k / size_row;
+  size_t k_b = k / size_col;
+
+  /*only on the group 0*/
+  if( group == 0 ) {
+    matrices_initialisation(&a, &b, &c, m, k_a, k_b, n, row, col);
+    if( NB_groups > 1 ) res = malloc( sizeof(double)*m*n );
+  } else matrices_allocation(&a, &b, &c, m, k_a, k_b, n);
+
+  /*-------------------Configuration for Summa algorihtm--------------------*/
+  /*--------------------Allocation of matrices block-------------------------*/
+  double *a_Summa, *b_Summa;
+  blocks_initialisation(&a_Summa, &b_Summa, m, Block_size, n);
+
+  /*--------------------Communication types for MPI--------------------------*/
+  MPI_Datatype Block_a;
+  MPI_Datatype Block_a_local;
+  MPI_Datatype Block_b;
+  MPI_Type_vector(m , Block_size, k_a, MPI_DOUBLE, &Block_a);
+  MPI_Type_vector(m , Block_size, Block_size, MPI_DOUBLE, &Block_a_local);
+  MPI_Type_vector(Block_size, n, n, MPI_DOUBLE, &Block_b);
+  MPI_Type_commit(&Block_a);
+  MPI_Type_commit(&Block_a_local);
+  MPI_Type_commit(&Block_b);
+  /*-------------Communication types for MPI are configured------------------*/
+
+  MPI_Barrier(my_world);
+  start_time = MPI_Wtime();
+  if( NB_groups > 1 ) {
+    err = MPI_Bcast(a, m*k_a, MPI_DOUBLE, 0, group_line);
+    if (err != MPI_SUCCESS) {
+      perror("Error Bcast A\n");
+      return -1;
+    }
+    err = MPI_Bcast(b, n*k_b, MPI_DOUBLE, 0, group_line);
+    if (err != MPI_SUCCESS) {
+      perror("Error Bcast B\n");
+      return -1;
+    }
+    MPI_Barrier(my_world);
+  }
+  end_time_intern = MPI_Wtime();
+  communication_time += end_time_intern - start_time;
+
+  XBT_INFO( "group %zu NB_block: %zu, NB_groups %zu\n",group,NB_Block, NB_groups);
+  XBT_INFO("m %zu,  k_a %zu,  k_b %zu,  n %zu,  Block_size %zu, group*NB_Block/NB_groups %zu, "
+           "(group+1)*NB_Block/NB_groups %zu, row %zu,  col %zu, size_row %zu,  size_col %zu\n",m, k_a, k_b, n,
+           Block_size, group*NB_Block/NB_groups, (group+1)*NB_Block/NB_groups,row, col, size_row, size_col);
+
+
+  Summa(a, b, c, k_a, n, n, m, k_a, k_b, n, Block_size, group*NB_Block/NB_groups, (group+1)*NB_Block/NB_groups,
+          row, col, size_row, size_col, a_Summa, b_Summa, Block_a, Block_a_local, Block_b, row_comm, col_comm, 0);
+
+  /*-------------------------End Summa algorihtm-----------------------------*/
+
+  MPI_Comm_rank(group_line, &myrank);
+
+  MPI_Barrier(my_world);
+  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);
+    if (err != MPI_SUCCESS) {
+      perror("Error Bcast A\n");
+      return -1;
+    }
+  }else{
+    double *swap= c;
+    c = res;
+    res=swap;
+  }
+  MPI_Barrier(my_world);
+  end_time_reduce = MPI_Wtime();
+
+  MPI_Barrier(my_world);
+  end_time = MPI_Wtime();
+  time = end_time - start_time;
+  double reduce_time = end_time_reduce - start_time_reduce;
+  printf("communication time: %e reduce time: %e seconds, total time: %e seconds\n", communication_time, reduce_time,
+         time);
+  MPI_Barrier(my_world);
+
+#if CHECK_25D
+  if(myrank == 0)
+    check_result(res, a, b, m, n, k_a, k_b, row, col, size_row, size_col);
+#endif
+
+  // close properly the pragram
+  MPI_Type_free(&Block_a);
+  MPI_Type_free(&Block_a_local);
+  MPI_Type_free(&Block_b);
+
+  free(a_Summa);
+  free(b_Summa);
+
+  free( a );
+  free( b );
+  if( NB_groups > 1 ) {
+    free( c );
+  }
+  free(res);
+
+  MPI_Barrier(MPI_COMM_WORLD);
+  MPI_Comm_free(&my_world);
+  MPI_Comm_free(&group_comm);
+  MPI_Comm_free(&group_line);
+  MPI_Comm_free(&row_comm);
+  MPI_Comm_free(&col_comm);
+  return 0;
+}
 
 int main(int argc, char ** argv)
 {
-
   size_t    m   = 1024 , n   = 1024 , k = 1024;
   size_t    NB_Block = 16;
   size_t    Block_size = k/NB_Block ;
@@ -39,8 +248,6 @@ int main(int argc, char ** argv)
      y index on N
      Z index on K */
 
-
-
   int myrank;
   int NB_proc;
   size_t row, col, size_row, size_col; //description: vitual processor topology
@@ -50,7 +257,6 @@ int main(int argc, char ** argv)
   MPI_Init(&argc, &argv);
 
   /* Find out my identity in the default communicator */
-
   MPI_Comm_rank ( MPI_COMM_WORLD, &myrank );
   MPI_Comm_size ( MPI_COMM_WORLD, &NB_proc );
 
@@ -65,8 +271,6 @@ int main(int argc, char ** argv)
     size_row = NB_proc/size_col;
   }
 
-
-  // for the degub
 #if DEBUG_MPI
   size_t loop=1;
   while(loop==1);
@@ -79,19 +283,17 @@ int main(int argc, char ** argv)
   while ((opt = getopt(argc, argv, "hr:c:M:N:K:B:G:g:k:P:")) != -1) {
     switch(opt) {
       case 'h':
-        XBT_INFO(
-                    "Usage: mxm_cblas_test [options]\n"
-                    "  -M I  M size (default: %zu)\n"
-                    "  -N I  N size (default: %zu)\n"
-                    "  -K I  K size (default: %zu)\n"
-                    "  -B I  Block size on the k dimension (default: %zu)\n"
-                    "  -G I  Number of processor groups (default: %zu)\n"
-                    "  -g I  group index (default: %zu)\n"
-                    "  -k I  group rank (default: %zu)\n"
-                    "  -r I  processor row size (default: %zu)\n"
-                    "  -c I  processor col size (default: %zu)\n"
-                    "  -h  help\n",
-                    m, n, k, Block_size, NB_groups, group, key, row, col);
+        XBT_INFO("Usage: mxm_cblas_test [options]\n"
+                 "  -M I  M size (default: %zu)\n"
+                 "  -N I  N size (default: %zu)\n"
+                 "  -K I  K size (default: %zu)\n"
+                 "  -B I  Block size on the k dimension (default: %zu)\n"
+                 "  -G I  Number of processor groups (default: %zu)\n"
+                 "  -g I  group index (default: %zu)\n"
+                 "  -k I  group rank (default: %zu)\n"
+                 "  -r I  processor row size (default: %zu)\n"
+                 "  -c I  processor col size (default: %zu)\n"
+                 "  -h  help\n", m, n, k, Block_size, NB_groups, group, key, row, col);
         return 0;
       case 'M':
         m = xbt_str_parse_int(optarg, "Invalid M size: %s");
@@ -120,26 +322,12 @@ int main(int argc, char ** argv)
       case 'c':
         size_col = xbt_str_parse_int(optarg, "Invalid processor col size: %s");
         break;
-        /*case 'P':
-          str_mask = strdup(optarg);
-          break;*/
     }
   }
 
+  two_dot_five( m, k, n, Block_size, group, key, size_row, size_col,  NB_groups);
 
-
-
-
-
-
-  // Defined the device if we use the GPU
-  //TODO explain parameters
-
-
-  two_dot_five( m, k, n, Block_size, group, key,
-               size_row, size_col,  NB_groups);
-
-  // close properly the pragram
+  // close properly the program
   MPI_Barrier(MPI_COMM_WORLD);
   MPI_Finalize();
   return 0;
index fe56602..3305772 100644 (file)
@@ -8,38 +8,33 @@
 #include <math.h>
 #include <stdio.h>
 #include "xbt/log.h"
- XBT_LOG_NEW_DEFAULT_CATEGORY(MM_init,
-                             "Messages specific for this msg example");
+ XBT_LOG_NEW_DEFAULT_CATEGORY(MM_init, "Messages specific for this msg example");
 #define _unused(x) ((void)x)
 
-
-void matrices_initialisation( double ** p_a, double ** p_b, double ** p_c,
-                              size_t m, size_t k_a, size_t k_b, size_t n,
-                              size_t row, size_t col)
+void matrices_initialisation(double ** p_a, double ** p_b, double ** p_c, size_t m, size_t k_a, size_t k_b, size_t n,
+                             size_t row, size_t col)
 {
-
-  size_t x,y,z;
+  size_t x, y, z;
   size_t lda = k_a;
   size_t ldb = n;
   size_t ldc = n;
-  double *a, *b, *c;
   _unused(row);
 
-  a =  malloc(sizeof(double) * m * k_a);
+  double *a =  malloc(sizeof(double) * m * k_a);
 
   if ( a == 0 ){
     perror("Error allocation Matrix A");
     exit(-1);
   }
 
-  b = malloc(sizeof(double) * k_b * n);
+  double *b = malloc(sizeof(double) * k_b * n);
 
   if ( b == 0 ){
     perror("Error allocation Matrix B");
     exit(-1);
   }
 
-  c = malloc(sizeof(double) * m * n);
+  double *c = malloc(sizeof(double) * m * n);
   if ( c == 0 ){
     perror("Error allocation Matrix C");
     exit(-1);
@@ -75,27 +70,23 @@ void matrices_initialisation( double ** p_a, double ** p_b, double ** p_c,
   }
 }
 
-void matrices_allocation( double ** p_a, double ** p_b, double ** p_c,
-                          size_t m, size_t k_a, size_t k_b, size_t n)
+void matrices_allocation( double ** p_a, double ** p_b, double ** p_c, size_t m, size_t k_a, size_t k_b, size_t n)
 {
-
-  double * a, *b, *c;
-
-  a =  malloc(sizeof(double) * m * k_a);
+  double *a =  malloc(sizeof(double) * m * k_a);
 
   if ( a == 0 ){
     perror("Error allocation Matrix A");
     exit(-1);
   }
 
-  b = malloc(sizeof(double) * k_b * n);
+  double *b = malloc(sizeof(double) * k_b * n);
 
   if ( b == 0 ){
     perror("Error allocation Matrix B");
     exit(-1);
   }
 
-  c = malloc(sizeof(double) * m * n);
+  double *c = malloc(sizeof(double) * m * n);
   if ( c == 0 ){
     perror("Error allocation Matrix C");
     exit(-1);
@@ -104,25 +95,22 @@ void matrices_allocation( double ** p_a, double ** p_b, double ** p_c,
   *p_a=a;
   *p_b =b;
   *p_c=c;
-
 }
 
-void blocks_initialisation( double ** p_a_local, double ** p_b_local,
-                            size_t m, size_t B_k, size_t n)
+void blocks_initialisation( double ** p_a_local, double ** p_b_local, size_t m, size_t B_k, size_t n)
 {
   size_t x,y,z;
   size_t lda = B_k;
   size_t ldb = n;
-  double * a_local, *b_local;
 
-  a_local =  malloc(sizeof(double) * m * B_k);
+  double *a_local =  malloc(sizeof(double) * m * B_k);
 
   if ( a_local == 0 ){
     perror("Error allocation Matrix A");
     exit(-1);
   }
 
-  b_local = malloc(sizeof(double) * B_k * n);
+  double *b_local = malloc(sizeof(double) * B_k * n);
 
   if ( b_local == 0 ){
     perror("Error allocation Matrix B");
@@ -145,10 +133,8 @@ void blocks_initialisation( double ** p_a_local, double ** p_b_local,
   }
 }
 
-void check_result(double *c, double *a, double *b,
-                  size_t m, size_t n, size_t k_a, size_t k_b,
-                  size_t row, size_t col,
-                  size_t size_row, size_t size_col)
+void check_result(double *c, double *a, double *b, size_t m, size_t n, size_t k_a, size_t k_b,
+                  size_t row, size_t col, size_t size_row, size_t size_col)
 {
   size_t x,y;
   size_t ldc = n;
@@ -162,7 +148,6 @@ void check_result(double *c, double *a, double *b,
   /* these variable could be use to check the result in function of the
    * matrix initialization */
 
-
   /*Display for checking */
 #ifdef SIMPLE_MATRIX
   XBT_INFO("Value get : %f excepted %zu multiply by y\n", c[((int)m/2)*ldc+1],size_row*k_a );
@@ -179,11 +164,9 @@ void check_result(double *c, double *a, double *b,
 #endif
       {
 #ifdef SIMPLE_MATRIX
-        XBT_INFO( "%f\t%zu, y : %zu x : %zu \n",
-               c[x*ldc+y], size_row*k_a, y, x);
+        XBT_INFO( "%f\t%zu, y : %zu x : %zu \n", c[x*ldc+y], size_row*k_a, y, x);
 #else
-        XBT_INFO( "%f\t%zu, y : %zu x : %zu \n",
-               c[x*ldc+y], y*(size_col*m)*((size_col*m)-1)/2, y, x);
+        XBT_INFO( "%f\t%zu, y : %zu x : %zu \n", c[x*ldc+y], y*(size_col*m)*((size_col*m)-1)/2, y, x);
 #endif
         goto error_exit;
       }
@@ -192,10 +175,6 @@ void check_result(double *c, double *a, double *b,
   XBT_INFO("result check: ok\n");
   return;
 error_exit:
-  XBT_INFO("result check not ok\n"
-         "WARNING the test could be lead to some "
-         "errors ( precision with double )\n");
+  XBT_INFO("result check not ok\nWARNING the test could be lead to some errors ( precision with double )\n");
   return;
 }
-
-
index cb51445..3f90768 100644 (file)
@@ -4,27 +4,19 @@
 /* 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
- *
- */
+/* Classical Block Matrix Multiplication example */
 
 #include "Matrix_init.h"
 #include "Summa.h"
 #include "xbt/log.h"
 #include <stdio.h>
 
- XBT_LOG_NEW_DEFAULT_CATEGORY(MM_Summa,
-                             "Messages specific for this msg example");
-
-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,
+XBT_LOG_NEW_DEFAULT_CATEGORY(MM_Summa, "Messages specific for this msg example");
+
+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
@@ -41,14 +33,10 @@ double Summa(double *a, double *b, double *c,
   size_t lda_local = lda;
   size_t ldb_local = ldb;
 
-
   double time, computation_time = 0, communication_time = 0;
   double start_time, end_time; //time mesure
   double start_time_intern, end_time_intern; //time mesure
 
-
-
-
   start_time = MPI_Wtime();
 
   /*-------------Distributed Matrix Multiplication algorithm-----------------*/
@@ -80,8 +68,7 @@ double Summa(double *a, double *b, double *c,
       pos_b = (iter % B_proc_col) * ldb * Block_size;
     }
 #endif
-    XBT_DEBUG( "pivot: %zu, iter: %zu, B_proc_col: %zu, "
-                "size_col:%zu, size_row: %zu\n",
+    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);*/
@@ -115,8 +102,7 @@ double Summa(double *a, double *b, double *c,
     if(size_col > 1){
       if( pivot_row == row ){
         B_b = b + pos_b;
-        XBT_DEBUG("sent B_b Block_size: %zu, pos:%zu \n",
-                    ldb, pos_b);
+        XBT_DEBUG("sent B_b Block_size: %zu, pos:%zu \n", ldb, pos_b);
       }else{
         B_b = b_local;
         XBT_DEBUG("recieve B_b %zu,%zu \n", Block_size,n);
@@ -157,10 +143,7 @@ double Summa(double *a, double *b, double *c,
 
   end_time = MPI_Wtime();
   time = end_time - start_time ;
-  printf("communication time: %e seconds, "
-         "computation time: %e seconds\n",
-         communication_time, computation_time);
-
+  printf("communication time: %e seconds, computation time: %e seconds\n", communication_time, computation_time);
 
   return time;
 }
index c0ce248..03c9d57 100644 (file)
@@ -5,14 +5,11 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <mpi.h>
-double Summa(
-                     double *a, double *b, double *c,
-                     size_t lda, size_t ldb, size_t ldc,
+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_Datatype Block_a, MPI_Datatype Block_a_local, MPI_Datatype Block_b,
                      MPI_Comm row_comm, MPI_Comm col_comm, int subs);
 
diff --git a/examples/smpi/MM/command_exemple b/examples/smpi/MM/command_exemple
deleted file mode 100644 (file)
index 2cc9b7c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../smpi_script/bin/smpirun --cfg=smpi/running_power:2.1175E9 -np 2 -platform ../../platforms/cluster.xml  -hostfile host ./MM_mpi
index daea198..fb3c404 100644 (file)
@@ -24,7 +24,6 @@
 
 int main(int argc, char *argv[])
 {
-
   int size, rank;
   int N;
   struct timeval *start_time = NULL, *stop_time = NULL;
@@ -46,7 +45,6 @@ int main(int argc, char *argv[])
   }
 
   for (N = N_START; N <= N_STOP; N = N_NEXT) {
-
     buffer = malloc(sizeof(char) * N);
 
     if (0 == rank) {
@@ -64,8 +62,7 @@ int main(int argc, char *argv[])
       MPI_Bcast(buffer, N, MPI_BYTE, 0, MPI_COMM_WORLD);
       if (0 == rank) {
         for (j = 1; j < size; j++) {
-          MPI_Recv(&check, 1, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD,
-                   MPI_STATUS_IGNORE);
+          MPI_Recv(&check, 1, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
         }
       } else {
         MPI_Send(&rank, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
@@ -78,20 +75,16 @@ int main(int argc, char *argv[])
         MPI_Abort(MPI_COMM_WORLD, GETTIMEOFDAY_ERROR);
         exit(EXIT_FAILURE);
       }
-      seconds =
-          (double) (stop_time->tv_sec - start_time->tv_sec) +
-          (double) (stop_time->tv_usec -
-                    start_time->tv_usec) / ONE_MILLION;
+      seconds = (double) (stop_time->tv_sec - start_time->tv_sec) +
+                (double) (stop_time->tv_usec - start_time->tv_usec) / ONE_MILLION;
     }
 
     free(buffer);
 
     if (0 == rank) {
-      printf("N: %10d, iter: %d, time: %10f s, avg rate: %12f Mbps\n", N,
-             ITER, seconds,
+      printf("N: %10d, iter: %d, time: %10f s, avg rate: %12f Mbps\n", N, ITER, seconds,
              ((double) N * ITER * 8) / (1024.0 * 1024.0 * seconds));
     }
-
   }
 
   if (0 == rank) {
index acc6af8..fd25813 100644 (file)
@@ -8,25 +8,21 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include <mpi.h>
-
 #include <xbt/str.h>
 
 #define ITERATIONS         10
-
 #define USAGE_ERROR        1
 #define SANITY_ERROR       2
 #define GETTIMEOFDAY_ERROR 3
 
 int main(int argc, char *argv[])
 {
-
   int size, rank;
   int N, n, i, j, k, current_iteration, successful_iterations = 0;
   double *matrix = NULL, *vector = NULL, *vcalc, *vcheck;
   MPI_Status status;
   struct timeval *start_time = NULL, *stop_time = NULL;
-  long parallel_usecs, parallel_usecs_total =
-      0, sequential_usecs, sequential_usecs_total = 0;
+  long parallel_usecs, parallel_usecs_total = 0, sequential_usecs, sequential_usecs_total = 0;
 
   MPI_Init(&argc, &argv);
 
@@ -34,7 +30,6 @@ int main(int argc, char *argv[])
   MPI_Comm_size(MPI_COMM_WORLD, &size);
 
   if (0 == rank) {
-
     // root node parses cmdline args
     if (2 > argc || !isdigit(*argv[1])) {
       printf("usage:\n%s <size>\n", argv[0]);
@@ -46,14 +41,10 @@ int main(int argc, char *argv[])
 
     start_time = (struct timeval *) malloc(sizeof(struct timeval));
     stop_time = (struct timeval *) malloc(sizeof(struct timeval));
-
   }
 
-  for (current_iteration = 0; current_iteration < ITERATIONS;
-       current_iteration++) {
-
+  for (current_iteration = 0; current_iteration < ITERATIONS; current_iteration++) {
     if (0 == rank) {
-
       matrix = (double *) malloc(N * N * sizeof(double));
       vector = (double *) malloc(N * sizeof(double));
 
@@ -65,8 +56,7 @@ int main(int argc, char *argv[])
         vector[i] = (double) rand() / ((double) RAND_MAX + 1);
       }
 
-      // for the sake of argument, the parallel algorithm begins
-      // when the root node begins to transmit the matrix to the
+      // for the sake of argument, the parallel algorithm begins when the root node begins to transmit the matrix to the
       // workers.
       if (-1 == gettimeofday(start_time, NULL)) {
         printf("couldn't set start_time on node 0!\n");
@@ -77,48 +67,40 @@ int main(int argc, char *argv[])
       for (i = 1; i < size; i++) {
         MPI_Send(&N, 1, MPI_INT, i, 0, MPI_COMM_WORLD);
       }
-
     } else {
       MPI_Recv(&N, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
     }
 
     // this algorithm uses at most N processors...
     if (rank < N) {
-
       if (size > N)
         size = N;
       n = N / size + ((rank < (N % size)) ? 1 : 0);
 
       if (0 == rank) {
-
         for (i = 1, j = n; i < size && j < N; i++, j += k) {
           k = N / size + ((i < (N % size)) ? 1 : 0);
-          MPI_Send(matrix + N * j, N * k, MPI_DOUBLE, i, 0,
-                   MPI_COMM_WORLD);
+          MPI_Send(matrix + N * j, N * k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
           MPI_Send(vector, N, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
         }
 
         // sanity check
 #ifdef DEBUG
         if (i != size || j != N) {
-          printf("index calc error: i = %d, size = %d, j = %d, N = %d\n",
-                 i, size, j, N);
+          printf("index calc error: i = %d, size = %d, j = %d, N = %d\n", i, size, j, N);
           MPI_Abort(MPI_COMM_WORLD, SANITY_ERROR);
           exit(SANITY_ERROR);
         }
 #endif
 
         vcalc = (double *) malloc(N * sizeof(double));
-
       } else {
-
         matrix = (double *) malloc(N * n * sizeof(double));
         vector = (double *) malloc(N * sizeof(double));
         vcalc = (double *) malloc(n * sizeof(double));
 
         MPI_Recv(matrix, N * n, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &status);
         MPI_Recv(vector, N, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &status);
-
       }
 
       for (i = 0; i < n; i++) {
@@ -131,18 +113,15 @@ int main(int argc, char *argv[])
       if (0 != rank) {
         MPI_Send(vcalc, n, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
       } else {
-
         for (i = 1, j = n; i < size && j < N; i++, j += k) {
           k = N / size + ((i < (N % size)) ? 1 : 0);
-          MPI_Recv(vcalc + j, k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD,
-                   &status);
+          MPI_Recv(vcalc + j, k, MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &status);
         }
 
         // sanity check
 #ifdef DEBUG
         if (i != size || j != N) {
-          printf("index calc error 2: i = %d, size = %d, j = %d, N = %d\n",
-                 i, size, j, N);
+          printf("index calc error 2: i = %d, size = %d, j = %d, N = %d\n", i, size, j, N);
           MPI_Abort(MPI_COMM_WORLD, SANITY_ERROR);
           exit(SANITY_ERROR);
         }
@@ -154,9 +133,8 @@ int main(int argc, char *argv[])
           exit(GETTIMEOFDAY_ERROR);
         }
 
-        parallel_usecs =
-            (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
-            (start_time->tv_sec * 1000000 + start_time->tv_usec);
+        parallel_usecs = (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
+                         (start_time->tv_sec * 1000000 + start_time->tv_usec);
 
         if (-1 == gettimeofday(start_time, NULL)) {
           printf("couldn't set start_time on node 0!\n");
@@ -178,9 +156,8 @@ int main(int argc, char *argv[])
           exit(GETTIMEOFDAY_ERROR);
         }
 
-        sequential_usecs =
-            (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
-            (start_time->tv_sec * 1000000 + start_time->tv_usec);
+        sequential_usecs = (stop_time->tv_sec * 1000000 + stop_time->tv_usec) -
+                           (start_time->tv_sec * 1000000 + start_time->tv_usec);
 
         // verify correctness
         for (i = 0; i < N && vcalc[i] == vcheck[i]; i++);
@@ -188,12 +165,9 @@ int main(int argc, char *argv[])
         printf("prog: blocking, i: %d ", current_iteration);
 
         if (i == N) {
-          printf
-              ("ptime: %ld us, stime: %ld us, speedup: %.3f, nodes: %d, efficiency: %.3f\n",
-               parallel_usecs, sequential_usecs,
-               (double) sequential_usecs / (double) parallel_usecs, size,
-               (double) sequential_usecs / ((double) parallel_usecs *
-                                            (double) size));
+          printf("ptime: %ld us, stime: %ld us, speedup: %.3f, nodes: %d, efficiency: %.3f\n",
+               parallel_usecs, sequential_usecs, (double) sequential_usecs / (double) parallel_usecs, size,
+               (double) sequential_usecs / ((double) parallel_usecs * (double) size));
 
           parallel_usecs_total += parallel_usecs;
           sequential_usecs_total += sequential_usecs;
@@ -203,36 +177,28 @@ int main(int argc, char *argv[])
         }
 
         free(vcheck);
-
       }
 
       free(matrix);
       free(vector);
       free(vcalc);
     }
-
   }
 
   if (0 == rank) {
     printf("prog: blocking, ");
     if (0 < successful_iterations) {
-      printf
-          ("iterations: %d, avg. ptime: %.3f us, avg. stime: %.3f us, avg. speedup: %.3f, nodes: %d, avg. efficiency: %.3f\n",
-           successful_iterations,
-           (double) parallel_usecs_total / (double) successful_iterations,
-           (double) sequential_usecs_total /
-           (double) successful_iterations,
-           (double) sequential_usecs_total / (double) parallel_usecs_total,
-           size,
-           (double) sequential_usecs_total /
-           ((double) parallel_usecs_total * (double) size));
+      printf("iterations: %d, avg. ptime: %.3f us, avg. stime: %.3f us, avg. speedup: %.3f, nodes: %d, avg. efficiency: %.3f\n",
+           successful_iterations, (double) parallel_usecs_total / (double) successful_iterations,
+           (double) sequential_usecs_total / (double) successful_iterations,
+           (double) sequential_usecs_total / (double) parallel_usecs_total, size,
+           (double) sequential_usecs_total / ((double) parallel_usecs_total * (double) size));
     } else {
       printf("no successful iterations!\n");
     }
 
     free(start_time);
     free(stop_time);
-
   }
 
   MPI_Finalize();
index 969fe9a..39697b0 100644 (file)
@@ -4,16 +4,10 @@
 /* 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. */
 
-#include <stdio.h>
-#include "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
+#include "simgrid/msg.h"
 #include "mpi.h"
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-#include "smpi/smpi.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-    "Messages specific for this msg example");
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 static int smpi_replay(int argc, char *argv[]) {
   smpi_replay_run(&argc, &argv);
@@ -22,29 +16,19 @@ static int smpi_replay(int argc, char *argv[]) {
 
 int main(int argc, char *argv[]){
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
-  const char *description_file;
 
   MSG_init(&argc, argv);
 
-  if (argc < 4) {
-    printf("Usage: %s description_file platform_file deployment_file\n", argv[0]);
-    printf("example: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0]);
-    exit(1);
-  }
-  description_file = argv[1];
-  platform_file = argv[2];
-  application_file = argv[3];
-
+  xbt_assert(argc > 3, "Usage: %s description_file platform_file deployment_file\n"
+             "\tExample: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
 
   /*  Simulation setting */
-  MSG_create_environment(platform_file);
+  MSG_create_environment(argv[2]);
 
   /*   Application deployment: read the description file in order to identify instances to launch */
-  FILE* fp = fopen(description_file, "r");
+  FILE* fp = fopen(argv[1], "r");
   if (fp == NULL)
-    xbt_die("Cannot open %s", description_file);
+    xbt_die("Cannot open %s", argv[1]);
   ssize_t read;
   char   *line = NULL;
   size_t n   = 0;
@@ -66,7 +50,7 @@ int main(int argc, char *argv[]){
     xbt_free(line_char);
   }
 
-  MSG_launch_application(application_file);
+  MSG_launch_application(argv[3]);
   SMPI_init();
 
   res = MSG_main();
@@ -74,9 +58,5 @@ int main(int argc, char *argv[]){
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
   SMPI_finalize();
-  if (res == MSG_OK)
-    return 0;
-  else
-    return 1;
-
+  return res != MSG_OK;
 }
index 119c30f..9fe316b 100644 (file)
@@ -4,23 +4,11 @@
 /* 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. */
 
-#include <stdio.h>
-#include "simgrid/msg.h"            /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
-#include "xbt/sysdep.h"         /* calloc, printf */
+#include "simgrid/msg.h"
 #include "mpi.h"
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
-
-int master(int argc, char *argv[]);
-int slave(int argc, char *argv[]);
-int master_mpi(int argc, char *argv[]);
-int alltoall_mpi(int argc, char *argv[]);
-
-/** sender function  */
-int master(int argc, char *argv[])
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int master(int argc, char *argv[])
 {
   long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
   double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
@@ -38,18 +26,14 @@ int master(int argc, char *argv[])
 
     sprintf(mailbox, "slave-%ld", i % slaves_count);
     sprintf(sprintf_buffer, "Task_%d", i);
-    task =
-        MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size,
-                        NULL);
+    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
     if (number_of_tasks < 10000 || i % 10000 == 0)
-      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name,
-            number_of_tasks, mailbox);
+      XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
 
     MSG_task_send(task, mailbox);
   }
 
-  XBT_INFO
-      ("All tasks have been dispatched. Let's tell everybody the computation is over.");
+  XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
   for (i = 0; i < slaves_count; i++) {
     char mailbox[80];
 
@@ -58,12 +42,10 @@ int master(int argc, char *argv[])
     MSG_task_send(finalize, mailbox);
   }
 
-//  XBT_INFO("Goodbye now!");
   return 0;
-}                               /* end_of_master */
-
+}
 
-int master_mpi(int argc, char *argv[])
+static int master_mpi(int argc, char *argv[])
 {
   MPI_Init(&argc, &argv);
 
@@ -72,22 +54,18 @@ int master_mpi(int argc, char *argv[])
   XBT_INFO("here for rank %d", rank);
   int test[1000]={rank};
   if(rank==0)
-        MPI_Send(&test, 1000, 
-                 MPI_INT, 1, 1, MPI_COMM_WORLD); 
+    MPI_Send(&test, 1000, MPI_INT, 1, 1, MPI_COMM_WORLD);
   else
-        MPI_Recv(&test, 1000, 
-                 MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUSES_IGNORE); 
+    MPI_Recv(&test, 1000, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
 
   XBT_INFO("After comm %d", rank);
   MPI_Finalize();
 
   XBT_INFO("After finalize %d %d", rank, test[0]);
   return 0;
-}                               /* end_of_master */
-
+}
 
-
-int alltoall_mpi(int argc, char *argv[])
+static int alltoall_mpi(int argc, char *argv[])
 {
   MPI_Init(&argc, &argv);
 
@@ -104,11 +82,9 @@ int alltoall_mpi(int argc, char *argv[])
   free(in);
   MPI_Finalize();
   return 0;
-}                               /* end_of_master */
-
+}
 
-/** Receiver function  */
-int slave(int argc, char *argv[])
+static int slave(int argc, char *argv[])
 {
   msg_task_t task = NULL;
   XBT_ATTRIB_UNUSED int res;
@@ -139,46 +115,32 @@ int slave(int argc, char *argv[])
   XBT_INFO("I'm done. See you!");
 
   return 0;
-}                               /* end_of_slave */
+}
 
-/** Main function */
 int main(int argc, char *argv[])
 {
   msg_error_t res;
-  const char *platform_file;
-  const char *application_file;
 
   MSG_init(&argc, argv);
 
-  if (argc < 3) {
-    printf("Usage: %s platform_file deployment_file\n", argv[0]);
-    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
-    exit(1);
-  }
-  platform_file = argv[1];
-  application_file = argv[2];
+  xbt_assert(argc > 2,"Usage: %s platform_file deployment_file\n"
+             "\nexample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
+
+  MSG_create_environment(argv[1]);
+
+  MSG_function_register("master", master);
+  MSG_function_register("slave", slave);
+  // launch two MPI applications as well, one using master_mpi function as main on 2 nodes
+  SMPI_app_instance_register("master_mpi", master_mpi,2);
+  // the second performing an alltoall on 4 nodes
+  SMPI_app_instance_register("alltoall_mpi", alltoall_mpi,4);
+  MSG_launch_application(argv[2]);
+  SMPI_init();
 
-  {                             /*  Simulation setting */
-    MSG_create_environment(platform_file);
-  }
-  {                             /*   Application deployment */
-    MSG_function_register("master", master);
-    MSG_function_register("slave", slave);
-    // launch two MPI applications as well, one using master_mpi function as main on 2 nodes
-    SMPI_app_instance_register("master_mpi", master_mpi,2);
-    // the second performing an alltoall on 4 nodes
-    SMPI_app_instance_register("alltoall_mpi", alltoall_mpi,4);
-    MSG_launch_application(application_file);
-    SMPI_init();
-  }
   res = MSG_main();
 
   XBT_INFO("Simulation time %g", MSG_get_clock());
 
-
   SMPI_finalize();
-  if (res == MSG_OK)
-    return 0;
-  else
-    return 1;
-}                               /* end_of_main */
+  return res != MSG_OK;
+}
index 7cae75e..1d51086 100644 (file)
@@ -26,7 +26,6 @@
 + examples/msg/actions/NAS_LU_S_4/.*
 + examples/msg/chord/chord3\.xml
 
-+ examples/smpi/MM/command_exemple
 + examples/smpi/MM/host
 + examples/smpi/NAS/.*