Bläddra i källkod

update example fmm_cheb.cpp

Dhairya Malhotra 11 år sedan
förälder
incheckning
8dde7b6a45
2 ändrade filer med 48 tillägg och 38 borttagningar
  1. 44 37
      examples/src/fmm_cheb.cpp
  2. 4 1
      scripts/.results.sh

+ 44 - 37
examples/src/fmm_cheb.cpp

@@ -386,50 +386,19 @@ void fmm_test(int test_case, size_t N, size_t M, bool unif, int mult_order, int
   CheckChebOutput<FMM_Tree_t>(tree, (typename TestFn<Real_t>::Fn_t) fn_input_, mykernel->ker_dim[0], std::string("Input"));
 
   for(size_t iter=0;iter<6;iter++){ // Load balance.
-    { //Output max, min tree size.
-      long node_cnt=0;
-      std::vector<FMMNode_t*>& nodes=tree->GetNodeList();
-      for(size_t i=0;i<nodes.size();i++){
-        FMMNode_t* n=nodes[i];
-        if(!n->IsGhost() && n->IsLeaf()) node_cnt++;
-      }
-
-      if(!myrank) std::cout<<"MAX, MIN Nodes: ";
-      long max=0;
-      long min=0;
-      MPI_Allreduce(&node_cnt, &max, 1, MPI_LONG, MPI_MAX, comm);
-      MPI_Allreduce(&node_cnt, &min, 1, MPI_LONG, MPI_MIN, comm);
-      if(!myrank) std::cout<<max<<' ';
-      if(!myrank) std::cout<<min<<'\n';
-    }
-    tree->RedistNodes();
-    { //Output max, min tree size.
-      long node_cnt=0;
-      std::vector<FMMNode_t*>& nodes=tree->GetNodeList();
-      for(size_t i=0;i<nodes.size();i++){
-        FMMNode_t* n=nodes[i];
-        if(!n->IsGhost() && n->IsLeaf()) node_cnt++;
-      }
-
-      if(!myrank) std::cout<<"MAX, MIN Nodes: ";
-      long max=0;
-      long min=0;
-      MPI_Allreduce(&node_cnt, &max, 1, MPI_LONG, MPI_MAX, comm);
-      MPI_Allreduce(&node_cnt, &min, 1, MPI_LONG, MPI_MIN, comm);
-      if(!myrank) std::cout<<max<<' ';
-      if(!myrank) std::cout<<min<<'\n';
-    }
+    // Setup FMM
     tree->SetupFMM(fmm_mat);
-
     tree->RunFMM();
+
+    //Re-run and time
     MPI_Barrier(comm);
     double tt=-omp_get_wtime();
     tree->RunFMM();
     tt+=omp_get_wtime();
 
-    { // Set weights
-      std::vector<FMMNode_t*> nlist=tree->GetNodeList();
+    { // Redistribute
       size_t node_cnt=0;
+      std::vector<FMMNode_t*> nlist=tree->GetNodeList();
       for(size_t i=0;i<nlist.size();i++){
         if(nlist[i]->IsLeaf() && !nlist[i]->IsGhost())
           node_cnt++;
@@ -437,9 +406,47 @@ void fmm_test(int test_case, size_t N, size_t M, bool unif, int mult_order, int
       for(size_t i=0;i<nlist.size();i++){
         nlist[i]->NodeCost()=(tt*100000000)/node_cnt;
       }
+
+      { //Output max, min tree size.
+        long node_cnt=0;
+        std::vector<FMMNode_t*>& nodes=tree->GetNodeList();
+        for(size_t i=0;i<nodes.size();i++){
+          FMMNode_t* n=nodes[i];
+          if(!n->IsGhost() && n->IsLeaf()) node_cnt++;
+        }
+
+        if(!myrank) std::cout<<"MAX, MIN Nodes: ";
+        long max=0;
+        long min=0;
+        MPI_Allreduce(&node_cnt, &max, 1, MPI_LONG, MPI_MAX, comm);
+        MPI_Allreduce(&node_cnt, &min, 1, MPI_LONG, MPI_MIN, comm);
+        if(!myrank) std::cout<<max<<' ';
+        if(!myrank) std::cout<<min<<'\n';
+      }
+      tree->RedistNodes();
+      { //Output max, min tree size.
+        long node_cnt=0;
+        std::vector<FMMNode_t*>& nodes=tree->GetNodeList();
+        for(size_t i=0;i<nodes.size();i++){
+          FMMNode_t* n=nodes[i];
+          if(!n->IsGhost() && n->IsLeaf()) node_cnt++;
+        }
+
+        if(!myrank) std::cout<<"MAX, MIN Nodes: ";
+        long max=0;
+        long min=0;
+        MPI_Allreduce(&node_cnt, &max, 1, MPI_LONG, MPI_MAX, comm);
+        MPI_Allreduce(&node_cnt, &min, 1, MPI_LONG, MPI_MIN, comm);
+        if(!myrank) std::cout<<max<<' ';
+        if(!myrank) std::cout<<min<<'\n';
+      }
     }
   }
 
+  // Setup FMM
+  tree->SetupFMM(fmm_mat);
+  tree->RunFMM();
+
   //Re-run FMM
   tree->ClearFMMData();
   tree->RunFMM();
@@ -511,7 +518,7 @@ int main(int argc, char **argv){
     MPI_Allreduce(&t, &tt, 1, pvfmm::par::Mpi_datatype<double>::value(), MPI_SUM, comm_);
     tt=tt/np;
 
-    int clr=(t<tt*1.1?0:1);
+    int clr=(t<tt*1.5?0:1);
     MPI_Comm_split(comm_, clr, myrank, &comm );
     if(clr){
       MPI_Finalize();

+ 4 - 1
scripts/.results.sh

@@ -111,6 +111,8 @@ for (( l=0; l<${#nodes[@]}; l++ )) ; do
     for i in ${NODE_LIST} ; do 
       NODES=$(( $NODES + $i )); 
     done;
+    PROC_NOMIC="$(grep -hir "Number of MPI processes:" ${FNAME_NOMIC} | tail -n 1 | tr -s ' ' | rev | cut -d ' ' -f 1 | rev)"
+    PROC="$(grep -hir "Number of MPI processes:" ${FNAME} | tail -n 1 | tr -s ' ' | rev | cut -d ' ' -f 1 | rev)"
     #---------------------------------------------------------------------
     # Parse Data: Time, Flop, Flop/s 
     for (( i=0; i<$N; i++ )) ; do
@@ -119,6 +121,7 @@ for (( l=0; l<${#nodes[@]}; l++ )) ; do
       T_MAX[i]="$(grep -hir "$x  " ${FNAME} | tail -n 1 | tr -s ' ' | rev | cut -d ' ' -f 10 | rev)"
       if [ "${T_MAX[i]}" == "" ]; then continue; fi;
       FP_AVG[i]="$(grep -hir "$x  " ${FNAME_NOMIC} | tail -n 1 | tr -s ' ' | rev | cut -d ' ' -f 8 | rev)"
+      FP_AVG[i]=$(echo "scale=10;${FP_AVG[i]}*${PROC_NOMIC}/${mpi_proc[l]}" | bc 2> /dev/null)
       FLOPS[i]=$(echo "scale=10;${FP_AVG[i]}/(${T_MAX[i]}+0.0001)" | bc 2> /dev/null)
 
       if [ "${FLOPS[i]}" != "" ] && [ -f ${FNAME_MIC} ] && [ -f ${FNAME_ASYNC} ] && [ -f ${FNAME_NOMIC} ] ; then 
@@ -148,7 +151,7 @@ for (( l=0; l<${#nodes[@]}; l++ )) ; do
     done;
     printf "   |" >> ${RESULT_FNAME}      
     #---------------------------------------------------------------------
-    printf "${PARAM_FORMAT}"            "${mpi_proc[l]}" >> ${RESULT_FNAME}      
+    printf "${PARAM_FORMAT}"            "${PROC}" >> ${RESULT_FNAME}      
     printf "${PARAM_FORMAT}"             "${threads[l]}" >> ${RESULT_FNAME}      
     printf "${PARAM_FORMAT}"               "${nodes[l]}" >> ${RESULT_FNAME}      
     printf "${PARAM_FORMAT}" "$((${NODES}/${nodes[l]}))" >> ${RESULT_FNAME}