Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It dependends on the use of dev_imageStack. dev_imageStack is a pointer to CPU memory holding pointers to GPU memory. You would not be able to pass dev_imageStack to a kernel and read from it and your kernel will most likly crash. You could pass dev_imageStack[0].. dev_imageStack[X] to your kernel because that is a pointer to the GPU memory.</p> <p>If you need to pass all the frames with a pointer i would suggest to allocate a 1D array and perform the frame offset inside the kernel to get the correct frame.</p> <pre><code>unsigned char* dev_imageStack; cudaMalloc((void**)&amp;dev_imageStack, imageSize*X); </code></pre> <p>And when you use it you should access the frames by offseting into the array with Y*imageSize where Y is the frame you want to access.</p> <p>If you want to do it similar to the way you described than you have to do it like this:</p> <pre><code>unsigned char** host_imageStack = new unsigned char*[X]; for(int i = 0; i &lt; X; i++) { cudaMalloc( (void**) &amp;host_imageStack[i], imageSize*sizeof(char)); cudaMemcpy(host_imageStack[i], "char_ptr_to_frame_i_on_host", imageSize*sizeof(char),cudaMemcpyHostToDevice); } unsigned char** dev_imageStack; cudaMalloc((void**)&amp;dev_imageStack, X*sizeof(char*)); cudaMemcpy(dev_imageStack,host_imageStack,X*sizeof(char*),cudaMemcpyHostToDevice); </code></pre> <p>And now you could use the dev_imageStack as a 2D pointer to your kernel. Accessing frames and pixels will be done by calling dev_imageStack[frame_id][pixel_id] in kernel.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload