반응형
http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clCreateBuffer.html
cl_mem clCreateBuffer (
cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_int *errcode_ret)
flags
CL_MEM_READ_WRITE
CL_MEM_WRITE_ONLY
CL_MEM_READ_ONLY
CL_MEM_USE_HOST_PTR
CL_MEM_ALLOC_HOST_PTR
CL_MEM_COPY_HOST_PTR
cl_mem clEnqueueWriteBuffer (
cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
cl_int clEnqueueReadBuffer (
cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
NOTICE! cl_mem 자체가 포인터이다.
(typedef struct _cl_mem * cl_mem;)
호스트
cl_mem clmem_input = clCreateBuffer(context, CL_MEM_WRITE_ONLY, SIZE, 0, err);
clEnqueueWriteBuffer(commandq, clmem_input, CL_TRUE, 0, SIZE, INPUT_ptr, 0, 0);
clSetKernelArg(kernel, arg++, sizeof(cl_mem), clmem_input);
cl_mem clmem_result = clCreateBuffer(context, CL_MEM_READ_ONLY, SIZE, 0, err);
clSetKernelArg(kernel, arg++, sizeof(cl_mem),
clmem_result );
커널
__kernel Goo(global unsigned char* clmem1, local unsigned char* clmem2)
{
}
호스트
clEnqueueReadBuffer(commandq, clmem_result, CL_TRUE, 0, SIZE, OUTPUT_ptr, 0,0,0);
clReleaseMemObject(clmem_input);
clReleaseMemObject(clmem_result);
반응형
'Program Language > OpenCL' 카테고리의 다른 글
OpenCL 포팅 (0) | 2012.10.05 |
---|---|
Release (0) | 2012.09.24 |
OpenCL 외부파일 쉽게 컴파일하기 (0) | 2012.09.21 |
[OCL] #include cannot open source file "......cl" (0) | 2012.09.21 |
Intel OpenCL visual studio 설정 (0) | 2012.08.08 |
댓글