Hello. I am new with CUDA. I wrote a C++ code that is working and I want to use it with CUDA. The GitHub of the project is here: https://github.com/Julien-Livet/TestIntegerCuda. The compilation gives me three errors (cf. below) that I don’t understand, so I don’t arrive to solve them. Can you help me please?
/usr/include/thrust/system/cuda/detail/internal/copy_cross_system.h(107): error: reinterpret_cast cannot cast away const or other type qualifiers
detected during:
instantiation of "OutputIt thrust::cuda_cub::__copy::cross_system_copy_n(thrust::execution_policy<System1> &, thrust::execution_policy<System2> &, InputIt, Size, OutputIt, thrust::detail::true_type) [with System1=thrust::system::cpp::detail::tag, System2=thrust::cuda_cub::tag, InputIt=const unsigned long long *, Size=std::ptrdiff_t, OutputIt=thrust::device_ptr<const unsigned long long>]"
(222): here
instantiation of "OutputIt thrust::cuda_cub::__copy::cross_system_copy_n(thrust::cuda_cub::cross_system<System1, System2>, InputIt, Size, OutputIt) [with System1=thrust::system::cpp::detail::tag, System2=thrust::cuda_cub::tag, InputIt=const unsigned long long *, Size=std::ptrdiff_t, OutputIt=thrust::device_ptr<const unsigned long long>]"
(238): here
instantiation of "OutputIterator thrust::cuda_cub::__copy::cross_system_copy(thrust::cuda_cub::cross_system<System1, System2>, InputIterator, InputIterator, OutputIterator) [with System1=thrust::system::cpp::detail::tag, System2=thrust::cuda_cub::tag, InputIterator=const unsigned long long *, OutputIterator=thrust::device_ptr<const unsigned long long>]"
/usr/include/thrust/system/cuda/detail/copy.h(162): here
instantiation of "OutputIterator thrust::cuda_cub::copy(thrust::cuda_cub::cross_system<System1, System2>, InputIterator, InputIterator, OutputIterator) [with System1=thrust::system::cpp::detail::tag, System2=thrust::cuda_cub::tag, InputIterator=const unsigned long long *, OutputIterator=thrust::device_ptr<const unsigned long long>]"
/usr/include/thrust/system/cuda/detail/assign_value.h(72): here
instantiation of "void thrust::cuda_cub::assign_value(thrust::cuda_cub::cross_system<System1, System2> &, Pointer1, Pointer2) [with System1=thrust::cuda_cub::tag, System2=thrust::system::cpp::detail::tag, Pointer1=thrust::device_ptr<const unsigned long long>, Pointer2=const unsigned long long *]"
/usr/include/thrust/detail/reference.h(370): here
[ 7 instantiation contexts not shown ]
instantiation of "Integer<T, Vector, void> operator*(Integer<T, Vector, void>, const Integer<T, Vector, void> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(3454): here
instantiation of "std::pair<Integer<T, Vector, void>, Integer<T, Vector, void>> computeQrBurnikelZiegler(const Integer<T, Vector, void> &, const Integer<T, Vector, void> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(978): here
instantiation of "Integer<T, Vector, std::enable_if<<expression>, void>::type> &Integer<T, Vector, std::enable_if<<expression>, void>::type>::operator%=(const Integer<T, Vector, std::enable_if<<expression>, void>::type> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(2544): here
instantiation of "Integer<T, Vector, void> operator%(Integer<T, Vector, void>, const S &) [with T=unsigned long long, S=unsigned int, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(116): here
instantiation of "void Integer_isPrime_trialDivision(const unsigned int *, size_t, const T *, size_t, const T *, size_t, __nv_bool *) [with T=unsigned long long]"
Integer.cuh(1868): here
/usr/include/thrust/system/detail/sequential/copy.inl(61): error: no instance of function template "thrust::system::detail::sequential::trivial_copy_n" matches the argument list
argument types are: (const unsigned long long *, const Size, const unsigned long long *)
detected during:
instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::true_type) [with InputIterator=const unsigned long long *, OutputIterator=thrust::device_ptr<const unsigned long long>]"
(122): here
instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy<DerivedPolicy> &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=const unsigned long long *, OutputIterator=thrust::device_ptr<const unsigned long long>]"
/usr/include/thrust/detail/copy.inl(36): here
instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base<System> &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=const unsigned long long *, OutputIterator=thrust::device_ptr<const unsigned long long>]"
/usr/include/thrust/system/cuda/detail/copy.h(123): here
instantiation of "OutputIterator thrust::cuda_cub::copy(thrust::cuda_cub::execution_policy<System> &, InputIterator, InputIterator, OutputIterator) [with System=thrust::cuda_cub::tag, InputIterator=const unsigned long long *, OutputIterator=thrust::device_ptr<const unsigned long long>]"
/usr/include/thrust/system/cuda/detail/assign_value.h(42): here
instantiation of "void thrust::cuda_cub::assign_value(thrust::cuda_cub::execution_policy<DerivedPolicy> &, Pointer1, Pointer2) [with DerivedPolicy=thrust::cuda_cub::tag, Pointer1=thrust::device_ptr<const unsigned long long>, Pointer2=const unsigned long long *]"
/usr/include/thrust/system/cuda/detail/assign_value.h(80): here
[ 8 instantiation contexts not shown ]
instantiation of "Integer<T, Vector, void> operator*(Integer<T, Vector, void>, const Integer<T, Vector, void> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(3454): here
instantiation of "std::pair<Integer<T, Vector, void>, Integer<T, Vector, void>> computeQrBurnikelZiegler(const Integer<T, Vector, void> &, const Integer<T, Vector, void> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(978): here
instantiation of "Integer<T, Vector, std::enable_if<<expression>, void>::type> &Integer<T, Vector, std::enable_if<<expression>, void>::type>::operator%=(const Integer<T, Vector, std::enable_if<<expression>, void>::type> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(2544): here
instantiation of "Integer<T, Vector, void> operator%(Integer<T, Vector, void>, const S &) [with T=unsigned long long, S=unsigned int, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(116): here
instantiation of "void Integer_isPrime_trialDivision(const unsigned int *, size_t, const T *, size_t, const T *, size_t, __nv_bool *) [with T=unsigned long long]"
Integer.cuh(1868): here
/usr/include/thrust/system/cuda/detail/assign_value.h(47): error: expression must be a modifiable lvalue
detected during:
instantiation of "void thrust::cuda_cub::assign_value(thrust::cuda_cub::execution_policy<DerivedPolicy> &, Pointer1, Pointer2) [with DerivedPolicy=thrust::cuda_cub::tag, Pointer1=thrust::device_ptr<const unsigned long long>, Pointer2=const unsigned long long *]"
(80): here
instantiation of "void thrust::cuda_cub::assign_value(thrust::cuda_cub::cross_system<System1, System2> &, Pointer1, Pointer2) [with System1=thrust::cuda_cub::tag, System2=thrust::system::cpp::detail::tag, Pointer1=thrust::device_ptr<const unsigned long long>, Pointer2=const unsigned long long *]"
/usr/include/thrust/detail/reference.h(370): here
instantiation of "void thrust::reference<Element, Pointer, Derived>::strip_const_assign_value(const System &, OtherPointer) [with Element=const unsigned long long, Pointer=thrust::device_ptr<const unsigned long long>, Derived=thrust::device_reference<const unsigned long long>, System=thrust::cuda_cub::cross_system<thrust::cuda_cub::tag, thrust::system::cpp::detail::tag>, OtherPointer=const unsigned long long *]"
/usr/include/thrust/detail/reference.h(348): here
instantiation of "void thrust::reference<Element, Pointer, Derived>::assign_from(System0 *, System1 *, OtherPointer) [with Element=const unsigned long long, Pointer=thrust::device_ptr<const unsigned long long>, Derived=thrust::device_reference<const unsigned long long>, System0=thrust::device_system_tag, System1=thrust::host_system_tag, OtherPointer=const unsigned long long *]"
/usr/include/thrust/detail/reference.h(360): here
instantiation of "void thrust::reference<Element, Pointer, Derived>::assign_from(OtherPointer) [with Element=const unsigned long long, Pointer=thrust::device_ptr<const unsigned long long>, Derived=thrust::device_reference<const unsigned long long>, OtherPointer=const unsigned long long *]"
/usr/include/thrust/detail/reference.h(156): here
[ 4 instantiation contexts not shown ]
instantiation of "Integer<T, Vector, void> operator*(Integer<T, Vector, void>, const Integer<T, Vector, void> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(3454): here
instantiation of "std::pair<Integer<T, Vector, void>, Integer<T, Vector, void>> computeQrBurnikelZiegler(const Integer<T, Vector, void> &, const Integer<T, Vector, void> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(978): here
instantiation of "Integer<T, Vector, std::enable_if<<expression>, void>::type> &Integer<T, Vector, std::enable_if<<expression>, void>::type>::operator%=(const Integer<T, Vector, std::enable_if<<expression>, void>::type> &) [with T=unsigned long long, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(2544): here
instantiation of "Integer<T, Vector, void> operator%(Integer<T, Vector, void>, const S &) [with T=unsigned long long, S=unsigned int, Vector=thrust::device_vector<unsigned long long, thrust::device_allocator<unsigned long long>>]"
Integer.cuh(116): here
instantiation of "void Integer_isPrime_trialDivision(const unsigned int *, size_t, const T *, size_t, const T *, size_t, __nv_bool *) [with T=unsigned long long]"
Integer.cuh(1868): here
3 errors detected in the compilation of "main.cu".