mirror of
https://github.com/fumiama/gozel.git
synced 2026-07-02 00:30:24 +08:00
feat(gen): impl. all specs except union
This commit is contained in:
@@ -3,14 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fumiama/gozel"
|
"github.com/fumiama/gozel/ze"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := gozel.InitZe()
|
hs, err := ze.InitGPUDrivers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
desc := gozel.GPGPUDriverTypeDesc()
|
fmt.Println(hs)
|
||||||
fmt.Println(gozel.InitDrivers(&desc))
|
|
||||||
}
|
}
|
||||||
|
|||||||
47
cmd/gen/api.go
Normal file
47
cmd/gen/api.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
var apif *os.File
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
f, err := os.Create("api.go")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
apif = f
|
||||||
|
apif.WriteString(`// Code generated by cmd/gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2026 Fumiama Minamoto
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
* @file api.go
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package gozel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/fumiama/gozel/internal/zecall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func addAPI(name string) {
|
||||||
|
apif.WriteString("\n\tif err := zecall.Register(\"")
|
||||||
|
apif.WriteString(name)
|
||||||
|
apif.WriteString("\"); err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"[gozel.warn]\", err)\n\t}\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func closeAPI() {
|
||||||
|
apif.WriteString("\n}\n")
|
||||||
|
apif.Close()
|
||||||
|
}
|
||||||
@@ -42,6 +42,8 @@ func main() {
|
|||||||
specdir = os.DirFS(*spec)
|
specdir = os.DirFS(*spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer closeAPI()
|
||||||
|
|
||||||
fmt.Println("[main] parsing core APIs...")
|
fmt.Println("[main] parsing core APIs...")
|
||||||
f, err := specdir.Open("include/level_zero/ze_api.h")
|
f, err := specdir.Open("include/level_zero/ze_api.h")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
169
cmd/gen/scan.go
169
cmd/gen/scan.go
@@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
)
|
)
|
||||||
@@ -42,42 +41,52 @@ var (
|
|||||||
"int": "int32",
|
"int": "int32",
|
||||||
"unsigned int": "uint32",
|
"unsigned int": "uint32",
|
||||||
|
|
||||||
"float": "float32",
|
"float": "float32",
|
||||||
"double": "float64",
|
"double": "float64",
|
||||||
|
"float*": "*float32",
|
||||||
|
"double*": "*float64",
|
||||||
}
|
}
|
||||||
unsafeExcludeRegions = map[string]struct{}{
|
unsafeExcludeRegions = map[string]struct{}{
|
||||||
"bfloat16conversions": {},
|
"core_bfloat16conversions": {},
|
||||||
"globaloffset": {},
|
"core_globaloffset": {},
|
||||||
"linkonceodr": {},
|
"core_linkonceodr": {},
|
||||||
"subgroups": {},
|
"core_subgroups": {},
|
||||||
}
|
}
|
||||||
zecallExcludeRegions = map[string]struct{}{
|
zecallExcludeRegions = map[string]struct{}{
|
||||||
"bandwidth": {},
|
"core_bandwidth": {},
|
||||||
"bfloat16conversions": {},
|
"core_bfloat16conversions": {},
|
||||||
"CacheLineSize": {},
|
"core_CacheLineSize": {},
|
||||||
"callbacks": {},
|
"core_callbacks": {},
|
||||||
"common": {},
|
"core_common": {},
|
||||||
"counterbasedeventpool": {},
|
"core_counterbasedeventpool": {},
|
||||||
"deviceipversion": {},
|
"core_deviceipversion": {},
|
||||||
"deviceLUID": {},
|
"core_deviceLUID": {},
|
||||||
"deviceusablememproperties": {},
|
"core_deviceusablememproperties": {},
|
||||||
"driverDDIHandles": {},
|
"core_driverDDIHandles": {},
|
||||||
"EUCount": {},
|
"core_EUCount": {},
|
||||||
"externalMemMap": {},
|
"core_externalMemMap": {},
|
||||||
"floatAtomics": {},
|
"core_floatAtomics": {},
|
||||||
"imageFormatSupport": {},
|
"core_imageFormatSupport": {},
|
||||||
"imageviewplanar": {},
|
"core_imageviewplanar": {},
|
||||||
"kernelMaxGroupSizeProperties": {},
|
"core_kernelMaxGroupSizeProperties": {},
|
||||||
"linkonceodr": {},
|
"core_linkonceodr": {},
|
||||||
"memoryCompressionHints": {},
|
"core_memoryCompressionHints": {},
|
||||||
"memoryProperties": {},
|
"core_memoryProperties": {},
|
||||||
"powersavinghint": {},
|
"core_powersavinghint": {},
|
||||||
"program": {},
|
"core_program": {},
|
||||||
"raytracing": {},
|
"core_raytracing": {},
|
||||||
"relaxedAllocLimits": {},
|
"core_relaxedAllocLimits": {},
|
||||||
"SRGB": {},
|
"core_SRGB": {},
|
||||||
"subAllocationsProperties": {},
|
"core_subAllocationsProperties": {},
|
||||||
"subgroups": {},
|
"core_subgroups": {},
|
||||||
|
|
||||||
|
"sysm_common": {},
|
||||||
|
"sysm_eccState": {},
|
||||||
|
"sysm_memoryBwCounterValidBits": {},
|
||||||
|
"sysm_memPageOfflineState": {},
|
||||||
|
"sysm_powerDomainProperties": {},
|
||||||
|
|
||||||
|
"tols_common": {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -95,18 +104,8 @@ func infh(name string) string {
|
|||||||
func scanHeader(name string, scan *bufio.Scanner) {
|
func scanHeader(name string, scan *bufio.Scanner) {
|
||||||
ln := 0
|
ln := 0
|
||||||
var regionfile *os.File
|
var regionfile *os.File
|
||||||
symtab := symbolTable{
|
|
||||||
"ZE_APICALL": &symbol{symbolTypeConst, symbolSubTypeDefine, "ZE_APICALL", []string{""}},
|
|
||||||
"ZE_APIEXPORT": &symbol{symbolTypeConst, symbolSubTypeDefine, "ZE_APIEXPORT", []string{""}},
|
|
||||||
"ZE_DLLEXPORT": &symbol{symbolTypeConst, symbolSubTypeDefine, "ZE_DLLEXPORT", []string{""}},
|
|
||||||
}
|
|
||||||
fileheadersb := strings.Builder{}
|
fileheadersb := strings.Builder{}
|
||||||
region := ""
|
region := ""
|
||||||
_ = os.RemoveAll(name)
|
|
||||||
err := os.MkdirAll(name, 0755)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Sprintf("%s L%d: cannot create region folder %s, err: %v", name, ln, region, err))
|
|
||||||
}
|
|
||||||
for scan.Scan() {
|
for scan.Scan() {
|
||||||
ln++
|
ln++
|
||||||
t := scan.Text()
|
t := scan.Text()
|
||||||
@@ -122,24 +121,23 @@ func scanHeader(name string, scan *bufio.Scanner) {
|
|||||||
panic(fmt.Sprintf("%s L%d: unexpected empty region", name, ln))
|
panic(fmt.Sprintf("%s L%d: unexpected empty region", name, ln))
|
||||||
}
|
}
|
||||||
fmt.Println(infh(name), "scanning region", region)
|
fmt.Println(infh(name), "scanning region", region)
|
||||||
f, err := os.Create(path.Join(name, region+".go"))
|
k := fmt.Sprint(name, "_", region)
|
||||||
|
f, err := os.Create(fmt.Sprint(k, ".go"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("%s L%d: cannot create region %s, err: %v", name, ln, region, err))
|
panic(fmt.Sprintf("%s L%d: cannot create region %s, err: %v", name, ln, region, err))
|
||||||
}
|
}
|
||||||
f.WriteString("// Code generated by cmd/gen. DO NOT EDIT.\n\n")
|
f.WriteString("// Code generated by cmd/gen. DO NOT EDIT.\n\n")
|
||||||
f.WriteString(fileheadersb.String())
|
f.WriteString(fileheadersb.String())
|
||||||
f.WriteString("\n")
|
f.WriteString("\n")
|
||||||
f.WriteString("package ")
|
f.WriteString("package gozel\n\n")
|
||||||
f.WriteString(name)
|
|
||||||
f.WriteString("\n\n")
|
|
||||||
noimport := true
|
noimport := true
|
||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
sb.WriteString("import (")
|
sb.WriteString("import (")
|
||||||
if _, ok := unsafeExcludeRegions[region]; !ok {
|
if _, ok := unsafeExcludeRegions[k]; !ok {
|
||||||
sb.WriteString("\n\t\"unsafe\"\n")
|
sb.WriteString("\n\t\"unsafe\"\n")
|
||||||
noimport = false
|
noimport = false
|
||||||
}
|
}
|
||||||
if _, ok := zecallExcludeRegions[region]; !ok {
|
if _, ok := zecallExcludeRegions[k]; !ok {
|
||||||
sb.WriteString("\n\t\"github.com/fumiama/gozel/internal/zecall\"\n")
|
sb.WriteString("\n\t\"github.com/fumiama/gozel/internal/zecall\"\n")
|
||||||
noimport = false
|
noimport = false
|
||||||
}
|
}
|
||||||
@@ -151,7 +149,7 @@ func scanHeader(name string, scan *bufio.Scanner) {
|
|||||||
// block barrier
|
// block barrier
|
||||||
case strings.HasPrefix(t, "///////////////////////////////////////////////////////////////////////////////"):
|
case strings.HasPrefix(t, "///////////////////////////////////////////////////////////////////////////////"):
|
||||||
fmt.Println(" [scan] enter", region, "block")
|
fmt.Println(" [scan] enter", region, "block")
|
||||||
ln = scanBlocks(name, scan, regionfile, ln, symtab)
|
ln = scanBlocks(name, scan, regionfile, ln)
|
||||||
fmt.Println(" [scan] leave", region, "block")
|
fmt.Println(" [scan] leave", region, "block")
|
||||||
// pragma end
|
// pragma end
|
||||||
case strings.HasPrefix(t, "#pragma endregion"):
|
case strings.HasPrefix(t, "#pragma endregion"):
|
||||||
@@ -170,7 +168,7 @@ func scanHeader(name string, scan *bufio.Scanner) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkSymbolName(
|
func checkSymbolName(
|
||||||
symtab symbolTable, ln int, name, sname, goname string,
|
ln int, name, sname, goname string,
|
||||||
sb *strings.Builder, f *os.File, eq func() *symbol) bool {
|
sb *strings.Builder, f *os.File, eq func() *symbol) bool {
|
||||||
if _, ok := symtab[sname]; ok {
|
if _, ok := symtab[sname]; ok {
|
||||||
panic(fmt.Sprintf("%s L%d: func #define %s has been defined", name, ln, sname))
|
panic(fmt.Sprintf("%s L%d: func #define %s has been defined", name, ln, sname))
|
||||||
@@ -195,7 +193,7 @@ func checkSymbolName(
|
|||||||
|
|
||||||
func scanBlocks(
|
func scanBlocks(
|
||||||
name string, scan *bufio.Scanner, f *os.File,
|
name string, scan *bufio.Scanner, f *os.File,
|
||||||
ln int, symtab symbolTable,
|
ln int,
|
||||||
) int {
|
) int {
|
||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
ppskip2nextblk := false
|
ppskip2nextblk := false
|
||||||
@@ -253,7 +251,7 @@ func scanBlocks(
|
|||||||
if !strings.Contains(argn, "(") { // is const define
|
if !strings.Contains(argn, "(") { // is const define
|
||||||
sname := strings.TrimSpace(argn)
|
sname := strings.TrimSpace(argn)
|
||||||
val := symtab.apply(strings.TrimSpace(argv))
|
val := symtab.apply(strings.TrimSpace(argv))
|
||||||
checkSymbolName(symtab, ln, name, sname, sname, &sb, f, func() *symbol {
|
checkSymbolName(ln, name, sname, sname, &sb, f, func() *symbol {
|
||||||
return newSymbolConst(sname, val, symbolSubTypeDefine)
|
return newSymbolConst(sname, val, symbolSubTypeDefine)
|
||||||
})
|
})
|
||||||
f.WriteString("const ")
|
f.WriteString("const ")
|
||||||
@@ -274,7 +272,7 @@ func scanBlocks(
|
|||||||
sname = strings.TrimSpace(sname)
|
sname = strings.TrimSpace(sname)
|
||||||
args = strings.TrimSpace(args)
|
args = strings.TrimSpace(args)
|
||||||
eval := strings.TrimSpace(argseval[n+1:])
|
eval := strings.TrimSpace(argseval[n+1:])
|
||||||
checkSymbolName(symtab, ln, name, sname, sname, &sb, f, func() *symbol {
|
checkSymbolName(ln, name, sname, sname, &sb, f, func() *symbol {
|
||||||
return newSymbolFunc(sname, args, eval, symbolSubTypeDefine)
|
return newSymbolFunc(sname, args, eval, symbolSubTypeDefine)
|
||||||
})
|
})
|
||||||
f.WriteString("func ")
|
f.WriteString("func ")
|
||||||
@@ -287,12 +285,45 @@ func scanBlocks(
|
|||||||
f.WriteString(eval)
|
f.WriteString(eval)
|
||||||
f.WriteString("\n}\n\n")
|
f.WriteString("\n}\n\n")
|
||||||
case strings.HasPrefix(t, "typedef "):
|
case strings.HasPrefix(t, "typedef "):
|
||||||
ln = scanTypedef(name, scan, f, ln, symtab, t, &sb)
|
ln = scanTypedef(name, scan, f, ln, t, &sb)
|
||||||
case strings.HasPrefix(t, "ZE_APIEXPORT "):
|
case strings.HasPrefix(t, "ZE_APIEXPORT "):
|
||||||
if !strings.HasSuffix(t, " ZE_APICALL") {
|
if !strings.HasSuffix(t, " ZE_APICALL") {
|
||||||
panic(fmt.Sprintf("%s L%d: unexpected func line %s", name, ln, t))
|
panic(fmt.Sprintf("%s L%d: unexpected func line %s", name, ln, t))
|
||||||
}
|
}
|
||||||
ln = scanFunc(name, scan, f, ln, symtab, t, &sb)
|
ln = scanFunc(name, scan, f, ln, t, &sb)
|
||||||
|
case strings.HasPrefix(t, "static const ") && strings.HasSuffix(t, "= {"):
|
||||||
|
t = strings.TrimSpace(t[13 : len(t)-3])
|
||||||
|
i := strings.LastIndex(t, " ")
|
||||||
|
if i <= 0 {
|
||||||
|
panic(fmt.Sprintf("%s L%d: unexpected short var %s", name, ln, t))
|
||||||
|
}
|
||||||
|
typ := symtab.apply(strings.TrimSpace(t[:i]))
|
||||||
|
rnam := []rune(strings.TrimSpace(t[i+1:]))
|
||||||
|
rnam[0] = unicode.ToUpper(rnam[0])
|
||||||
|
nam := string(rnam)
|
||||||
|
f.WriteString(strings.Replace(sb.String(), "/ @brief", " "+nam, 1))
|
||||||
|
sb.Reset()
|
||||||
|
f.WriteString("var ")
|
||||||
|
f.WriteString(nam)
|
||||||
|
f.WriteString(" = ")
|
||||||
|
f.WriteString(typ)
|
||||||
|
f.WriteString("{")
|
||||||
|
for {
|
||||||
|
f.WriteString("\n")
|
||||||
|
s, isfin := scanln(name, scan, &ln)
|
||||||
|
if isfin {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
f.WriteString("\t")
|
||||||
|
if strings.HasPrefix(s, "0,") && strings.Contains(s, "///< p") {
|
||||||
|
f.WriteString("nil,")
|
||||||
|
f.WriteString(s[2:])
|
||||||
|
} else {
|
||||||
|
f.WriteString(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.WriteString("}\n\n")
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("%s L%d: unexpected line %s", name, ln, t))
|
panic(fmt.Sprintf("%s L%d: unexpected line %s", name, ln, t))
|
||||||
}
|
}
|
||||||
@@ -302,7 +333,7 @@ func scanBlocks(
|
|||||||
|
|
||||||
func scanTypedef(
|
func scanTypedef(
|
||||||
name string, scan *bufio.Scanner, f *os.File,
|
name string, scan *bufio.Scanner, f *os.File,
|
||||||
ln int, symtab symbolTable, firstln string, sb *strings.Builder,
|
ln int, firstln string, sb *strings.Builder,
|
||||||
) int {
|
) int {
|
||||||
s, newln := get1sentence(firstln, scan, ln)
|
s, newln := get1sentence(firstln, scan, ln)
|
||||||
if newln < 0 {
|
if newln < 0 {
|
||||||
@@ -326,7 +357,7 @@ func scanTypedef(
|
|||||||
}
|
}
|
||||||
goname := us2camel(fnname)
|
goname := us2camel(fnname)
|
||||||
fnname += "_t"
|
fnname += "_t"
|
||||||
checkSymbolName(symtab, ln, name, fnname, goname, sb, f, func() *symbol {
|
checkSymbolName(ln, name, fnname, goname, sb, f, func() *symbol {
|
||||||
return newSymbolConst(fnname, goname, symbolSubTypeFuncPtr)
|
return newSymbolConst(fnname, goname, symbolSubTypeFuncPtr)
|
||||||
})
|
})
|
||||||
f.WriteString("// gozel warn: please use C function pointer loaded from C library!\n")
|
f.WriteString("// gozel warn: please use C function pointer loaded from C library!\n")
|
||||||
@@ -510,7 +541,7 @@ func scanTypedef(
|
|||||||
}
|
}
|
||||||
sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";")
|
sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";")
|
||||||
val := us2camel(strings.TrimSuffix(sname, "_t"))
|
val := us2camel(strings.TrimSuffix(sname, "_t"))
|
||||||
checkSymbolName(symtab, ln, name, sname, val, sb, f, func() *symbol {
|
checkSymbolName(ln, name, sname, val, sb, f, func() *symbol {
|
||||||
return newSymbolConst(sname, val, symbolSubTypeLargeStruct)
|
return newSymbolConst(sname, val, symbolSubTypeLargeStruct)
|
||||||
})
|
})
|
||||||
f.WriteString("type ")
|
f.WriteString("type ")
|
||||||
@@ -563,7 +594,7 @@ func scanTypedef(
|
|||||||
}
|
}
|
||||||
sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";")
|
sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";")
|
||||||
val := us2camel(strings.TrimSuffix(sname, "_t"))
|
val := us2camel(strings.TrimSuffix(sname, "_t"))
|
||||||
redirect := checkSymbolName(symtab, ln, name, sname, val, sb, f, func() *symbol {
|
redirect := checkSymbolName(ln, name, sname, val, sb, f, func() *symbol {
|
||||||
return newSymbolConst(sname, val, symbolSubTypeEnum)
|
return newSymbolConst(sname, val, symbolSubTypeEnum)
|
||||||
})
|
})
|
||||||
replaces := ""
|
replaces := ""
|
||||||
@@ -611,7 +642,7 @@ func scanTypedef(
|
|||||||
sname := strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(typs[1]), ";"))
|
sname := strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(typs[1]), ";"))
|
||||||
val := us2camel(strings.TrimSuffix(sname, "_t"))
|
val := us2camel(strings.TrimSuffix(sname, "_t"))
|
||||||
origtyp := strings.TrimSuffix(symtab.apply(strings.TrimSpace(typs[0])), "_t")
|
origtyp := strings.TrimSuffix(symtab.apply(strings.TrimSpace(typs[0])), "_t")
|
||||||
checkSymbolName(symtab, ln, name, sname, val, sb, f, func() *symbol {
|
checkSymbolName(ln, name, sname, val, sb, f, func() *symbol {
|
||||||
return newSymbolConst(sname, val, symbolSubTypeEmptyStruct)
|
return newSymbolConst(sname, val, symbolSubTypeEmptyStruct)
|
||||||
})
|
})
|
||||||
f.WriteString("type ")
|
f.WriteString("type ")
|
||||||
@@ -624,11 +655,11 @@ func scanTypedef(
|
|||||||
|
|
||||||
func scanFunc(
|
func scanFunc(
|
||||||
name string, scan *bufio.Scanner, f *os.File,
|
name string, scan *bufio.Scanner, f *os.File,
|
||||||
ln int, symtab symbolTable, firstln string, sb *strings.Builder,
|
ln int, firstln string, sb *strings.Builder,
|
||||||
) int {
|
) int {
|
||||||
//TODO: register func
|
//TODO: register func
|
||||||
rettyp := strings.TrimSpace(firstln[13 : len(firstln)-11])
|
rettyp := strings.TrimSpace(firstln[13 : len(firstln)-11])
|
||||||
rettyp = symtab.apply(strings.TrimSpace(rettyp))
|
rettyp = strings.TrimSuffix(symtab.apply(strings.TrimSpace(rettyp)), "_t")
|
||||||
fnname, isfin := scanln(name, scan, &ln)
|
fnname, isfin := scanln(name, scan, &ln)
|
||||||
if isfin {
|
if isfin {
|
||||||
panic(fmt.Sprintf("%s L%d: unexpected early end func name line %s", name, ln, fnname))
|
panic(fmt.Sprintf("%s L%d: unexpected early end func name line %s", name, ln, fnname))
|
||||||
@@ -661,6 +692,9 @@ func scanFunc(
|
|||||||
f.WriteString(argln[4:])
|
f.WriteString(argln[4:])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if argln == "void" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
argtypnam, argcomment, ok := strings.Cut(argln, "//")
|
argtypnam, argcomment, ok := strings.Cut(argln, "//")
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Sprintf("%s L%d: unexpected non-comment func arg line %s", name, ln, argln))
|
panic(fmt.Sprintf("%s L%d: unexpected non-comment func arg line %s", name, ln, argln))
|
||||||
@@ -675,13 +709,17 @@ func scanFunc(
|
|||||||
argsb.WriteString(", uintptr(")
|
argsb.WriteString(", uintptr(")
|
||||||
argtyp := strings.TrimSpace(strings.ReplaceAll(argtypnam[:i], "const ", ""))
|
argtyp := strings.TrimSpace(strings.ReplaceAll(argtypnam[:i], "const ", ""))
|
||||||
isp := strings.HasSuffix(argtyp, "*") // is pointer
|
isp := strings.HasSuffix(argtyp, "*") // is pointer
|
||||||
|
pmark := "*"
|
||||||
|
if strings.HasSuffix(argtyp, "**") { // is pointer's pointer
|
||||||
|
pmark = "**"
|
||||||
|
}
|
||||||
convtyp, ok := typemap[argtyp]
|
convtyp, ok := typemap[argtyp]
|
||||||
if ok {
|
if ok {
|
||||||
argtyp = convtyp
|
argtyp = convtyp
|
||||||
}
|
}
|
||||||
if isp {
|
if isp {
|
||||||
if !ok {
|
if !ok {
|
||||||
argtyp = "*" + argtyp[:len(argtyp)-1]
|
argtyp = pmark + argtyp[:len(argtyp)-len(pmark)]
|
||||||
}
|
}
|
||||||
argsb.WriteString("unsafe.Pointer(")
|
argsb.WriteString("unsafe.Pointer(")
|
||||||
} else {
|
} else {
|
||||||
@@ -689,7 +727,7 @@ func scanFunc(
|
|||||||
if ok && sym.sstype == symbolSubTypeLargeStruct &&
|
if ok && sym.sstype == symbolSubTypeLargeStruct &&
|
||||||
!strings.HasPrefix(argnam, "p") {
|
!strings.HasPrefix(argnam, "p") {
|
||||||
isp = true
|
isp = true
|
||||||
argtyp = "*" + argtyp
|
argtyp = pmark + argtyp
|
||||||
argcomment += " (gozel hack: converted to a hidden pointer from a struct value)"
|
argcomment += " (gozel hack: converted to a hidden pointer from a struct value)"
|
||||||
argsb.WriteString("unsafe.Pointer(")
|
argsb.WriteString("unsafe.Pointer(")
|
||||||
}
|
}
|
||||||
@@ -716,5 +754,6 @@ func scanFunc(
|
|||||||
f.WriteString("\"")
|
f.WriteString("\"")
|
||||||
f.WriteString(argsb.String())
|
f.WriteString(argsb.String())
|
||||||
f.WriteString(")\n}\n\n")
|
f.WriteString(")\n}\n\n")
|
||||||
|
addAPI(origfnname)
|
||||||
return ln
|
return ln
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -11,6 +14,13 @@ var (
|
|||||||
errNoSuchSymbol = errors.New("no such sybmol")
|
errNoSuchSymbol = errors.New("no such sybmol")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var symtab = symbolTable{
|
||||||
|
"ZE_APICALL": &symbol{symbolTypeConst, symbolSubTypeDefine, "ZE_APICALL", []string{""}},
|
||||||
|
"ZE_APIEXPORT": &symbol{symbolTypeConst, symbolSubTypeDefine, "ZE_APIEXPORT", []string{""}},
|
||||||
|
"ZE_DLLEXPORT": &symbol{symbolTypeConst, symbolSubTypeDefine, "ZE_DLLEXPORT", []string{""}},
|
||||||
|
"~(0ULL": &symbol{symbolTypeConst, symbolSubTypeDefine, "~(0ULL", []string{"(^uint64(0)"}},
|
||||||
|
}
|
||||||
|
|
||||||
type symbolTable map[string]*symbol
|
type symbolTable map[string]*symbol
|
||||||
|
|
||||||
func (st symbolTable) apply(t string) string {
|
func (st symbolTable) apply(t string) string {
|
||||||
@@ -96,7 +106,18 @@ func (s *symbol) extract1stFunc(txt string) (args []string, a, b int, err error)
|
|||||||
func (s *symbol) replace(txt string) string {
|
func (s *symbol) replace(txt string) string {
|
||||||
switch s.stype {
|
switch s.stype {
|
||||||
case symbolTypeConst:
|
case symbolTypeConst:
|
||||||
return strings.ReplaceAll(txt, s.name, s.fields[0])
|
escapes := regexp.QuoteMeta(s.name)
|
||||||
|
re := regexp.MustCompile(`(` + escapes + `[^\w_])|(` + escapes + `$)`)
|
||||||
|
return string(re.ReplaceAllFunc([]byte(txt), func(b []byte) []byte {
|
||||||
|
last := rune(b[len(b)-1])
|
||||||
|
if unicode.IsLetter(last) || last == '_' {
|
||||||
|
return []byte(s.fields[0])
|
||||||
|
}
|
||||||
|
buf := bytes.NewBuffer(make([]byte, 0, 128))
|
||||||
|
buf.WriteString(s.fields[0])
|
||||||
|
buf.WriteByte(b[len(b)-1])
|
||||||
|
return buf.Bytes()
|
||||||
|
}))
|
||||||
case symbolTypeFunc:
|
case symbolTypeFunc:
|
||||||
paras := strings.Split(s.fields[0], ",")
|
paras := strings.Split(s.fields[0], ",")
|
||||||
txts := []string{}
|
txts := []string{}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
// ZE_BFLOAT16_CONVERSIONS_EXT_NAME Bfloat16 Conversions Extension Name
|
// ZE_BFLOAT16_CONVERSIONS_EXT_NAME Bfloat16 Conversions Extension Name
|
||||||
const ZE_BFLOAT16_CONVERSIONS_EXT_NAME = "ZE_extension_bfloat16_conversions"
|
const ZE_BFLOAT16_CONVERSIONS_EXT_NAME = "ZE_extension_bfloat16_conversions"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/fumiama/gozel/internal/zecall"
|
"github.com/fumiama/gozel/internal/zecall"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
// ZE_LINKONCE_ODR_EXT_NAME Linkonce ODR Extension Name
|
// ZE_LINKONCE_ODR_EXT_NAME Linkonce ODR Extension Name
|
||||||
const ZE_LINKONCE_ODR_EXT_NAME = "ZE_extension_linkonce_odr"
|
const ZE_LINKONCE_ODR_EXT_NAME = "ZE_extension_linkonce_odr"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
// ZE_SUBGROUPS_EXT_NAME Subgroups Extension Name
|
// ZE_SUBGROUPS_EXT_NAME Subgroups Extension Name
|
||||||
const ZE_SUBGROUPS_EXT_NAME = "ZE_extension_subgroups"
|
const ZE_SUBGROUPS_EXT_NAME = "ZE_extension_subgroups"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package core
|
package gozel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package gozel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
zeLibraryName = "ze_loader.dll"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
libZeLoader syscall.DLL
|
|
||||||
)
|
|
||||||
|
|
||||||
func InitZe() error {
|
|
||||||
h, err := syscall.LoadLibrary(zeLibraryName)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
libZeLoader = syscall.DLL{Handle: h, Name: zeLibraryName}
|
|
||||||
procZeInitDrivers, err = libZeLoader.FindProc("zeInitDrivers")
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("zeInitDrivers not found in ze_loader.dll: %w", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
141
rntm_common.go
Normal file
141
rntm_common.go
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
// Code generated by cmd/gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019-2025 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
* @file zer_api.h
|
||||||
|
* @version v1.15-r1.15.31
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package gozel
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/fumiama/gozel/internal/zecall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ZeDefaultGPUImmediateCommandQueueDesc Immediate Command List default descriptor for GPU devices
|
||||||
|
var ZeDefaultGPUImmediateCommandQueueDesc = ZeCommandQueueDesc{
|
||||||
|
ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC, ///< stype
|
||||||
|
nil, ///< pNext
|
||||||
|
0, ///< ordinal
|
||||||
|
0, ///< index
|
||||||
|
ZE_COMMAND_QUEUE_FLAG_IN_ORDER | ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT, ///< flags
|
||||||
|
ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, ///< mode
|
||||||
|
ZE_COMMAND_QUEUE_PRIORITY_NORMAL, ///< priority
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZeDefaultGPUDeviceMemAllocDesc Device Unified Shared Memory Allocation default descriptor for GPU
|
||||||
|
/// devices
|
||||||
|
var ZeDefaultGPUDeviceMemAllocDesc = ZeDeviceMemAllocDesc{
|
||||||
|
ZE_STRUCTURE_TYPE_DEVICE_MEM_ALLOC_DESC, ///< stype
|
||||||
|
nil, ///< pNext
|
||||||
|
ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_CACHED, ///< flags
|
||||||
|
0, ///< ordinal
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZeDefaultGPUHostMemAllocDesc Host Unified Shared Memory Allocation default descriptor for GPU
|
||||||
|
/// devices
|
||||||
|
var ZeDefaultGPUHostMemAllocDesc = ZeHostMemAllocDesc{
|
||||||
|
ZE_STRUCTURE_TYPE_HOST_MEM_ALLOC_DESC, ///< stype
|
||||||
|
nil, ///< pNext
|
||||||
|
ZE_HOST_MEM_ALLOC_FLAG_BIAS_CACHED | ZE_HOST_MEM_ALLOC_FLAG_BIAS_INITIAL_PLACEMENT, ///< flags
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZerGetLastErrorDescription Retrieves a string describing the last error code returned by the
|
||||||
|
/// default driver in the current thread.
|
||||||
|
///
|
||||||
|
/// @details
|
||||||
|
/// - String returned is thread local.
|
||||||
|
/// - String is only updated on calls returning an error, i.e., not on calls
|
||||||
|
/// returning ::ZE_RESULT_SUCCESS.
|
||||||
|
/// - String may be empty if driver considers error code is already explicit
|
||||||
|
/// enough to describe cause.
|
||||||
|
/// - Memory pointed to by ppString is owned by the default driver.
|
||||||
|
/// - String returned is null-terminated.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// - ::ZE_RESULT_SUCCESS
|
||||||
|
/// - ::ZE_RESULT_ERROR_UNINITIALIZED
|
||||||
|
/// - ::ZE_RESULT_ERROR_DEVICE_LOST
|
||||||
|
/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY
|
||||||
|
/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY
|
||||||
|
/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT
|
||||||
|
/// - ::ZE_RESULT_ERROR_UNSUPPORTED_FEATURE
|
||||||
|
/// - ::ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE
|
||||||
|
/// - ::ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS
|
||||||
|
/// - ::ZE_RESULT_ERROR_NOT_AVAILABLE
|
||||||
|
/// - ::ZE_RESULT_ERROR_DEVICE_REQUIRES_RESET
|
||||||
|
/// - ::ZE_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE
|
||||||
|
/// - ::ZE_RESULT_ERROR_UNKNOWN
|
||||||
|
/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
|
||||||
|
/// + `nullptr == ppString`
|
||||||
|
func ZerGetLastErrorDescription(
|
||||||
|
ppString **byte, // ppString [in,out] pointer to a null-terminated array of characters describing cause of error.
|
||||||
|
) (ZeResult, error) {
|
||||||
|
return zecall.Call[ZeResult]("zerGetLastErrorDescription", uintptr(unsafe.Pointer(ppString)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZerTranslateDeviceHandleToIdentifier Translates device handle to integer identifier.
|
||||||
|
///
|
||||||
|
/// @details
|
||||||
|
/// - The implementation of this function should be lock-free.
|
||||||
|
/// - This function does not return error code, to get info about failure
|
||||||
|
/// user may use ::zerGetLastErrorDescription function.
|
||||||
|
/// - In case of failure, this function returns UINT32_MAX.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// - integer identifier for the device
|
||||||
|
/// - UINT32_MAX
|
||||||
|
func ZerTranslateDeviceHandleToIdentifier(
|
||||||
|
hDevice ZeDeviceHandle, // hDevice [in] handle of the device
|
||||||
|
) (uint32, error) {
|
||||||
|
return zecall.Call[uint32]("zerTranslateDeviceHandleToIdentifier", uintptr(hDevice))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZerTranslateIdentifierToDeviceHandle Translates to integer identifier to a device handle.
|
||||||
|
///
|
||||||
|
/// @details
|
||||||
|
/// - The driver must be initialized before calling this function.
|
||||||
|
/// - The implementation of this function should be lock-free.
|
||||||
|
/// - This function does not return error code, to get info about failure
|
||||||
|
/// user may use ::zerGetLastErrorDescription function.
|
||||||
|
/// - In case of failure, this function returns null.
|
||||||
|
/// - Details on the error can be retrieved using
|
||||||
|
/// ::zerGetLastErrorDescription function.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// - handle of the device with the given identifier
|
||||||
|
/// - nullptr
|
||||||
|
func ZerTranslateIdentifierToDeviceHandle(
|
||||||
|
identifier uint32, // identifier [in] integer identifier of the device
|
||||||
|
) (ZeDeviceHandle, error) {
|
||||||
|
return zecall.Call[ZeDeviceHandle]("zerTranslateIdentifierToDeviceHandle", uintptr(identifier))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZerGetDefaultContext Retrieves handle to default context from the default driver.
|
||||||
|
///
|
||||||
|
/// @details
|
||||||
|
/// - The driver must be initialized before calling this function.
|
||||||
|
/// - The implementation of this function should be lock-free.
|
||||||
|
/// - This returned context contains all the devices available in the
|
||||||
|
/// default driver.
|
||||||
|
/// - This function does not return error code, to get info about failure
|
||||||
|
/// user may use ::zerGetLastErrorDescription function.
|
||||||
|
/// - In case of failure, this function returns null.
|
||||||
|
/// - Details on the error can be retrieved using
|
||||||
|
/// ::zerGetLastErrorDescription function.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// - handle of the default context
|
||||||
|
/// - nullptr
|
||||||
|
func ZerGetDefaultContext(
|
||||||
|
) (ZeContextHandle, error) {
|
||||||
|
return zecall.Call[ZeContextHandle]("zerGetDefaultContext")
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
// Code generated by gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package sysm
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user