lion03 / thrust

Automatically exported from code.google.com/p/thrust
Apache License 2.0
0 stars 0 forks source link

error: no instance of constructor "thrust::device_reference<T>::device_reference [with T=int]" matches the argument list #244

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please post a short code sample which reproduces the problem:

//from the getting started guide:
// initialize vectors
thrust::device_vector<int>  A(3);
thrust::device_vector<char> B(3);
A[0] = 10;  A[1] = 20;  A[2] = 30;
B[0] = 'x'; B[1] = 'y'; B[2] = 'z';

// create iterator (type omitted)
typedef typename thrust::device_vector<int>::iterator                     
IntIterator;
typedef typename thrust::device_vector<char>::iterator                     
CharIterator;

typedef typename thrust::tuple<IntIterator, CharIterator> IteratorTuple;

thrust::zip_iterator<IteratorTuple> first;
thrust::zip_iterator<IteratorTuple> last;

first = (thrust::zip_iterator<IteratorTuple>) 
thrust::make_zip_iterator(thrust::make_tuple(A.begin(), B.begin()));
last  = (thrust::zip_iterator<IteratorTuple>) 
thrust::make_zip_iterator(thrust::make_tuple(A.end(),   B.end()));

first[0];   // returns tuple(10, 'x')
first[1];  // returns tuple(20, 'y')
first[2];  // returns tuple(30, 'z')

// maximum of [first, last)
thrust::maximum< thrust::tuple<int,char> > binary_op;
thrust::reduce(first, last, first[0], binary_op); // returns tuple(30, 'z');

What is the expected output? What do you see instead?
error: no instance of constructor 
"thrust::device_reference<T>::device_reference [with T=int]" matches the 
argument list

What version of Thrust are you using? Thrust v1.3.0 Which version of nvcc? 
release 3.1, V0.2.1221 Which host
compiler? MSVS 2008 Version 9.0.30729.1 On what operating system? Windows 7 
64-bit

Please provide any additional information below.

Original issue reported on code.google.com by bhar...@gmail.com on 6 Oct 2010 at 11:20

GoogleCodeExporter commented 8 years ago
Thanks for the report.  This is an unfortunate consequence of device_reference 
semantics.

This change to the end of the program fixes the compilation:

  thrust::tuple<int,char> init = first[0];
  thrust::reduce(first, last, init, binary_op); // returns tuple(30, 'z');

I've updated the getting started guide with the correct code.

Original comment by jaredhoberock on 7 Oct 2010 at 4:14

GoogleCodeExporter commented 8 years ago

Original comment by wnbell on 6 Feb 2011 at 6:50