Beispiel #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)))
}
Beispiel #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)
	}
}
Beispiel #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)
	}
}