Skip to content

Commit

Permalink
Test combined internal/user-side use of NVTX
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed May 2, 2024
1 parent ca7109a commit 031833d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cub/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ option(METAL_BUILD_EXAMPLES OFF)
option(METAL_BUILD_TESTS OFF)
CPMAddPackage("gh:brunocodutra/[email protected]")

CPMAddPackage(NAME NVTX GITHUB_REPOSITORY NVIDIA/NVTX GIT_TAG release-v3 DOWNLOAD_ONLY True SYSTEM)
add_subdirectory(${NVTX_SOURCE_DIR}/c ${NVTX_BINARY_DIR}/c)

find_package(CUDAToolkit)

set(curand_default OFF)
Expand Down Expand Up @@ -276,6 +279,9 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)

add_executable(${test_target} "${test_src}")
target_link_libraries(${test_target} ${cub_target})
if (${test_src} MATCHES "test_nvtx_in_usercode.cu")
target_link_libraries(${test_target} nvtx3-cpp)
endif()
cub_clone_target_properties(${test_target} ${cub_target})
target_include_directories(${test_target} PRIVATE "${CUB_SOURCE_DIR}/test")
target_compile_definitions(${test_target} PRIVATE CUB_DETAIL_DEBUG_ENABLE_SYNC)
Expand Down
20 changes: 20 additions & 0 deletions cub/test/test_nvtx_in_usercode.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <cub/device/device_for.cuh> // internal include of NVTX
#include <thrust/iterator/counting_iterator.h>
#include <nvtx3/nvtx3.hpp> // user-side include of NVTX, retrieved elsewhere

struct Op
{
_CCCL_HOST_DEVICE void operator()(int i) const
{
printf("%d\n", i);
}
};

int main()
{
nvtx3::scoped_range range("user-range"); // user-side use of NVTX

thrust::counting_iterator<int> it{0};
cub::DeviceFor::ForEach(it, it + 16, Op{}); // internal use of NVTX
cudaDeviceSynchronize();
}

0 comments on commit 031833d

Please sign in to comment.