您好我正在尝试编写CUDA内核来执行以下代码.
for (n = 0; n < (total-1); n++)
{
a = values[n];
for ( i = n+1; i < total ; i++)
{
b = values[i] - a;
c = b*b;
if( c < 10)
newvalues[i] = c;
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我目前所拥有的,但它似乎没有给出正确的结果?有谁知道我做错了什么.干杯
__global__ void calc(int total, float *values, float *newvalues){
float a,b,c;
int idx = blockIdx.x * blockDim.x + threadIdx.x;
for (int n = idx; n < (total-1); n += blockDim.x*gridDim.x){
a = values[n];
for(int i = n+1; i < …Run Code Online (Sandbox Code Playgroud) cuda ×1