Closed GoogleCodeExporter closed 8 years ago
This is the expected behavior.
unsigned char cannot represent values greater than 255.
Original comment by jaredhoberock
on 5 Jul 2011 at 8:51
The operator returns ints, though. thrust::reduce should return a value which
is the same as the return type of the operator. On CPU it actually does that.
Therefore, I don't quite understand your reasoning, can you explain in more
detail?
Original comment by boiling....@gmail.com
on 8 Sep 2011 at 8:45
Unlike std::accumulate, thrust::reduce requires binary_op to be commutative
[1]. Your expectation
sum=binary_op(sum,nextval),
ignores commutativity. The CUDA implementation is putting the sum on the RHS
of the operator [2] and converting to unsigned char.
[1]
http://wiki.thrust.googlecode.com/hg/html/group__reductions.html#ga268b8b31c9c3a
2e6e4b3b6be1f5c202d
[2]
http://code.google.com/p/thrust/source/browse/thrust/detail/backend/cuda/reduce.
inl#99
Original comment by jaredhoberock
on 8 Sep 2011 at 9:08
Ok, I missed that point. Thanks for the explanation!
Original comment by boiling....@gmail.com
on 8 Sep 2011 at 12:19
Original issue reported on code.google.com by
boiling....@gmail.com
on 4 Jul 2011 at 1:23