Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[example,smpi,MM] remove the specification of parameter per a file
authorjean-noel quintin <jnquintin@dhcp-892b9b4c.ucd.ie>
Thu, 11 Oct 2012 07:57:21 +0000 (08:57 +0100)
committerjean-noel quintin <jnquintin@dhcp-892b9b4c.ucd.ie>
Thu, 11 Oct 2012 07:57:21 +0000 (08:57 +0100)
                  - improve the upkeep of the code

examples/smpi/MM/CMakeLists.txt
examples/smpi/MM/MM_mpi.c
examples/smpi/MM/param.c [deleted file]
examples/smpi/MM/param.h [deleted file]
examples/smpi/MM/param_template_file.txt [deleted file]
examples/smpi/MM/topo.c [deleted file]
examples/smpi/MM/topo.h [deleted file]

index 190a4c5..86bc8d6 100644 (file)
@@ -7,7 +7,7 @@ if(enable_smpi)
 
   include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi")
 
 
   include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi")
 
-add_executable(MM_mpi MM_mpi.c 2.5D_MM.c Summa.c topo.c param.c Matrix_init.c)
+add_executable(MM_mpi MM_mpi.c 2.5D_MM.c Summa.c Matrix_init.c)
 
 ### Add definitions for compile
 if(NOT WIN32)
 
 ### Add definitions for compile
 if(NOT WIN32)
index 6ff27c0..df0b9bc 100644 (file)
@@ -4,8 +4,6 @@
  */
 
 
  */
 
 
-#include "topo.h"
-#include "param.h"
 #include "Matrix_init.h"
 #include "2.5D_MM.h"
 #include "xbt/log.h"
 #include "Matrix_init.h"
 #include "2.5D_MM.h"
 #include "xbt/log.h"
@@ -68,12 +66,11 @@ int main(int argc, char ** argv)
   while(loop==1);
 #endif
 
   while(loop==1);
 #endif
 
-  int opt, display = 0;
-  char *conf_file = NULL;
+  int opt = 0;
   optind = 1;
 
   //get the parameter from command line
   optind = 1;
 
   //get the parameter from command line
-  while ((opt = getopt(argc, argv, "hdf:r:c:M:N:K:B:G:g:k:P:")) != -1) {
+  while ((opt = getopt(argc, argv, "hr:c:M:N:K:B:G:g:k:P:")) != -1) {
     switch(opt) {
       case 'h':
         XBT_INFO(
     switch(opt) {
       case 'h':
         XBT_INFO(
@@ -87,8 +84,6 @@ int main(int argc, char ** argv)
                     "  -k I    group rank(default: %zu)\n"
                     "  -r I    processor row size (default: %zu)\n"
                     "  -c I    processor col size (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"
-                    " -f {Filename} provide the file with the configuration\n"
-                    "  -d  display the configuration file on the stderr\n"
                     "  -h      help\n",
                     m, n, k, Block_size, NB_groups, group, key, row, col);
         return 0;
                     "  -h      help\n",
                     m, n, k, Block_size, NB_groups, group, key, row, col);
         return 0;
@@ -122,40 +117,9 @@ int main(int argc, char ** argv)
         /*case 'P':
           str_mask = strdup(optarg);
           break;*/
         /*case 'P':
           str_mask = strdup(optarg);
           break;*/
-      case 'f':
-        conf_file = strdup(optarg);
-        break;
-      case 'd':
-        display = 1;
-        break;
     }
   }
     }
   }
