Passing `cuda::proclaim_return_type` to `thrust::make_transform_iterator` gives compilation error
fkallen opened this issue · 1 comments
fkallen commented
The following code does not compile with cuda toolkit 12.1
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda/functional(77): error: no instance of constructor "lambda [](int)->int::<unnamed>" matches the argument list
argument types are: (cuda::__4::__detail::__return_type_wrapper<int, lambda [](int)->int>)
: __fn_(cuda::std::__4::forward<_Fn>(__fn)) {}
^
detected during:
instantiation of "cuda::__4::__detail::__return_type_wrapper<_Ret, _DecayFn>::__return_type_wrapper(_Fn &&) noexcept [with _Ret=int, _DecayFn=lambda [](int)->int, _Fn=cuda::__4::__detail::__return_type_wrapper<int, lambda [](int)->int> &]" at line 221 of /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/iterator/transform_iterator.h
instantiation of "thrust::transform_iterator<AdaptableUnaryFunction, Iterator, Reference, Value>::transform_iterator(const Iterator &, AdaptableUnaryFunction) [with AdaptableUnaryFunction=cuda::__4::__detail::__return_type_wrapper<int, lambda [](int)->int>, Iterator=thrust::counting_iterator<int, thrust::use_default, thrust::use_default, thrust::use_default>, Reference=thrust::use_default, Value=thrust::use_default]" at line 345 of /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/iterator/transform_iterator.h
instantiation of "thrust::transform_iterator<AdaptableUnaryFunction, Iterator, thrust::use_default, thrust::use_default> thrust::make_transform_iterator(Iterator, AdaptableUnaryFunction) [with AdaptableUnaryFunction=cuda::__4::__detail::__return_type_wrapper<int, lambda [](int)->int>, Iterator=thrust::counting_iterator<int, thrust::use_default, thrust::use_default, thrust::use_default>]"
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <cuda/functional>
int main(){
int factor = 2;
auto iterator = thrust::make_transform_iterator(
thrust::make_counting_iterator(0),
cuda::proclaim_return_type<int>([factor] __device__ (int i){
return factor * i;
})
);
}
miscco commented
I fear this is not a libcu++ issue but a compiler bug. I just tested it with 12.2 and it worked fine there, so I am closing this as there is nothing we can do there.