Unable to call thrust on CUDA memory -
I am trying to find an array (already present in CUDA memory) using the emphasis library. Here are some answers, have said that this emphasis is possible by wrapping: using device_ptr, but it is throwing an error for me.
initial code
cudaMemcpy ((* Zero *) (data + rotation), (zero *) d_output, size (unsigned int) * rows * cols, cudaMemcpyDeviceToHost); Thrust: Device_Vector & lt; Unsigned Inter & gt; Vec (data + curved), (data + + + + strips + rows * cols); Sum = thrust :: less (vec.begin (), vec.end ());
< P> The above code works perfectly well, but if I do it, thrust :: device_ptr unsigned int> outputPtrBegin (d_output); thrust: device_ptr < Unsigned int & gt; Outputprint ((d_output + stride + (rows * cols)); Sum = thrust :: less (outputPtrBegin, outputPtrEnd);
This throws me the following error. / P>
Finish after throwing an example of 'thrust :: system :: system_error' (): An invalid memory access was encountered, the canceled (core dump)
What could be the problem? Thank you very much for your time.
< P> * Edit input from Robert Kowlow I have a question (related to the above declaration)Based on the value of the toggle, I need to call the emphasis
If (toggle) {emphasis: device_ptr> unsigned interval & gt; OutputPtrBegin (d_output); Thrust: device_ptr & lt; Unsigned int & gt; Output To ((d_output + (rows * cols)); } Other {emphasis: device_ptr & lt; Unsigned Inter & gt; OutputPtrBegin (d_X); Thrust: device_ptr & lt; Unsigned int & gt; Outputprint ((d_X + (rows * cols))}}
But the compilation says output output and outputprint are not declared, because they are in the if statement before and after How do I declare these device pointers?
This is incorrect:
Thrust: device_ptr & lt; unsigned int * outputprint ((d_output + stride + (rows * cols));
It should be:
< Code> thrust :: device_ptr & lt; unsigned Int> per output ((d_output + (rows * cols));
In your first (work) example, you are copying an area from the device to the host. However, that field starts with d_output
and its length is on the rows * cols
elements. This is the data that you eventually decrease
Going through the operation Yes, on the host, it is copied to the area that starts from data + dive
It is irrelevant but in the end you are reducing the rows * cols
elements in your first implementation.
It is quite clear that in other implementations, you are trying to start less operation than initially d_output
and d_output + stride + (rows * cols) < Going to / code>. This is not the same size operation.
In addition, you may want to do something like this instead:
thrust :: device_ptr < Unsigned int & gt; OutputPtrBegin (d_output); Thrust: device_ptr & lt; Unsigned int & gt; OutputPtrEnd = Output PtrBegin + (rows * cols); Sum = thrust :: less (outputPtrBegin, outputPtrEnd);
If you (toggle) {emphasis: device_ptr < Unsigned) instead of your second question (please post new questions as new questions):
integer & gt; OutputPtrBegin (d_output); Thrust: device_ptr & lt; Unsigned int & gt; Output To ((d_output + (rows * cols)); } Other {emphasis: device_ptr & lt; Unsigned Inter & gt; OutputPtrBegin (d_X); Thrust: device_ptr & lt; Unsigned int & gt; Outputprint ((d_X + (rows * cols));}
Do something like this:
thrust :: device_ptr unsigned int & gt; OutputPtrBegin; thrust: device_ptr outputPtrEnd; if (toggle) output PtrBegin = thrust :: device_pointer_cast (d_output); Else outputPtrBegin = thrust :: device_pointer_cast & lt; unsigned & Gt; (d_X); OutputPtrEnd = Output PtrBegin + (rows * cols);
Comments
Post a Comment