Exemplo n.º 1
0
// Info returns the name, platform, toolkit, and compute identifiers
func (af *AFInfo) Info() error {

	cdname := C.CString(af.DName)
	cdplatform := C.CString(af.DPlatform)
	ctoolkit := C.CString(af.Toolkit)
	ccompute := C.CString(af.Compute)

	defer func() {
		C.free(unsafe.Pointer(cdname))
		C.free(unsafe.Pointer(cdplatform))
		C.free(unsafe.Pointer(ctoolkit))
		C.free(unsafe.Pointer(ccompute))
	}()

	aferr := C.af_device_info(cdname, cdplatform, ctoolkit, ccompute)

	if aferr != 0 {
		return ErrGetDeviceInfo
	}

	af.DName = C.GoString(cdname)
	af.DPlatform = C.GoString(cdplatform)
	af.Toolkit = C.GoString(ctoolkit)
	af.Compute = C.GoString(ccompute)

	// fmt.Printf("[%s, %s, %s, %s]\n", af.DName, af.DPlatform, af.Toolkit, af.Compute)

	return nil
}
Exemplo n.º 2
0
// Info returns the name, platform, toolkit, and compute identifiers
func GetDeviceInfo() (info DeviceInfo, e error) {

	cdname := C.CString(info.DName)
	cdplatform := C.CString(info.DPlatform)
	ctoolkit := C.CString(info.Toolkit)
	ccompute := C.CString(info.Compute)

	defer func() {
		C.free(unsafe.Pointer(cdname))
		C.free(unsafe.Pointer(cdplatform))
		C.free(unsafe.Pointer(ctoolkit))
		C.free(unsafe.Pointer(ccompute))
	}()

	e = af_call(C.af_device_info(cdname, cdplatform, ctoolkit, ccompute))

	info.DName = C.GoString(cdname)
	info.DPlatform = C.GoString(cdplatform)
	info.Toolkit = C.GoString(ctoolkit)
	info.Compute = C.GoString(ccompute)

	return
}