Skip to content

Commit 3e5ea18

Browse files
Enable CUB NVTX ranges only if the NVTX3 C++ API V1 is available
1 parent 06de31f commit 3e5ea18

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

cub/cub/detail/nvtx.cuh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@
3737
# pragma system_header
3838
#endif // no system header
3939

40-
// Enable the functionality of this header if
40+
// Include the NVTX3 C++ API if:
4141
// * The NVTX3 C API is available in CTK
4242
// * NVTX is not explicitly disabled
43-
// * C++14 is availabl for cuda::std::optional
44-
#if __has_include(<nvtx3/nvToolsExt.h>) && !defined(NVTX_DISABLE) && _CCCL_STD_VER >= 2014
43+
#if __has_include(<nvtx3/nvToolsExt.h> ) && !defined(NVTX_DISABLE)
4544
// Include our NVTX3 C++ wrapper if not available from the CTK
4645
# if __has_include(<nvtx3/nvtx3.hpp>) // TODO(bgruber): replace by a check for the first CTK version shipping the header
4746
# include <nvtx3/nvtx3.hpp>
4847
# else // __has_include(<nvtx3/nvtx3.hpp>)
4948
# include "nvtx3.hpp"
5049
# endif // __has_include(<nvtx3/nvtx3.hpp>)
50+
#endif // __has_include(<nvtx3/nvToolsExt.h>) && !defined(NVTX_DISABLE) && _CCCL_STD_VER > 2011
5151

52+
// Enable the functionality of this header if:
53+
// * The NVTX3 C++ API V1 is available
54+
// * C++14 is availabl for cuda::std::optional
55+
#if defined(NVTX3_CPP_DEFINITIONS_V1_0) && _CCCL_STD_VER >= 2014
5256
# include <cuda/std/optional>
5357

5458
CUB_NAMESPACE_BEGIN
@@ -82,7 +86,14 @@ CUB_NAMESPACE_END
8286
(void) __cub_nvtx3_range;)
8387

8488
# define CUB_DETAIL_NVTX_RANGE_SCOPE(name) CUB_DETAIL_NVTX_RANGE_SCOPE_IF(true, name)
85-
#else // __has_include(<nvtx3/nvToolsExt.h>) && !defined(NVTX_DISABLE) && _CCCL_STD_VER > 2011
89+
#else // defined(NVTX3_CPP_DEFINITIONS_V1_0) && _CCCL_STD_VER >= 2014
90+
// Tell the user we don't support their NVTX3 version.
91+
# if defined(_CCCL_COMPILER_MSVC)
92+
# pragma message("warning: CUB only supports NVTX3 V1. Please open an issue on GitHub.")
93+
# else
94+
# warning CUB only supports NVTX3 V1. Please open an issue on GitHub.
95+
# endif
96+
8697
# define CUB_DETAIL_NVTX_RANGE_SCOPE_IF(condition, name)
8798
# define CUB_DETAIL_NVTX_RANGE_SCOPE(name)
88-
#endif // __has_include(<nvtx3/nvToolsExt.h>) && !defined(NVTX_DISABLE) && _CCCL_STD_VER > 2011
99+
#endif // defined(NVTX3_CPP_DEFINITIONS_V1_0) && _CCCL_STD_VER >= 2014

0 commit comments

Comments
 (0)