Exemple #1
0
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetKernelInfo.html
func GetKernelInfo(ker Kernel, paramName KernelInfo, paramValueSize uint64, paramValue unsafe.Pointer, paramValueSizeRet *uint64) ErrorCode {
	return ErrorCode(C.clGetKernelInfo(ker, C.cl_kernel_info(paramName), C.size_t(paramValueSize), paramValue, (*C.size_t)(paramValueSizeRet)))
}
Exemple #2
0
func CLGetKernelInfo(kernel CL_kernel,
	param_name CL_kernel_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.clGetKernelInfo(kernel.cl_kernel,
				C.cl_kernel_info(param_name),
				C.size_t(param_value_size),
				nil,
				&c_param_value_size_ret)
		} else {
			switch param_name {

			case CL_KERNEL_FUNCTION_NAME,
				CL_KERNEL_ATTRIBUTES:

				value := make([]C.char, param_value_size)
				c_errcode_ret = C.clGetKernelInfo(kernel.cl_kernel,
					C.cl_kernel_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value[0]),
					&c_param_value_size_ret)

				*param_value = C.GoStringN(&value[0], C.int(c_param_value_size_ret-1))

			case CL_KERNEL_NUM_ARGS,
				CL_KERNEL_REFERENCE_COUNT:

				var value C.cl_uint
				c_errcode_ret = C.clGetKernelInfo(kernel.cl_kernel,
					C.cl_kernel_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_uint(value)

			case CL_KERNEL_CONTEXT:
				var value C.cl_context
				c_errcode_ret = C.clGetKernelInfo(kernel.cl_kernel,
					C.cl_kernel_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_context{value}

			case CL_KERNEL_PROGRAM:
				var value C.cl_program
				c_errcode_ret = C.clGetKernelInfo(kernel.cl_kernel,
					C.cl_kernel_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_program{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)
	}
}
Exemple #3
0
func CLGetKernelArgInfo(kernel CL_kernel,
	arg_index CL_uint,
	param_name CL_kernel_arg_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.clGetKernelArgInfo(kernel.cl_kernel,
				C.cl_uint(arg_index),
				C.cl_kernel_arg_info(param_name),
				C.size_t(param_value_size),
				nil,
				&c_param_value_size_ret)
		} else {
			switch param_name {

			case CL_KERNEL_ARG_ADDRESS_QUALIFIER:

				var value C.cl_kernel_arg_address_qualifier
				c_errcode_ret = C.clGetKernelArgInfo(kernel.cl_kernel,
					C.cl_uint(arg_index),
					C.cl_kernel_arg_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_kernel_arg_address_qualifier(value)

			case CL_KERNEL_ARG_ACCESS_QUALIFIER:

				var value C.cl_kernel_arg_access_qualifier
				c_errcode_ret = C.clGetKernelArgInfo(kernel.cl_kernel,
					C.cl_uint(arg_index),
					C.cl_kernel_arg_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_kernel_arg_access_qualifier(value)

			case CL_KERNEL_ARG_TYPE_NAME,
				CL_KERNEL_ARG_NAME:

				value := make([]C.char, param_value_size)
				c_errcode_ret = C.clGetKernelInfo(kernel.cl_kernel,
					C.cl_kernel_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value[0]),
					&c_param_value_size_ret)

				*param_value = C.GoStringN(&value[0], C.int(c_param_value_size_ret-1))

			case CL_KERNEL_ARG_TYPE_QUALIFIER:

				var value C.cl_kernel_arg_type_qualifier
				c_errcode_ret = C.clGetKernelArgInfo(kernel.cl_kernel,
					C.cl_uint(arg_index),
					C.cl_kernel_arg_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_kernel_arg_type_qualifier(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)
	}
}
Exemple #4
0
func (k *Kernel) NumArgs() (int, error) {
	var num C.cl_uint
	err := C.clGetKernelInfo(k.clKernel, C.CL_KERNEL_NUM_ARGS, C.size_t(unsafe.Sizeof(num)), unsafe.Pointer(&num), nil)
	return int(num), toError(err)
}
Exemple #5
0
func (k *Kernel) Program() (*Program, error) {
	var program C.cl_program
	err := C.clGetKernelInfo(k.clKernel, C.CL_KERNEL_PROGRAM, C.size_t(unsafe.Sizeof(program)), unsafe.Pointer(&program), nil)
	return &Program{clProgram: program, devices: nil}, toError(err)
}
Exemple #6
0
func (k *Kernel) Context() (*Context, error) {
	var context C.cl_context
	err := C.clGetKernelInfo(k.clKernel, C.CL_KERNEL_CONTEXT, C.size_t(unsafe.Sizeof(context)), unsafe.Pointer(&context), nil)
	return &Context{clContext: context, devices: nil}, toError(err)
}
Exemple #7
0
func (k *Kernel) Attributes() (string, error) {
	var name C.char
	err := C.clGetKernelInfo(k.clKernel, C.CL_KERNEL_ATTRIBUTES, C.size_t(unsafe.Sizeof(name)), unsafe.Pointer(&name), nil)
	return C.GoString(&name), toError(err)
}
Exemple #8
0
func (k *Kernel) FunctionName() (string, error) {
	var name C.char
	err := C.clGetKernelInfo(k.clKernel, C.CL_KERNEL_FUNCTION_NAME, C.size_t(unsafe.Sizeof(name)), unsafe.Pointer(&name), nil)
	return C.GoString(&name), toError(err)
}
Exemple #9
0
func (k *Kernel) ReferenceCount() (int, error) {
	var num C.cl_uint
	err := C.clGetKernelInfo(k.clKernel, C.CL_KERNEL_REFERENCE_COUNT, C.size_t(unsafe.Sizeof(num)), unsafe.Pointer(&num), nil)
	return int(num), toError(err)
}