Ejemplo n.º 1
0
func (k *Kernel) ArgName(index int) (string, error) {
	var strC [1024]byte
	var strN C.size_t
	// get the size of the string
	if err := C.clGetKernelArgInfo(k.clKernel, C.cl_uint(index), C.CL_KERNEL_ARG_NAME, 8, nil, &strN); err != C.CL_SUCCESS {
		return "", toError(err)
	}
	if err := C.clGetKernelArgInfo(k.clKernel, C.cl_uint(index), C.CL_KERNEL_ARG_NAME, strN, unsafe.Pointer(&strC[0]), &strN); err != C.CL_SUCCESS {
		return "", toError(err)
	}
	return string(strC[:strN]), nil
}
Ejemplo n.º 2
0
func (k *Kernel) ArgTypeName(index int) (string, error) {
	var strC [1024]byte
	var strN C.size_t
	if err := C.clGetKernelArgInfo(k.clKernel, C.cl_uint(index), C.CL_KERNEL_ARG_TYPE_NAME, 1024, unsafe.Pointer(&strC[0]), &strN); err != C.CL_SUCCESS {
		return "", toError(err)
	}
	return string(strC[:strN]), nil
}
Ejemplo n.º 3
0
func (k *Kernel) ArgAccessQualifier(index int) (string, error) {
	var val C.cl_kernel_arg_access_qualifier
	var err C.cl_int
	defer C.free(err)
	if err = C.clGetKernelArgInfo(k.clKernel, C.cl_uint(index), C.CL_KERNEL_ARG_ACCESS_QUALIFIER, C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil); err != C.CL_SUCCESS {
		return "", toError(err)
	}
	switch val {
	default:
		return "", toError(err)
	case C.CL_KERNEL_ARG_ACCESS_READ_ONLY:
		return "ReadOnly", nil
	case C.CL_KERNEL_ARG_ACCESS_READ_WRITE:
		return "ReadWrite", nil
	case C.CL_KERNEL_ARG_ACCESS_WRITE_ONLY:
		return "WriteOnly", nil
	case C.CL_KERNEL_ARG_ACCESS_NONE:
		return "None", nil
	}
}
Ejemplo n.º 4
0
func (k *Kernel) ArgAddressQualifier(index int) (string, error) {
	var val C.cl_kernel_arg_address_qualifier
	var err C.cl_int
	defer C.free(err)
	if err = C.clGetKernelArgInfo(k.clKernel, C.cl_uint(index), C.CL_KERNEL_ARG_ADDRESS_QUALIFIER, C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil); err != C.CL_SUCCESS {
		return "", toError(err)
	}
	switch val {
	default:
		return "", toError(err)
	case C.CL_KERNEL_ARG_ADDRESS_GLOBAL:
		return "Global", nil
	case C.CL_KERNEL_ARG_ADDRESS_LOCAL:
		return "Local", nil
	case C.CL_KERNEL_ARG_ADDRESS_CONSTANT:
		return "Constant", nil
	case C.CL_KERNEL_ARG_ADDRESS_PRIVATE:
		return "Private", nil
	}
}
Ejemplo n.º 5
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)
	}
}
Ejemplo n.º 6
0
func (k *Kernel) ArgTypeQualifier(index int) (C.cl_kernel_arg_type_qualifier, error) {
	var val C.cl_kernel_arg_type_qualifier
	err := C.clGetKernelArgInfo(k.clKernel, C.cl_uint(index), C.CL_KERNEL_ARG_TYPE_QUALIFIER, C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil)
	return val, toError(err)
}