Skip to content

Commit

Permalink
Add a standalone test for NVTX ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Apr 26, 2024
1 parent 892f5be commit f3bb6bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cub/test/insert_nested_NVTX_range_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ struct NestedNVTXRangeGuard
# define CUB_DETAIL_BEFORE_NVTX_RANGE_SCOPE(name) \
::cuda::std::optional<::NestedNVTXRangeGuard> __cub_nvtx3_reentrency_guard; \
NV_IF_TARGET(NV_IS_HOST, __cub_nvtx3_reentrency_guard.emplace(name););
#endif
#endif // defined(__cpp_inline_variables)
28 changes: 28 additions & 0 deletions cub/test/test_nvtx_standalone.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// The purpose of this test is to verify that CUB can use NVTX without any additional dependencies. It is built as part
// of the unit tests, but can also be built standalone:

// Compile (from current directory):
// nvcc test_nvtx_standalone.cu -I../../cub -I../../thrust -I../../libcudacxx/include -o nvtx_standalone
// Profile & view:
// (nsys profile -o nvtx_standalone.nsys-rep -f true ./nvtx_standalone || true) && nsys-ui nvtx_standalone.nsys-rep

#include <cub/device/device_for.cuh>

#include <thrust/iterator/counting_iterator.h>

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

int main()
{
CUB_DETAIL_NVTX_RANGE_SCOPE("main");

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

0 comments on commit f3bb6bd

Please sign in to comment.