/** * \file profile.cpp * \author Dhairya Malhotra, dhairya.malhotra@gmail.com * \date 2-11-2011 * \brief This file contains implementation of the class Profile. */ #include #include #include #include #include #include #include #include #include #include #include #include namespace pvfmm{ long long Profile::Add_FLOP(long long inc){ long long orig_val=FLOP; #if __PROFILE__ >= 0 #pragma omp atomic update FLOP+=inc; #endif return orig_val; } long long Profile::Add_MEM(long long inc){ long long orig_val=MEM; #if __PROFILE__ >= 0 #pragma omp atomic update MEM+=inc; for(size_t i=0;i= 0 enable_state=state; #endif return orig_val; } void Profile::Tic(const char* name_, const MPI_Comm* comm_,bool sync_, int verbose){ #if __PROFILE__ >= 0 //sync_=true; if(!enable_state) return; if(verbose<=__PROFILE__ && verb_level.size()==enable_depth){ if(comm_!=NULL && sync_) MPI_Barrier(*comm_); #ifdef __VERBOSE__ int rank=0; if(comm_!=NULL) MPI_Comm_rank(*comm_,&rank); if(!rank){ for(size_t i=0;i= 0 if(!enable_state) return; ASSERT_WITH_MSG(!verb_level.empty(),"Unbalanced extra Toc()"); if(verb_level.top()<=__PROFILE__ && verb_level.size()==enable_depth){ ASSERT_WITH_MSG(!name.empty() && !comm.empty() && !sync.empty() && !max_mem.empty(),"Unbalanced extra Toc()"); std::string name_=name.top(); MPI_Comm* comm_=comm.top(); bool sync_=sync.top(); //sync_=true; e_log.push_back(false); s_log.push_back(sync_); n_log.push_back(name_); t_log.push_back(omp_get_wtime()); f_log.push_back(FLOP); m_log.push_back(MEM); max_m_log.push_back(max_mem.back()); #ifndef NDEBUG if(comm_!=NULL && sync_) MPI_Barrier(*comm_); #endif name.pop(); comm.pop(); sync.pop(); max_mem.pop_back(); #ifdef __VERBOSE__ int rank=0; if(comm_!=NULL) MPI_Comm_rank(*comm_,&rank); if(!rank){ for(size_t i=0;i= 0 ASSERT_WITH_MSG(name.empty(),"Missing balancing Toc()"); int np, rank; MPI_Comm c_self=MPI_COMM_SELF; if(comm_==NULL) comm_=&c_self; MPI_Barrier(*comm_); MPI_Comm_size(*comm_,&np); MPI_Comm_rank(*comm_,&rank); std::stack tt; std::stack ff; std::stack mm; int width=10; size_t level=0; if(!rank && e_log.size()>0){ std::cout<<"\n"< out_stack; std::string s; out_stack.push(s); for(size_t i=0;ij && lj && l Profile::sync; std::stack Profile::name; std::stack Profile::comm; std::vector Profile::max_mem; unsigned int Profile::enable_depth=0; std::stack Profile::verb_level; std::vector Profile::e_log; std::vector Profile::s_log; std::vector Profile::n_log; std::vector Profile::t_log; std::vector Profile::f_log; std::vector Profile::m_log; std::vector Profile::max_m_log; }//end namespace