예제 #1
0
파일: kernel.go 프로젝트: xfong/tmpCL
func (k *Kernel) GlobalWorkGroupSize(device *Device) ([3]int, error) {
	var size [3]C.size_t
	if err := C.clGetKernelWorkGroupInfo(k.clKernel, device.nullableId(), C.CL_KERNEL_GLOBAL_WORK_SIZE, C.size_t(unsafe.Sizeof(size)), unsafe.Pointer(&size[0]), nil); err != C.CL_SUCCESS {
		return [3]int{-1, -1, -1}, toError(err)
	}
	return [3]int{int(size[0]), int(size[1]), int(size[2])}, nil
}
예제 #2
0
파일: kernel.go 프로젝트: xfong/tmpCL
func (k *Kernel) CompileWorkGroupSize(device *Device) ([3]int, error) {
	var wgSize [3]C.size_t
	defer C.free(wgSize)
	if err := C.clGetKernelWorkGroupInfo(k.clKernel, device.nullableId(), C.CL_KERNEL_COMPILE_WORK_GROUP_SIZE, C.size_t(unsafe.Sizeof(wgSize)), unsafe.Pointer(&wgSize), nil); err != C.CL_SUCCESS {
		return [3]int{-1, -1, -1}, toError(err)
	}
	return [3]int{int(wgSize[0]), int(wgSize[1]), int(wgSize[2])}, nil
}
예제 #3
0
파일: kernel.go 프로젝트: Dirbaio/gominer
func CLGetKernelWorkGroupInfo(kernel CL_kernel,
	device CL_device_id,
	param_name CL_kernel_work_group_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.clGetKernelWorkGroupInfo(kernel.cl_kernel,
				device.cl_device_id,
				C.cl_kernel_work_group_info(param_name),
				C.size_t(param_value_size),
				nil,
				&c_param_value_size_ret)
		} else {
			switch param_name {

			case CL_KERNEL_GLOBAL_WORK_SIZE,
				CL_KERNEL_COMPILE_WORK_GROUP_SIZE:

				var value [3]C.size_t
				c_errcode_ret = C.clGetKernelWorkGroupInfo(kernel.cl_kernel,
					device.cl_device_id,
					C.cl_kernel_work_group_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value[0]),
					&c_param_value_size_ret)

				*param_value = [3]CL_size_t{CL_size_t(value[0]), CL_size_t(value[1]), CL_size_t(value[2])}

			case CL_KERNEL_WORK_GROUP_SIZE,
				CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE:

				var value C.size_t
				c_errcode_ret = C.clGetKernelWorkGroupInfo(kernel.cl_kernel,
					device.cl_device_id,
					C.cl_kernel_work_group_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_size_t(value)

			case CL_KERNEL_LOCAL_MEM_SIZE,
				CL_KERNEL_PRIVATE_MEM_SIZE:
				var value C.cl_ulong
				c_errcode_ret = C.clGetKernelWorkGroupInfo(kernel.cl_kernel,
					device.cl_device_id,
					C.cl_kernel_work_group_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_ulong(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)
	}
}
예제 #4
0
파일: package.go 프로젝트: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetKernelWorkGroupInfo.html
func GetKernelWorkGroupInfo(ker Kernel, did DeviceId, paramName KernelWorkGroupInfo, paramValueSize uint64, paramValue unsafe.Pointer, paramValueSizeRet *uint64) ErrorCode {
	return ErrorCode(C.clGetKernelWorkGroupInfo(ker, did, C.cl_kernel_work_group_info(paramName), C.size_t(paramValueSize), paramValue, (*C.size_t)(paramValueSizeRet)))
}
예제 #5
0
func (k *Kernel) PreferredWorkGroupSizeMultiple(device *Device) (int, error) {
	var size C.size_t
	err := C.clGetKernelWorkGroupInfo(k.clKernel, device.nullableId(), C.CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, C.size_t(unsafe.Sizeof(size)), unsafe.Pointer(&size), nil)
	return int(size), toError(err)
}
예제 #6
0
파일: kernel.go 프로젝트: xfong/tmpCL
func (k *Kernel) WorkGroupPrivateMemSize(device *Device) (int, error) {
	var size C.size_t
	err := C.clGetKernelWorkGroupInfo(k.clKernel, device.nullableId(), C.CL_KERNEL_PRIVATE_MEM_SIZE, C.size_t(unsafe.Sizeof(size)), unsafe.Pointer(&size), nil)
	return int(size), toError(err)
}