Esempio n. 1
0
// Enqueue commands to write to a region in buffer object from host memory.
func (q *CommandQueue) EnqueueWriteBufferRect(buffer *MemObject, blocking bool, buffer_origin, host_origin, region *Dim3, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch int, dataPtr unsafe.Pointer, eventWaitList []*Event) (*Event, error) {
	var event C.cl_event
	host_offset := make([]C.size_t, 3)
	defer C.free(host_offset)
	host_offset[0], host_offset[1], host_offset[2] = (C.size_t)(host_origin.X), (C.size_t)(host_origin.Y), (C.size_t)(host_origin.Z)
	buffer_offset := make([]C.size_t, 3)
	defer C.free(buffer_offset)
	buffer_offset[0], buffer_offset[1], buffer_offset[2] = (C.size_t)(buffer_origin.X), (C.size_t)(buffer_origin.Y), (C.size_t)(buffer_origin.Z)
	mem_size := make([]C.size_t, 3)
	defer C.free(mem_size)
	mem_size[0], mem_size[1], mem_size[2] = (C.size_t)(region.X), (C.size_t)(region.Y), (C.size_t)(region.Z)
	err := toError(C.clEnqueueWriteBufferRect(q.clQueue, buffer.clMem, clBool(blocking), &buffer_offset[0], &host_offset[0], &mem_size[0],
		(C.size_t)(buffer_row_pitch), (C.size_t)(buffer_slice_pitch), (C.size_t)(host_row_pitch), (C.size_t)(host_slice_pitch),
		dataPtr, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
	return newEvent(event), err
}
Esempio n. 2
0
func CLEnqueueWriteBufferRect(command_queue CL_command_queue,
	buffer CL_mem,
	blocking_write CL_bool,
	buffer_origin [3]CL_size_t,
	host_origin [3]CL_size_t,
	region [3]CL_size_t,
	buffer_row_pitch CL_size_t,
	buffer_slice_pitch CL_size_t,
	host_row_pitch CL_size_t,
	host_slice_pitch 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_buffer_origin [3]C.size_t
	var c_host_origin [3]C.size_t
	var c_region [3]C.size_t

	for i := 0; i < 3; i++ {
		c_buffer_origin[i] = C.size_t(buffer_origin[i])
		c_host_origin[i] = C.size_t(host_origin[i])
		c_region[i] = C.size_t(region[i])
	}

	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.clEnqueueWriteBufferRect(command_queue.cl_command_queue,
			buffer.cl_mem,
			C.cl_bool(blocking_write),
			&c_buffer_origin[0],
			&c_host_origin[0],
			&c_region[0],
			C.size_t(buffer_row_pitch),
			C.size_t(buffer_slice_pitch),
			C.size_t(host_row_pitch),
			C.size_t(host_slice_pitch),
			ptr,
			C.cl_uint(num_events_in_wait_list),
			&c_event_wait_list[0],
			&c_event)
	} else {
		c_errcode_ret = C.clEnqueueWriteBufferRect(command_queue.cl_command_queue,
			buffer.cl_mem,
			C.cl_bool(blocking_write),
			&c_buffer_origin[0],
			&c_host_origin[0],
			&c_region[0],
			C.size_t(buffer_row_pitch),
			C.size_t(buffer_slice_pitch),
			C.size_t(host_row_pitch),
			C.size_t(host_slice_pitch),
			ptr,
			0,
			nil,
			&c_event)
	}

	if event != nil {
		event.cl_event = c_event
	}

	return CL_int(c_errcode_ret)
}