ManagerInterActive.cpp

Go to the documentation of this file.
00001 
00015 #include "ManagerInterActive.hpp"
00016 #include <Utils/Util.hpp>
00017 
00018 
00019 namespace OA {
00020   namespace Activity {
00021 
00022 static bool debug = false;
00023 
00024 ManagerInterActive::ManagerInterActive(
00025     OA_ptr<Activity::ActivityIRInterface> _ir) : mIR(_ir)
00026 {
00027     OA_DEBUG_CTRL_MACRO("DEBUG_ManagerInterActive:ALL", debug);
00028 }
00029 
00033 OA_ptr<InterActive> 
00034 ManagerInterActive::performAnalysis(
00035         OA_ptr<CallGraph::Interface> callGraph,
00036         OA_ptr<DataFlow::ParamBindings> paramBind,
00037         OA_ptr<Alias::InterAliasInterface> interAlias,
00038         OA_ptr<SideEffect::InterSideEffectInterface> interSE,
00039         OA_ptr<CFG::EachCFGInterface> eachCFG)
00040 {
00041   assert(0); // currently not working, ManagerICFGActive is better approach
00042              // and therefore haven't updated this one with fixes
00043 
00044   OA_ptr<InterActive> retval;
00045   retval = new InterActive;
00046 
00047   // create a Manager that generates interprocedure dep information
00048   OA_ptr<ManagerInterDep> depman;
00049   depman = new ManagerInterDep(mIR);
00050   OA_ptr<InterDep> interDep = depman->performAnalysis(callGraph, paramBind,
00051           interAlias, interSE, eachCFG);
00052 
00053   if (debug) { interDep->dump(std::cout, mIR); }
00054 
00055   // based on the dep information, ManagerInterVary will query the 
00056   // subroutine for what locations are indep or get that information
00057   // from other routines in the call graph
00058   OA_ptr<ManagerInterVary> varyman;
00059   varyman = new ManagerInterVary(mIR);
00060   OA_ptr<InterVary> interVary = varyman->performAnalysis(callGraph, paramBind,
00061           interAlias, eachCFG, interDep);
00062   
00063   if (debug) { interVary->dump(std::cout, mIR); }
00064   
00065   // based on the dep information, ManagerInterUseful will query the 
00066   // subroutine for what locations are dep or get that information
00067   // from other routines in the call graph
00068   OA_ptr<ManagerInterUseful> usefulman;
00069   usefulman = new ManagerInterUseful(mIR);
00070   OA_ptr<InterUseful> interUseful = usefulman->performAnalysis(callGraph, 
00071           paramBind, interAlias, eachCFG, interDep);
00072 
00073   if (debug) { interUseful->dump(std::cout, mIR); }
00074 
00075   // Iterate over the procedures in the call graph
00076   OA_ptr<CallGraph::Interface::NodesIterator> procIter
00077       = callGraph->getNodesIterator();
00078   for ( ; procIter->isValid(); ++(*procIter)) { 
00079     
00080     ProcHandle proc = procIter->current()->getProc();
00081 
00082     // if this procedure isn't defined then move on
00083     if (proc==ProcHandle(0)) { 
00084         continue;
00085     }
00086 
00087     //set currentProc()
00088     //mIR->currentProc(proc);
00089 
00090     // get Alias::Interface for this proc
00091     OA_ptr<Alias::Interface> alias;
00092     alias = interAlias->getAliasResults(proc);
00093 
00094     // get CFG for this proc
00095     OA_ptr<CFG::Interface> cfg;
00096     cfg = eachCFG->getCFGResults(proc);
00097 
00098     // get useful for this proc
00099     OA_ptr<UsefulStandard> useful = interUseful->getUsefulResults(proc);
00100 
00101     // get vary for this proc
00102     OA_ptr<VaryStandard> vary = interVary->getVaryResults(proc);
00103 
00104     // create Active manager
00105     OA_ptr<Activity::ManagerActiveStandard> activeman;
00106     activeman = new Activity::ManagerActiveStandard(mIR);
00107 
00108     OA_ptr<ActiveStandard> active 
00109         = activeman->performAnalysis(proc, cfg,
00110                 alias,vary, useful);
00111     if (debug) { active->dump(std::cout, mIR); }
00112 
00113     // put activity results in InterMPICFGActivity
00114     retval->mapProcToActive(proc,active);
00115 
00116   }
00117 
00118   // iterate over all symbols to determine the size
00119   OA_ptr<SymHandleIterator> symIter = retval->getActiveSymIterator();
00120   int bytes = 0;
00121   for ( ; symIter->isValid(); (*symIter)++ ) {
00122       SymHandle sym = symIter->current();
00123 
00124       bytes += mIR->getSizeInBytes(sym);
00125 
00126       if (debug) {
00127           std::cout << "ManagerInterActive: sym = " << mIR->toString(sym)
00128                     << ", size = " << mIR->getSizeInBytes(sym) << ", bytes = "
00129                     << bytes << std::endl;
00130       }
00131   }
00132   retval->setActiveSizeInBytes(bytes);
00133  
00134   return retval;
00135 }
00136  
00137 
00138   } // end of namespace Activity
00139 } // end of namespace OA