Exemplo n.º 1
0
func CLCreateKernel(program CL_program,
	kernel_name []byte,
	errcode_ret *CL_int) CL_kernel {

	if kernel_name == nil {
		if errcode_ret != nil {
			*errcode_ret = CL_INVALID_VALUE
		}
		return CL_kernel{nil}
	}

	var c_errcode_ret C.cl_int
	var c_kernel C.cl_kernel

	var c_kernel_name *C.char

	c_kernel_name = C.CString(string(kernel_name))
	defer C.free(unsafe.Pointer(c_kernel_name))

	c_kernel = C.clCreateKernel(program.cl_program,
		c_kernel_name, &c_errcode_ret)

	if errcode_ret != nil {
		*errcode_ret = CL_int(c_errcode_ret)
	}

	return CL_kernel{c_kernel}
}
Exemplo n.º 2
0
func CreateKernel(program *Program, name string) *Kernel {
	var kernel Kernel
	var error C.cl_int
	kernel.item = C.clCreateKernel(program.item, C.CString(name), &error)
	fmt.Printf("Kernel error:%d\n", error)
	return &kernel
}
Exemplo n.º 3
0
func (p *Program) CreateKernel(name string) (*Kernel, error) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	var err C.cl_int
	clKernel := C.clCreateKernel(p.clProgram, cName, &err)
	if err != C.CL_SUCCESS {
		return nil, toError(err)
	}
	kernel := &Kernel{clKernel: clKernel, name: name}
	runtime.SetFinalizer(kernel, releaseKernel)
	return kernel, nil
}
Exemplo n.º 4
0
func (p *Program) NewKernelNamed(name string) (*Kernel, error) {
	var c_kernel C.cl_kernel
	var err C.cl_int

	cs := C.CString(name)
	defer C.free(unsafe.Pointer(cs))

	if c_kernel = C.clCreateKernel(p.id, cs, &err); err != C.CL_SUCCESS {
		return nil, Cl_error(err)
	}

	kernel := &Kernel{id: c_kernel}
	runtime.SetFinalizer(kernel, (*Kernel).release)

	return kernel, nil
}
Exemplo n.º 5
0
Arquivo: package.go Projeto: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateKernel.html
func CreateKernel(prog Program, kernelName *uint8, errcode *ErrorCode) Kernel {
	return Kernel(C.clCreateKernel(prog, (*C.char)(unsafe.Pointer(kernelName)), (*C.cl_int)(unsafe.Pointer(errcode))))
}