-  if( display == 1 ){
-    print_conf(MPI_COMM_WORLD, myrank,NULL,NULL);
-    MPI_Barrier(MPI_COMM_WORLD);
-    MPI_Finalize();
-    exit(0);
-  }
 
 
-  char **conf;
-  //char ***conf_all;
-  if(conf_file == NULL){
-    conf = get_conf(MPI_COMM_WORLD, "default_conf", -1);
-  }else{
-    conf = get_conf(MPI_COMM_WORLD, conf_file, -1);
-    //conf_all = get_conf_all(conf_file);
-  }
-  if(conf == NULL){
-        XBT_INFO(
-                "No configuration for me inside the file\n");
-  }else{
-
-
-    if(NB_groups !=1){
-      /* Get my group number from the config file */
-      group = (size_t)atoi(conf[4]);
-    }
-  }
 
 
 
 
 
 
diff --git a/examples/smpi/MM/param.c b/examples/smpi/MM/param.c
deleted file mode 100644 (file)
index 0d932fb..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*!
- * get the parameter specific to the process from a file
- *
- */
-
-#include "topo.h"
-#include "param.h"
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <mpi.h>
-#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(MM_param,
-                             "Messages specific for this msg example");
-
-int match(const char *s, char p);
-char** get_list_param(const char* input);
-int match(const char *s, char p)
-{
-  int c = 0;
-  while (*s != '\0') {
-    if (strncmp(s++, &p, 1)) continue;
-    c++;
-  }
-  return c;
-}
-
-char** get_list_param(const char* input){
-  if(input==NULL) return NULL;
-  char *line = strdup(input);
-  int size = match(line, ' ');
-  char **list_param = malloc(size*sizeof(char*));
-  char *pch = strtok (line," \t\n");
-  int i = 0;
-  while (pch != NULL)
-  {
-    if(strcmp(pch,"") != 0 ) {
-      list_param[i] = pch;
-      i++;
-    }
-    pch = strtok (NULL, " \t\n");
-  }
-  return list_param;
-}
-
-char** get_conf(MPI_Comm comm, const char * filename, int mynoderank)
-{
-  if(filename == NULL) return NULL;
-  if(mynoderank == -1){
-    MPI_Comm comm_node;
-    split_comm_intra_node(comm, &comm_node, -1);
-    MPI_Comm_rank ( comm_node, &mynoderank );
-    MPI_Comm_free(&comm_node);
-  }
-  char name[MPI_MAX_PROCESSOR_NAME];
-  int len;
-  MPI_Get_processor_name(name, &len);
-  FILE* conf;
-  conf = fopen(filename, "r");
-  if (conf == NULL) {
-    XBT_DEBUG(
-              "Try to open the configuration file %s\n", filename);
-    perror("fopen");
-    return NULL;
-  }
-  char *machine_name = NULL;
-  size_t number = 0;
-  int err = 1;
-  int index = -1;
-
-
-  /* Try to find the line correponding to this processor */
-  while((err = getdelim(&machine_name, &number, ' ', conf)) != -1) {
-    while(err == 1){
-      err = getdelim(&machine_name, &number, ' ', conf);
-    }
-    if(err == -1) break;
-    XBT_DEBUG(
-              "read: %s cmp to %s\n", machine_name, name);
-    /* the first element is in machine_name
-       it's normally a processor name */
-    /* remove the delimiter before doing the comparison*/
-    machine_name[strlen(machine_name)-1] = 0;
-
-    if(strcmp(machine_name,name) == 0){
-      /* the machine name match */
-
-      /* try to get for which process with the index*/
-      char* char_index=NULL;
-      err = getdelim(&char_index, &number, ' ', conf);
-      while(err == 1){
-        err = getdelim(&char_index, &number, ' ', conf);
-      }
-      if(err == -1) break;
-
-      index=atoi(char_index);
-      XBT_DEBUG(
-                "read: %d cmp to %d\n",
-                index, mynoderank);
-
-      if(index == mynoderank){
-        /* we have found the good line
-         * we rebuild the line to get every information*/
-        char* line = NULL;
-        number = 0;
-        if (getline(&line,&number,conf) == -1)
-          xbt_die("Cannot get line");
-        char* line1 = NULL;
-        asprintf(&line1,"%s %s %s",name,char_index,line);
-        return get_list_param(line1);
-      }
-    }
-
-    /*prepare for the next line*/
-    free(machine_name);
-    machine_name = NULL;
-    number = 0;
-    err = getline(&machine_name, &number,  conf);
-    if (err >= 1) {
-      free(machine_name);
-      machine_name = NULL;
-      number = 0;
-    }
-
-  }
-  XBT_DEBUG(
-            "No configuration for %s %d\n", name, mynoderank );
-  return NULL;
-}
-
-
-
-
-void print_conf(MPI_Comm comm, int rank, FILE* file, char * default_options){
-  char name[MPI_MAX_PROCESSOR_NAME];
-  int len;
-  MPI_Get_processor_name(name, &len);
-  if(file == NULL) file = stdout;
-
-  MPI_Comm comm_node;
-  split_comm_intra_node(comm, &comm_node, 0);
-
-  char ** names = get_names(comm);
-  int* index = get_index( comm,  comm_node);
-  MPI_Comm_free(&comm_node);
-  int size;
-  MPI_Comm_size(comm, &size);
-  int i=0;
-  if(rank == 0){
-    fprintf(file, "#processor_name index USER ARGS (like the cpu binding ...)\n");
-    for(i = 0; i < size; i++){
-      if(default_options != NULL)
-        fprintf(file, "%s %d %s\n", names[i],index[i],default_options);
-      else
-        fprintf(file, "%s %d\n", names[i],index[i]);
-    }
-  }
-  free(names);
-  free(index);
-  return;
-}
diff --git a/examples/smpi/MM/param.h b/examples/smpi/MM/param.h
deleted file mode 100644 (file)
index d6c2bf8..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef param_H_
-#define param_H_
-
-#include <stdio.h>
-
-/*!
- * \page param Provide specific parameters to some processes
- * List of functions:
- * - get_conf - reads a file and returns the specific parameters for the process
- * - print_conf - prints the file for the platform used for this execution
- *
- * here an examples of file:
- *
- * \include utils/param_template_file.txt
- *
- * each process will get the list of arguments specific to its.
- *
- * for example, the process 3<sup>th</sup> on the node1 will receive a pointer
- * on an array of char*:
- *
- *
- *  "node1" "2" "node1_arg21" "node1_arg22" "node1_arg2"
- */
-
-/*! reads a file and returns the specific parameters for the process */
-char** get_conf(MPI_Comm comm, const char * filename, int mynoderank);
-
-
-/*! prints the file for the platform used for this execution */
-void print_conf(MPI_Comm comm, int rank, FILE* file, char * default_options);
-
-#endif /*param_H_*/
diff --git a/examples/smpi/MM/param_template_file.txt b/examples/smpi/MM/param_template_file.txt
deleted file mode 100644 (file)
index d983d3e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-node1 0 node1_arg01 node1_arg02 node1_arg03
-node1 1 node1_arg11 node1_arg12 node1_arg13
-node1 2 node1_arg21 node1_arg22 node1_arg23
-node1 3 node1_arg31 node1_arg32 node1_arg33
-node2 0 node2_arg01 node2_arg02 node2_arg03
-node2 1 node2_arg11 node2_arg12 node2_arg13
-node3 0 node3_arg01 node3_arg02 node3_arg03
-node3 1 node3_arg11 node3_arg12 node3_arg13
-node3 2 node3_arg21 node3_arg22 node3_arg23
diff --git a/examples/smpi/MM/topo.c b/examples/smpi/MM/topo.c
deleted file mode 100644 (file)
index 2c6d92a..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*!
- * get the information of which thread are on the same node
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include "topo.h"
-
-int split_comm_intra_node(MPI_Comm comm, MPI_Comm* comm_intra, int key) {
-  // collect processor names
-  char name[MPI_MAX_PROCESSOR_NAME];
-  int len;
-  int size;
-  char** names = get_names(comm);
-  int color = -1;
-  int i = 0;
-
-  MPI_Get_processor_name(name, &len);
-  MPI_Comm_size(comm, &size);
-  while (i < size){
-    if (strcmp(name, names[i]) == 0) {
-      break;
-    }
-    i++;
-  }
-  color = i;
-  free(names);
-  // split the communicator
-  return MPI_Comm_split(comm, color, key, comm_intra);
-}
-
-char** get_names(MPI_Comm comm){
-  char name[MPI_MAX_PROCESSOR_NAME];
-  int len;
-  int size;
-  int i;
-  char** friendly_names;
-  char*  names;
-
-  MPI_Get_processor_name(name, &len);
-  MPI_Comm_size(comm, &size);
-  friendly_names = malloc(sizeof(char*) * size);
-  names          = malloc(sizeof(char) * MPI_MAX_PROCESSOR_NAME * size);
-
-  MPI_Allgather(name, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, names,
-                MPI_MAX_PROCESSOR_NAME, MPI_CHAR, comm);
-
-  for( i = 0; i < size;i++) friendly_names[i] = &names[MPI_MAX_PROCESSOR_NAME * i];
-  return friendly_names;
-}
-
-int* get_index(MPI_Comm comm, MPI_Comm comm_intra){
-  int rank = 0;
-  int size;
-  int* index;
-
-  MPI_Comm_rank(comm_intra, &rank);
-  MPI_Comm_size(comm, &size);
-  index = (int*)malloc(sizeof(int) * size);
-  MPI_Allgather(&rank, 1, MPI_INT, index, 1, MPI_INT, comm);
-  return index;
-}
-
diff --git a/examples/smpi/MM/topo.h b/examples/smpi/MM/topo.h
deleted file mode 100644 (file)
index 06e29e5..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef topo_H_
-#define topo_H_
-#include <mpi.h>
-
-/*!
- * \defgroup topo.h
- * file related to the plateform description.
- *
- * provide a communicator between the process on the same node*/
-int split_comm_intra_node(MPI_Comm comm, MPI_Comm* comm_intra, int key);
-
-
-int* get_index(MPI_Comm comm, MPI_Comm comm_intra);
-char** get_names(MPI_Comm comm);
-
-#endif /*topo_H_*/