未能初始化 opencl 向量文字
所以我试图在我的 opencl 主机代码中初始化一个变量,如下所示:
cl_float2 es = (cl_float2)(0.0f,0.0f);
其中,使用 Clang 2.9,失败:
source/solveEikonalEq.c:75:38: warning: expression result unused [-Wunused-value]
cl_float2 es = (cl_float2)(0.0f,0.0f);
^~~~
source/solveEikonalEq.c:75:26: error: cast to union type from type 'float' not present in union
cl_float2 es = (cl_float2)(0.0f,0.0f); //ray's tangent vector
^ ~~~~~~~~~~~
并且,当使用 GCC 4.6.1 时,失败:
source/solveEikonalEq.c:75:42: warning: left-hand operand of comma expression has no effect [-Wunused-value]
source/solveEikonalEq.c:75:26: error: cast to union type from type not present in union
我正在使用 AMD 的 opencl sdk,并且可以构建例子就好了。 我做错了什么?
So i'm trying to initialize a variable in my opencl host code like this:
cl_float2 es = (cl_float2)(0.0f,0.0f);
Which, using Clang 2.9, fails with:
source/solveEikonalEq.c:75:38: warning: expression result unused [-Wunused-value]
cl_float2 es = (cl_float2)(0.0f,0.0f);
^~~~
source/solveEikonalEq.c:75:26: error: cast to union type from type 'float' not present in union
cl_float2 es = (cl_float2)(0.0f,0.0f); //ray's tangent vector
^ ~~~~~~~~~~~
And, when using GCC 4.6.1, fails with:
source/solveEikonalEq.c:75:42: warning: left-hand operand of comma expression has no effect [-Wunused-value]
source/solveEikonalEq.c:75:26: error: cast to union type from type not present in union
I'm using AMD's opencl sdk, and can build the examples just fine.
What is it i'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在尝试在主机代码中使用 OpenCL C 样式初始化程序,该代码可能是使用 C 编译器编译的。换句话说,这种初始化方式仅在您的内核中有效。在那里,您不会使用平台类型,而只会使用
float2
。在您的主机代码中尝试一下:
这对您有用。
You are trying to use an OpenCL C-style initializer in your host code, which is presumably compiled with a C compiler. That style of initialization is only valid in your kernels, in other words. And there, you would not use a platform type, but would instead just use a
float2
.Try this in your host code instead:
That will work for you.