如何将数组传递给OpenCL中的函数?我得到错误"..argument of type"_global float*"与行c [n] = FindIndexFromArray(a,3)中类型为"float*"的参数不兼容;
float FindIndexFromArray(float myArray[], float Key)
{
// simple looping to find the index
for (int i=0;i<sizeof(myArray);i++)
if (myArray[i]==Key)
return i;
}
kernel void ProcessArray(
global read_only float* myArray,
global read_only float* Key,
global write_only float* c )
{
int index = get_global_id(0);
c[index] = FindIndexFromArray(myArray, Key); // How do I pass myArray parameter?
}
Run Code Online (Sandbox Code Playgroud)
我编辑的源代码:
float FindIndexFromArray(__global read_only float* myArray[], __global read_only float* Key)
{
// simple looping to find the …Run Code Online (Sandbox Code Playgroud) 我正在从TMS学习组件。我得到了“ ... rtl100.bpl找不到...”。如果我使用包含“ rtl”的“使用运行时程序包构建”,可能会发生此错误。
rtl100.bpl在哪里(我正在使用D2007)?我该怎么办才能解决此错误?
我使用此函数将文件读取到字符串
function LoadFile(const FileName: TFileName): string;
begin
with TFileStream.Create(FileName,
fmOpenRead or fmShareDenyWrite) do begin
try
SetLength(Result, Size);
Read(Pointer(Result)^, Size);
except
Result := '';
Free;
raise;
end;
Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
这是文件的文字:
version
Run Code Online (Sandbox Code Playgroud)
这是LoadFile的返回值:
'ÿþv'#0'e'#0'r'#0's'#0'i'#0'o'#0'n'#0
Run Code Online (Sandbox Code Playgroud)
我想创建一个包含"verabc"的新文件.问题是我仍然有问题用"abc"替换"sion".我正在使用D2007.如果我删除所有#0,那么结果将成为中文字符.