thrust set operations not compiling [duplicate]












0
















This question is an exact duplicate of:




  • thrust set difference fails to compile with calling a __host__ function from a __host__ __device__ function is not allowed

    1 answer




I tried a simple program using thrust::set. It finds the difference of two sets. However I get compilation error.



#include <thrust/set_operations.h>
#include <thrust/execution_policy.h>
#include <thrust/device_vector.h>

int main()
{
thrust::device_vector<int> A1(7);
thrust::device_vector<int> A2(5);

thrust::device_vector<int> result(3);

A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result);

return 0;
}


The compilation error is:



/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/set_operation.inl(555): warning: calling a host function from a host device function is not allowed
detected during:
instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
(578): here
instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure thrust::system::cuda::detail::detail::set_operation_detail::make_set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>,
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
instantiation of "OutputIterator InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
(560): here
instantiation of "void thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::operator()() const [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/launch_closure.inl(52): here
instantiation of "void thrust::system::cuda::detail::detail::launch_closure_by_value(Closure) [with Closure=thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure<(unsigned short)128U, (unsigned short)15U, thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, signed long, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::device_vector>, thrust::less, thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
difference.cu(15): here
thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
difference.cu(15): here



/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(106): error: no operator "++" matches these operands
operand types are: ++ thrust::device_vector>
detected during:
instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
difference.cu(15): here



/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(76): error: no operator "*" matches these operands
operand types are: * thrust::device_vector>
detected during:
instantiation of "thrust::detail::enable_if::value, void>::type thrust::system::detail::sequential::general_copy_detail::iter_assign(OutputIterator, InputIterator) [with OutputIterator=thrust::device_vector>, InputIterator=thrust::detail::normal_iterator>]"
(112): here
instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
difference.cu(15): here



7 errors detected in the compilation of "/tmp/tmpxft_00007f24_00000000-9_difference.cpp1.ii".










share|improve this question













marked as duplicate by talonmies, Community Dec 10 '18 at 11:47


