Exemplo n.º 1
0
Arquivo: image.go Projeto: xfong/tmpCL
// Enqueues a command to map a region of an image object into the host address space and returns a pointer to this mapped region.
func (q *CommandQueue) EnqueueMapImage(buffer *MemObject, blocking bool, flags MapFlag, origin, region [3]int, eventWaitList []*Event) (*MappedMemObject, *Event, error) {
	cOrigin := sizeT3(origin)
	cRegion := sizeT3(region)
	var event C.cl_event
	var err C.cl_int
	var rowPitch, slicePitch C.size_t
	ptr := C.clEnqueueMapImage(q.clQueue, buffer.clMem, clBool(blocking), flags.toCl(), &cOrigin[0], &cRegion[0], &rowPitch, &slicePitch, 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
	}
	size := 0 // TODO: could calculate this
	return &MappedMemObject{ptr: ptr, size: size, rowPitch: int(rowPitch), slicePitch: int(slicePitch)}, ev, nil
}
Exemplo n.º 2
0
Arquivo: package.go Projeto: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMapImage.html
func EnqueueMapImage(cq CommandQueue, image Mem, blocking_map Bool, map_flags MapFlags, origin3 *uint64, region3 *uint64, image_row_pitch *uint64, image_slice_pitch *uint64, num_events_in_wait_list uint32, event_wait_list *Event, event *Event, errcode_ret *int32) unsafe.Pointer {
	return unsafe.Pointer(C.clEnqueueMapImage(cq, image, C.cl_bool(blocking_map), C.cl_map_flags(map_flags), (*C.size_t)(unsafe.Pointer(origin3)), (*C.size_t)(unsafe.Pointer(region3)), (*C.size_t)(unsafe.Pointer(image_row_pitch)), (*C.size_t)(unsafe.Pointer(image_slice_pitch)), 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))))
}
Exemplo n.º 3
0
Arquivo: image.go Projeto: xfong/gocl
func CLEnqueueMapImage(command_queue CL_command_queue,
	image CL_mem,
	blocking_map CL_bool,
	map_flags CL_map_flags,
	origin [3]CL_size_t,
	region [3]CL_size_t,
	image_row_pitch *CL_size_t,
	image_slice_pitch *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_origin, c_region [3]C.size_t
	var c_image_row_pitch, c_image_slice_pitch C.size_t
	var c_event C.cl_event
	var c_errcode_ret C.cl_int
	var c_ptr_ret unsafe.Pointer

	for i := 0; i < 3; i++ {
		c_origin[i] = C.size_t(origin[i])
		c_region[i] = C.size_t(region[i])
	}

	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.clEnqueueMapImage(command_queue.cl_command_queue,
			image.cl_mem,
			C.cl_bool(blocking_map),
			C.cl_map_flags(map_flags),
			&c_origin[0],
			&c_region[0],
			&c_image_row_pitch,
			&c_image_slice_pitch,
			C.cl_uint(num_events_in_wait_list),
			&c_event_wait_list[0],
			&c_event,
			&c_errcode_ret)
	} else {
		c_ptr_ret = C.clEnqueueMapImage(command_queue.cl_command_queue,
			image.cl_mem,
			C.cl_bool(blocking_map),
			C.cl_map_flags(map_flags),
			&c_origin[0],
			&c_region[0],
			&c_image_row_pitch,
			&c_image_slice_pitch,
			0,
			nil,
			&c_event,
			&c_errcode_ret)
	}

	if image_row_pitch != nil {
		*image_row_pitch = CL_size_t(c_image_row_pitch)
	}
	if image_slice_pitch != nil {
		*image_slice_pitch = CL_size_t(c_image_slice_pitch)
	}

	if event != nil {
		event.cl_event = c_event
	}
	if errcode_ret != nil {
		*errcode_ret = CL_int(c_errcode_ret)
	}

	return c_ptr_ret
}