You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

profiling_manager.h 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright 2019 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MINDSPORE_CCSRC_DEVICE_ASCEND_PROFILING_PROFILING_MANAGER_H_
  17. #define MINDSPORE_CCSRC_DEVICE_ASCEND_PROFILING_PROFILING_MANAGER_H_
  18. #include <map>
  19. #include <cstring>
  20. #include <string>
  21. #include <memory>
  22. using std::map;
  23. using std::string;
  24. namespace mindspore {
  25. namespace device {
  26. namespace ascend {
  27. // PROFILING_CUSTOM_LOGID_START 3
  28. const uint64_t kProfilingFpStartLogId = 1;
  29. const uint64_t kProfilingBpEndLogId = 2;
  30. const uint64_t kProfilingIterEndLogId = 255;
  31. class ProfilingEngineImpl;
  32. class ProfilingManager {
  33. public:
  34. static ProfilingManager &GetInstance();
  35. uint64_t GetJobId() const;
  36. bool ReportProfilingData(const map<uint32_t, string> &op_taskId_map) const;
  37. bool StartupProfiling(uint32_t device_id);
  38. bool StopProfiling() const;
  39. inline bool IsProfiling() const {
  40. const char *is_profiling = std::getenv("PROFILING_MODE");
  41. return (is_profiling != nullptr && (strcmp("true", is_profiling) == 0));
  42. }
  43. protected:
  44. ProfilingManager();
  45. ~ProfilingManager() { prof_handle_ = nullptr; }
  46. private:
  47. std::shared_ptr<ProfilingEngineImpl> engine_0_;
  48. uint32_t device_id_;
  49. void *prof_handle_;
  50. };
  51. } // namespace ascend
  52. } // namespace device
  53. } // namespace mindspore
  54. #endif // MINDSPORE_CCSRC_DEVICE_ASCEND_PROFILING_PROFILING_MANAGER_H_