[問題] openCL kernal中如何知道index屬於誰?
開發平台(Platform): (Ex: Win10, Linux, ...)
Win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
vc2017
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
OpenCL
問題(Question):
我在kernal中傳入3個大小不同的一維陣列
我如何知道get_global_id(0) 回傳的index是屬於誰的?
餵入的資料(Input):
三個大小不同的一維陣列,a_Cost為輸出
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
__kernel void CostDataMat_kernel(__global const int a_RangeUpScale, __global
const int a_ImgWidth, __global const int a_ImgHeight, __global const char
*a_Left, __global const char *a_Right, __global int *a_Cost) {
// Get the index of the current element to be processed
int index = get_global_id(0);
int ImgSize = a_ImgWidth*a_ImgHeight;
int layer = index/ImgSize;
int layer_mod = index%ImgSize;
int i = layer_mod/a_ImgWidth;
int j = layer_mod%a_ImgWidth;
int Y_Abs = 0;
int Cb_Abs = 0;
int Cr_Abs = 0;
// Do the operation
Y_Abs = abs(a_Left[layer_mod*3] - a_Right[layer_mod*3]);
Cr_Abs = abs(a_Left[layer_mod*3+1] - a_Right[layer_mod*3+1]);
Cb_Abs = abs(a_Left[layer_mod*3+2] - a_Right[layer_mod*3+2]);
if(j >= a_RangeUpScale)
{
a_Cost[index] = Y_Abs + ((Cr_Abs + Cb_Abs)>>1);
}
else
{
if(layer < j+1)
{
a_Cost[index] = Y_Abs + ((Cr_Abs + Cb_Abs)>>1);
}
else
{
a_Cost[index] = -1;
}
}
}
補充說明(Supplement):
另外想請教各位大大,如何知道kernal有哪些函數可以用 ex: abs 等等的
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.34.230.27
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1503390765.A.64C.html
※ 編輯: hardman1110 (114.34.230.27), 08/22/2017 16:50:46
推
08/22 17:04, , 1F
08/22 17:04, 1F
→
08/22 17:06, , 2F
08/22 17:06, 2F
→
08/22 17:06, , 3F
08/22 17:06, 3F
→
08/22 17:07, , 4F
08/22 17:07, 4F
→
08/22 17:07, , 5F
08/22 17:07, 5F
→
08/22 17:09, , 6F
08/22 17:09, 6F
→
08/22 17:09, , 7F
08/22 17:09, 7F
→
08/22 17:09, , 8F
08/22 17:09, 8F
→
08/22 17:11, , 9F
08/22 17:11, 9F
→
08/22 17:12, , 10F
08/22 17:12, 10F
→
08/22 17:13, , 11F
08/22 17:13, 11F
推
08/22 17:25, , 12F
08/22 17:25, 12F
→
08/22 17:25, , 13F
08/22 17:25, 13F
→
08/22 17:26, , 14F
08/22 17:26, 14F
→
08/22 17:26, , 15F
08/22 17:26, 15F
→
08/22 17:26, , 16F
08/22 17:26, 16F
→
08/22 17:26, , 17F
08/22 17:26, 17F
→
08/22 17:27, , 18F
08/22 17:27, 18F
→
08/22 17:27, , 19F
08/22 17:27, 19F
→
08/22 17:28, , 20F
08/22 17:28, 20F
→
08/22 17:29, , 21F
08/22 17:29, 21F
→
08/22 17:29, , 22F
08/22 17:29, 22F
→
08/22 17:29, , 23F
08/22 17:29, 23F
→
08/22 17:30, , 24F
08/22 17:30, 24F
→
08/22 17:45, , 25F
08/22 17:45, 25F
→
08/22 17:45, , 26F
08/22 17:45, 26F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):