[翻译]  “Can't convert between vector values of different size”

[CHINESE]  "不能在不同大小的矢量值之间转换"


站长推荐:程序员必备10TBJava大数据机器学习人工智能从入门到精通视频教程下载


I'm trying to run a Runge-Kutta 4 on C language. The code is as follows:

我想在C语言上运行Runge-Kutta 4。代码如下:

__kernel void updade_state( __global float8 *q,__global float8 *qm, __global float8 *v){

const int gid = get_global_id(0);
float8 qs;


//k1
f( q, v);
qs = q[gid] + dt * v[gid]/6.0;
qm[gid] = q[gid] + 0.5 * dt * v[gid];

//k2
f(qm, v);
qs +=  dt * v[gid]/3.0;
qm[gid] = q[gid] + 0.5 * dt * v[gid];

//k3
f( qm, v);
qs +=  dt * v[gid]/3.0;
qm[gid] = q[gid] + dt * v[gid];

//k4
f( qm, v);
qs +=  dt * v[gid]/6.0;

//update particle
q[gid] = qs;

}

}

I'm using pyopencl module to access my graphics card ("gid") in order to run a simulation of multiple particles much more efficiently.

我正在使用pyopencl模块访问我的显卡(“gid”),以便更有效地运行对多个粒子的模拟。

Apart from the function f that is being called in the kernel, the rest of the kernel is being built in a python program, through which it is added the constant value of dt, present in my Runge-Kutta code.

除了在内核中调用的函数f之外,内核的其余部分都构建在一个python程序中,通过这个程序,它将增加我的Runge-Kutta代码中显示的dt的常量值。

However, when I run the whole thing, the following error message shows:

然而,当我运行整个程序时,以下错误消息显示:

<kernel>:52:22: error: can't convert between vector values of different size ('double' and 'float8')
    qs = q[gid] + dt * v[gid]/6.0;
                  ~~ ^ ~~~~~~
<kernel>:53:33: error: can't convert between vector values of different size ('double' and 'float8')
    qm[gid] = q[gid] + 0.5 * dt * v[gid];
                       ~~~~~~~~ ^ ~~~~~~
<kernel>:57:15: error: can't convert between vector values of different size ('double' and 'float8')
    qs +=  dt * v[gid]/3.0;
           ~~ ^ ~~~~~~
<kernel>:58:33: error: can't convert between vector values of different size ('double' and 'float8')
    qm[gid] = q[gid] + 0.5 * dt * v[gid];
                       ~~~~~~~~ ^ ~~~~~~
<kernel>:62:15: error: can't convert between vector values of different size ('double' and 'float8')
    qs +=  dt * v[gid]/3.0;
           ~~ ^ ~~~~~~
<kernel>:63:27: error: can't convert between vector values of different size ('double' and 'float8')
    qm[gid] = q[gid] + dt * v[gid];
                       ~~ ^ ~~~~~~
<kernel>:67:15: error: can't convert between vector values of different size ('double' and 'float8')
    qs +=  dt * v[gid]/6.0;

Cheers

干杯

1 个解决方案

#1


1  

Well, I went around the problem and solved it by casting the value dt and other constants in the kernel, as suggested by Jiminion. This is not the most elegant solution but it works.

我绕过了这个问题,通过在内核中引入dt和其他常数来解决它,正如Jiminion所建议的。这不是最优雅的解决方案,但确实有效。

__kernel void updade_state( __global float8 *q,__global float8 *qm, __global float8 *v){

const int gid = get_global_id(0);
float8 qs;
float  dt, c1, c2, c3;

c1 = 6.0;
c2 = 3.0;
c3 = 0.5;    

dt = 0.0001;


//k1
f( q, v);
qs = q[gid] + dt * v[gid]/c1;
qm[gid] = q[gid] + c3 * dt * v[gid];

//k2
f(qm, v);
qs +=  dt * v[gid]/c2;
qm[gid] = q[gid] + c3 * dt * v[gid];

//k3
f( qm, v);
qs +=  dt * v[gid]/c2;
qm[gid] = q[gid] + dt * v[gid];

//k4
f( qm, v);
qs +=  dt * v[gid]/c1;

//update photon
q[gid] = qs;

}

}

本站声明
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。


 
© 2014-2018 ITdaan.com 粤ICP备14056181号