File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ option(METAL_BUILD_EXAMPLES OFF)
2626option (METAL_BUILD_TESTS OFF )
2727CPMAddPackage("gh:brunocodutra/metal@2.1.4" )
2828
29+ CPMAddPackage(
30+ NAME NVTX
31+ GITHUB_REPOSITORY NVIDIA/NVTX
32+ GIT_TAG release-v3
33+ DOWNLOAD_ONLY
34+ SYSTEM
35+ )
36+ include ("${NVTX_SOURCE_DIR} /c/nvtxImportedTargets.cmake" )
37+
2938find_package (CUDAToolkit)
3039
3140set (curand_default OFF )
@@ -280,6 +289,10 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)
280289 target_include_directories (${test_target} PRIVATE "${CUB_SOURCE_DIR} /test" )
281290 target_compile_definitions (${test_target} PRIVATE CUB_DETAIL_DEBUG_ENABLE_SYNC)
282291
292+ if ("${test_target} " MATCHES "nvtx_in_usercode" )
293+ target_link_libraries (${test_target} nvtx3-cpp)
294+ endif ()
295+
283296 if (CUB_IN_THRUST)
284297 thrust_fix_clang_nvcc_build_for(${test_target} )
285298 endif ()
Original file line number Diff line number Diff line change 1+ #include < cub/device/device_for.cuh> // internal include of NVTX
2+
3+ #include < thrust/iterator/counting_iterator.h>
4+
5+ #include < nvtx3/nvtx3.hpp> // user-side include of NVTX, retrieved elsewhere
6+
7+ struct Op
8+ {
9+ _CCCL_HOST_DEVICE void operator ()(int i) const
10+ {
11+ printf (" %d\n " , i);
12+ }
13+ };
14+
15+ int main ()
16+ {
17+ nvtx3::scoped_range range (" user-range" ); // user-side use of NVTX
18+
19+ thrust::counting_iterator<int > it{0 };
20+ cub::DeviceFor::ForEach (it, it + 16 , Op{}); // internal use of NVTX
21+ cudaDeviceSynchronize ();
22+ }
You can’t perform that action at this time.
0 commit comments