Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's suppose you have a kernel that computes the three values. Each thread in your configuration will compute the three values for each (r,c) pair.</p> <pre><code>__global__ value_kernel(Y, H, X, W) { r = blockIdx.x + Y; c = threadIdx.x + W; chan1value = ... chan2value = ... chan3value = ... } </code></pre> <p>I don't believe you can calculate the sum (completely in parallel, at least) in the above kernel. You won't be able to use += like you have above. You could put it all in one kernel if you have only one thread in each block (row) do the sum and mean, like this...</p> <pre><code>__global__ both_kernel(Y, H, X, W) { r = blockIdx.x + Y; c = threadIdx.x + W; chan1value = ... chan2value = ... chan3value = ... if(threadIdx.x == 0) { ch1RowSum = 0; ch2RowSum = 0; ch3RowSum = 0; for(i=0; i&lt;blockDim.x; i++) { ch1RowSum += chan1value; ch2RowSum += chan2value; ch3RowSum += chan3value; } ch1Mean = ch1RowSum / blockDim.x; ch2Mean = ch2RowSum / blockDim.x; ch3Mean = ch3RowSum / blockDim.x; } } </code></pre> <p>but it's probably better to use the first value kernel and then a second kernel for both sums and means... It's possible to further parallelize the kernel below, and if it's separate you can focus on that when you're ready.</p> <pre><code>__global__ sum_kernel(Y,W) { r = blockIdx.x + Y; ch1RowSum = 0; ch2RowSum = 0; ch3RowSum = 0; for(i=0; i&lt;W; i++) { ch1RowSum += chan1value; ch2RowSum += chan2value; ch3RowSum += chan3value; } ch1Mean = ch1RowSum / W; ch2Mean = ch2RowSum / W; ch3Mean = ch3RowSum / W; } </code></pre>
    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