thrust

CUDA Thrust reduction with double2 arrays

与世无争的帅哥 提交于 2019-12-01 19:25:01
I have the following (compilable and executable) code using CUDA Thrust to perform reductions of float2 arrays. It works correctly using namespace std; // includes, system #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <conio.h> #include <typeinfo> #include <iostream> // includes CUDA #include <cuda.h> #include <cuda_runtime.h> // includes Thrust #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/reduce.h> // float2 + struct struct add_float2 { __device__ float2 operator()(const float2& a, const float2& b) const { float2 r;

How to debug cuda thrust functions in visual studio 2010 with parallel nsight

痞子三分冷 提交于 2019-12-01 18:04:34
I am using visual studio 2010, parallel nsight 2.2 and cuda 4.2 for learning. My system is Windows 8 pro x64. I opened the radix sort project which included by cuda computing SDK in VS, and compiled it with no error. The sort code uses thrust library: if(keysOnly) thrust::sort(d_keys.begin(), d_keys.end()); else thrust::sort_by_key(d_keys.begin(), d_keys.end(), d_values.begin()); I want to know how thrust dispatch the sort function to cuda kernels, so I tried to add breakpoints in front of lines above and compiled the project in debug mode. But when I use parallel nsight for cuda debugging,

How to debug cuda thrust functions in visual studio 2010 with parallel nsight

北慕城南 提交于 2019-12-01 18:02:12
问题 I am using visual studio 2010, parallel nsight 2.2 and cuda 4.2 for learning. My system is Windows 8 pro x64. I opened the radix sort project which included by cuda computing SDK in VS, and compiled it with no error. The sort code uses thrust library: if(keysOnly) thrust::sort(d_keys.begin(), d_keys.end()); else thrust::sort_by_key(d_keys.begin(), d_keys.end(), d_values.begin()); I want to know how thrust dispatch the sort function to cuda kernels, so I tried to add breakpoints in front of

Sorting Pixels from opengl using CUDA and Thrust

╄→гoц情女王★ 提交于 2019-12-01 14:48:45
I rendered a scene with opengl (I can also render it to a texture) I want to use CUDA / Thrust to sort this rendered image How do I link the texture I made from : cudaGraphicsGLRegisterImage to be used via thrust? maybe something like this ? how to calculate an average from a int2 array using Thrust Robert Crovella I'm not sure it makes sense to try and use textures directly with thrust. However using an ordinary GL pixel buffer can be made to work directly with thrust. The following example creates an openGL pixel buffer with a particular green/black pattern, and then displays it. When you

Cuda Thrust Custom function

爷,独闯天下 提交于 2019-12-01 13:48:18
How can I impliment this function in Thrust? for (i=0;i<n;i++) if (i==pos) h1[i]=1/h1[i]; else h1[i]=-h1[i]/value; In CUDA I did it like: __global__ void inverse_1(double* h1, double value, int pos, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < N){ if (i == pos) h1[i] = 1 / h1[i]; else h1[i] = -h1[i] / value; } } Thanks! You need to create a binary functor to apply the operation, then use a counting iterator as the second input. You can pass pos and value into the functor's constructor. It'd look something like: struct inv1_functor { const int pos; const double value; inv1

How to use CUB and Thrust in one CUDA code

扶醉桌前 提交于 2019-12-01 13:37:39
I'm trying to introduce some CUB into my "old" Thrust code, and so have started with a small example to compare thrust::reduce_by_key with cub::DeviceReduce::ReduceByKey , both applied to thrust::device_vectors . The thrust part of the code is fine, but the CUB part, which naively uses raw pointers obtained via thrust::raw_pointer_cast, crashes after the CUB calls. I put in a cudaDeviceSynchronize() to try to solve this problem, but it didn't help. The CUB part of the code was cribbed from the CUB web pages. On OSX the runtime error is: libc++abi.dylib: terminate called throwing an exception

Sorting Pixels from opengl using CUDA and Thrust

不羁岁月 提交于 2019-12-01 13:30:46
问题 I rendered a scene with opengl (I can also render it to a texture) I want to use CUDA / Thrust to sort this rendered image How do I link the texture I made from : cudaGraphicsGLRegisterImage to be used via thrust? maybe something like this ? how to calculate an average from a int2 array using Thrust 回答1: I'm not sure it makes sense to try and use textures directly with thrust. However using an ordinary GL pixel buffer can be made to work directly with thrust. The following example creates an

Using cuBLAS with complex numbers from Thrust

帅比萌擦擦* 提交于 2019-12-01 13:17:09
问题 In my code I use arrays with complex numbers from thrust library and I would like to use cublasZgeam() in order to transpose the array. Using complex numbers from cuComplex.h is not a preferable option since I do a lot of arithmetic on the array and cuComplex doesnt have defined operators such as * +=. This is how I defined array which I want to transpose thrust::complex<float> u[xmax][xmax]; I have found this https://github.com/jtravs/cuda_complex, but using it as such: #include "cuComplex

Cuda Thrust Custom function

旧巷老猫 提交于 2019-12-01 13:10:44
问题 How can I impliment this function in Thrust? for (i=0;i<n;i++) if (i==pos) h1[i]=1/h1[i]; else h1[i]=-h1[i]/value; In CUDA I did it like: __global__ void inverse_1(double* h1, double value, int pos, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < N){ if (i == pos) h1[i] = 1 / h1[i]; else h1[i] = -h1[i] / value; } } Thanks! 回答1: You need to create a binary functor to apply the operation, then use a counting iterator as the second input. You can pass pos and value into the

Why intersection of Thrust Library is returning unexpected result?

☆樱花仙子☆ 提交于 2019-12-01 12:27:46
I'm using the library Thrust to get intersection set of a two larger sets of integers. In test with 2 small inputs i got correct results, but when i use two sets with 10^8 and 65535*1024 elements i got a empty set. Who's can explain this problem? Changing the two first variables to smaller values the thrust returns a expected intersection set. My code is following. #include <thrust/set_operations.h> #include <thrust/device_vector.h> #include <thrust/device_ptr.h> #include <iostream> #include <stdio.h> int main() { int sizeArrayLonger = 100*1000*1000; int sizeArraySmaller = 65535*1024; int