- 论坛徽章:
- 24
|
回复 1# fender0107401
- // source code for the add kernel
- const char source[] =
- "__kernel void add(__global const float *a,"
- " __global const float *b,"
- " __global float *c)"
- "{"
- " const uint i = get_global_id(0);"
- " c[i] = a[i] + b[i];"
- "}";
- // create the program with the source
- compute::program program =
- compute::program::create_with_source(source, context);
复制代码 其实只有 opencl kernel 的代码是在 GPU 上运行的,例如上面这段只有 “const char source” 里这段会进 GPU, 这一段里必须是 opencl 的代码不能调用一般 c/c++ 的库,程序其他部分和一般的 c/c++ 程序一样。 |
|