2626# pragma system_header
2727#endif // no system header
2828#include < thrust/detail/copy.h>
29+ #include < thrust/detail/nvtx_policy.h>
2930#include < thrust/system/detail/generic/select_system.h>
3031
3132// Include all active backend system implementations (generic, sequential, host and device)
@@ -52,7 +53,7 @@ copy(const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
5253 InputIterator last,
5354 OutputIterator result)
5455{
55- _CCCL_NVTX_RANGE_SCOPE ( " thrust::copy" );
56+ _CCCL_NVTX_RANGE_SCOPE_IF (detail::should_enable_nvtx_for_policy<DerivedPolicy>(), " thrust::copy" );
5657 using thrust::system::detail::generic::copy;
5758 return copy (thrust::detail::derived_cast (thrust::detail::strip_const (exec)), first, last, result);
5859} // end copy()
@@ -62,7 +63,7 @@ template <typename DerivedPolicy, typename InputIterator, typename Size, typenam
6263_CCCL_HOST_DEVICE OutputIterator copy_n (
6364 const thrust::detail::execution_policy_base<DerivedPolicy>& exec, InputIterator first, Size n, OutputIterator result)
6465{
65- _CCCL_NVTX_RANGE_SCOPE ( " thrust::copy_n" );
66+ _CCCL_NVTX_RANGE_SCOPE_IF (detail::should_enable_nvtx_for_policy<DerivedPolicy>(), " thrust::copy_n" );
6667 using thrust::system::detail::generic::copy_n;
6768 return copy_n (thrust::detail::derived_cast (thrust::detail::strip_const (exec)), first, n, result);
6869} // end copy_n()
@@ -78,7 +79,8 @@ _CCCL_HOST_DEVICE OutputIterator two_system_copy(
7879 InputIterator last,
7980 OutputIterator result)
8081{
81- _CCCL_NVTX_RANGE_SCOPE (" thrust::two_system_copy" );
82+ _CCCL_NVTX_RANGE_SCOPE_IF (should_enable_nvtx_for_policy<System1>() || should_enable_nvtx_for_policy<System2>(),
83+ " thrust::two_system_copy" );
8284 using thrust::system::detail::generic::select_system;
8385
8486 return thrust::copy (
@@ -98,7 +100,8 @@ _CCCL_HOST_DEVICE OutputIterator two_system_copy_n(
98100 Size n,
99101 OutputIterator result)
100102{
101- _CCCL_NVTX_RANGE_SCOPE (" thrust::two_system_copy_n" );
103+ _CCCL_NVTX_RANGE_SCOPE_IF (should_enable_nvtx_for_policy<System1>() || should_enable_nvtx_for_policy<System2>(),
104+ " thrust::two_system_copy_n" );
102105 using thrust::system::detail::generic::select_system;
103106
104107 return thrust::copy_n (
@@ -113,9 +116,11 @@ _CCCL_HOST_DEVICE OutputIterator two_system_copy_n(
113116template <typename InputIterator, typename OutputIterator>
114117OutputIterator copy (InputIterator first, InputIterator last, OutputIterator result)
115118{
116- _CCCL_NVTX_RANGE_SCOPE (" thrust::copy" );
117119 using System1 = typename thrust::iterator_system<InputIterator>::type;
118120 using System2 = typename thrust::iterator_system<OutputIterator>::type;
121+ _CCCL_NVTX_RANGE_SCOPE_IF (
122+ detail::should_enable_nvtx_for_policy<System1>() || detail::should_enable_nvtx_for_policy<System2>(),
123+ " thrust::copy" );
119124
120125 System1 system1;
121126 System2 system2;
@@ -126,9 +131,11 @@ OutputIterator copy(InputIterator first, InputIterator last, OutputIterator resu
126131template <typename InputIterator, typename Size, typename OutputIterator>
127132OutputIterator copy_n (InputIterator first, Size n, OutputIterator result)
128133{
129- _CCCL_NVTX_RANGE_SCOPE (" thrust::copy_n" );
130134 using System1 = typename thrust::iterator_system<InputIterator>::type;
131135 using System2 = typename thrust::iterator_system<OutputIterator>::type;
136+ _CCCL_NVTX_RANGE_SCOPE_IF (
137+ detail::should_enable_nvtx_for_policy<System1>() || detail::should_enable_nvtx_for_policy<System2>(),
138+ " thrust::copy_n" );
132139
133140 System1 system1;
134141 System2 system2;
0 commit comments