Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat t735.cu
- #include <thrust/device_vector.h>
- #include <thrust/iterator/permutation_iterator.h>
- #include <thrust/iterator/transform_iterator.h>
- #include <thrust/device_ptr.h>
- #include <thrust/extrema.h>
- #include <stdint.h>
- #define DSIZE 4
- // Piece 1
- struct MultiplyFunction : public thrust::unary_function<uint32_t, uint32_t> {
- uint32_t Y;
- MultiplyFunction( uint32_t y ) {
- Y = y;
- }
- __device__ uint32_t operator()( uint32_t x ) {
- return x * Y;
- }
- };
- // Piece 2
- #define my_auto( name, value ) typeof( value ) name = value
- int main(){
- // Piece 3
- thrust::device_ptr<uint8_t> start;
- thrust::device_ptr<uint32_t> Keys1, IndirectKeys;
- uint32_t jump, rowsCount;
- // adds
- thrust::device_vector<uint8_t> my_data(DSIZE,1);
- thrust::device_vector<uint32_t> my_keys(DSIZE, 1);
- thrust::device_vector<uint32_t> my_ikeys(DSIZE, 1);
- jump = 1;
- rowsCount = 1;
- start = my_data.data();
- Keys1 = my_keys.data();
- IndirectKeys = my_ikeys.data();
- // Piece 4
- my_auto( begin, thrust::make_permutation_iterator(
- start,
- thrust::make_transform_iterator(
- thrust::make_permutation_iterator(
- Keys1,
- IndirectKeys
- ),
- MultiplyFunction( jump )
- )
- ) );
- my_auto( end, begin + rowsCount );
- my_auto( tuple, thrust::minmax_element( begin, end ) ); // Invalid access on the CPU.
- }
- $ nvcc -o t735 t735.cu
- $ cuda-memcheck ./t735
- ========= CUDA-MEMCHECK
- ========= ERROR SUMMARY: 0 errors
- $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement