OpenCL代码返回零

时间:2016-05-04 05:02:56

标签: c opencl gpu

这个开放的CL代码编译好了但是在执行时保持返回0.0f作为'call [0]'的值

typedef struct tag_sinterest {
    __global float *h_phi;
    __global float *l_phi;
} sinterest;

typedef struct tag_sfutures {
    int time;
    __global float put;
    __global sinterest *call;
} sfutures;

float square(float _number) {
    return(_number*_number);
}

__kernel void Futures(__global sfutures *_futures,
    int _futures_index, __global float *_call, __global float *_call_weight) {
    int i = get_global_id(0);
    int j = get_global_id(1);
    int k = get_global_id(2);

    float _weight = 0.0f;

    _weight += (float)square(_futures[_futures_index-1].call[j].h_phi[k]-_futures[i].call[j].h_phi[k]);
    _weight += (float)square(_futures[_futures_index-1].call[j].l_phi[k]-_futures[i].call[j].l_phi[k]);

    _call[0] += _weight*_futures[k].put;
    _call_weight[0] += _weight;
}

它意味着复制这些for循环,它们在主机上运行良好(C#):

void Futures(Sfutures[] Futures,int FuturesIndex,ref float Call,ref float CallWeight) {
    for(int f=0;f<_FUTURES;f++) {
        for(int I=0;I<_INTEREST;I++) {
            float _weight = 0.0f;

            _weight += (float)pow(Futures[FuturesIndex-1].call[f].h_phi[I]-Futures[i].call[f].h_phi[I],2.0f);
            _weight += (float)pow(Futures[FuturesIndex-1].call[f].l_phi[I]-Futures[i].call[f].l_phi[I],2.0f);

            Call += _weight*Futures[i].put;
            CallWeight += _weight;
        }
    }
}

这是为什么?我在Windows 10 64位上有一个intel HD 4000,OpenCL 1.2

0 个答案:

没有答案