当我尝试使用Radeon grafic卡在我的linxu薄荷计算机上运行以下pyopencl代码时出现以下错误。
不支持wordpuzzle中地址空间的初始化程序
程序很容易理解:我有一个INT数组,我将其复制到内核。我读出了INT数组的第一个数字,并根据返回的数字我想从CharSSet中选择char并返回它。
当我替换
wordbuff [0] = charSet [ a_g [0] ];
与
wordbuff [0] = charSSet [ 10 ];
然后它运作良好! WHY ???
el Code:
import numpy as np
import pyopencl as cl
a_np = np.array([10,22,5,3,8])
ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)
mf = cl.mem_flags
a_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a_np)
wordValue = np.array(['\0','\0','\0','\0','\0','\0'])
word_buffer = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=wordValue)
prg = cl.Program(ctx, """
__kernel void wordpuzzle(
__global const int *a_g, __global unsigned char *wordbuff)
{
int gid = get_global_id(0);
char charSSet[53] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
if (gid == 0){
wordbuff[0] = charSSet[a_g[0]];
}
}
""").build()
res_g = cl.Buffer(ctx, mf.WRITE_ONLY, a_np.nbytes)
prg.wordpuzzle(queue, (1,), (1,), a_g, word_buffer)
theChars = np.empty_like(wordValue)
cl.enqueue_read_buffer(queue,word_buffer,theChars)
print(theChars)
整个错误报告:
选择平台:[0] 选择[0]:设置环境变量PYOPENCL_CTX =''以避免 被问到了。 Traceback(最近一次调用最后一次):文件 “demo.py”,第35行,in msgstr“”“”。“。build()文件”/usr/lib/python2.7/dist-packages/pyopencl/init.py“,第213行, 建立 options = options,source = self._source)文件“/usr/lib/python2.7/dist-packages/pyopencl/init.py”,第253行,in _build_and_catch_errors 引发错误pyopencl.RuntimeError:clBuildProgram失败:构建程序失败 -
建立在:
不支持wordpuzzle中地址空间的初始值设定项(选项:-I /usr/lib/python2.7/dist-packages/pyopencl/cl)(源码保存为 /tmp/tmp7PxezZ.cl)