1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-25 05:20:14 +08:00

feat: add all other needs

This commit is contained in:
源文雨
2026-03-25 23:25:56 +08:00
parent 32ada81b80
commit 64de25bd44
28 changed files with 4678 additions and 416 deletions

View File

@@ -2,8 +2,11 @@ package ze
import "github.com/fumiama/gozel"
// DeviceHandle is a handle to a Level Zero driver's device object.
type DeviceHandle gozel.ZeDeviceHandle
// DeviceGet retrieves all devices within the driver.
func (h DriverHandle) DeviceGet() ([]gozel.ZeDeviceHandle, error) {
func (h DriverHandle) DeviceGet() ([]DeviceHandle, error) {
var count uint32
_, err := gozel.ZeDeviceGet(gozel.ZeDriverHandle(h), &count, nil)
if err != nil {
@@ -12,10 +15,24 @@ func (h DriverHandle) DeviceGet() ([]gozel.ZeDeviceHandle, error) {
if count == 0 {
return nil, nil
}
devices := make([]gozel.ZeDeviceHandle, count)
_, err = gozel.ZeDeviceGet(gozel.ZeDriverHandle(h), &count, &devices[0])
devices := make([]DeviceHandle, count)
_, err = gozel.ZeDeviceGet(gozel.ZeDriverHandle(h), &count, (*gozel.ZeDeviceHandle)(&devices[0]))
if err != nil {
return nil, err
}
return devices, nil
}
// DeviceGetProperties retrieves properties of the device.
func (h DeviceHandle) DeviceGetProperties() (prop gozel.ZeDeviceProperties, err error) {
prop.Stype = gozel.ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES
_, err = gozel.ZeDeviceGetProperties(gozel.ZeDeviceHandle(h), &prop)
return
}
// DeviceGetComputeProperties retrieves compute properties of the device.
func (h DeviceHandle) DeviceGetComputeProperties() (prop gozel.ZeDeviceComputeProperties, err error) {
prop.Stype = gozel.ZE_STRUCTURE_TYPE_DEVICE_COMPUTE_PROPERTIES
_, err = gozel.ZeDeviceGetComputeProperties(gozel.ZeDeviceHandle(h), &prop)
return
}