tvm
nvtx.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
27 #ifndef TVM_SUPPORT_CUDA_NVTX_H_
28 #define TVM_SUPPORT_CUDA_NVTX_H_
29 
30 #include <string>
31 
32 #ifndef TVM_NVTX_ENABLED
33 #define TVM_NVTX_ENABLED 0
34 #endif
35 
36 #if TVM_NVTX_ENABLED
37 #include <nvtx3/nvToolsExt.h>
38 #endif // TVM_NVTX_ENABLED
39 
40 namespace tvm {
41 namespace support {
42 
47  public:
49 #if TVM_NVTX_ENABLED
50  explicit NVTXScopedRange(const char* name) { nvtxRangePush(name); }
51 #else
52  explicit NVTXScopedRange(const char* name) {}
53 #endif // TVM_NVTX_ENABLED
55  explicit NVTXScopedRange(const std::string& name) : NVTXScopedRange(name.c_str()) {}
57 #if TVM_NVTX_ENABLED
58  ~NVTXScopedRange() { nvtxRangePop(); }
59 #else
61 #endif // TVM_NVTX_ENABLED
62  NVTXScopedRange(const NVTXScopedRange& other) = delete;
63  NVTXScopedRange(NVTXScopedRange&& other) = delete;
64  NVTXScopedRange& operator=(const NVTXScopedRange& other) = delete;
66 };
67 
68 #ifdef _MSC_VER
69 #define TVM_NVTX_FUNC_SCOPE() ::tvm::support::NVTXScopedRange _nvtx_func_scope_(__FUNCSIG__);
70 #else
71 #define TVM_NVTX_FUNC_SCOPE() \
72  ::tvm::support::NVTXScopedRange _nvtx_func_scope_(__PRETTY_FUNCTION__);
73 #endif
74 
75 } // namespace support
76 } // namespace tvm
77 
78 #endif // TVM_SUPPORT_CUDA_NVTX_H_
A class to create a NVTX range. No-op if TVM is not built against NVTX.
Definition: nvtx.h:46
~NVTXScopedRange()
Exit an NVTX scoped range.
Definition: nvtx.h:60
NVTXScopedRange(NVTXScopedRange &&other)=delete
NVTXScopedRange(const NVTXScopedRange &other)=delete
NVTXScopedRange & operator=(NVTXScopedRange &&other)=delete
NVTXScopedRange(const char *name)
Enter an NVTX scoped range.
Definition: nvtx.h:52
NVTXScopedRange & operator=(const NVTXScopedRange &other)=delete
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40