Beispiel #1
0
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetMemObjectInfo.html
func GetMemObjectInfo(mem Mem, paramName MemInfo, paramValueSize uint64, paramValue unsafe.Pointer, paramValueSizeRet *uint64) ErrorCode {
	return ErrorCode(C.clGetMemObjectInfo(mem, C.cl_mem_info(paramName), C.size_t(paramValueSize), paramValue, (*C.size_t)(paramValueSizeRet)))
}
Beispiel #2
0
func CLGetMemObjectInfo(memobj CL_mem,
	param_name CL_mem_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.clGetMemObjectInfo(memobj.cl_mem,
				C.cl_mem_info(param_name),
				C.size_t(param_value_size),
				nil,
				&c_param_value_size_ret)
		} else {
			switch param_name {
			case CL_MEM_TYPE:
				var value C.cl_mem_object_type
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_mem_object_type(value)
			case CL_MEM_FLAGS:
				var value C.cl_mem_flags
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_mem_flags(value)
			case CL_MEM_SIZE,
				CL_MEM_OFFSET:
				var value C.size_t
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_size_t(value)
			case CL_MEM_HOST_PTR:
				var value unsafe.Pointer
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = value
			case CL_MEM_MAP_COUNT,
				CL_MEM_REFERENCE_COUNT:
				var value C.cl_uint
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_uint(value)
			case CL_MEM_CONTEXT:
				var value C.cl_context
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_context{value}
			case CL_MEM_ASSOCIATED_MEMOBJECT:
				var value C.cl_mem
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_mem{value}

			case CL_MEM_USES_SVM_POINTER:
				var value C.cl_bool
				c_errcode_ret = C.clGetMemObjectInfo(memobj.cl_mem,
					C.cl_mem_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_bool(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)
	}
}