allendaicool / thrust

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

Why not provide a member function that returns the raw device pointer? #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Thank you for your great product. But why not provide a member function that 
returns the raw device pointer? I think thrust::raw_pointer_cast(&data[0]) is 
urgly. 

Original issue reported on code.google.com by SunMingming on 11 Jul 2010 at 10:43

GoogleCodeExporter commented 9 years ago
Hi Sun, thanks for your suggestion.

I agree that &data[0] is ugly, but it's also the way the STL works. The 
upcoming C++0x standard adds a .data() member function to the vector container 
that returns a pointer.  We've gone ahead and added .data() to host_vector and 
device_vector, so you can now do
   device_ptr<float> dev_ptr = my_device_vector.data();
to get a device_ptr to the underlying data, or
   float * raw_ptr = raw_pointer_cast(my_device_vector.data());
to convert the device_ptr to a raw pointer.  I understand this isn't quite as 
simple as you probably wanted, but it is the closest we can get while 
conforming to the C++0x standard.

[1] 
http://code.google.com/p/thrust/source/browse/thrust/detail/vector_base.h#284

Original comment by wnbell on 11 Jul 2010 at 6:51

GoogleCodeExporter commented 9 years ago
Thank you for your help. You are right. Mantaining the consistency of interface 
is important for productivity. The data() method is good. I like it. 

Original comment by SunMingming on 12 Jul 2010 at 6:31

GoogleCodeExporter commented 9 years ago
Marking as WontFix

Original comment by jaredhoberock on 12 Jul 2010 at 8:43