1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-05 00:10:24 +08:00
This commit is contained in:
源文雨
2026-03-26 00:39:39 +08:00
parent cfc2c9d771
commit 9f94f92b50
7 changed files with 20 additions and 23 deletions

View File

@@ -11,11 +11,6 @@ linters:
- misspell
- unconvert
- revive
settings:
revive:
rules:
- name: exported
disabled: true
exclusions:
rules:
- path: ^cmd/
@@ -32,10 +27,6 @@ linters:
- errcheck
source: "^\\s*defer "
formatters:
enable:
- gofmt
issues:
max-issues-per-linter: 0
max-same-issues: 0

1
doc.go
View File

@@ -1,3 +1,4 @@
// Package gozel provides Go bindings for the Intel Level Zero API.
package gozel
//go:generate go run ./cmd/gen

View File

@@ -1,3 +1,4 @@
// Package main demonstrates quick start usage of the gozel Level Zero bindings.
package main
import (

View File

@@ -1,3 +1,4 @@
// Package main demonstrates vector addition using the gozel Level Zero bindings.
package main
import (
@@ -91,36 +92,36 @@ func main() {
}
defer q.Destroy()
hbuf_v1, err := ctx.MemAllocHost(bufsz, 1)
hbufV1, err := ctx.MemAllocHost(bufsz, 1)
if err != nil {
panic(err)
}
defer ctx.MemFree(hbuf_v1)
defer ctx.MemFree(hbufV1)
hbuf_v2, err := ctx.MemAllocHost(bufsz, 1)
hbufV2, err := ctx.MemAllocHost(bufsz, 1)
if err != nil {
panic(err)
}
defer ctx.MemFree(hbuf_v2)
defer ctx.MemFree(hbufV2)
dbuf_v1, err := ctx.MemAllocDevice(dev, bufsz, 1)
dbufV1, err := ctx.MemAllocDevice(dev, bufsz, 1)
if err != nil {
panic(err)
}
defer ctx.MemFree(dbuf_v1)
defer ctx.MemFree(dbufV1)
dbuf_v2, err := ctx.MemAllocDevice(dev, bufsz, 1)
dbufV2, err := ctx.MemAllocDevice(dev, bufsz, 1)
if err != nil {
panic(err)
}
defer ctx.MemFree(dbuf_v2)
defer ctx.MemFree(dbufV2)
floatbuf := make([]float32, 2*N)
for i := range floatbuf {
floatbuf[i] = rand.Float32()
}
zev1, zev2 := unsafe.Slice((*float32)(hbuf_v1), N), unsafe.Slice((*float32)(hbuf_v2), N)
zev1, zev2 := unsafe.Slice((*float32)(hbufV1), N), unsafe.Slice((*float32)(hbufV2), N)
copy(zev1, floatbuf[:N])
copy(zev2, floatbuf[N:])
@@ -136,11 +137,11 @@ func main() {
}
defer krn.Destroy()
err = krn.SetArgumentValue(0, unsafe.Sizeof(uintptr(0)), unsafe.Pointer(&dbuf_v1))
err = krn.SetArgumentValue(0, unsafe.Sizeof(uintptr(0)), unsafe.Pointer(&dbufV1))
if err != nil {
panic(err)
}
err = krn.SetArgumentValue(1, unsafe.Sizeof(uintptr(0)), unsafe.Pointer(&dbuf_v2))
err = krn.SetArgumentValue(1, unsafe.Sizeof(uintptr(0)), unsafe.Pointer(&dbufV2))
if err != nil {
panic(err)
}
@@ -155,11 +156,11 @@ func main() {
}
defer lstpre.Destroy()
err = lstpre.AppendMemoryCopy(dbuf_v1, hbuf_v1, bufsz)
err = lstpre.AppendMemoryCopy(dbufV1, hbufV1, bufsz)
if err != nil {
panic(err)
}
err = lstpre.AppendMemoryCopy(dbuf_v2, hbuf_v2, bufsz)
err = lstpre.AppendMemoryCopy(dbufV2, hbufV2, bufsz)
if err != nil {
panic(err)
}
@@ -203,7 +204,7 @@ func main() {
}
defer lstpost.Destroy()
err = lstpost.AppendMemoryCopy(hbuf_v1, dbuf_v1, bufsz)
err = lstpost.AppendMemoryCopy(hbufV1, dbufV1, bufsz)
if err != nil {
panic(err)
}

View File

@@ -1,3 +1,4 @@
// Package zecall provides internal helpers for calling Level Zero functions via purego.
package zecall
import (

View File

@@ -7,6 +7,7 @@ import (
"strconv"
)
// ReturnTypes constrains the set of numeric types that can be returned from a Level Zero call.
type ReturnTypes interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 |
~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64

View File

@@ -1,3 +1,4 @@
// Package ze provides high-level wrappers around Level Zero command objects.
package ze
import (