OpenCL内核函数中定义double类型变量

 

要在OpenCL的kernel函数中使用双精度的变量,必须在配置页打开

“强制支持双精度浮点(强制cl_khr_fp64)”选项,即在kernel函数

定义前加上如下红色部分那句话:

 

 

#pragma OPENCL EXTENSION cl_khr_fp64: enable

 

__kernel void templateKernel(__global double * output_pop,
                                               __global double * output_pop_fit,
                                               __global double * input_pop,
                                               __global double * input_pop_fit,
        const     unsigned int d)
{
     uint tid = get_global_id(0);
     for (unsigned int i=0;i     {
          output_pop[tid*d+i] = input_pop[tid*d+i]*2;
     }
     output_pop_fit[tid] = input_pop_fit[tid]*2;
}

你可能感兴趣的:(OpenCL)