'clCreateBuffer'에 해당되는 글 1건

  1. 2012.09.24 clCreateBuffer clEnqueueWriteBuffer clSetKernelArg clEnqueueReadBuffer



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);




저작자 표시 비영리 변경 금지
신고
Posted by Leo 리오 트랙백 0 : 댓글 0