コード例 #1
0
ファイル: kernel.go プロジェクト: Dirbaio/gominer
func CLCreateKernelsInProgram(program CL_program,
	num_kernels CL_uint,
	kernels []CL_kernel,
	num_kernels_ret *CL_uint) CL_int {

	if (num_kernels == 0 && kernels != nil) || (num_kernels_ret == nil && kernels == nil) {
		return CL_INVALID_VALUE
	} else {
		var c_num_kernels_ret C.cl_uint
		var c_errcode_ret C.cl_int

		if kernels == nil {
			c_errcode_ret = C.clCreateKernelsInProgram(program.cl_program,
				C.cl_uint(num_kernels),
				nil,
				&c_num_kernels_ret)
		} else {
			c_kernels := make([]C.cl_kernel, len(kernels))
			c_errcode_ret = C.clCreateKernelsInProgram(program.cl_program,
				C.cl_uint(num_kernels),
				&c_kernels[0],
				&c_num_kernels_ret)
			if c_errcode_ret == C.CL_SUCCESS {
				for i := 0; i < len(kernels); i++ {
					kernels[i].cl_kernel = c_kernels[i]
				}
			}
		}
		if num_kernels_ret != nil {
			*num_kernels_ret = CL_uint(c_num_kernels_ret)
		}

		return CL_int(c_errcode_ret)
	}
}
コード例 #2
0
ファイル: kernel.go プロジェクト: xfong/tmpCL
func (p *Program) CreateKernelsInProgram() ([]*Kernel, error) {
	var num_kerns C.cl_uint
	err := C.clCreateKernelsInProgram(p.clProgram, 1, nil, &num_kerns)
	if toError(err) != nil {
		fmt.Printf("Error getting number of kernels to create \n")
		return nil, toError(err)
	}
	kernel_list := make([]C.cl_kernel, int(num_kerns))
	err = C.clCreateKernelsInProgram(p.clProgram, num_kerns, &kernel_list[0], nil)
	if toError(err) != nil {
		fmt.Printf("Error creating kernels \n")
		return nil, toError(err)
	}
	returnKerns := make([]*Kernel, len(kernel_list))
	for i, kptr := range kernel_list {
		testKern := &Kernel{clKernel: kptr, name: ""}
		kname, errK := testKern.FunctionName()
		if errK == nil {
			returnKerns[i].clKernel = kptr
			returnKerns[i].name = kname
		} else {
			fmt.Printf("Error getting information about kernel %d \n", i)
			returnKerns[i] = nil
		}
	}
	return returnKerns, nil
}
コード例 #3
0
ファイル: package.go プロジェクト: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateKernelsInProgram.html
func CreateKernelsInProgram(prog Program, numKernels uint32, kernels *Kernel, numKernelsRet *uint32) ErrorCode {
	return ErrorCode(C.clCreateKernelsInProgram(prog, C.cl_uint(numKernels), (*C.cl_kernel)(unsafe.Pointer(kernels)), (*C.cl_uint)(unsafe.Pointer(numKernelsRet))))
}