This question was marked as an exact duplicate of an existing question.























    0
















    This question is an exact duplicate of:




    • thrust set difference fails to compile with calling a __host__ function from a __host__ __device__ function is not allowed

      1 answer




    I tried a simple program using thrust::set. It finds the difference of two sets. However I get compilation error.



    #include <thrust/set_operations.h>
    #include <thrust/execution_policy.h>
    #include <thrust/device_vector.h>

    int main()
    {
    thrust::device_vector<int> A1(7);
    thrust::device_vector<int> A2(5);

    thrust::device_vector<int> result(3);

    A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
    A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

    thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result);

    return 0;
    }


    The compilation error is:



    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/set_operation.inl(555): warning: calling a host function from a host device function is not allowed
    detected during:
    instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
    (578): here
    instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure thrust::system::cuda::detail::detail::set_operation_detail::make_set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>,
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
    instantiation of "OutputIterator InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
    (560): here
    instantiation of "void thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::operator()() const [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/launch_closure.inl(52): here
    instantiation of "void thrust::system::cuda::detail::detail::launch_closure_by_value(Closure) [with Closure=thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure<(unsigned short)128U, (unsigned short)15U, thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, signed long, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::device_vector>, thrust::less, thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    difference.cu(15): here
    thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
    instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
    instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
    instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
    instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    difference.cu(15): here



    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(106): error: no operator "++" matches these operands
    operand types are: ++ thrust::device_vector>
    detected during:
    instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
    instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
    instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
    instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
    instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
    instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
    instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    difference.cu(15): here



    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(76): error: no operator "*" matches these operands
    operand types are: * thrust::device_vector>
    detected during:
    instantiation of "thrust::detail::enable_if::value, void>::type thrust::system::detail::sequential::general_copy_detail::iter_assign(OutputIterator, InputIterator) [with OutputIterator=thrust::device_vector>, InputIterator=thrust::detail::normal_iterator>]"
    (112): here
    instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
    instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
    instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
    instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
    instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
    instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
    instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
    instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
    difference.cu(15): here



    7 errors detected in the compilation of "/tmp/tmpxft_00007f24_00000000-9_difference.cpp1.ii".










    share|improve this question













    marked as duplicate by talonmies, Community Dec 10 '18 at 11:47


    This question was marked as an exact duplicate of an existing question.





















      0












      0








      0









      This question is an exact duplicate of:




      • thrust set difference fails to compile with calling a __host__ function from a __host__ __device__ function is not allowed

        1 answer




      I tried a simple program using thrust::set. It finds the difference of two sets. However I get compilation error.



      #include <thrust/set_operations.h>
      #include <thrust/execution_policy.h>
      #include <thrust/device_vector.h>

      int main()
      {
      thrust::device_vector<int> A1(7);
      thrust::device_vector<int> A2(5);

      thrust::device_vector<int> result(3);

      A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
      A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

      thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result);

      return 0;
      }


      The compilation error is:



      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/set_operation.inl(555): warning: calling a host function from a host device function is not allowed
      detected during:
      instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
      (578): here
      instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure thrust::system::cuda::detail::detail::set_operation_detail::make_set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>,
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
      (560): here
      instantiation of "void thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::operator()() const [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/launch_closure.inl(52): here
      instantiation of "void thrust::system::cuda::detail::detail::launch_closure_by_value(Closure) [with Closure=thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure<(unsigned short)128U, (unsigned short)15U, thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, signed long, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::device_vector>, thrust::less, thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here
      thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
      instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
      instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
      instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here



      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(106): error: no operator "++" matches these operands
      operand types are: ++ thrust::device_vector>
      detected during:
      instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
      instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
      instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
      instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here



      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(76): error: no operator "*" matches these operands
      operand types are: * thrust::device_vector>
      detected during:
      instantiation of "thrust::detail::enable_if::value, void>::type thrust::system::detail::sequential::general_copy_detail::iter_assign(OutputIterator, InputIterator) [with OutputIterator=thrust::device_vector>, InputIterator=thrust::detail::normal_iterator>]"
      (112): here
      instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
      instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
      instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
      instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here



      7 errors detected in the compilation of "/tmp/tmpxft_00007f24_00000000-9_difference.cpp1.ii".










      share|improve this question















      This question is an exact duplicate of:




      • thrust set difference fails to compile with calling a __host__ function from a __host__ __device__ function is not allowed

        1 answer




      I tried a simple program using thrust::set. It finds the difference of two sets. However I get compilation error.



      #include <thrust/set_operations.h>
      #include <thrust/execution_policy.h>
      #include <thrust/device_vector.h>

      int main()
      {
      thrust::device_vector<int> A1(7);
      thrust::device_vector<int> A2(5);

      thrust::device_vector<int> result(3);

      A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
      A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

      thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result);

      return 0;
      }


      The compilation error is:



      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/set_operation.inl(555): warning: calling a host function from a host device function is not allowed
      detected during:
      instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
      (578): here
      instantiation of "thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure thrust::system::cuda::detail::detail::set_operation_detail::make_set_operation_closure(InputIterator1, Size, InputIterator2, InputIterator3, InputIterator4, OutputIterator, Compare, SetOperation) [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>,
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
      (560): here
      instantiation of "void thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure::operator()() const [with threads_per_block=(unsigned short)128U, work_per_thread=(unsigned short)15U, InputIterator1=thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, Size=signed long, InputIterator2=thrust::detail::normal_iterator>, InputIterator3=thrust::detail::normal_iterator>, InputIterator4=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, Compare=thrust::less, SetOperation=thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/detail/launch_closure.inl(52): here
      instantiation of "void thrust::system::cuda::detail::detail::launch_closure_by_value(Closure) [with Closure=thrust::system::cuda::detail::detail::set_operation_detail::set_operation_closure<(unsigned short)128U, (unsigned short)15U, thrust::detail::normal_iterator, thrust::system::cuda::detail::par_t, thrust::use_default, thrust::use_default>>, signed long, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::detail::normal_iterator>, thrust::device_vector>, thrust::less, thrust::system::cuda::detail::set_difference_detail::serial_bounded_set_difference>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here
      thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
      instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
      instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
      instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here



      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(106): error: no operator "++" matches these operands
      operand types are: ++ thrust::device_vector>
      detected during:
      instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
      instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
      instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
      instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here



      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/general_copy.h(76): error: no operator "*" matches these operands
      operand types are: * thrust::device_vector>
      detected during:
      instantiation of "thrust::detail::enable_if::value, void>::type thrust::system::detail::sequential::general_copy_detail::iter_assign(OutputIterator, InputIterator) [with OutputIterator=thrust::device_vector>, InputIterator=thrust::detail::normal_iterator>]"
      (112): here
      instantiation of "OutputIterator thrust::system::detail::sequential::general_copy(InputIterator, InputIterator, OutputIterator) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(74): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy_detail::copy(InputIterator, InputIterator, OutputIterator, thrust::detail::false_type) [with InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/copy.inl(120): here
      instantiation of "OutputIterator thrust::system::detail::sequential::copy(thrust::system::detail::sequential::execution_policy &, InputIterator, InputIterator, OutputIterator) [with DerivedPolicy=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/copy.inl(37): here
      instantiation of "OutputIterator thrust::copy(const thrust::detail::execution_policy_base &, InputIterator, InputIterator, OutputIterator) [with System=thrust::detail::seq_t, InputIterator=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/sequential/set_operations.h(79): here
      instantiation of "OutputIterator thrust::system::detail::sequential::set_difference(thrust::system::detail::sequential::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakOrdering) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakOrdering=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::detail::seq_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/cuda/detail/set_difference.inl(157): here
      instantiation of "RandomAccessIterator3 thrust::system::cuda::detail::set_difference(thrust::system::cuda::detail::execution_policy &, RandomAccessIterator1, RandomAccessIterator1, RandomAccessIterator2, RandomAccessIterator2, RandomAccessIterator3, Compare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, RandomAccessIterator1=thrust::detail::normal_iterator>, RandomAccessIterator2=thrust::detail::normal_iterator>, RandomAccessIterator3=thrust::device_vector>, Compare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(65): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator, StrictWeakCompare) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>, StrictWeakCompare=thrust::less]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/system/detail/generic/set_operations.inl(51): here
      instantiation of "OutputIterator thrust::system::detail::generic::set_difference(thrust::execution_policy &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with ExecutionPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      /usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/set_operations.inl(45): here
      instantiation of "OutputIterator thrust::set_difference(const thrust::detail::execution_policy_base &, InputIterator1, InputIterator1, InputIterator2, InputIterator2, OutputIterator) [with DerivedPolicy=thrust::system::cuda::detail::par_t, InputIterator1=thrust::detail::normal_iterator>, InputIterator2=thrust::detail::normal_iterator>, OutputIterator=thrust::device_vector>]"
      difference.cu(15): here



      7 errors detected in the compilation of "/tmp/tmpxft_00007f24_00000000-9_difference.cpp1.ii".





      This question is an exact duplicate of:




      • thrust set difference fails to compile with calling a __host__ function from a __host__ __device__ function is not allowed

        1 answer








      compiler-errors set difference thrust






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 6:05









      user27665user27665

      357416




      357416




      marked as duplicate by talonmies, Community Dec 10 '18 at 11:47


      This question was marked as an exact duplicate of an existing question.









      marked as duplicate by talonmies, Community Dec 10 '18 at 11:47


      This question was marked as an exact duplicate of an existing question.


























          1 Answer
          1






          active

          oldest

          votes


















          0














          There was a typo: it has to be result.begin() instead of result. I post the correct code for any other newbie.



          #include <thrust/set_operations.h>
          #include <thrust/execution_policy.h>
          #include <thrust/device_vector.h>

          int main()
          {
          thrust::device_vector<int> A1(7);
          thrust::device_vector<int> A2(5);

          thrust::device_vector<int> result(3);

          A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
          A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

          thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result.begin());

          std::cout<<"A1=";
          thrust::copy(A1.begin(), A1.end(), std::ostream_iterator<int>(std::cout, " "));
          std::cout<<std::endl;

          std::cout<<"A2=";
          thrust::copy(A2.begin(), A2.end(), std::ostream_iterator<int>(std::cout, " "));
          std::cout<<std::endl;

          std::cout<<"result=";
          thrust::copy(result.begin(), result.end(), std::ostream_iterator<int>(std::cout, " "));
          std::cout<<std::endl;

          return 0;
          }

          ./difference
          A1=0 1 3 4 5 6 9
          A2=1 3 5 7 0
          result=0 4 6





          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            There was a typo: it has to be result.begin() instead of result. I post the correct code for any other newbie.



            #include <thrust/set_operations.h>
            #include <thrust/execution_policy.h>
            #include <thrust/device_vector.h>

            int main()
            {
            thrust::device_vector<int> A1(7);
            thrust::device_vector<int> A2(5);

            thrust::device_vector<int> result(3);

            A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
            A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

            thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result.begin());

            std::cout<<"A1=";
            thrust::copy(A1.begin(), A1.end(), std::ostream_iterator<int>(std::cout, " "));
            std::cout<<std::endl;

            std::cout<<"A2=";
            thrust::copy(A2.begin(), A2.end(), std::ostream_iterator<int>(std::cout, " "));
            std::cout<<std::endl;

            std::cout<<"result=";
            thrust::copy(result.begin(), result.end(), std::ostream_iterator<int>(std::cout, " "));
            std::cout<<std::endl;

            return 0;
            }

            ./difference
            A1=0 1 3 4 5 6 9
            A2=1 3 5 7 0
            result=0 4 6





            share|improve this answer




























              0














              There was a typo: it has to be result.begin() instead of result. I post the correct code for any other newbie.



              #include <thrust/set_operations.h>
              #include <thrust/execution_policy.h>
              #include <thrust/device_vector.h>

              int main()
              {
              thrust::device_vector<int> A1(7);
              thrust::device_vector<int> A2(5);

              thrust::device_vector<int> result(3);

              A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
              A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

              thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result.begin());

              std::cout<<"A1=";
              thrust::copy(A1.begin(), A1.end(), std::ostream_iterator<int>(std::cout, " "));
              std::cout<<std::endl;

              std::cout<<"A2=";
              thrust::copy(A2.begin(), A2.end(), std::ostream_iterator<int>(std::cout, " "));
              std::cout<<std::endl;

              std::cout<<"result=";
              thrust::copy(result.begin(), result.end(), std::ostream_iterator<int>(std::cout, " "));
              std::cout<<std::endl;

              return 0;
              }

              ./difference
              A1=0 1 3 4 5 6 9
              A2=1 3 5 7 0
              result=0 4 6





              share|improve this answer


























                0












                0








                0







                There was a typo: it has to be result.begin() instead of result. I post the correct code for any other newbie.



                #include <thrust/set_operations.h>
                #include <thrust/execution_policy.h>
                #include <thrust/device_vector.h>

                int main()
                {
                thrust::device_vector<int> A1(7);
                thrust::device_vector<int> A2(5);

                thrust::device_vector<int> result(3);

                A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
                A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

                thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result.begin());

                std::cout<<"A1=";
                thrust::copy(A1.begin(), A1.end(), std::ostream_iterator<int>(std::cout, " "));
                std::cout<<std::endl;

                std::cout<<"A2=";
                thrust::copy(A2.begin(), A2.end(), std::ostream_iterator<int>(std::cout, " "));
                std::cout<<std::endl;

                std::cout<<"result=";
                thrust::copy(result.begin(), result.end(), std::ostream_iterator<int>(std::cout, " "));
                std::cout<<std::endl;

                return 0;
                }

                ./difference
                A1=0 1 3 4 5 6 9
                A2=1 3 5 7 0
                result=0 4 6





                share|improve this answer













                There was a typo: it has to be result.begin() instead of result. I post the correct code for any other newbie.



                #include <thrust/set_operations.h>
                #include <thrust/execution_policy.h>
                #include <thrust/device_vector.h>

                int main()
                {
                thrust::device_vector<int> A1(7);
                thrust::device_vector<int> A2(5);

                thrust::device_vector<int> result(3);

                A1[0]=0;A1[1]=1;A1[2]=3;A1[3]=4;A1[4]=5;A1[5]=6;A1[6]=9;
                A2[0]=1;A2[1]=3;A2[2]=5;A2[3]=7;

                thrust::set_difference(thrust::device, A1.begin(), A1.end(), A2.begin(), A2.end(), result.begin());

                std::cout<<"A1=";
                thrust::copy(A1.begin(), A1.end(), std::ostream_iterator<int>(std::cout, " "));
                std::cout<<std::endl;

                std::cout<<"A2=";
                thrust::copy(A2.begin(), A2.end(), std::ostream_iterator<int>(std::cout, " "));
                std::cout<<std::endl;

                std::cout<<"result=";
                thrust::copy(result.begin(), result.end(), std::ostream_iterator<int>(std::cout, " "));
                std::cout<<std::endl;

                return 0;
                }

                ./difference
                A1=0 1 3 4 5 6 9
                A2=1 3 5 7 0
                result=0 4 6






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 7:38









                user27665user27665

                357416




                357416

















                    Popular posts from this blog

                    Tonle Sap (See)

                    I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

                    Guatemaltekische Davis-Cup-Mannschaft