allendaicool / thrust

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

consider refining dispatch to retain variable references longer #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We sometimes implement specific versions of an algorithm with more general
versions of the algorithm.  For example, we can implement
   find(Iterator first, Iterator last, T& value)
with 
   find_if(Iterator first, Iterator last, Predicate pred)
by defining a Predicate that does the comparison.

An unintended side effect of this scheme is that the Predicate must hold a
copy of 'value' and not a reference, because it might be copied to the
device.  A more correct implementation would retain a distinct find() path
through the host/device dispatch and only implement find with find_if in
the device backend.

Like issue #119 this is a case of where Thrust is a little too presumptuous.

Original issue reported on code.google.com by wnbell on 7 Apr 2010 at 11:08

GoogleCodeExporter commented 9 years ago
If we really cared, we could give the predicate to find_if a reference instead 
of a value

Original comment by jaredhoberock on 7 Apr 2010 at 3:01

GoogleCodeExporter commented 9 years ago
The new dispatch layer eliminates this problem.

Original comment by wnbell on 2 Nov 2011 at 4:48