1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-24 04:24:53 +08:00

feat(ze): add event support & vadd demo & refactor (#5)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
fumiama
2026-03-28 18:00:12 +08:00
committed by GitHub
parent 163549e271
commit b821801ecd
134 changed files with 481 additions and 49 deletions

View File

@@ -4,6 +4,7 @@ package main
import (
_ "embed"
"fmt"
"math"
"math/rand"
"os"
"strconv"
@@ -11,7 +12,7 @@ import (
"time"
"unsafe"
"github.com/fumiama/gozel"
"github.com/fumiama/gozel/gozel"
"github.com/fumiama/gozel/ze"
)
@@ -69,8 +70,7 @@ func main() {
fmt.Printf("%-28s (%d, %d, %d)\n", "Max Group Count (X, Y, Z):", cprop.Maxgroupcountx, cprop.Maxgroupcounty, cprop.Maxgroupcountz)
fmt.Printf("%-28s %d\n", "Max Total Group Size:", cprop.Maxtotalgroupsize)
fmt.Printf("%-28s %d\n", "Max Shared Local Memory:", cprop.Maxsharedlocalmemory)
fmt.Printf("%-28s %d\n", "Num Subgroup Sizes:", cprop.Numsubgroupsizes)
fmt.Printf("%-28s %v\n", "Subgroup Sizes:", cprop.Subgroupsizes[:])
fmt.Printf("%-28s %v\n", "Subgroup Sizes:", cprop.Subgroupsizes[:cprop.Numsubgroupsizes])
var (
X, Y, Z = uintptr(cprop.Maxgroupsizex), uintptr(1), uintptr(1)
@@ -84,7 +84,7 @@ func main() {
fmt.Printf("%-28s %d\n", "Total Elements (N):", N)
fmt.Printf("%-28s %d MiB\n", "Buffer Size:", bufsz/1024/1024)
q, err := ctx.CommandQueueCreate(dev)
q, err := ctx.CommandQueueCreate(dev, gozel.ZE_COMMAND_QUEUE_MODE_DEFAULT)
if err != nil {
panic(err)
}
@@ -135,11 +135,11 @@ func main() {
}
defer krn.Destroy()
err = krn.SetArgumentValue(0, unsafe.Sizeof(uintptr(0)), unsafe.Pointer(&dbufV1))
err = krn.SetArgumentValue(0, &dbufV1)
if err != nil {
panic(err)
}
err = krn.SetArgumentValue(1, unsafe.Sizeof(uintptr(0)), unsafe.Pointer(&dbufV2))
err = krn.SetArgumentValue(1, &dbufV2)
if err != nil {
panic(err)
}
@@ -154,16 +154,16 @@ func main() {
}
defer lstpre.Destroy()
err = lstpre.AppendMemoryCopy(dbufV1, hbufV1, bufsz)
err = lstpre.AppendMemoryCopy(dbufV1, hbufV1, bufsz, 0)
if err != nil {
panic(err)
}
err = lstpre.AppendMemoryCopy(dbufV2, hbufV2, bufsz)
err = lstpre.AppendMemoryCopy(dbufV2, hbufV2, bufsz, 0)
if err != nil {
panic(err)
}
err = lstpre.AppendBarrier()
err = lstpre.AppendBarrier(0)
if err != nil {
panic(err)
}
@@ -181,12 +181,12 @@ func main() {
err = lstcalc.AppendLaunchKernel(krn, &gozel.ZeGroupCount{
Groupcountx: uint32(groupCount), Groupcounty: 1, Groupcountz: 1,
})
}, 0)
if err != nil {
panic(err)
}
err = lstcalc.AppendBarrier()
err = lstcalc.AppendBarrier(0)
if err != nil {
panic(err)
}
@@ -202,7 +202,7 @@ func main() {
}
defer lstpost.Destroy()
err = lstpost.AppendMemoryCopy(hbufV1, dbufV1, bufsz)
err = lstpost.AppendMemoryCopy(hbufV1, dbufV1, bufsz, 0)
if err != nil {
panic(err)
}
@@ -217,7 +217,7 @@ func main() {
if err != nil {
panic(err)
}
err = q.Synchronize()
err = q.Synchronize(math.MaxUint64)
if err != nil {
panic(err)
}