以下代码分别使用boost.compute和opencl c ++包装器添加两个向量.结果显示boost.compute比opencl c ++包装器慢近20倍.我想知道我是否错过使用boost.compute或它确实很慢.平台:win7,vs2013,提升1.55,boost.compute 0.2,ATI Radeon HD 4600
代码使用c ++包装器:
#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
#include <boost/timer/timer.hpp>
#include <boost/smart_ptr/scoped_array.hpp>
#include <fstream>
#include <numeric>
#include <algorithm>
#include <functional>
int main(){
static char kernelSourceCode[] = "\
__kernel void vadd(__global int * a, __global int * b, __global int * c){\
size_t i = get_global_id(0);\
\
c[i] = a[i] + b[i];\
}\
";
using type = boost::scoped_array<int>;
size_t const BUFFER_SIZE = 1UL << 13;
type A(new int[BUFFER_SIZE]);
type B(new int[BUFFER_SIZE]);
type C(new int[BUFFER_SIZE]); …Run Code Online (Sandbox Code Playgroud)