forked from NVIDIA/cccl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix transform iterator for non-copy-constructible types
Fixes: NVIDIA#3541
- Loading branch information
1 parent
abfb7b4
commit 7d45c81
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
target_compile_options(${test_target} PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>: --extended-lambda>) | ||
|
||
# this check is actually not correct, because we must check the host compiler, not the CXX compiler. | ||
# We rely on that those are usually the same ;) | ||
if ("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13) | ||
# When clang >= 13 is used as host compiler, we get the following warning: | ||
# nvcc_internal_extended_lambda_implementation:312:22: error: definition of implicit copy constructor for '__nv_hdl_wrapper_t<false, true, false, __nv_dl_tag<void (*)(), &TestAddressStabilityLambda, 2>, int (const int &)>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy] | ||
# 312 | __nv_hdl_wrapper_t & operator=(const __nv_hdl_wrapper_t &in) = delete; | ||
# | ^ | ||
# Let's suppress it until NVBug 4980157 is resolved. | ||
target_compile_options(${test_target} PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>: -Wno-deprecated-copy>) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <thrust/iterator/transform_iterator.h> | ||
#include <thrust/logical.h> | ||
|
||
#include <unittest/unittest.h> | ||
|
||
// see also: https://github.com/NVIDIA/cccl/issues/3541 | ||
template <class Vector> | ||
void TestTransformWithLambda() | ||
{ | ||
using T = typename Vector::value_type; | ||
Vector A{1, 2, 3, 4, 5, 6, 7}; | ||
const auto result = thrust::any_of(A.begin(), A.end(), [] __host__ __device__(T v) { | ||
return v < 4; | ||
}); | ||
ASSERT_EQUAL(result, true); | ||
} | ||
|
||
DECLARE_INTEGRAL_VECTOR_UNITTEST(TestTransformWithLambda); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters