Reply to comment

> однако функция умножения таким образом не запускается
Какая ошибка выводится?
>Я чувствую подвох в этом, поэтому выставил BLOCK_SIZE = 1 вместо 16
Никто же не запрещает сделать 2 переменные BLOCK_SIZE_X = 3 BLOCK_SIZE_Y = 16(или другие значения).

  1. int nGridY = lny/BLOCK_SIDE_Y;
  2. if(lny%BLOCK_SIDE_Y !=0){
  3.   nGridY++;
  4. }

А в кернале поспаить проверку что бы лишние значения не считались как то так например:
  1.        
  2. __global__ void foo(int x_end, int y_end){
  3.   const unsigned int x =  blockIdx.x*blockDim.x + threadIdx.x;
  4.   const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
  5.   if((x_end > x) && (y_end > y) ){
  6.     ..............
  7.   }
  8. }

Где x_end и y_end размер ImageRGB

Примичания: 1) Конечно не стоит забывать что потоки не попавшие в if будут простивать 2) Блок потоков размером 3Х16 - плохой вариант. Если уж BLOCK_SIZE_Х = 3 - жёстко то BLOCK_SIZE_Y я бы сделал равным 85(3*85 = 255 потоков). Но это уже дело оптимизации

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <i> <table> <td> <tr> <th>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Images can be added to this post.

More information about formatting options

Copyright © 2008-2011 Alex Tutubalin