|
9 | 9 |
|
10 | 10 | // Ondemand tracing is not supported on Apple or edge platform |
11 | 11 | #if defined(__APPLE__) || defined(EDGE_PROFILER_USE_KINETO) |
12 | | -#defineENABLE_GLOBAL_OBSERVER (0) |
| 12 | +constexprboolkEnableGlobalObserver =false; |
13 | 13 | #else |
14 | | -#defineENABLE_GLOBAL_OBSERVER (1) |
| 14 | +constexprboolkEnableGlobalObserver =true; |
15 | 15 | #endif |
16 | 16 |
|
17 | 17 | namespacetorch { |
@@ -90,28 +90,28 @@ class LibKinetoClient : public libkineto::ClientInterface { |
90 | 90 | }// namespace profiler::impl |
91 | 91 |
|
92 | 92 | voidglobal_kineto_init() { |
93 | | -#if ENABLE_GLOBAL_OBSERVER |
94 | | -if (c10::utils::get_env("KINETO_USE_DAEMON").has_value()) { |
95 | | -libkineto_init( |
96 | | -/*cpuOnly=*/!(at::hasCUDA() ||at::hasXPU() ||at::hasMTIA()), |
97 | | -/*logOnError=*/true); |
98 | | -libkineto::api().suppressLogMessages(); |
| 93 | +ifconstexpr (kEnableGlobalObserver) { |
| 94 | +if (c10::utils::get_env("KINETO_USE_DAEMON").has_value()) { |
| 95 | +libkineto_init( |
| 96 | +/*cpuOnly=*/!(at::hasCUDA() ||at::hasXPU() ||at::hasMTIA()), |
| 97 | +/*logOnError=*/true); |
| 98 | +libkineto::api().suppressLogMessages(); |
| 99 | + } |
99 | 100 | } |
100 | | -#endif |
101 | 101 | } |
102 | 102 |
|
103 | | -#if ENABLE_GLOBAL_OBSERVER |
104 | 103 | namespace { |
105 | 104 |
|
106 | 105 | structRegisterLibKinetoClient { |
107 | 106 | RegisterLibKinetoClient() { |
108 | | -static profiler::impl::LibKinetoClient client; |
109 | | -libkineto::api().registerClient(&client); |
| 107 | +ifconstexpr (kEnableGlobalObserver) { |
| 108 | +static profiler::impl::LibKinetoClient client; |
| 109 | +libkineto::api().registerClient(&client); |
| 110 | + } |
110 | 111 | } |
111 | 112 | } register_libkineto_client; |
112 | 113 |
|
113 | 114 | }// namespace |
114 | | -#endif |
115 | 115 |
|
116 | 116 | }// namespace torch |
117 | 117 | #endif// USE_KINETO |