• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2022 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 
17 #ifndef MINDSPORE_MONITOR_H
18 #define MINDSPORE_MONITOR_H
19 
20 #include <memory>
21 #include <mutex>
22 #include <unordered_map>
23 #include <vector>
24 #include "minddata/dataset/engine/perf/profiling.h"
25 #include "minddata/dataset/util/cond_var.h"
26 #include "minddata/dataset/util/status.h"
27 
28 namespace mindspore {
29 namespace dataset {
30 class ExecutionTree;
31 class ProfilingManager;
32 class ConfigManager;
33 
34 class Monitor {
35  public:
36   // Monitor object constructor
37   explicit Monitor(ProfilingManager *profiling_manager);
38 
39   ~Monitor();
40 
41   // Functor for Perf Monitor main loop.
42   // This function will be the entry point of mindspore::Dataset::Task
43   Status operator()();
44 
45   // Setter for execution tree pointer
SetTree(ExecutionTree * tree)46   void SetTree(ExecutionTree *tree) { tree_ = tree; }
47 
48  private:
49   // private constructor
50   Monitor(ProfilingManager *profiling_manager, const std::shared_ptr<ConfigManager> &cfg);
51 
52   ProfilingManager *profiling_manager_;
53   int64_t sampling_interval_;
54   ExecutionTree *tree_;
55   std::mutex mux_;
56   CondVar cv_;
57 };
58 }  // namespace dataset
59 }  // namespace mindspore
60 
61 #endif  // MINDSPORE_MONITOR_H
62