Skip to content

Commit

Permalink
Test proclaim_copyable_arguments for lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Nov 15, 2024
1 parent bb1c7e7 commit 9c84e62
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions thrust/testing/address_stability.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target_compile_options(${test_target} PRIVATE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:--extended-lambda>)
35 changes: 35 additions & 0 deletions thrust/testing/address_stability.cu
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,38 @@ void TestAddressStabilityUserDefinedFunctionObject()
static_assert(proclaims_copyable_arguments<decltype(proclaim_copyable_arguments(my_plus<const int&&>{}))>::value, "");
}
DECLARE_UNITTEST(TestAddressStabilityUserDefinedFunctionObject);

void TestAddressStabilityLambda()
{
using ::cuda::proclaim_copyable_arguments;
using ::cuda::proclaims_copyable_arguments;

{
auto l = [](const int& i) {
return i + 2;
};
static_assert(!proclaims_copyable_arguments<decltype(l)>::value, "");
auto pr_l = proclaim_copyable_arguments(l);
ASSERT_EQUAL(pr_l(3), 5);
static_assert(proclaims_copyable_arguments<decltype(pr_l)>::value, "");
}

{
auto l = [] __device__(const int& i) {
return i + 2;
};
static_assert(!proclaims_copyable_arguments<decltype(l)>::value, "");
auto pr_device_l = proclaim_copyable_arguments(l);
(void) pr_device_l;
static_assert(proclaims_copyable_arguments<decltype(pr_device_l)>::value, "");
}

{
auto l = [] __host__ __device__(const int& i) { return i + 2; };
static_assert(!proclaims_copyable_arguments<decltype(l)>::value, "");
auto pr_l = proclaim_copyable_arguments(l);
ASSERT_EQUAL(pr_l(3), 5);
static_assert(proclaims_copyable_arguments<decltype(pr_l)>::value, "");
}
}
DECLARE_UNITTEST(TestAddressStabilityLambda);

0 comments on commit 9c84e62

Please sign in to comment.