Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

buildDA.C

Go to the documentation of this file.
00001 
00007 #include "mpi.h"
00008 #include "petsc.h"
00009 #include "sys.h"
00010 #include "parUtils.h"
00011 #include "TreeNode.h"
00012 #include "colors.h"
00013 #include "oda.h"
00014 #include <cstdlib>
00015 #include "externVars.h"
00016 #include "dendro.h"
00017 
00018 //Don't want time to be synchronized. Need to check load imbalance.
00019 #ifdef MPI_WTIME_IS_GLOBAL
00020 #undef MPI_WTIME_IS_GLOBAL
00021 #endif
00022 
00023 int main(int argc, char ** argv ) {     
00024   int size, rank;
00025   char bFile[50];
00026   bool compressLut=false;
00027   double localTime, totalTime;
00028   double startTime, endTime;
00029   DendroIntL locSz, totalSz;
00030   std::vector<ot::TreeNode> balOct;
00031 
00032   PetscInitialize(&argc,&argv,"options",NULL);
00033   ot::RegisterEvents();
00034   ot::DA_Initialize(MPI_COMM_WORLD);
00035 
00036 #ifdef PETSC_USE_LOG
00037   int stages[1];
00038   PetscLogStageRegister(&stages[0],"ODACreate");
00039 #endif
00040 
00041   MPI_Comm_size(MPI_COMM_WORLD,&size);
00042   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
00043   if(argc < 2) {
00044     std::cerr << "Usage: " << argv[0] << "inpfile compressLut[0] " << std::endl;
00045     return -1;
00046   }
00047   if(argc > 2) { compressLut = (bool)(atoi(argv[2]));}
00048 
00049   sprintf(bFile,"%s%d_%d.ot",argv[1],rank,size);        
00050 
00051   if(!rank){
00052     std::cout << " reading  "<<bFile<<std::endl; // Point size
00053   }
00054   ot::readNodesFromFile (bFile,balOct);
00055   if(!rank){
00056     std::cout << " finished reading  "<<bFile<<std::endl; // Point size
00057   }
00058   // compute total inp size and output size
00059   locSz = balOct.size();
00060   par::Mpi_Reduce<DendroIntL>(&locSz, &totalSz, 1, MPI_SUM, 0, MPI_COMM_WORLD);
00061   par::Mpi_Reduce<double>(&localTime, &totalTime, 1, MPI_MAX, 0, MPI_COMM_WORLD);
00062 
00063   if(!rank) {
00064     std::cout << "# of Balanced Octants: "<< totalSz << std::endl;       
00065   }
00066 
00067   //ODA ...
00068   MPI_Barrier(MPI_COMM_WORLD);  
00069 #ifdef PETSC_USE_LOG
00070   PetscLogStagePush(stages[0]);
00071 #endif
00072   startTime = MPI_Wtime();
00073   assert(!(balOct.empty()));
00074   ot::DA da(balOct, MPI_COMM_WORLD, MPI_COMM_WORLD, compressLut);
00075   endTime = MPI_Wtime();
00076 #ifdef PETSC_USE_LOG
00077   PetscLogStagePop();
00078 #endif
00079   balOct.clear();
00080   // compute total inp size and output size
00081   locSz = da.getNodeSize();
00082   localTime = endTime - startTime;
00083   par::Mpi_Reduce<DendroIntL>(&locSz, &totalSz, 1, MPI_SUM, 0, MPI_COMM_WORLD);
00084   par::Mpi_Reduce<double>(&localTime, &totalTime, 1, MPI_MAX, 0, MPI_COMM_WORLD);
00085 
00086   if(!rank) {
00087     std::cout << "Total # Vertices: "<< totalSz << std::endl;       
00088     std::cout << "Time to build ODA: "<<totalTime << std::endl;
00089   }
00090 
00091   if (!rank) {
00092     std::cout << GRN << "Finalizing ..." << NRM << std::endl;
00093   }
00094 
00095   ot::DA_Finalize();
00096   PetscFinalize();
00097 }//end function
00098 

Generated on Tue Mar 24 16:13:58 2009 for DENDRO by  doxygen 1.3.9.1