profile.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _PVFMM_PROFILE_HPP_
  2. #define _PVFMM_PROFILE_HPP_
  3. #include <string>
  4. #include <vector>
  5. #include <stack>
  6. #include <pvfmm/common.hpp>
  7. #ifndef PVFMM_PROFILE
  8. #define PVFMM_PROFILE -1
  9. #endif
  10. namespace pvfmm {
  11. class Comm;
  12. class Profile {
  13. public:
  14. static Long Add_FLOP(Long inc);
  15. static Long Add_MEM(Long inc);
  16. static bool Enable(bool state);
  17. static void Tic(const char* name_, const Comm* comm_ = NULL, bool sync_ = false, Integer level = 0);
  18. static void Toc();
  19. static void print(const Comm* comm_ = NULL);
  20. static void reset();
  21. private:
  22. struct ProfileData {
  23. Long MEM;
  24. Long FLOP;
  25. bool enable_state;
  26. std::stack<bool> sync;
  27. std::stack<std::string> name;
  28. std::stack<const Comm*> comm;
  29. std::vector<Long> max_mem;
  30. Integer enable_depth;
  31. std::stack<int> verb_level;
  32. std::vector<bool> e_log;
  33. std::vector<bool> s_log;
  34. std::vector<std::string> n_log;
  35. std::vector<double> t_log;
  36. std::vector<Long> f_log;
  37. std::vector<Long> m_log;
  38. std::vector<Long> max_m_log;
  39. ProfileData() {
  40. FLOP = 0;
  41. MEM = 0;
  42. enable_state = false;
  43. enable_depth = 0;
  44. }
  45. };
  46. static inline ProfileData& ProfData() {
  47. static ProfileData p;
  48. return p;
  49. }
  50. };
  51. } // end namespace
  52. #include <pvfmm/profile.txx>
  53. #endif //_PVFMM_PROFILE_HPP_