func CLEnqueueWriteBuffer(command_queue CL_command_queue, buffer CL_mem, blocking_write CL_bool, offset CL_size_t, cb CL_size_t, ptr unsafe.Pointer, num_events_in_wait_list CL_uint, event_wait_list []CL_event, event *CL_event) CL_int { if (num_events_in_wait_list == 0 && event_wait_list != nil) || (num_events_in_wait_list != 0 && event_wait_list == nil) || int(num_events_in_wait_list) != len(event_wait_list) { return CL_INVALID_EVENT_WAIT_LIST } var c_event C.cl_event var c_errcode_ret C.cl_int if num_events_in_wait_list != 0 { var c_event_wait_list []C.cl_event c_event_wait_list = make([]C.cl_event, num_events_in_wait_list) for i := 0; i < int(num_events_in_wait_list); i++ { c_event_wait_list[i] = event_wait_list[i].cl_event } c_errcode_ret = C.clEnqueueWriteBuffer(command_queue.cl_command_queue, buffer.cl_mem, C.cl_bool(blocking_write), C.size_t(offset), C.size_t(cb), ptr, C.cl_uint(num_events_in_wait_list), &c_event_wait_list[0], &c_event) } else { c_errcode_ret = C.clEnqueueWriteBuffer(command_queue.cl_command_queue, buffer.cl_mem, C.cl_bool(blocking_write), C.size_t(offset), C.size_t(cb), ptr, 0, nil, &c_event) } if event != nil { event.cl_event = c_event } return CL_int(c_errcode_ret) }
func (cq *CommandQueue) EnqueueWriteBuffer(buf *Buffer, data []byte, offset uint32) error { if ret := C.clEnqueueWriteBuffer(cq.id, buf.id, C.CL_TRUE, C.size_t(offset), C.size_t(len(data)), unsafe.Pointer(&data[0]), 0, nil, nil); ret != C.CL_SUCCESS { return Cl_error(ret) } return nil }
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBuffer.html func EnqueueWriteBuffer(cq CommandQueue, buffer Mem, blocking_write Bool, offset uint64, size uint64, ptr unsafe.Pointer, num_events_in_wait_list uint32, event_wait_list *Event, event *Event) ErrorCode { return ErrorCode(C.clEnqueueWriteBuffer(cq, buffer, C.cl_bool(blocking_write), C.size_t(offset), C.size_t(size), unsafe.Pointer(ptr), C.cl_uint(num_events_in_wait_list), (*C.cl_event)(unsafe.Pointer(event_wait_list)), (*C.cl_event)(unsafe.Pointer(event)))) }
// Enqueue commands to write to a buffer object from host memory. func (q *CommandQueue) EnqueueWriteBuffer(buffer *MemObject, blocking bool, offset, dataSize int, dataPtr unsafe.Pointer, eventWaitList []*Event) (*Event, error) { var event C.cl_event err := toError(C.clEnqueueWriteBuffer(q.clQueue, buffer.clMem, clBool(blocking), C.size_t(offset), C.size_t(dataSize), dataPtr, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event)) return newEvent(event), err }