본문 바로가기
Program Language/OpenCL

clCreateBuffer clEnqueueWriteBuffer clSetKernelArg clEnqueueReadBuffer

by Leo 리오 2012. 9. 24.
반응형



http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clCreateBuffer.html

cl_mem clCreateBuffer (cl_context contextcl_mem_flags flagssize_t sizevoid *host_ptrcl_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_queuecl_mem buffercl_bool blocking_writesize_t offsetsize_t cb, const void *ptrcl_uint num_events_in_wait_list, const cl_event *event_wait_listcl_event *event)


cl_int clSetKernelArg (cl_kernel kernelcl_uint arg_indexsize_t arg_size, const void *arg_value)


cl_int clEnqueueReadBuffer (cl_command_queue command_queuecl_mem buffercl_bool blocking_readsize_t offsetsize_t cbvoid *ptrcl_uint num_events_in_wait_list, const cl_event *event_wait_listcl_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

댓글