예제 #1
0
// Enqueues a command to map a region of the buffer object given by buffer into the host address space and returns a pointer to this mapped region.
func (q *CommandQueue) EnqueueMapBuffer(buffer *MemObject, blocking bool, flags MapFlag, offset, size int, eventWaitList []*Event) (*MappedMemObject, *Event, error) {
	var event C.cl_event
	var err C.cl_int
	ptr := C.clEnqueueMapBuffer(q.clQueue, buffer.clMem, clBool(blocking), flags.toCl(), C.size_t(offset), C.size_t(size), C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event, &err)
	if err != C.CL_SUCCESS {
		return nil, nil, toError(err)
	}
	ev := newEvent(event)
	if ptr == nil {
		return nil, ev, ErrUnknown
	}
	return &MappedMemObject{ptr: ptr, size: size}, ev, nil
}
예제 #2
0
파일: package.go 프로젝트: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMapBuffer.html
func EnqueueMapBuffer(cq CommandQueue, buffer Mem, blocking_map Bool, map_flags uint64, offset uint64, size uint64, num_events_in_wait_list uint32, event_wait_list *Event, event *Event, errcode_ret *int32) unsafe.Pointer {
	return unsafe.Pointer(C.clEnqueueMapBuffer(cq, buffer, C.cl_bool(blocking_map), C.cl_map_flags(map_flags), C.size_t(offset), C.size_t(size), C.cl_uint(num_events_in_wait_list), (*C.cl_event)(unsafe.Pointer(event_wait_list)), (*C.cl_event)(unsafe.Pointer(event)), (*C.cl_int)(unsafe.Pointer(errcode_ret))))
}
예제 #3
0
파일: buffer.go 프로젝트: Dirbaio/gominer
func CLEnqueueMapBuffer(command_queue CL_command_queue,
	buffer CL_mem,
	blocking_map CL_bool,
	map_flags CL_map_flags,
	offset CL_size_t,
	cb CL_size_t,
	num_events_in_wait_list CL_uint,
	event_wait_list []CL_event,
	event *CL_event,
	errcode_ret *CL_int) unsafe.Pointer {

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

		if errcode_ret != nil {
			*errcode_ret = CL_INVALID_EVENT_WAIT_LIST
		}
		return nil
	}

	var c_event C.cl_event
	var c_errcode_ret C.cl_int
	var c_ptr_ret unsafe.Pointer

	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_ptr_ret = C.clEnqueueMapBuffer(command_queue.cl_command_queue,
			buffer.cl_mem,
			C.cl_bool(blocking_map),
			C.cl_map_flags(map_flags),
			C.size_t(offset),
			C.size_t(cb),
			C.cl_uint(num_events_in_wait_list),
			&c_event_wait_list[0],
			&c_event,
			&c_errcode_ret)
	} else {
		c_ptr_ret = C.clEnqueueMapBuffer(command_queue.cl_command_queue,
			buffer.cl_mem,
			C.cl_bool(blocking_map),
			C.cl_map_flags(map_flags),
			C.size_t(offset),
			C.size_t(cb),
			0,
			nil,
			&c_event,
			&c_errcode_ret)
	}

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

	if errcode_ret != nil {
		*errcode_ret = CL_int(c_errcode_ret)
	}

	return c_ptr_ret
}