예제 #1
0
파일: event.go 프로젝트: xfong/tmpCL
func (e *Event) GetReferenceCount() (int, error) {
	if e.clEvent != nil {
		var outCount C.cl_uint
		err := C.clGetEventInfo(e.clEvent, C.CL_EVENT_REFERENCE_COUNT, C.size_t(unsafe.Sizeof(outCount)), unsafe.Pointer(&outCount), nil)
		return int(outCount), toError(err)
	}
	return 0, toError(C.CL_INVALID_EVENT)
}
예제 #2
0
파일: event.go 프로젝트: xfong/tmpCL
func (e *Event) GetContext() (*Context, error) {
	if e.clEvent != nil {
		var outContext C.cl_context
		err := C.clGetEventInfo(e.clEvent, C.CL_EVENT_CONTEXT, C.size_t(unsafe.Sizeof(outContext)), unsafe.Pointer(&outContext), nil)
		return &Context{clContext: outContext, devices: nil}, toError(err)
	}
	return nil, toError(C.CL_INVALID_EVENT)
}
예제 #3
0
파일: event.go 프로젝트: xfong/tmpCL
func (e *Event) GetCommandQueue() (*CommandQueue, error) {
	if e.clEvent != nil {
		var outQueue C.cl_command_queue
		err := C.clGetEventInfo(e.clEvent, C.CL_EVENT_COMMAND_QUEUE, C.size_t(unsafe.Sizeof(outQueue)), unsafe.Pointer(&outQueue), nil)
		return &CommandQueue{clQueue: outQueue, device: nil}, toError(err)
	}
	return nil, toError(C.CL_INVALID_EVENT)
}
예제 #4
0
파일: event.go 프로젝트: xfong/tmpCL
func (e *Event) GetStatus() (CommandExecStatus, error) {
	if e.clEvent != nil {
		var status C.cl_int
		err := C.clGetEventInfo(e.clEvent, C.CL_EVENT_COMMAND_EXECUTION_STATUS, C.size_t(unsafe.Sizeof(status)), unsafe.Pointer(&status), nil)
		switch {
		case status == C.CL_QUEUED:
			return CommandExecStatusQueued, toError(err)
		case status == C.CL_SUBMITTED:
			return CommandExecStatusSubmitted, toError(err)
		case status == C.CL_RUNNING:
			return CommandExecStatusRunning, toError(err)
		case status == C.CL_COMPLETE:
			return CommandExecStatusComplete, toError(err)
		default:
			return -1, toError(err)
		}
	}
	return -1, toError(C.CL_INVALID_EVENT)
}
예제 #5
0
파일: package.go 프로젝트: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetEventInfo.html
func GetEventInfo(e Event, paramName uint32, paramValueSize uint64, paramValue unsafe.Pointer, paramValueSizeRet *uint64) ErrorCode {
	return ErrorCode(C.clGetEventInfo(e.clEvent, C.cl_event_info(paramName), C.size_t(paramValueSize), paramValue, (*C.size_t)(paramValueSizeRet)))
}
예제 #6
0
파일: event.go 프로젝트: Dirbaio/gominer
func CLGetEventInfo(event CL_event,
	param_name CL_event_info,
	param_value_size CL_size_t,
	param_value *interface{},
	param_value_size_ret *CL_size_t) CL_int {

	if (param_value_size == 0 || param_value == nil) && param_value_size_ret == nil {
		return CL_INVALID_VALUE
	} else {
		var c_param_value_size_ret C.size_t
		var c_errcode_ret C.cl_int

		if param_value_size == 0 || param_value == nil {
			c_errcode_ret = C.clGetEventInfo(event.cl_event,
				C.cl_event_info(param_name),
				C.size_t(param_value_size),
				nil,
				&c_param_value_size_ret)
		} else {
			switch param_name {
			case CL_EVENT_COMMAND_QUEUE:
				var value C.cl_command_queue
				c_errcode_ret = C.clGetEventInfo(event.cl_event,
					C.cl_event_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_command_queue{value}

			case CL_EVENT_COMMAND_TYPE:
				var value C.cl_command_type
				c_errcode_ret = C.clGetEventInfo(event.cl_event,
					C.cl_event_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_command_type(value)

			case CL_EVENT_CONTEXT:
				var value C.cl_context
				c_errcode_ret = C.clGetEventInfo(event.cl_event,
					C.cl_event_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_context{value}

			case CL_EVENT_REFERENCE_COUNT:
				var value C.cl_uint
				c_errcode_ret = C.clGetEventInfo(event.cl_event,
					C.cl_event_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_uint(value)

			case CL_EVENT_COMMAND_EXECUTION_STATUS:
				var value C.cl_int
				c_errcode_ret = C.clGetEventInfo(event.cl_event,
					C.cl_event_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_int(value)
			default:
				return CL_INVALID_VALUE
			}
		}

		if param_value_size_ret != nil {
			*param_value_size_ret = CL_size_t(c_param_value_size_ret)
		}

		return CL_int(c_errcode_ret)
	}
}
예제 #7
0
파일: event.go 프로젝트: xfong/tmpCL
func (e *Event) GetCommandType() (CommandType, error) {
	if e.clEvent != nil {
		var status C.cl_command_type
		var err C.cl_int
		err = C.clGetEventInfo(e.clEvent, C.CL_EVENT_COMMAND_TYPE, C.size_t(unsafe.Sizeof(status)), unsafe.Pointer(&status), nil)
		if gl_sharing_ext {
			check, gl_command_type := getGlCommandType(status)
			if check {
				return gl_command_type, toError(err)
			}
		}
		if dx9_sharing_ext {
			check, dx9_command_type := getDX9CommandType(status)
			if check {
				return dx9_command_type, toError(err)
			}
		}
		if d3d10_sharing_ext {
			check, d3d10_command_type := getD3D10CommandType(status)
			if check {
				return d3d10_command_type, toError(err)
			}
		}
		if d3d11_sharing_ext {
			check, d3d11_command_type := getD3D11CommandType(status)
			if check {
				return d3d11_command_type, toError(err)
			}
		}
		switch status {
		case C.CL_COMMAND_NDRANGE_KERNEL:
			return CommandNDRangeKernel, toError(err)
		case C.CL_COMMAND_TASK:
			return CommandTask, toError(err)
		case C.CL_COMMAND_NATIVE_KERNEL:
			return CommandNativeKernel, toError(err)
		case C.CL_COMMAND_READ_BUFFER:
			return CommandReadBuffer, toError(err)
		case C.CL_COMMAND_WRITE_BUFFER:
			return CommandWriteBuffer, toError(err)
		case C.CL_COMMAND_COPY_BUFFER:
			return CommandCopyBuffer, toError(err)
		case C.CL_COMMAND_READ_IMAGE:
			return CommandReadImage, toError(err)
		case C.CL_COMMAND_WRITE_IMAGE:
			return CommandWriteImage, toError(err)
		case C.CL_COMMAND_COPY_IMAGE:
			return CommandCopyImage, toError(err)
		case C.CL_COMMAND_COPY_BUFFER_TO_IMAGE:
			return CommandCopyBufferToImage, toError(err)
		case C.CL_COMMAND_COPY_IMAGE_TO_BUFFER:
			return CommandCopyImageToBuffer, toError(err)
		case C.CL_COMMAND_MAP_BUFFER:
			return CommandMapBuffer, toError(err)
		case C.CL_COMMAND_MAP_IMAGE:
			return CommandMapImage, toError(err)
		case C.CL_COMMAND_UNMAP_MEM_OBJECT:
			return CommandUnmapMemObject, toError(err)
		case C.CL_COMMAND_MARKER:
			return CommandMarker, toError(err)
		default:
			return -1, toError(err)
		}
	}
	return -1, toError(C.CL_INVALID_EVENT)
}