Merge branch 'charm' of charmgit:charm into charm
authorEmmanuel Jeannot <ejeannot@mobile-192-17-202-71.near.uiuc.edu>
Wed, 30 Mar 2011 20:34:51 +0000 (22:34 +0200)
committerEmmanuel Jeannot <ejeannot@mobile-192-17-202-71.near.uiuc.edu>
Wed, 30 Mar 2011 20:34:51 +0000 (22:34 +0200)
src/ck-ldb/tm_bucket.c
src/ck-ldb/tm_mapping.c
src/ck-ldb/tm_tree.c

index f2c2e17d0147829895369a323f53a14b9ac04579..115105bb7853ccb427edfea4478dfa39bcce6e00 100644 (file)
@@ -111,14 +111,20 @@ void check_bucket(bucket_t *b,double **tab,double inf, double sup,int N){
   }
 }
 
-void  display_bucket_list(bucket_list_t bucket_list){
+void  display_pivots(bucket_list_t bucket_list){
   int i;
-  double inf,sup;
 
   for(i=0;i<bucket_list->nb_buckets-1;i++){
     printf("pivot[%d]=%f\n",i,bucket_list->pivot[i]);
   }
   printf("\n");
+}
+
+void  display_bucket_list(bucket_list_t bucket_list){
+  int i;
+  double inf,sup;
+
+  display_pivots(bucket_list);
 
   for(i=0;i<bucket_list->nb_buckets;i++){
     inf=bucket_list->pivot[i];
@@ -246,9 +252,9 @@ void partial_sort(bucket_list_t *bl,double **tab,int N,int nb_buckets){
 
 
   n=pow(nb_buckets,2);
-  printf("N=%d, n=%d\n",N,n);
   
   assert(n=N);
+  printf("N=%d, n=%d\n",N,n);
   sample=(int*)malloc(2*sizeof(int)*n);
   
   for(k=0;k<n;k++){
@@ -267,13 +273,13 @@ void partial_sort(bucket_list_t *bl,double **tab,int N,int nb_buckets){
   
   global_bl=bucket_list;
   qsort(sample,n,2*sizeof(int),tab_cmp);
-
-  /*  for(k=0;k<N;k++){
-    i=sample[k]/N;
-    j=sample[k]%N;
+  /*
+  for(k=0;k<n;k++){
+    i=sample[2*k];
+    j=sample[2*k+1];
     printf("%f\n",tab[i][j]);
-  }
-  */
+    }*/
+  
   pivot=(double*)malloc(sizeof(double)*nb_buckets-1);
   id=1;
   for(k=1;k<nb_buckets;k++){
@@ -453,6 +459,9 @@ void bucket_grouping(double **tab,tree_t *tab_node, tree_t *new_tab_node, int ar
   partial_sort(&bucket_list,tab,N,8);
   duration=TOC;
   printf("Partial sorting=%fs\n",duration);  
+
+  display_pivots(bucket_list);
+
  
   TIC;
   l=0;
index 435e8a4e7fbd32213e7715a7a80cc6f29dac2aac..f7c49665052671e6872a537353506a48bf38dd9b 100644 (file)
@@ -643,9 +643,12 @@ void TreeMatchMapping(int nb_obj, int nb_proc, double **comm_mat,  double *obj_w
   int i;
   TIC;
   
-  for(i=0;i<nb_obj;i++)
+  for(i=0;i<nb_obj;i++){
     sol[i]=i;
-
+    //    printf("%f ",obj_weight[i]);
+  }
+  //printf("\n");
+  
 
   //  return;
 
@@ -669,8 +672,12 @@ void TreeMatchMapping(int nb_obj, int nb_proc, double **comm_mat,  double *obj_w
 
   //display_tab(comm_mat,N);
 
+  TIC;
   comm_tree=build_tree_from_topology(topology,comm_mat,nb_obj,obj_weight,comm_speed);
+  printf("Tree buildinbg time=%f\n",TOC);
+  TIC;
   map_topology(topology,comm_tree,nb_proc,1,sol,NULL);
+  printf("Topology mapping time=%f\n",TOC);
 
 
   if(topology->nb_levels>d)
index d448a4d2db552701caaba02e8cc73aff382f19d6..3b06e87e05a11cc5b169cd13a3d1ef3b37b35480 100644 (file)
@@ -101,6 +101,7 @@ double *aggregate_obj_weight(tree_t *new_tab_node, double *tab, int M){
   res=(double*)malloc(M*sizeof(double));
   
   for(i=0;i<M;i++){
+    res[i]=0.0;
     for(i1=0;i1<new_tab_node[i].arity;i1++){
       id1=new_tab_node[i].child[i1]->id;
       res[i]+=tab[id1];
@@ -804,12 +805,14 @@ double **build_cost_matrix(double **comm_matrix, double* obj_weight, double comm
     avg+=obj_weight[i];
   avg/=N;
 
+  printf("avg=%f\n",avg);
+
   for(i=0;i<N;i++)
     for(j=0;j<N;j++)
       if(i==j)
        res[i][j]=0;
       else
-       res[i][j]=comm_matrix[i][j]/comm_speed-abs(avg-(obj_weight[i]+obj_weight[j])/2);
+       res[i][j]=1e-4*comm_matrix[i][j]/comm_speed-fabs(avg-(obj_weight[i]+obj_weight[j])/2);
 
   return res;
   
@@ -825,7 +828,7 @@ double **build_cost_matrix(double **comm_matrix, double* obj_weight, double comm
   N: size of tab and tab_node. i.e. number of nodes at the considered level
   M: size of new_tab_node (i.e) the number of parents
   Hence we have: M*arity=N
-*/void group_nodes(double **comm_matrix,tree_t *tab_node, tree_t *new_tab_node, int arity,int N, int M, double* obj_weigth, double comm_speed){
+*/void group_nodes(double **comm_matrix,tree_t *tab_node, tree_t *new_tab_node, int depth, int arity,int N, int M, double* obj_weigth, double comm_speed){
   tree_t **cur_group;
   int j,l,n;
   long int k;
@@ -841,10 +844,11 @@ double **build_cost_matrix(double **comm_matrix, double* obj_weight, double comm
   tab=build_cost_matrix(comm_matrix,obj_weigth,comm_speed,N);
 
 
+
   k=choose(N,arity);
   printf("Number of groups:%ld\n",k);
   
-  if(k>30000){
+  if(k>30000||depth>5){
   #ifdef DEBUG
     printf("Fast Grouping...\n");
 #endif
@@ -853,6 +857,7 @@ double **build_cost_matrix(double **comm_matrix, double* obj_weight, double comm
     
     TIC;
     if(arity<=2){
+      //super_fast_grouping(tab,tab_node,new_tab_node,arity,N,M,k);
       bucket_grouping(tab,tab_node,new_tab_node,arity,N,M,k);
     }else{
       fast_grouping(tab,tab_node,new_tab_node,arity,N,M,k);
@@ -1148,7 +1153,7 @@ tree_t *build_level_topology(tree_t *tab_node,double **com_mat,int N,int arity,i
     speed=comm_speed[depth];
   else
     speed=-1;
-  group_nodes(com_mat,tab_node,new_tab_node,arity,N,M,obj_weight,speed);
+  group_nodes(com_mat,tab_node,new_tab_node,depth,arity,N,M,obj_weight,speed);
  
   /*based on that grouping aggregate the communication matrix*/
   new_com_mat=aggregate_com_mat(new_tab_node,com_mat,M);