2013年3月20日 星期三

OpenCL筆記

OpenCL主要分成四個部份

Platform model -- device 和 host

Execution model -- kernel如何在device上執行

Memory model -- abstract memory hierarchy

Programming model -- 定義concurrency model如何map 到physical hardware


(1) Initialize platforms

clGetPlatformIDs(...,...,...);

(2)Initialize devices

clGetDeviceIDs(...,...,...,...,...);

(3) Create a context

clCreateContext(...,...,...,...,...,...,...);

(4) Create a command queue

clCreateCommandQueue(...);

(5) Create device buffers

clCreateBuffer(...);

(6) Write host data to device buffers

clEnqueueWriteBuffer(...);

(7) Create and compile the program

clCreateProgramWithSource(...);

clBuildProgram(...);

(8) Create the kernel

clCreateKernel(...);

(9) Set kernel arguments

clSetKernelArg(...);

(10) Configure the work-item structure

size_t globalWorkSize[1];

globalWorkSize[0]=2048;

(11) Enqueue the kernel for execution

clEnqueueNDRangeKernel(...);

(12) Read output results to host

clEnqueueReadBuffer(...);

(13) Release OpenCL Resources

clRealeaseKernel(...);
clRealeaseProgram(...);
...







沒有留言:

張貼留言