profile.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _SCTL_PROFILE_HPP_
  2. #define _SCTL_PROFILE_HPP_
  3. #include <string>
  4. #include <vector>
  5. #include <stack>
  6. #include SCTL_INCLUDE(common.hpp)
  7. #ifndef SCTL_PROFILE
  8. #define SCTL_PROFILE -1
  9. #endif
  10. namespace SCTL_NAMESPACE {
  11. class Comm;
  12. class Profile {
  13. public:
  14. static Long Add_MEM(Long inc);
  15. static Long Add_FLOP(Long inc);
  16. static bool Enable(bool state);
  17. static void Tic(const char* name_, const Comm* comm_ = nullptr, bool sync_ = false, Integer level = 0);
  18. static void Toc();
  19. static void print(const Comm* comm_ = nullptr);
  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. MEM = 0;
  41. FLOP = 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 SCTL_INCLUDE(profile.txx)
  53. #endif //_SCTL_PROFILE_HPP_