File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 25
25
*
26
26
******************************************************************************/
27
27
#include " insert_nested_NVTX_range_guard.h"
28
- // above header needs to be included first
29
28
30
29
#include < cub/config.cuh>
31
30
Original file line number Diff line number Diff line change 8
8
9
9
#include < catch2/catch_test_macros.hpp>
10
10
11
- #if defined(__cpp_inline_variables)
12
11
inline thread_local bool entered = false ;
13
12
14
13
struct NestedNVTXRangeGuard
15
14
{
16
- NestedNVTXRangeGuard (const char * name)
15
+ // complain only about CUB nested NVTX ranges, not Thrust
16
+ bool inside_cub_range;
17
+
18
+ explicit NestedNVTXRangeGuard (const char * name)
19
+ : inside_cub_range(strstr(name, " cub::" ) == name)
17
20
{
18
21
UNSCOPED_INFO (" Entering NVTX range " << name);
19
- // complain only about CUB nested NVTX ranges, not Thrust
20
- if (strstr (name, " cub::" ) == name)
22
+ if (inside_cub_range)
21
23
{
22
24
if (entered)
23
25
{
@@ -29,12 +31,14 @@ struct NestedNVTXRangeGuard
29
31
30
32
~NestedNVTXRangeGuard ()
31
33
{
32
- entered = false ;
34
+ if (inside_cub_range)
35
+ {
36
+ entered = false ;
37
+ }
33
38
UNSCOPED_INFO (" Leaving NVTX range" );
34
39
}
35
40
};
36
41
37
- # define _CCCL_BEFORE_NVTX_RANGE_SCOPE (name ) \
38
- ::cuda::std::optional<::NestedNVTXRangeGuard> __cub_nvtx3_reentrency_guard; \
39
- NV_IF_TARGET (NV_IS_HOST, __cub_nvtx3_reentrency_guard.emplace(name););
40
- #endif // defined(__cpp_inline_variables)
42
+ #define _CCCL_BEFORE_NVTX_RANGE_SCOPE (name ) \
43
+ ::cuda::std::optional<::NestedNVTXRangeGuard> __cub_nvtx3_reentrency_guard; \
44
+ NV_IF_TARGET (NV_IS_HOST, __cub_nvtx3_reentrency_guard.emplace(name););
You can’t perform that action at this time.
0 commit comments