開發平台(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 等等的