diff --git a/cmd/gen/scan.go b/cmd/gen/scan.go index 6ea8aa0..a2a48a3 100644 --- a/cmd/gen/scan.go +++ b/cmd/gen/scan.go @@ -8,6 +8,7 @@ import ( "os" "path" "strings" + "unicode" ) const ( @@ -16,9 +17,38 @@ const ( var ( typemap = map[string]string{ - "char": "byte", - "void*": "unsafe.Pointer", - "const void*": "unsafe.Pointer", + "char": "byte", + "char*": "*byte", + "const char*": "*byte", + "char**": "**byte", + "const char**": "**byte", + + "void*": "unsafe.Pointer", + "void *": "unsafe.Pointer", + "const void*": "unsafe.Pointer", + "void**": "*unsafe.Pointer", + "void **": "*unsafe.Pointer", + "const void**": "*unsafe.Pointer", + + "size_t": "uintptr", + "size_t*": "*uintptr", + + "int": "int32", + + "float": "float32", + "double": "float64", + } + unsafeExcludeRegions = map[string]struct{}{ + "globaloffset": {}, + } + zecallExcludeRegions = map[string]struct{}{ + "CacheLineSize": {}, + "common": {}, + "driverDDIHandles": {}, + "floatAtomics": {}, + "program": {}, + "raytracing": {}, + "relaxedAllocLimits": {}, } ) @@ -37,9 +67,9 @@ func scanHeader(name string, scan *bufio.Scanner) { ln := 0 var regionfile *os.File symtab := symbolTable{ - "ZE_APICALL": &symbol{symbolTypeConst, "ZE_APICALL", []string{""}}, - "ZE_APIEXPORT": &symbol{symbolTypeConst, "ZE_APIEXPORT", []string{""}}, - "ZE_DLLEXPORT": &symbol{symbolTypeConst, "ZE_DLLEXPORT", []string{""}}, + "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{} region := "" @@ -72,7 +102,14 @@ func scanHeader(name string, scan *bufio.Scanner) { f.WriteString("\n") f.WriteString("package ") f.WriteString(name) - f.WriteString("\n\nimport (\n\t\"unsafe\"\n)\n\n") + f.WriteString("\n\nimport (") + if _, ok := unsafeExcludeRegions[region]; !ok { + f.WriteString("\n\t\"unsafe\"\n") + } + if _, ok := zecallExcludeRegions[region]; !ok { + f.WriteString("\n\t\"github.com/fumiama/gozel/internal/zecall\"\n") + } + f.WriteString(")\n\n") regionfile = f // block barrier case strings.HasPrefix(t, "///////////////////////////////////////////////////////////////////////////////"): @@ -124,11 +161,10 @@ func scanBlocks( ln int, symtab symbolTable, ) int { sb := strings.Builder{} - skip2nextblk := false //TODO: check logic - ifdepth := 0 + ppskip2nextblk := false + ppifdepth := 0 isparsing := func() bool { - //TODO: more condition - return ifdepth > 0 + return ppifdepth > 0 } for scan.Scan() { ln++ @@ -143,7 +179,7 @@ func scanBlocks( fmt.Printf("[warn] %s L%d: non-0 sb at block end: %s\n", name, ln, &sb) } return ln - case skip2nextblk: + case ppskip2nextblk: continue // is definition's comment case strings.HasPrefix(t, "/// "): @@ -154,7 +190,7 @@ func scanBlocks( panic(fmt.Sprintf("%s L%d: unexpected short #if", name, ln)) } if t[3] == ' ' { // is platform related judgement - skip2nextblk = true + ppskip2nextblk = true continue } if t[:8] != "#ifndef " { @@ -166,22 +202,22 @@ func scanBlocks( ln = skip2endif(scan, ln) continue } - ifdepth++ + ppifdepth++ case strings.HasPrefix(t, "#endif"): - ifdepth-- - if ifdepth < 0 { + ppifdepth-- + if ppifdepth < 0 { panic(fmt.Sprintf("%s L%d: unexpected unpaired #endif", name, ln)) } case strings.HasPrefix(t, "#define "): - if !strings.Contains(t, "(") { // is const define - argseval := trimEmptyStringArray(strings.Split(t[8:], " ")) - if len(argseval) != 2 { - panic(fmt.Sprintf("%s L%d: unexpected const #define line %s", name, ln, t)) - } - sname := strings.TrimSpace(argseval[0]) - val := strings.TrimSpace(argseval[1]) + argn, argv, ok := strings.Cut(t[8:], " ") + if !ok { + panic(fmt.Sprintf("%s L%d: unexpected short #define line %s", name, ln, t)) + } + if !strings.Contains(argn, "(") { // is const define + sname := strings.TrimSpace(argn) + val := symtab.apply(strings.TrimSpace(argv)) checkSymbolName(symtab, ln, name, sname, sname, &sb, f, func() *symbol { - return newSymbolConst(sname, val) + return newSymbolConst(sname, val, symbolSubTypeDefine) }) f.WriteString("const ") f.WriteString(sname) @@ -202,7 +238,7 @@ func scanBlocks( args = strings.TrimSpace(args) eval := strings.TrimSpace(argseval[n+1:]) checkSymbolName(symtab, ln, name, sname, sname, &sb, f, func() *symbol { - return newSymbolFunc(sname, args, eval) + return newSymbolFunc(sname, args, eval, symbolSubTypeDefine) }) f.WriteString("func ") f.WriteString(sname) @@ -214,226 +250,407 @@ func scanBlocks( f.WriteString(eval) f.WriteString("\n}\n\n") case strings.HasPrefix(t, "typedef "): - s, newln := get1sentence(t, scan, ln) - if newln < 0 { - panic(fmt.Sprintf("%s L%d: unexpected sentence end from", name, ln)) + ln = scanTypedef(name, scan, f, ln, symtab, t, &sb) + case strings.HasPrefix(t, "ZE_APIEXPORT "): + if !strings.HasSuffix(t, " ZE_APICALL") { + panic(fmt.Sprintf("%s L%d: unexpected func line %s", name, ln, t)) } - ln = newln - if strings.Contains(s, "\n") { // multi-line typedef - lines := strings.Split(s, "\n") - if len(lines) < 4 { - panic(fmt.Sprintf("%s L%d: unexpected short multi typdef line %s", name, ln, t)) - } - if lines[1] != "{" { - panic(fmt.Sprintf("%s L%d: unexpected non-{ multi typdef line %s", name, ln, t)) - } - switch { - case strings.Contains(lines[0], " struct "): - fsb := bytes.NewBuffer(make([]byte, 0, 256)) - for i, stat := range lines[2:] { - if strings.HasPrefix(stat, "}") { - lines = lines[2+i:] - break - } - fsb.WriteString("\n") - if stat == "" { - continue - } - stat = strings.TrimSpace(stat) - vname := "" - c := "" - switch { - case strings.HasPrefix(stat, "char ") || strings.HasPrefix(stat, "void* ") || - strings.HasPrefix(stat, "const void*"): - remains, sz := "", "" - ok := false - remains, c, ok = strings.Cut(stat, ";") - if !ok { - panic(fmt.Sprintf("%s L%d: unsupported non-end line %s", name, ln, stat)) - } - c = strings.TrimPrefix(strings.TrimSpace(c), "//") - remains = strings.TrimSpace(remains) - i := strings.LastIndex(remains, " ") - vname = remains[i+1:] - tn := strings.TrimSpace(remains[:i]) - tname, ok := typemap[tn] - if !ok { - panic(fmt.Sprintf("%s L%d: unsupported type %s", name, ln, tname)) - } - vname, sz, ok = strings.Cut(vname, "[") - vname = us2camel(strings.TrimSpace(vname)) - fsb.WriteString("\t") - if ok { // is array - fsb.WriteString(vname) - fsb.WriteString(" [") - fsb.WriteString(sz) - fsb.WriteString(tname) - } else { - fsb.WriteString(vname) - fsb.WriteString(" ") - fsb.WriteString(tname) - } - case strings.Contains(stat, "_t "): - remains, sz := "", "" - ok := false - remains, c, ok = strings.Cut(stat, ";") - if !ok { - panic(fmt.Sprintf("%s L%d: unsupported non-end line %s", name, ln, stat)) - } - c = strings.TrimPrefix(strings.TrimSpace(c), "//") - tname, remains, ok := strings.Cut(remains, "_t ") - if !ok { - panic(fmt.Sprintf("%s L%d: unexpected statement %s", name, ln, stat)) - } - tname = strings.TrimSpace(tname) - k := tname + "_t" - if symtab.contains(k) { - tname = symtab[k].replace(k) - } - vname, sz, ok = strings.Cut(remains, "[") - vname = us2camel(strings.TrimSpace(vname)) - fsb.WriteString("\t") - if ok { // is array - fsb.WriteString(vname) - fsb.WriteString(" [") - fsb.WriteString(sz) - fsb.WriteString(tname) - } else { - fsb.WriteString(vname) - fsb.WriteString(" ") - fsb.WriteString(tname) - } - case strings.HasPrefix(stat, "///< "): - fsb.Truncate(fsb.Len() - 1) - fsb.WriteString(stat[4:]) - default: - panic(fmt.Sprintf("%s L%d: unexpected statement %s", name, ln, stat)) - } - if c != "" { - fsb.WriteString("\t// ") - fsb.WriteString(strings.Replace(c, "/<", vname, 1)) - } - } - if len(lines) != 1 { - panic(fmt.Sprintf("%s L%d: unexpected len > 1 last lines %s", name, ln, strings.Join(lines, "\n"))) - } - if !strings.HasPrefix(lines[0], "}") { - panic(fmt.Sprintf("%s L%d: unexpected last line %s", name, ln, lines[0])) - } - sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";") - val := us2camel(strings.TrimSuffix(sname, "_t")) - checkSymbolName(symtab, ln, name, sname, val, &sb, f, func() *symbol { - return newSymbolConst(sname, val) - }) - f.WriteString("type ") - f.WriteString(val) - f.WriteString(" struct {") - _, _ = io.Copy(f, fsb) - f.WriteString("\n}\n\n") - continue - case strings.Contains(lines[0], " enum "): - fsb := strings.Builder{} - iscontinouscomment := false - for i, stat := range lines[2:] { - if strings.HasPrefix(stat, "}") { - lines = lines[2+i:] - break - } - fsb.WriteString("\n") - if stat == "" { - continue - } - stat = strings.TrimSpace(stat) - if strings.HasPrefix(stat, "//") { - if !iscontinouscomment { - fsb.WriteString("\n") - } - fsb.WriteString("\t") - fsb.WriteString(stat) - iscontinouscomment = true - continue - } - if iscontinouscomment { - fsb.WriteString("\n") - } - iscontinouscomment = false - constval, comment, ok := strings.Cut(stat, "//") - if !ok { - panic(fmt.Sprintf("%s L%d: unexpected enum line %s", name, ln, stat)) - } - cname, _, _ := strings.Cut(constval, "=") - fsb.WriteString("\t") - fsb.WriteString(strings.TrimSuffix(strings.TrimSpace(constval), ",")) - fsb.WriteString("\t// ") - fsb.WriteString(strings.Replace(comment, "/<", strings.TrimSpace(cname), 1)) - } - if len(lines) != 1 { - panic(fmt.Sprintf("%s L%d: unexpected len > 1 last lines %s", name, ln, strings.Join(lines, "\n"))) - } - if !strings.HasPrefix(lines[0], "}") { - panic(fmt.Sprintf("%s L%d: unexpected last line %s", name, ln, lines[0])) - } - sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";") - val := us2camel(strings.TrimSuffix(sname, "_t")) - redirect := checkSymbolName(symtab, ln, name, sname, val, &sb, f, func() *symbol { - return newSymbolConst(sname, val) - }) - replaces := "" - if !redirect { - f.WriteString("type ") - f.WriteString(val) - f.WriteString(" uintptr\nconst (") - replaces = " " + val + " =" - } else { - _, _ = f.Seek(-1, io.SeekCurrent) - f.WriteString("const (") - replaces = " " + val + "s =" - } - vars := strings.ReplaceAll(fsb.String(), " =", replaces) - if strings.Contains(vars, "(") { - vars = symtab.apply(vars) - } - f.WriteString(vars) - f.WriteString("\n)\n\n") - continue - } - } - // single-line typedef, empty struct or type alias, replace with "type" statement - typs := trimEmptyStringArray(strings.Split(s[8:], " ")) - if len(typs) == 0 { - panic(fmt.Sprintf("%s L%d: unexpected single typdef line %s", name, ln, t)) - } - if strings.TrimSpace(typs[0]) == "struct" { - if len(typs) != 3 || !strings.Contains(typs[1], "handle_t") || - !strings.Contains(typs[2], "*") { - if symtab.contains(strings.TrimSuffix(typs[2], ";")) { - fmt.Printf("[warn] %s L%d: skip duplicated single typdef %s\n", name, ln, strings.Join(typs, "_____")) - } else { - fmt.Printf("[warn] %s L%d: skip future expected single typdef %s\n", name, ln, strings.Join(typs, "_____")) - } - continue - } - typs = typs[1:] - typs[0] = "uintptr" - typs[1] = strings.TrimPrefix(strings.TrimSpace(typs[1]), "*") - } - if len(typs) != 2 { - panic(fmt.Sprintf("%s L%d: unexpected typdef line %s", name, ln, t)) - } - sname := strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(typs[1]), ";")) - val := us2camel(strings.TrimSuffix(sname, "_t")) - origtyp := strings.TrimSuffix(strings.TrimSpace(typs[0]), "_t") - checkSymbolName(symtab, ln, name, sname, val, &sb, f, func() *symbol { - return newSymbolConst(sname, val) - }) - f.WriteString("type ") - f.WriteString(val) - f.WriteString(" ") - f.WriteString(origtyp) - f.WriteString("\n\n") + ln = scanFunc(name, scan, f, ln, symtab, t, &sb) default: panic(fmt.Sprintf("%s L%d: unexpected line %s", name, ln, t)) } } return ln } + +func scanTypedef( + name string, scan *bufio.Scanner, f *os.File, + ln int, symtab symbolTable, firstln string, sb *strings.Builder, +) int { + s, newln := get1sentence(firstln, scan, ln) + if newln < 0 { + panic(fmt.Sprintf("%s L%d: unexpected sentence end from", name, ln)) + } + ln = newln + if strings.Contains(s, "\n") { // multi-line typedef + lines := strings.Split(s, "\n") + if len(lines) < 4 { + panic(fmt.Sprintf("%s L%d: unexpected short multi typdef line %s", name, ln, firstln)) + } + if lines[1] != "{" { + panic(fmt.Sprintf("%s L%d: unexpected non-{ multi typdef line %s", name, ln, firstln)) + } + switch { + case strings.Contains(lines[0], " struct "): + fsb := bytes.NewBuffer(make([]byte, 0, 256)) + for i, stat := range lines[2:] { + if strings.HasPrefix(stat, "}") { + lines = lines[2+i:] + break + } + fsb.WriteString("\n") + if stat == "" { + continue + } + stat = strings.TrimSpace(stat) + vname := "" + c := "" + switch { + case strings.HasPrefix(stat, "///< "): + fsb.Truncate(fsb.Len() - 1) + fsb.WriteString(stat[4:]) + case strings.HasPrefix(stat, "char ") || strings.HasPrefix(stat, "void* ") || + strings.HasPrefix(stat, "const void* ") || strings.HasPrefix(stat, "int ") || + strings.HasPrefix(stat, "const void** ") || strings.HasPrefix(stat, "const char* ") || + strings.HasPrefix(stat, "const char** ") || strings.HasPrefix(stat, "float ") || + strings.HasPrefix(stat, "double "): + remains, sz := "", "" + ok := false + remains, c, ok = strings.Cut(stat, ";") + if !ok { + panic(fmt.Sprintf("%s L%d: unsupported non-end line %s", name, ln, stat)) + } + c = strings.TrimPrefix(strings.TrimSpace(c), "//") + remains = strings.TrimSpace(remains) + i := strings.LastIndex(remains, " ") + vname = remains[i+1:] + tn := strings.TrimSpace(remains[:i]) + tname, ok := typemap[tn] + if !ok { + panic(fmt.Sprintf("%s L%d: unsupported type %s", name, ln, tname)) + } + vname, sz, ok = strings.Cut(vname, "[") + vname = us2camel(strings.TrimSpace(vname)) + fsb.WriteString("\t") + if ok { // is array + fsb.WriteString(vname) + fsb.WriteString(" [") + fsb.WriteString(sz) + fsb.WriteString(tname) + } else { + fsb.WriteString(vname) + fsb.WriteString(" ") + fsb.WriteString(tname) + } + case strings.Contains(stat, "_t "): + remains, sz := "", "" + ok := false + remains, c, ok = strings.Cut(stat, ";") + if !ok { + panic(fmt.Sprintf("%s L%d: unsupported non-end line %s", name, ln, stat)) + } + c = strings.TrimPrefix(strings.TrimSpace(c), "//") + tname, remains, ok := strings.Cut(remains, "_t ") + if !ok { + panic(fmt.Sprintf("%s L%d: unexpected statement %s", name, ln, stat)) + } + tname = strings.TrimSpace(strings.ReplaceAll(tname, "const ", "")) + k := tname + "_t" + if symtab.contains(k) { + tname = symtab[k].replace(k) + } else if convname, ok := typemap[k]; ok { + tname = convname + } + vname, sz, ok = strings.Cut(remains, "[") + vname = us2camel(strings.TrimSpace(vname)) + fsb.WriteString("\t") + if ok { // is array + fsb.WriteString(vname) + fsb.WriteString(" [") + fsb.WriteString(sz) + fsb.WriteString(tname) + } else { + fsb.WriteString(vname) + fsb.WriteString(" ") + fsb.WriteString(tname) + } + case strings.Contains(stat, "_t* "): + remains, sz := "", "" + ok := false + remains, c, ok = strings.Cut(stat, ";") + if !ok { + panic(fmt.Sprintf("%s L%d: unsupported non-end line %s", name, ln, stat)) + } + c = strings.TrimPrefix(strings.TrimSpace(c), "//") + tname, remains, ok := strings.Cut(remains, "_t* ") + if !ok { + panic(fmt.Sprintf("%s L%d: unexpected statement %s", name, ln, stat)) + } + tname = strings.TrimSpace(strings.ReplaceAll(tname, "const ", "")) + k := tname + "_t" + if symtab.contains(k) { + tname = symtab[k].replace(k) + } else if convname, ok := typemap[k]; ok { + tname = convname + } + vname, sz, ok = strings.Cut(remains, "[") + vname = us2camel(strings.TrimSpace(vname)) + fsb.WriteString("\t") + if ok { // is array + fsb.WriteString(vname) + fsb.WriteString(" [") + fsb.WriteString(sz) + fsb.WriteString("*") + fsb.WriteString(tname) + } else { + fsb.WriteString(vname) + fsb.WriteString(" *") + fsb.WriteString(tname) + } + case strings.Contains(stat, "_t** "): + remains, sz := "", "" + ok := false + remains, c, ok = strings.Cut(stat, ";") + if !ok { + panic(fmt.Sprintf("%s L%d: unsupported non-end line %s", name, ln, stat)) + } + c = strings.TrimPrefix(strings.TrimSpace(c), "//") + tname, remains, ok := strings.Cut(remains, "_t** ") + if !ok { + panic(fmt.Sprintf("%s L%d: unexpected statement %s", name, ln, stat)) + } + tname = strings.TrimSpace(strings.ReplaceAll(tname, "const ", "")) + k := tname + "_t" + if symtab.contains(k) { + tname = symtab[k].replace(k) + } else if convname, ok := typemap[k]; ok { + tname = convname + } + vname, sz, ok = strings.Cut(remains, "[") + vname = us2camel(strings.TrimSpace(vname)) + fsb.WriteString("\t") + if ok { // is array + fsb.WriteString(vname) + fsb.WriteString(" [") + fsb.WriteString(sz) + fsb.WriteString("**") + fsb.WriteString(tname) + } else { + fsb.WriteString(vname) + fsb.WriteString(" **") + fsb.WriteString(tname) + } + default: + panic(fmt.Sprintf("%s L%d: unexpected statement %s", name, ln, stat)) + } + if c != "" { + fsb.WriteString("\t// ") + fsb.WriteString(strings.Replace(c, "/<", vname, 1)) + } + } + if len(lines) != 1 { + panic(fmt.Sprintf("%s L%d: unexpected len > 1 last lines %s", name, ln, strings.Join(lines, "\n"))) + } + if !strings.HasPrefix(lines[0], "}") { + panic(fmt.Sprintf("%s L%d: unexpected last line %s", name, ln, lines[0])) + } + sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";") + val := us2camel(strings.TrimSuffix(sname, "_t")) + checkSymbolName(symtab, ln, name, sname, val, sb, f, func() *symbol { + return newSymbolConst(sname, val, symbolSubTypeLargeStruct) + }) + f.WriteString("type ") + f.WriteString(val) + f.WriteString(" struct {") + _, _ = io.Copy(f, fsb) + f.WriteString("\n}\n\n") + return ln + case strings.Contains(lines[0], " enum "): + fsb := strings.Builder{} + iscontinouscomment := false + for i, stat := range lines[2:] { + if strings.HasPrefix(stat, "}") { + lines = lines[2+i:] + break + } + fsb.WriteString("\n") + if stat == "" { + continue + } + stat = strings.TrimSpace(stat) + if strings.HasPrefix(stat, "//") { + if !iscontinouscomment { + fsb.WriteString("\n") + } + fsb.WriteString("\t") + fsb.WriteString(stat) + iscontinouscomment = true + continue + } + if iscontinouscomment { + fsb.WriteString("\n") + } + iscontinouscomment = false + constval, comment, ok := strings.Cut(stat, "//") + if !ok { + panic(fmt.Sprintf("%s L%d: unexpected enum line %s", name, ln, stat)) + } + cname, _, _ := strings.Cut(constval, "=") + fsb.WriteString("\t") + fsb.WriteString(strings.TrimSuffix(strings.TrimSpace(constval), ",")) + fsb.WriteString("\t// ") + fsb.WriteString(strings.Replace(comment, "/<", strings.TrimSpace(cname), 1)) + } + if len(lines) != 1 { + panic(fmt.Sprintf("%s L%d: unexpected len > 1 last lines %s", name, ln, strings.Join(lines, "\n"))) + } + if !strings.HasPrefix(lines[0], "}") { + panic(fmt.Sprintf("%s L%d: unexpected last line %s", name, ln, lines[0])) + } + sname := strings.TrimSuffix(strings.TrimSpace(lines[0][1:]), ";") + val := us2camel(strings.TrimSuffix(sname, "_t")) + redirect := checkSymbolName(symtab, ln, name, sname, val, sb, f, func() *symbol { + return newSymbolConst(sname, val, symbolSubTypeEnum) + }) + replaces := "" + if !redirect { + f.WriteString("type ") + f.WriteString(val) + f.WriteString(" uintptr\nconst (") + replaces = " " + val + " =" + } else { + _, _ = f.Seek(-1, io.SeekCurrent) + f.WriteString("const (") + replaces = " " + val + "s =" + } + vars := strings.ReplaceAll(fsb.String(), " =", replaces) + if strings.Contains(vars, "(") { + vars = symtab.apply(vars) + } + f.WriteString(vars) + f.WriteString("\n)\n\n") + return ln + } + } + // single-line typedef, empty struct or type alias, replace with "type" statement + typs := trimEmptyStringArray(strings.Split(s[8:], " ")) + if len(typs) == 0 { + panic(fmt.Sprintf("%s L%d: unexpected single typdef line %s", name, ln, firstln)) + } + if strings.TrimSpace(typs[0]) == "struct" { + if len(typs) != 3 || !strings.Contains(typs[1], "handle_t") || + !strings.Contains(typs[2], "*") { + if symtab.contains(strings.TrimSuffix(typs[2], ";")) { + fmt.Printf("[warn] %s L%d: skip duplicated single typdef %s\n", name, ln, strings.Join(typs, "_____")) + } else { + fmt.Printf("[warn] %s L%d: skip future expected single typdef %s\n", name, ln, strings.Join(typs, "_____")) + } + return ln + } + typs = typs[1:] + typs[0] = "uintptr" + typs[1] = strings.TrimPrefix(strings.TrimSpace(typs[1]), "*") + } + if len(typs) != 2 { + panic(fmt.Sprintf("%s L%d: unexpected typdef line %s", name, ln, firstln)) + } + sname := strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(typs[1]), ";")) + val := us2camel(strings.TrimSuffix(sname, "_t")) + origtyp := strings.TrimSuffix(strings.TrimSpace(typs[0]), "_t") + checkSymbolName(symtab, ln, name, sname, val, sb, f, func() *symbol { + return newSymbolConst(sname, val, symbolSubTypeEmptyStruct) + }) + f.WriteString("type ") + f.WriteString(val) + f.WriteString(" ") + f.WriteString(origtyp) + f.WriteString("\n\n") + return ln +} + +func scanFunc( + name string, scan *bufio.Scanner, f *os.File, + ln int, symtab symbolTable, firstln string, sb *strings.Builder, +) int { + //TODO: register func + rettyp := strings.TrimSpace(firstln[13 : len(firstln)-11]) + rettyp = symtab.apply(strings.TrimSpace(rettyp)) + fnname, isfin := scanln(name, scan, &ln) + if isfin { + panic(fmt.Sprintf("%s L%d: unexpected early end func name line %s", name, ln, fnname)) + } + if !strings.HasSuffix(fnname, "(") { + panic(fmt.Sprintf("%s L%d: unexpected malformed func name line %s", name, ln, fnname)) + } + origfnname := strings.TrimSpace(fnname[:len(fnname)-1]) + fnname = origfnname + rf := []rune(fnname) + rf[0] = unicode.ToUpper(rf[0]) + fnname = string(rf) + if sb.Len() == 0 { + panic(fmt.Sprintf("%s L%d: unexpected non-comment for func %s", name, ln, fnname)) + } + brief := " " + fnname + f.WriteString(strings.Replace(sb.String(), "/ @brief", brief, 1)) + sb.Reset() + f.WriteString("func ") + f.WriteString(fnname) + f.WriteString("(") + argsb := strings.Builder{} + for { + argln, isfin := scanln(name, scan, &ln) + if isfin { + break + } + argln = strings.TrimSpace(argln) + if strings.HasPrefix(argln, "///< ") { + f.WriteString(argln[4:]) + continue + } + argtypnam, argcomment, ok := strings.Cut(argln, "//") + if !ok { + panic(fmt.Sprintf("%s L%d: unexpected non-comment func arg line %s", name, ln, argln)) + } + argtypnam = strings.TrimSpace(strings.TrimSuffix(strings.TrimSpace(argtypnam), ",")) + argcomment = strings.TrimSpace(argcomment) + i := strings.LastIndex(argtypnam, " ") + if i < 0 { + panic(fmt.Sprintf("%s L%d: unexpected short func arg line %s", name, ln, argln)) + } + argnam := strings.TrimSpace(argtypnam[i+1:]) + argsb.WriteString(", uintptr(") + argtyp := strings.TrimSpace(strings.ReplaceAll(argtypnam[:i], "const ", "")) + isp := strings.HasSuffix(argtyp, "*") // is pointer + convtyp, ok := typemap[argtyp] + if ok { + argtyp = convtyp + } + if isp { + if !ok { + argtyp = "*" + argtyp[:len(argtyp)-1] + } + argsb.WriteString("unsafe.Pointer(") + } else { + sym, ok := symtab[argtyp] + if ok && sym.sstype == symbolSubTypeLargeStruct && + !strings.HasPrefix(argnam, "p") { + isp = true + argtyp = "*" + argtyp + argcomment += " (gozel hack: converted to a hidden pointer from a struct value)" + argsb.WriteString("unsafe.Pointer(") + } + } + argsb.WriteString(argnam) + argsb.WriteString(")") + if isp { + argsb.WriteString(")") + } + f.WriteString("\n\t") + f.WriteString(argnam) + f.WriteString(" ") + f.WriteString(strings.TrimSuffix(symtab.apply(argtyp), "_t")) + f.WriteString(",") + f.WriteString("\t// ") + f.WriteString(strings.Replace(argcomment, "/<", argnam, 1)) + } + f.WriteString("\n) (") + f.WriteString(rettyp) + f.WriteString(", error) {\n\treturn zecall.Call[") + f.WriteString(rettyp) + f.WriteString("](\"") + f.WriteString(origfnname) + f.WriteString("\"") + f.WriteString(argsb.String()) + f.WriteString(")\n}\n\n") + return ln +} diff --git a/cmd/gen/symbol.go b/cmd/gen/symbol.go index 1e55c7d..d4e0aec 100644 --- a/cmd/gen/symbol.go +++ b/cmd/gen/symbol.go @@ -39,23 +39,35 @@ const ( symbolTypeFunc ) +type symbolSubType uintptr + +const ( + symbolSubTypeDefine symbolSubType = iota + symbolSubTypeEmptyStruct + symbolSubTypeLargeStruct + symbolSubTypeEnum +) + type symbol struct { stype symbolType + sstype symbolSubType name string fields []string } -func newSymbolConst(name, val string) *symbol { +func newSymbolConst(name, val string, sstype symbolSubType) *symbol { return &symbol{ stype: symbolTypeConst, + sstype: sstype, name: name, fields: []string{val}, } } -func newSymbolFunc(name, paras, evals string) *symbol { +func newSymbolFunc(name, paras, evals string, sstype symbolSubType) *symbol { return &symbol{ stype: symbolTypeFunc, + sstype: sstype, name: name, fields: []string{paras, evals}, } diff --git a/cmd/gen/utils.go b/cmd/gen/utils.go index cc927f6..6249c0b 100644 --- a/cmd/gen/utils.go +++ b/cmd/gen/utils.go @@ -3,6 +3,7 @@ package main import ( "bufio" "errors" + "fmt" "strings" "unicode" ) @@ -47,7 +48,7 @@ func getInsideRoundBrakets(txt string) (string, int, error) { } func get1sentence(firstln string, scan *bufio.Scanner, ln int) (string, int) { - if strings.Contains(firstln, ";") { + if strings.Contains(firstln, ";") && !strings.HasPrefix(strings.TrimSpace(firstln), "//") { return firstln, ln } bracedepth := 0 @@ -64,13 +65,25 @@ func get1sentence(firstln string, scan *bufio.Scanner, ln int) (string, int) { bracedepth-- } sb.WriteString(t) - if strings.Contains(t, ";") && bracedepth == 0 { + content, _, _ := strings.Cut(t, "//") + if strings.Contains(content, ";") && bracedepth == 0 { return sb.String(), ln } } return "", -1 } +func scanln(name string, scan *bufio.Scanner, ln *int) (s string, isfin bool) { + if !scan.Scan() { + panic(fmt.Sprintf("%s L%d: unexpected EOF", name, *ln)) + } + (*ln)++ + s = scan.Text() + content, _, _ := strings.Cut(s, "//") + isfin = strings.Contains(content, ";") + return +} + func us2camel(t string) string { sb := strings.Builder{} for s := range strings.SplitSeq(t, "_") { diff --git a/core/CacheLineSize.go b/core/CacheLineSize.go new file mode 100644 index 0000000..cf29b16 --- /dev/null +++ b/core/CacheLineSize.go @@ -0,0 +1,44 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" +) + +// ZE_CACHELINE_SIZE_EXT_NAME CacheLine Size Extension Name +const ZE_CACHELINE_SIZE_EXT_NAME = "ZE_extension_device_cache_line_size" + +// ZeDeviceCacheLineSizeExtVersion (ze_device_cache_line_size_ext_version_t) CacheLine Size Extension Version(s) +type ZeDeviceCacheLineSizeExtVersion uintptr +const ( + ZE_DEVICE_CACHE_LINE_SIZE_EXT_VERSION_1_0 ZeDeviceCacheLineSizeExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_DEVICE_CACHE_LINE_SIZE_EXT_VERSION_1_0 version 1.0 + ZE_DEVICE_CACHE_LINE_SIZE_EXT_VERSION_CURRENT ZeDeviceCacheLineSizeExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_DEVICE_CACHE_LINE_SIZE_EXT_VERSION_CURRENT latest known version + ZE_DEVICE_CACHE_LINE_SIZE_EXT_VERSION_FORCE_UINT32 ZeDeviceCacheLineSizeExtVersion = 0x7fffffff // ZE_DEVICE_CACHE_LINE_SIZE_EXT_VERSION_FORCE_UINT32 Value marking end of ZE_DEVICE_CACHE_LINE_SIZE_EXT_VERSION_* ENUMs + +) + +// ZeDeviceCacheLineSizeExt (ze_device_cache_line_size_ext_t) CacheLine Size queried using ::zeDeviceGetCacheProperties +/// +/// @details +/// - This structure may be returned from ::zeDeviceGetCacheProperties via +/// the `pNext` member of ::ze_device_cache_properties_t. +/// - Used for determining the cache line size supported on a device. +type ZeDeviceCacheLineSizeExt struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Cachelinesize uintptr // Cachelinesize [out] The cache line size in bytes. + +} + diff --git a/core/RTAS.go b/core/RTAS.go new file mode 100644 index 0000000..3973179 --- /dev/null +++ b/core/RTAS.go @@ -0,0 +1,458 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZE_RTAS_EXT_NAME Ray Tracing Acceleration Structure Extension Name +const ZE_RTAS_EXT_NAME = "ZE_extension_rtas" + +// ZeRtasBuilderExtVersion (ze_rtas_builder_ext_version_t) Ray Tracing Acceleration Structure Builder Extension Version(s) +type ZeRtasBuilderExtVersion uintptr +const ( + ZE_RTAS_BUILDER_EXT_VERSION_1_0 ZeRtasBuilderExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_RTAS_BUILDER_EXT_VERSION_1_0 version 1.0 + ZE_RTAS_BUILDER_EXT_VERSION_CURRENT ZeRtasBuilderExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_RTAS_BUILDER_EXT_VERSION_CURRENT latest known version + ZE_RTAS_BUILDER_EXT_VERSION_FORCE_UINT32 ZeRtasBuilderExtVersion = 0x7fffffff // ZE_RTAS_BUILDER_EXT_VERSION_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_EXT_VERSION_* ENUMs + +) + +// ZeRtasDeviceExtFlags (ze_rtas_device_ext_flags_t) Ray tracing acceleration structure device flags +type ZeRtasDeviceExtFlags uint32 +const ( + ZE_RTAS_DEVICE_EXT_FLAG_RESERVED ZeRtasDeviceExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RTAS_DEVICE_EXT_FLAG_RESERVED reserved for future use + ZE_RTAS_DEVICE_EXT_FLAG_FORCE_UINT32 ZeRtasDeviceExtFlags = 0x7fffffff // ZE_RTAS_DEVICE_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_RTAS_DEVICE_EXT_FLAG_* ENUMs + +) + +// ZeRtasFormatExt (ze_rtas_format_ext_t) Ray tracing acceleration structure format +/// +/// @details +/// - This is an opaque ray tracing acceleration structure format +/// identifier. +type ZeRtasFormatExt uintptr +const ( + ZE_RTAS_FORMAT_EXT_INVALID ZeRtasFormatExt = 0x0 // ZE_RTAS_FORMAT_EXT_INVALID Invalid acceleration structure format code + ZE_RTAS_FORMAT_EXT_MAX ZeRtasFormatExt = 0x7ffffffe // ZE_RTAS_FORMAT_EXT_MAX Maximum acceleration structure format code + ZE_RTAS_FORMAT_EXT_FORCE_UINT32 ZeRtasFormatExt = 0x7fffffff // ZE_RTAS_FORMAT_EXT_FORCE_UINT32 Value marking end of ZE_RTAS_FORMAT_EXT_* ENUMs + +) + +// ZeRtasBuilderExtFlags (ze_rtas_builder_ext_flags_t) Ray tracing acceleration structure builder flags +type ZeRtasBuilderExtFlags uint32 +const ( + ZE_RTAS_BUILDER_EXT_FLAG_RESERVED ZeRtasBuilderExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RTAS_BUILDER_EXT_FLAG_RESERVED Reserved for future use + ZE_RTAS_BUILDER_EXT_FLAG_FORCE_UINT32 ZeRtasBuilderExtFlags = 0x7fffffff // ZE_RTAS_BUILDER_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_EXT_FLAG_* ENUMs + +) + +// ZeRtasParallelOperationExtFlags (ze_rtas_parallel_operation_ext_flags_t) Ray tracing acceleration structure builder parallel operation flags +type ZeRtasParallelOperationExtFlags uint32 +const ( + ZE_RTAS_PARALLEL_OPERATION_EXT_FLAG_RESERVED ZeRtasParallelOperationExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RTAS_PARALLEL_OPERATION_EXT_FLAG_RESERVED Reserved for future use + ZE_RTAS_PARALLEL_OPERATION_EXT_FLAG_FORCE_UINT32 ZeRtasParallelOperationExtFlags = 0x7fffffff // ZE_RTAS_PARALLEL_OPERATION_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_RTAS_PARALLEL_OPERATION_EXT_FLAG_* ENUMs + +) + +// ZeRtasBuilderGeometryExtFlags (ze_rtas_builder_geometry_ext_flags_t) Ray tracing acceleration structure builder geometry flags +type ZeRtasBuilderGeometryExtFlags uint32 +const ( + ZE_RTAS_BUILDER_GEOMETRY_EXT_FLAG_NON_OPAQUE ZeRtasBuilderGeometryExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RTAS_BUILDER_GEOMETRY_EXT_FLAG_NON_OPAQUE non-opaque geometries invoke an any-hit shader + ZE_RTAS_BUILDER_GEOMETRY_EXT_FLAG_FORCE_UINT32 ZeRtasBuilderGeometryExtFlags = 0x7fffffff // ZE_RTAS_BUILDER_GEOMETRY_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_GEOMETRY_EXT_FLAG_* ENUMs + +) + +// ZeRtasBuilderPackedGeometryExtFlags (ze_rtas_builder_packed_geometry_ext_flags_t) Packed ray tracing acceleration structure builder geometry flags (see +/// ::ze_rtas_builder_geometry_ext_flags_t) +type ZeRtasBuilderPackedGeometryExtFlags uint8 + +// ZeRtasBuilderInstanceExtFlags (ze_rtas_builder_instance_ext_flags_t) Ray tracing acceleration structure builder instance flags +type ZeRtasBuilderInstanceExtFlags uint32 +const ( + ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_CULL_DISABLE ZeRtasBuilderInstanceExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_CULL_DISABLE disables culling of front-facing and back-facing triangles + ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE ZeRtasBuilderInstanceExtFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE reverses front and back face of triangles + ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_FORCE_OPAQUE ZeRtasBuilderInstanceExtFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_FORCE_OPAQUE forces instanced geometry to be opaque, unless ray flag forces it to + + ///< be non-opaque + + ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_FORCE_NON_OPAQUE ZeRtasBuilderInstanceExtFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_TRIANGLE_FORCE_NON_OPAQUE forces instanced geometry to be non-opaque, unless ray flag forces it + + ///< to be opaque + + ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_FORCE_UINT32 ZeRtasBuilderInstanceExtFlags = 0x7fffffff // ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_INSTANCE_EXT_FLAG_* ENUMs + +) + +// ZeRtasBuilderPackedInstanceExtFlags (ze_rtas_builder_packed_instance_ext_flags_t) Packed ray tracing acceleration structure builder instance flags (see +/// ::ze_rtas_builder_instance_ext_flags_t) +type ZeRtasBuilderPackedInstanceExtFlags uint8 + +// ZeRtasBuilderBuildOpExtFlags (ze_rtas_builder_build_op_ext_flags_t) Ray tracing acceleration structure builder build operation flags +/// +/// @details +/// - These flags allow the application to tune the acceleration structure +/// build operation. +/// - The acceleration structure builder implementation might choose to use +/// spatial splitting to split large or long primitives into smaller +/// pieces. This may result in any-hit shaders being invoked multiple +/// times for non-opaque primitives, unless +/// ::ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION is specified. +/// - Usage of any of these flags may reduce ray tracing performance. +type ZeRtasBuilderBuildOpExtFlags uint32 +const ( + ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_COMPACT ZeRtasBuilderBuildOpExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_COMPACT build more compact acceleration structure + ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION ZeRtasBuilderBuildOpExtFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION guarantees single any-hit shader invocation per primitive + ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_FORCE_UINT32 ZeRtasBuilderBuildOpExtFlags = 0x7fffffff // ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_BUILD_OP_EXT_FLAG_* ENUMs + +) + +// ZeRtasBuilderBuildQualityHintExt (ze_rtas_builder_build_quality_hint_ext_t) Ray tracing acceleration structure builder build quality hint +/// +/// @details +/// - Depending on use case different quality modes for acceleration +/// structure build are supported. +/// - A low-quality build builds an acceleration structure fast, but at the +/// cost of some reduction in ray tracing performance. This mode is +/// recommended for dynamic content, such as animated characters. +/// - A medium-quality build uses a compromise between build quality and ray +/// tracing performance. This mode should be used by default. +/// - Higher ray tracing performance can be achieved by using a high-quality +/// build, but acceleration structure build performance might be +/// significantly reduced. +type ZeRtasBuilderBuildQualityHintExt uintptr +const ( + ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_LOW ZeRtasBuilderBuildQualityHintExt = 0 // ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_LOW build low-quality acceleration structure (fast) + ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_MEDIUM ZeRtasBuilderBuildQualityHintExt = 1 // ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_MEDIUM build medium-quality acceleration structure (slower) + ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_HIGH ZeRtasBuilderBuildQualityHintExt = 2 // ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_HIGH build high-quality acceleration structure (slow) + ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_FORCE_UINT32 ZeRtasBuilderBuildQualityHintExt = 0x7fffffff // ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_BUILD_QUALITY_HINT_EXT_* ENUMs + +) + +// ZeRtasBuilderGeometryTypeExt (ze_rtas_builder_geometry_type_ext_t) Ray tracing acceleration structure builder geometry type +type ZeRtasBuilderGeometryTypeExt uintptr +const ( + ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_TRIANGLES ZeRtasBuilderGeometryTypeExt = 0 // ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_TRIANGLES triangle mesh geometry type + ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_QUADS ZeRtasBuilderGeometryTypeExt = 1 // ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_QUADS quad mesh geometry type + ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_PROCEDURAL ZeRtasBuilderGeometryTypeExt = 2 // ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_PROCEDURAL procedural geometry type + ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_INSTANCE ZeRtasBuilderGeometryTypeExt = 3 // ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_INSTANCE instance geometry type + ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_FORCE_UINT32 ZeRtasBuilderGeometryTypeExt = 0x7fffffff // ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_* ENUMs + +) + +// ZeRtasBuilderPackedGeometryTypeExt (ze_rtas_builder_packed_geometry_type_ext_t) Packed ray tracing acceleration structure builder geometry type (see +/// ::ze_rtas_builder_geometry_type_ext_t) +type ZeRtasBuilderPackedGeometryTypeExt uint8 + +// ZeRtasBuilderInputDataFormatExt (ze_rtas_builder_input_data_format_ext_t) Ray tracing acceleration structure data buffer element format +/// +/// @details +/// - Specifies the format of data buffer elements. +/// - Data buffers may contain instancing transform matrices, triangle/quad +/// vertex indices, etc... +type ZeRtasBuilderInputDataFormatExt uintptr +const ( + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3 ZeRtasBuilderInputDataFormatExt = 0 // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3 3-component float vector (see ::ze_rtas_float3_ext_t) + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3X4_COLUMN_MAJOR ZeRtasBuilderInputDataFormatExt = 1 // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3X4_COLUMN_MAJOR 3x4 affine transformation in column-major format (see + + ///< ::ze_rtas_transform_float3x4_column_major_ext_t) + + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3X4_ALIGNED_COLUMN_MAJOR ZeRtasBuilderInputDataFormatExt = 2 // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3X4_ALIGNED_COLUMN_MAJOR 3x4 affine transformation in column-major format (see + + ///< ::ze_rtas_transform_float3x4_aligned_column_major_ext_t) + + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3X4_ROW_MAJOR ZeRtasBuilderInputDataFormatExt = 3 // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3X4_ROW_MAJOR 3x4 affine transformation in row-major format (see + + ///< ::ze_rtas_transform_float3x4_row_major_ext_t) + + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_AABB ZeRtasBuilderInputDataFormatExt = 4 // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_AABB 3-dimensional axis-aligned bounding-box (see ::ze_rtas_aabb_ext_t) + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_TRIANGLE_INDICES_UINT32 ZeRtasBuilderInputDataFormatExt = 5 // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_TRIANGLE_INDICES_UINT32 Unsigned 32-bit triangle indices (see + + ///< ::ze_rtas_triangle_indices_uint32_ext_t) + + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_QUAD_INDICES_UINT32 ZeRtasBuilderInputDataFormatExt = 6 // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_QUAD_INDICES_UINT32 Unsigned 32-bit quad indices (see ::ze_rtas_quad_indices_uint32_ext_t) + ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FORCE_UINT32 ZeRtasBuilderInputDataFormatExt = 0x7fffffff // ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FORCE_UINT32 Value marking end of ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_* ENUMs + +) + +// ZeRtasBuilderPackedInputDataFormatExt (ze_rtas_builder_packed_input_data_format_ext_t) Packed ray tracing acceleration structure data buffer element format +/// (see ::ze_rtas_builder_input_data_format_ext_t) +type ZeRtasBuilderPackedInputDataFormatExt uint8 + +// ZeRtasBuilderExtHandle (ze_rtas_builder_ext_handle_t) Handle of ray tracing acceleration structure builder object +type ZeRtasBuilderExtHandle uintptr + +// ZeRtasParallelOperationExtHandle (ze_rtas_parallel_operation_ext_handle_t) Handle of ray tracing acceleration structure builder parallel +/// operation object +type ZeRtasParallelOperationExtHandle uintptr + +// ZeRtasBuilderExtDesc (ze_rtas_builder_ext_desc_t) Ray tracing acceleration structure builder descriptor +type ZeRtasBuilderExtDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Builderversion ZeRtasBuilderExtVersion // Builderversion [in] ray tracing acceleration structure builder version + +} + +// ZeRtasBuilderExtProperties (ze_rtas_builder_ext_properties_t) Ray tracing acceleration structure builder properties +type ZeRtasBuilderExtProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeRtasBuilderExtFlags // Flags [out] ray tracing acceleration structure builder flags + Rtasbuffersizebytesexpected uintptr // Rtasbuffersizebytesexpected [out] expected size (in bytes) required for acceleration structure buffer - When using an acceleration structure buffer of this size, the build is expected to succeed; however, it is possible that the build may fail with ::ZE_RESULT_EXT_RTAS_BUILD_RETRY + Rtasbuffersizebytesmaxrequired uintptr // Rtasbuffersizebytesmaxrequired [out] worst-case size (in bytes) required for acceleration structure buffer - When using an acceleration structure buffer of this size, the build is guaranteed to not run out of memory. + Scratchbuffersizebytes uintptr // Scratchbuffersizebytes [out] scratch buffer size (in bytes) required for acceleration structure build. + +} + +// ZeRtasParallelOperationExtProperties (ze_rtas_parallel_operation_ext_properties_t) Ray tracing acceleration structure builder parallel operation +/// properties +type ZeRtasParallelOperationExtProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeRtasParallelOperationExtFlags // Flags [out] ray tracing acceleration structure builder parallel operation flags + Maxconcurrency uint32 // Maxconcurrency [out] maximum number of threads that may join the parallel operation + +} + +// ZeRtasDeviceExtProperties (ze_rtas_device_ext_properties_t) Ray tracing acceleration structure device properties +/// +/// @details +/// - This structure may be passed to ::zeDeviceGetProperties, via `pNext` +/// member of ::ze_device_properties_t. +/// - The implementation shall populate `format` with a value other than +/// ::ZE_RTAS_FORMAT_EXT_INVALID when the device supports ray tracing. +type ZeRtasDeviceExtProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeRtasDeviceExtFlags // Flags [out] ray tracing acceleration structure device flags + Rtasformat ZeRtasFormatExt // Rtasformat [out] ray tracing acceleration structure format + Rtasbufferalignment uint32 // Rtasbufferalignment [out] required alignment of acceleration structure buffer + +} + +// ZeRtasFloat3Ext (ze_rtas_float3_ext_t) A 3-component vector type +type ZeRtasFloat3Ext struct { + X float32 // X [in] x-coordinate of float3 vector + Y float32 // Y [in] y-coordinate of float3 vector + Z float32 // Z [in] z-coordinate of float3 vector + +} + +// ZeRtasTransformFloat3x4ColumnMajorExt (ze_rtas_transform_float3x4_column_major_ext_t) 3x4 affine transformation in column-major layout +/// +/// @details +/// - A 3x4 affine transformation in column major layout, consisting of vectors +/// - vx=(vx_x, vx_y, vx_z), +/// - vy=(vy_x, vy_y, vy_z), +/// - vz=(vz_x, vz_y, vz_z), and +/// - p=(p_x, p_y, p_z) +/// - The transformation transforms a point (x, y, z) to: `x*vx + y*vy + +/// z*vz + p`. +type ZeRtasTransformFloat3x4ColumnMajorExt struct { + VxX float32 // VxX [in] element 0 of column 0 of 3x4 matrix + VxY float32 // VxY [in] element 1 of column 0 of 3x4 matrix + VxZ float32 // VxZ [in] element 2 of column 0 of 3x4 matrix + VyX float32 // VyX [in] element 0 of column 1 of 3x4 matrix + VyY float32 // VyY [in] element 1 of column 1 of 3x4 matrix + VyZ float32 // VyZ [in] element 2 of column 1 of 3x4 matrix + VzX float32 // VzX [in] element 0 of column 2 of 3x4 matrix + VzY float32 // VzY [in] element 1 of column 2 of 3x4 matrix + VzZ float32 // VzZ [in] element 2 of column 2 of 3x4 matrix + PX float32 // PX [in] element 0 of column 3 of 3x4 matrix + PY float32 // PY [in] element 1 of column 3 of 3x4 matrix + PZ float32 // PZ [in] element 2 of column 3 of 3x4 matrix + +} + +// ZeRtasTransformFloat3x4AlignedColumnMajorExt (ze_rtas_transform_float3x4_aligned_column_major_ext_t) 3x4 affine transformation in column-major layout with aligned column +/// vectors +/// +/// @details +/// - A 3x4 affine transformation in column major layout, consisting of vectors +/// - vx=(vx_x, vx_y, vx_z), +/// - vy=(vy_x, vy_y, vy_z), +/// - vz=(vz_x, vz_y, vz_z), and +/// - p=(p_x, p_y, p_z) +/// - The transformation transforms a point (x, y, z) to: `x*vx + y*vy + +/// z*vz + p`. +/// - The column vectors are aligned to 16-bytes and pad members are +/// ignored. +type ZeRtasTransformFloat3x4AlignedColumnMajorExt struct { + VxX float32 // VxX [in] element 0 of column 0 of 3x4 matrix + VxY float32 // VxY [in] element 1 of column 0 of 3x4 matrix + VxZ float32 // VxZ [in] element 2 of column 0 of 3x4 matrix + Pad0 float32 // Pad0 [in] ignored padding + VyX float32 // VyX [in] element 0 of column 1 of 3x4 matrix + VyY float32 // VyY [in] element 1 of column 1 of 3x4 matrix + VyZ float32 // VyZ [in] element 2 of column 1 of 3x4 matrix + Pad1 float32 // Pad1 [in] ignored padding + VzX float32 // VzX [in] element 0 of column 2 of 3x4 matrix + VzY float32 // VzY [in] element 1 of column 2 of 3x4 matrix + VzZ float32 // VzZ [in] element 2 of column 2 of 3x4 matrix + Pad2 float32 // Pad2 [in] ignored padding + PX float32 // PX [in] element 0 of column 3 of 3x4 matrix + PY float32 // PY [in] element 1 of column 3 of 3x4 matrix + PZ float32 // PZ [in] element 2 of column 3 of 3x4 matrix + Pad3 float32 // Pad3 [in] ignored padding + +} + +// ZeRtasTransformFloat3x4RowMajorExt (ze_rtas_transform_float3x4_row_major_ext_t) 3x4 affine transformation in row-major layout +/// +/// @details +/// - A 3x4 affine transformation in row-major layout, consisting of vectors +/// - vx=(vx_x, vx_y, vx_z), +/// - vy=(vy_x, vy_y, vy_z), +/// - vz=(vz_x, vz_y, vz_z), and +/// - p=(p_x, p_y, p_z) +/// - The transformation transforms a point (x, y, z) to: `x*vx + y*vy + +/// z*vz + p`. +type ZeRtasTransformFloat3x4RowMajorExt struct { + VxX float32 // VxX [in] element 0 of row 0 of 3x4 matrix + VyX float32 // VyX [in] element 1 of row 0 of 3x4 matrix + VzX float32 // VzX [in] element 2 of row 0 of 3x4 matrix + PX float32 // PX [in] element 3 of row 0 of 3x4 matrix + VxY float32 // VxY [in] element 0 of row 1 of 3x4 matrix + VyY float32 // VyY [in] element 1 of row 1 of 3x4 matrix + VzY float32 // VzY [in] element 2 of row 1 of 3x4 matrix + PY float32 // PY [in] element 3 of row 1 of 3x4 matrix + VxZ float32 // VxZ [in] element 0 of row 2 of 3x4 matrix + VyZ float32 // VyZ [in] element 1 of row 2 of 3x4 matrix + VzZ float32 // VzZ [in] element 2 of row 2 of 3x4 matrix + PZ float32 // PZ [in] element 3 of row 2 of 3x4 matrix + +} + +// ZeRtasAabbExt (ze_rtas_aabb_ext_t) A 3-dimensional axis-aligned bounding-box with lower and upper bounds +/// in each dimension +type ZeRtasAabbExt struct { + Lower ZeRtasFloat3Ext // Lower [in] lower bounds of AABB + Upper ZeRtasFloat3Ext // Upper [in] upper bounds of AABB + +} + +// ZeRtasTriangleIndicesUint32Ext (ze_rtas_triangle_indices_uint32_ext_t) Triangle represented using 3 vertex indices +/// +/// @details +/// - Represents a triangle using 3 vertex indices that index into a vertex +/// array that needs to be provided together with the index array. +/// - The linear barycentric u/v parametrization of the triangle is defined as: +/// - (u=0, v=0) at v0, +/// - (u=1, v=0) at v1, and +/// - (u=0, v=1) at v2 +type ZeRtasTriangleIndicesUint32Ext struct { + V0 uint32 // V0 [in] first index pointing to the first triangle vertex in vertex array + V1 uint32 // V1 [in] second index pointing to the second triangle vertex in vertex array + V2 uint32 // V2 [in] third index pointing to the third triangle vertex in vertex array + +} + +// ZeRtasQuadIndicesUint32Ext (ze_rtas_quad_indices_uint32_ext_t) Quad represented using 4 vertex indices +/// +/// @details +/// - Represents a quad composed of 4 indices that index into a vertex array +/// that needs to be provided together with the index array. +/// - A quad is a triangle pair represented using 4 vertex indices v0, v1, +/// v2, v3. +/// The first triangle is made out of indices v0, v1, v3 and the second triangle +/// from indices v2, v3, v1. The piecewise linear barycentric u/v parametrization +/// of the quad is defined as: +/// - (u=0, v=0) at v0, +/// - (u=1, v=0) at v1, +/// - (u=0, v=1) at v3, and +/// - (u=1, v=1) at v2 +/// This is achieved by correcting the u'/v' coordinates of the second +/// triangle by +/// *u = 1-u'* and *v = 1-v'*, yielding a piecewise linear parametrization. +type ZeRtasQuadIndicesUint32Ext struct { + V0 uint32 // V0 [in] first index pointing to the first quad vertex in vertex array + V1 uint32 // V1 [in] second index pointing to the second quad vertex in vertex array + V2 uint32 // V2 [in] third index pointing to the third quad vertex in vertex array + V3 uint32 // V3 [in] fourth index pointing to the fourth quad vertex in vertex array + +} + +// ZeRtasBuilderGeometryInfoExt (ze_rtas_builder_geometry_info_ext_t) Ray tracing acceleration structure builder geometry info +type ZeRtasBuilderGeometryInfoExt struct { + Geometrytype ZeRtasBuilderPackedGeometryTypeExt // Geometrytype [in] geometry type + +} + +// ZeRtasBuilderTrianglesGeometryInfoExt (ze_rtas_builder_triangles_geometry_info_ext_t) Ray tracing acceleration structure builder triangle mesh geometry info +/// +/// @details +/// - The linear barycentric u/v parametrization of the triangle is defined as: +/// - (u=0, v=0) at v0, +/// - (u=1, v=0) at v1, and +/// - (u=0, v=1) at v2 +type ZeRtasBuilderTrianglesGeometryInfoExt struct { + Geometrytype ZeRtasBuilderPackedGeometryTypeExt // Geometrytype [in] geometry type, must be ::ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_TRIANGLES + Geometryflags ZeRtasBuilderPackedGeometryExtFlags // Geometryflags [in] 0 or some combination of ::ze_rtas_builder_geometry_ext_flag_t bits representing the geometry flags for all primitives of this geometry + Geometrymask uint8 // Geometrymask [in] 8-bit geometry mask for ray masking + Triangleformat ZeRtasBuilderPackedInputDataFormatExt // Triangleformat [in] format of triangle buffer data, must be ::ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_TRIANGLE_INDICES_UINT32 + Vertexformat ZeRtasBuilderPackedInputDataFormatExt // Vertexformat [in] format of vertex buffer data, must be ::ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3 + Trianglecount uint32 // Trianglecount [in] number of triangles in triangle buffer + Vertexcount uint32 // Vertexcount [in] number of vertices in vertex buffer + Trianglestride uint32 // Trianglestride [in] stride (in bytes) of triangles in triangle buffer + Vertexstride uint32 // Vertexstride [in] stride (in bytes) of vertices in vertex buffer + Ptrianglebuffer unsafe.Pointer // Ptrianglebuffer [in] pointer to array of triangle indices in specified format + Pvertexbuffer unsafe.Pointer // Pvertexbuffer [in] pointer to array of triangle vertices in specified format + +} + +// ZeRtasBuilderQuadsGeometryInfoExt (ze_rtas_builder_quads_geometry_info_ext_t) Ray tracing acceleration structure builder quad mesh geometry info +/// +/// @details +/// - A quad is a triangle pair represented using 4 vertex indices v0, v1, +/// v2, v3. +/// The first triangle is made out of indices v0, v1, v3 and the second triangle +/// from indices v2, v3, v1. The piecewise linear barycentric u/v parametrization +/// of the quad is defined as: +/// - (u=0, v=0) at v0, +/// - (u=1, v=0) at v1, +/// - (u=0, v=1) at v3, and +/// - (u=1, v=1) at v2 +/// This is achieved by correcting the u'/v' coordinates of the second +/// triangle by +/// *u = 1-u'* and *v = 1-v'*, yielding a piecewise linear parametrization. +type ZeRtasBuilderQuadsGeometryInfoExt struct { + Geometrytype ZeRtasBuilderPackedGeometryTypeExt // Geometrytype [in] geometry type, must be ::ZE_RTAS_BUILDER_GEOMETRY_TYPE_EXT_QUADS + Geometryflags ZeRtasBuilderPackedGeometryExtFlags // Geometryflags [in] 0 or some combination of ::ze_rtas_builder_geometry_ext_flag_t bits representing the geometry flags for all primitives of this geometry + Geometrymask uint8 // Geometrymask [in] 8-bit geometry mask for ray masking + Quadformat ZeRtasBuilderPackedInputDataFormatExt // Quadformat [in] format of quad buffer data, must be ::ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_QUAD_INDICES_UINT32 + Vertexformat ZeRtasBuilderPackedInputDataFormatExt // Vertexformat [in] format of vertex buffer data, must be ::ZE_RTAS_BUILDER_INPUT_DATA_FORMAT_EXT_FLOAT3 + Quadcount uint32 // Quadcount [in] number of quads in quad buffer + Vertexcount uint32 // Vertexcount [in] number of vertices in vertex buffer + Quadstride uint32 // Quadstride [in] stride (in bytes) of quads in quad buffer + Vertexstride uint32 // Vertexstride [in] stride (in bytes) of vertices in vertex buffer + Pquadbuffer unsafe.Pointer // Pquadbuffer [in] pointer to array of quad indices in specified format + Pvertexbuffer unsafe.Pointer // Pvertexbuffer [in] pointer to array of quad vertices in specified format + +} + +// ZeRtasGeometryAabbsExtCbParams (ze_rtas_geometry_aabbs_ext_cb_params_t) AABB callback function parameters +type ZeRtasGeometryAabbsExtCbParams struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Primid uint32 // Primid [in] first primitive to return bounds for + Primidcount uint32 // Primidcount [in] number of primitives to return bounds for + Pgeomuserptr unsafe.Pointer // Pgeomuserptr [in] pointer provided through geometry descriptor + Pbuilduserptr unsafe.Pointer // Pbuilduserptr [in] pointer provided through ::zeRTASBuilderBuildExt function + Pboundsout *ZeRtasAabbExt // Pboundsout [out] destination buffer to write AABB bounds to + +} + diff --git a/core/barrier.go b/core/barrier.go new file mode 100644 index 0000000..85b621a --- /dev/null +++ b/core/barrier.go @@ -0,0 +1,155 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeCommandListAppendBarrier Appends an execution and global memory barrier into a command list. +/// +/// @details +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - If numWaitEvents is zero, then all previous commands, enqueued on same +/// command queue, must complete prior to the execution of the barrier. +/// This is not the case when numWaitEvents is non-zero. +/// - If numWaitEvents is non-zero, then only all phWaitEvents must be +/// signaled prior to the execution of the barrier. +/// - This command blocks all following commands from beginning until the +/// execution of the barrier completes. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **vkCmdPipelineBarrier** +/// - clEnqueueBarrierWithWaitList +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendBarrier( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before executing barrier; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before executing barrier +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendBarrier", uintptr(hCommandList), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendMemoryRangesBarrier Appends a global memory ranges barrier into a command list. +/// +/// @details +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - If numWaitEvents is zero, then all previous commands are completed +/// prior to the execution of the barrier. +/// - If numWaitEvents is non-zero, then then all phWaitEvents must be +/// signaled prior to the execution of the barrier. +/// - This command blocks all following commands from beginning until the +/// execution of the barrier completes. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pRangeSizes` +/// + `nullptr == pRanges` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendMemoryRangesBarrier( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + numRanges uint32, // numRanges [in] number of memory ranges + pRangeSizes *uintptr, // pRangeSizes [in][range(0, numRanges)] array of sizes of memory range + pRanges *unsafe.Pointer, // pRanges [in][range(0, numRanges)] array of memory ranges + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before executing barrier; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before executing barrier +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendMemoryRangesBarrier", uintptr(hCommandList), uintptr(numRanges), uintptr(unsafe.Pointer(pRangeSizes)), uintptr(unsafe.Pointer(pRanges)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeContextSystemBarrier Ensures in-bound writes to the device are globally observable. +/// +/// @details +/// - This is a special-case system level barrier that can be used to ensure +/// global observability of writes; +/// typically needed after a producer (e.g., NIC) performs direct writes +/// to the device's memory (e.g., Direct RDMA writes). +/// This is typically required when the memory corresponding to the writes +/// is subsequently accessed from a remote device. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +func ZeContextSystemBarrier( + hContext ZeContextHandle, // hContext [in] handle of context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextSystemBarrier", uintptr(hContext), uintptr(hDevice)) +} + diff --git a/core/cmdlist.go b/core/cmdlist.go new file mode 100644 index 0000000..b774823 --- /dev/null +++ b/core/cmdlist.go @@ -0,0 +1,517 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeCommandListFlags (ze_command_list_flags_t) Supported command list creation flags +type ZeCommandListFlags uint32 +const ( + ZE_COMMAND_LIST_FLAG_RELAXED_ORDERING ZeCommandListFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_COMMAND_LIST_FLAG_RELAXED_ORDERING driver may reorder commands (e.g., kernels, copies) between barriers + + ///< and synchronization primitives. + ///< using this flag may increase Host overhead of ::zeCommandListClose. + ///< therefore, this flag should **not** be set for low-latency usage-models. + + ZE_COMMAND_LIST_FLAG_MAXIMIZE_THROUGHPUT ZeCommandListFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_COMMAND_LIST_FLAG_MAXIMIZE_THROUGHPUT driver may perform additional optimizations that increase execution + + ///< throughput. + ///< using this flag may increase Host overhead of ::zeCommandListClose and ::zeCommandQueueExecuteCommandLists. + ///< therefore, this flag should **not** be set for low-latency usage-models. + + ZE_COMMAND_LIST_FLAG_EXPLICIT_ONLY ZeCommandListFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_COMMAND_LIST_FLAG_EXPLICIT_ONLY command list should be optimized for submission to a single command + + ///< queue and device engine. + ///< driver **must** disable any implicit optimizations for distributing + ///< work across multiple engines. + ///< this flag should be used when applications want full control over + ///< multi-engine submission and scheduling. + ///< This flag is **DEPRECATED** and implementations are not expected to + ///< support this feature. + + ZE_COMMAND_LIST_FLAG_IN_ORDER ZeCommandListFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_COMMAND_LIST_FLAG_IN_ORDER commands appended to this command list are executed in-order, with + + ///< driver implementation + ///< enforcing dependencies between them. Application is not required to + ///< have the signal event + ///< of a given command being the wait event of the next to define an + ///< in-order list, and + ///< application is allowed to pass signal and wait events to each appended + ///< command to implement + ///< more complex dependency graphs. Cannot be combined with ::ZE_COMMAND_LIST_FLAG_RELAXED_ORDERING. + + ZE_COMMAND_LIST_FLAG_EXP_CLONEABLE ZeCommandListFlags = /* ZE_BIT(4) */(( 1 << 4 )) // ZE_COMMAND_LIST_FLAG_EXP_CLONEABLE this command list may be cloned using ::zeCommandListCreateCloneExp + + ///< after ::zeCommandListClose. + + ZE_COMMAND_LIST_FLAG_COPY_OFFLOAD_HINT ZeCommandListFlags = /* ZE_BIT(5) */(( 1 << 5 )) // ZE_COMMAND_LIST_FLAG_COPY_OFFLOAD_HINT Try to offload copy operations to different engines. Applicable only + + ///< for compute queues. + ///< This is only a hint. Driver may ignore it per append call, based on + ///< platform capabilities or internal heuristics. + + ZE_COMMAND_LIST_FLAG_FORCE_UINT32 ZeCommandListFlags = 0x7fffffff // ZE_COMMAND_LIST_FLAG_FORCE_UINT32 Value marking end of ZE_COMMAND_LIST_FLAG_* ENUMs + +) + +// ZeCommandListDesc (ze_command_list_desc_t) Command List descriptor +type ZeCommandListDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Commandqueuegroupordinal uint32 // Commandqueuegroupordinal [in] command queue group ordinal to which this command list will be submitted + Flags ZeCommandListFlags // Flags [in] usage flags. must be 0 (default) or a valid combination of ::ze_command_list_flag_t; default behavior may use implicit driver-based heuristics to balance latency and throughput. + +} + +// ZeCommandListCreate Creates a command list on the context. +/// +/// @details +/// - A command list represents a sequence of commands for execution on a +/// command queue. +/// - The command list is created in the 'open' state. +/// - The application must only use the command list for the device, or its +/// sub-devices, which was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3f < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeCommandListCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object + desc *ZeCommandListDesc, // desc [in] pointer to command list descriptor + phCommandList *ZeCommandListHandle, // phCommandList [out] pointer to handle of command list object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListCreate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phCommandList))) +} + +// ZeCommandListCreateImmediate Creates an immediate command list on the context. +/// +/// @details +/// - An immediate command list is used for low-latency submission of +/// commands. +/// - An immediate command list creates an implicit command queue. +/// - Immediate command lists must not be passed to +/// ::zeCommandQueueExecuteCommandLists. +/// - Commands appended into an immediate command list may execute +/// synchronously, by blocking until the command is complete. +/// - The command list is created in the 'open' state and never needs to be +/// closed. +/// - The application must only use the command list for the device, or its +/// sub-devices, which was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == altdesc` +/// + `nullptr == phCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x7 < altdesc->flags` +/// + `::ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS < altdesc->mode` +/// + `::ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH < altdesc->priority` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeCommandListCreateImmediate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object + altdesc *ZeCommandQueueDesc, // altdesc [in] pointer to command queue descriptor + phCommandList *ZeCommandListHandle, // phCommandList [out] pointer to handle of command list object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListCreateImmediate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(altdesc)), uintptr(unsafe.Pointer(phCommandList))) +} + +// ZeCommandListDestroy Destroys a command list. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the command list before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this command list. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeCommandListDestroy( + hCommandList ZeCommandListHandle, // hCommandList [in][release] handle of command list object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListDestroy", uintptr(hCommandList)) +} + +// ZeCommandListClose Closes a command list; ready to be executed by a command queue. +/// +/// @details +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +func ZeCommandListClose( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list object to close +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListClose", uintptr(hCommandList)) +} + +// ZeCommandListReset Reset a command list to initial (empty) state; ready for appending +/// commands. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the command list before it is reset +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +func ZeCommandListReset( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list object to reset +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListReset", uintptr(hCommandList)) +} + +// ZeCommandListAppendWriteGlobalTimestamp Appends a memory write of the device's global timestamp value into a +/// command list. +/// +/// @details +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The timestamp frequency can be queried from the `timerResolution` +/// member of ::ze_device_properties_t. +/// - The number of valid bits in the timestamp value can be queried from +/// the `timestampValidBits` member of ::ze_device_properties_t. +/// - The application must ensure the memory pointed to by dstptr is +/// accessible by the device on which the command list was created. +/// - The application must ensure the command list and events were created, +/// and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == dstptr` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendWriteGlobalTimestamp( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + dstptr *uint64, // dstptr [in,out] pointer to memory where timestamp value will be written; must be 8byte-aligned. + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before executing query; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before executing query +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendWriteGlobalTimestamp", uintptr(hCommandList), uintptr(unsafe.Pointer(dstptr)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListHostSynchronize Synchronizes an immediate command list by waiting on the host for the +/// completion of all commands previously submitted to it. +/// +/// @details +/// - The application must call this function only with command lists +/// created with ::zeCommandListCreateImmediate. +/// - Waiting on one immediate command list shall not block the concurrent +/// execution of commands appended to other +/// immediate command lists created with either a different ordinal or +/// different index. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_NOT_READY +/// + timeout expired +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + handle does not correspond to an immediate command list +func ZeCommandListHostSynchronize( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the immediate command list + timeout uint64, // timeout [in] if non-zero, then indicates the maximum time (in nanoseconds) to yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; if zero, then immediately returns the status of the immediate command list; if `UINT64_MAX`, then function will not return until complete or device is lost. Due to external dependencies, timeout may be rounded to the closest value allowed by the accuracy of those dependencies. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListHostSynchronize", uintptr(hCommandList), uintptr(timeout)) +} + +// ZeCommandListGetDeviceHandle Gets the handle of the device on which the command list was created. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phDevice` +func ZeCommandListGetDeviceHandle( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + phDevice *ZeDeviceHandle, // phDevice [out] handle of the device on which the command list was created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListGetDeviceHandle", uintptr(hCommandList), uintptr(unsafe.Pointer(phDevice))) +} + +// ZeCommandListGetContextHandle Gets the handle of the context on which the command list was created. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phContext` +func ZeCommandListGetContextHandle( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + phContext *ZeContextHandle, // phContext [out] handle of the context on which the command list was created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListGetContextHandle", uintptr(hCommandList), uintptr(unsafe.Pointer(phContext))) +} + +// ZeCommandListGetOrdinal Gets the command queue group ordinal to which the command list is +/// submitted. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pOrdinal` +func ZeCommandListGetOrdinal( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + pOrdinal *uint32, // pOrdinal [out] command queue group ordinal to which command list is submitted +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListGetOrdinal", uintptr(hCommandList), uintptr(unsafe.Pointer(pOrdinal))) +} + +// ZeCommandListImmediateGetIndex Gets the command queue index within the group to which the immediate +/// command list is submitted. +/// +/// @details +/// - The application must call this function only with command lists +/// created with ::zeCommandListCreateImmediate. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_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_HANDLE +/// + `nullptr == hCommandListImmediate` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pIndex` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + handle does not correspond to an immediate command list +func ZeCommandListImmediateGetIndex( + hCommandListImmediate ZeCommandListHandle, // hCommandListImmediate [in] handle of the immediate command list + pIndex *uint32, // pIndex [out] command queue index within the group to which the immediate command list is submitted +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListImmediateGetIndex", uintptr(hCommandListImmediate), uintptr(unsafe.Pointer(pIndex))) +} + +// ZeCommandListIsImmediate Query whether a command list is an immediate command list. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pIsImmediate` +func ZeCommandListIsImmediate( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + pIsImmediate *ZeBool, // pIsImmediate [out] Boolean indicating whether the command list is an immediate command list (true) or not (false) +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListIsImmediate", uintptr(hCommandList), uintptr(unsafe.Pointer(pIsImmediate))) +} + diff --git a/core/cmdqueue.go b/core/cmdqueue.go new file mode 100644 index 0000000..ecc0b27 --- /dev/null +++ b/core/cmdqueue.go @@ -0,0 +1,330 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeCommandQueueFlags (ze_command_queue_flags_t) Supported command queue flags +type ZeCommandQueueFlags uint32 +const ( + ZE_COMMAND_QUEUE_FLAG_EXPLICIT_ONLY ZeCommandQueueFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_COMMAND_QUEUE_FLAG_EXPLICIT_ONLY command queue should be optimized for submission to a single device engine. + + ///< driver **must** disable any implicit optimizations for distributing + ///< work across multiple engines. + ///< this flag should be used when applications want full control over + ///< multi-engine submission and scheduling. + ///< This flag is **DEPRECATED** as flag + ///< ${X}_COMMAND_LIST_FLAG_EXPLICIT_ONLY is **DEPRECATED**. + + ZE_COMMAND_QUEUE_FLAG_IN_ORDER ZeCommandQueueFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_COMMAND_QUEUE_FLAG_IN_ORDER To be used only when creating immediate command lists. Commands + + ///< appended to the immediate command + ///< list are executed in-order, with driver implementation enforcing + ///< dependencies between them. + ///< Application is not required to have the signal event of a given + ///< command being the wait event of + ///< the next to define an in-order list, and application is allowed to + ///< pass signal and wait events + ///< to each appended command to implement more complex dependency graphs. + + ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT ZeCommandQueueFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_COMMAND_QUEUE_FLAG_COPY_OFFLOAD_HINT To be used only when creating immediate command lists and only for + + ///< compute queues. + ///< Try to offload copy operations to different engines. This is only a hint. + ///< Driver may ignore it per append call, based on platform capabilities + ///< or internal heuristics. + + ZE_COMMAND_QUEUE_FLAG_FORCE_UINT32 ZeCommandQueueFlags = 0x7fffffff // ZE_COMMAND_QUEUE_FLAG_FORCE_UINT32 Value marking end of ZE_COMMAND_QUEUE_FLAG_* ENUMs + +) + +// ZeCommandQueueMode (ze_command_queue_mode_t) Supported command queue modes +type ZeCommandQueueMode uintptr +const ( + ZE_COMMAND_QUEUE_MODE_DEFAULT ZeCommandQueueMode = 0 // ZE_COMMAND_QUEUE_MODE_DEFAULT implicit default behavior; uses driver-based heuristics + ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS ZeCommandQueueMode = 1 // ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS Device execution always completes immediately on execute; + + ///< Host thread is blocked using wait on implicit synchronization object + + ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS ZeCommandQueueMode = 2 // ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS Device execution is scheduled and will complete in future; + + ///< explicit synchronization object must be used to determine completeness + + ZE_COMMAND_QUEUE_MODE_FORCE_UINT32 ZeCommandQueueMode = 0x7fffffff // ZE_COMMAND_QUEUE_MODE_FORCE_UINT32 Value marking end of ZE_COMMAND_QUEUE_MODE_* ENUMs + +) + +// ZeCommandQueuePriority (ze_command_queue_priority_t) Supported command queue priorities +type ZeCommandQueuePriority uintptr +const ( + ZE_COMMAND_QUEUE_PRIORITY_NORMAL ZeCommandQueuePriority = 0 // ZE_COMMAND_QUEUE_PRIORITY_NORMAL [default] normal priority + ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW ZeCommandQueuePriority = 1 // ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW lower priority than normal + ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH ZeCommandQueuePriority = 2 // ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH higher priority than normal + ZE_COMMAND_QUEUE_PRIORITY_FORCE_UINT32 ZeCommandQueuePriority = 0x7fffffff // ZE_COMMAND_QUEUE_PRIORITY_FORCE_UINT32 Value marking end of ZE_COMMAND_QUEUE_PRIORITY_* ENUMs + +) + +// ZeCommandQueueDesc (ze_command_queue_desc_t) Command Queue descriptor +type ZeCommandQueueDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Ordinal uint32 // Ordinal [in] command queue group ordinal + Index uint32 // Index [in] command queue index within the group; must be zero. + Flags ZeCommandQueueFlags // Flags [in] usage flags. must be 0 (default) or a valid combination of ::ze_command_queue_flag_t; default behavior may use implicit driver-based heuristics to balance latency and throughput. + Mode ZeCommandQueueMode // Mode [in] operation mode + Priority ZeCommandQueuePriority // Priority [in] priority + +} + +// ZeCommandQueueCreate Creates a command queue on the context. +/// +/// @details +/// - A command queue represents a logical input stream to the device, tied +/// to a physical input stream. +/// - The application must only use the command queue for the device, or its +/// sub-devices, which was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @remarks +/// _Analogues_ +/// - **clCreateCommandQueue** +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phCommandQueue` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x7 < desc->flags` +/// + `::ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS < desc->mode` +/// + `::ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH < desc->priority` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeCommandQueueCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object + desc *ZeCommandQueueDesc, // desc [in] pointer to command queue descriptor + phCommandQueue *ZeCommandQueueHandle, // phCommandQueue [out] pointer to handle of command queue object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandQueueCreate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phCommandQueue))) +} + +// ZeCommandQueueDestroy Destroys a command queue. +/// +/// @details +/// - The application must destroy all fence handles created from the +/// command queue before destroying the command queue itself +/// - The application must ensure the device is not currently referencing +/// the command queue before it is deleted +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this command queue +/// - The application must **not** call this function from simultaneous +/// threads with the same command queue handle. +/// - The implementation of this function must be thread-safe. +/// +/// @remarks +/// _Analogues_ +/// - **clReleaseCommandQueue** +/// +/// @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_HANDLE +/// + `nullptr == hCommandQueue` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeCommandQueueDestroy( + hCommandQueue ZeCommandQueueHandle, // hCommandQueue [in][release] handle of command queue object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandQueueDestroy", uintptr(hCommandQueue)) +} + +// ZeCommandQueueExecuteCommandLists Executes a command list in a command queue. +/// +/// @details +/// - The command lists are submitted to the device in the order they are +/// received, whether from multiple calls (on the same or different +/// threads) or a single call with multiple command lists. +/// - The application must ensure the command lists are accessible by the +/// device on which the command queue was created. +/// - The application must ensure the device is not currently referencing +/// the command list since the implementation is allowed to modify the +/// contents of the command list for submission. +/// - The application must only execute command lists created with an +/// identical command queue group ordinal to the command queue. +/// - The application must use a fence created using the same command queue. +/// - The application must ensure the command queue, command list and fence +/// were created on the same context. +/// - The application must ensure the command lists being executed are not +/// immediate command lists. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - vkQueueSubmit +/// +/// @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_HANDLE +/// + `nullptr == hCommandQueue` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phCommandLists` +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `0 == numCommandLists` +/// - ::ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeCommandQueueExecuteCommandLists( + hCommandQueue ZeCommandQueueHandle, // hCommandQueue [in] handle of the command queue + numCommandLists uint32, // numCommandLists [in] number of command lists to execute + phCommandLists *ZeCommandListHandle, // phCommandLists [in][range(0, numCommandLists)] list of handles of the command lists to execute + hFence ZeFenceHandle, // hFence [in][optional] handle of the fence to signal on completion +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandQueueExecuteCommandLists", uintptr(hCommandQueue), uintptr(numCommandLists), uintptr(unsafe.Pointer(phCommandLists)), uintptr(hFence)) +} + +// ZeCommandQueueSynchronize Synchronizes a command queue by waiting on the host. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandQueue` +/// - ::ZE_RESULT_NOT_READY +/// + timeout expired +func ZeCommandQueueSynchronize( + hCommandQueue ZeCommandQueueHandle, // hCommandQueue [in] handle of the command queue + timeout uint64, // timeout [in] if non-zero, then indicates the maximum time (in nanoseconds) to yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; if zero, then immediately returns the status of the command queue; if `UINT64_MAX`, then function will not return until complete or device is lost. Due to external dependencies, timeout may be rounded to the closest value allowed by the accuracy of those dependencies. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandQueueSynchronize", uintptr(hCommandQueue), uintptr(timeout)) +} + +// ZeCommandQueueGetOrdinal Gets the command queue group ordinal. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandQueue` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pOrdinal` +func ZeCommandQueueGetOrdinal( + hCommandQueue ZeCommandQueueHandle, // hCommandQueue [in] handle of the command queue + pOrdinal *uint32, // pOrdinal [out] command queue group ordinal +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandQueueGetOrdinal", uintptr(hCommandQueue), uintptr(unsafe.Pointer(pOrdinal))) +} + +// ZeCommandQueueGetIndex Gets the command queue index within the group. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandQueue` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pIndex` +func ZeCommandQueueGetIndex( + hCommandQueue ZeCommandQueueHandle, // hCommandQueue [in] handle of the command queue + pIndex *uint32, // pIndex [out] command queue index within the group +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandQueueGetIndex", uintptr(hCommandQueue), uintptr(unsafe.Pointer(pIndex))) +} + diff --git a/core/context.go b/core/context.go new file mode 100644 index 0000000..fdb172c --- /dev/null +++ b/core/context.go @@ -0,0 +1,182 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeContextFlags (ze_context_flags_t) Supported context creation flags +type ZeContextFlags uint32 +const ( + ZE_CONTEXT_FLAG_TBD ZeContextFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_CONTEXT_FLAG_TBD reserved for future use + ZE_CONTEXT_FLAG_FORCE_UINT32 ZeContextFlags = 0x7fffffff // ZE_CONTEXT_FLAG_FORCE_UINT32 Value marking end of ZE_CONTEXT_FLAG_* ENUMs + +) + +// ZeContextDesc (ze_context_desc_t) Context descriptor +type ZeContextDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeContextFlags // Flags [in] creation flags. must be 0 (default) or a valid combination of ::ze_context_flag_t; default behavior may use implicit driver-based heuristics. + +} + +// ZeContextCreate Creates a context for the driver. +/// +/// @details +/// - The application must only use the context for the driver which was +/// provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phContext` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x1 < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeContextCreate( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver object + desc *ZeContextDesc, // desc [in] pointer to context descriptor + phContext *ZeContextHandle, // phContext [out] pointer to handle of context object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextCreate", uintptr(hDriver), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phContext))) +} + +// ZeContextCreateEx Creates a context for the driver. +/// +/// @details +/// - The application must only use the context for the driver which was +/// provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phContext` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x1 < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phDevices) && (0 < numDevices)` +func ZeContextCreateEx( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver object + desc *ZeContextDesc, // desc [in] pointer to context descriptor + numDevices uint32, // numDevices [in][optional] number of device handles; must be 0 if `nullptr == phDevices` + phDevices *ZeDeviceHandle, // phDevices [in][optional][range(0, numDevices)] array of device handles which context has visibility. if nullptr, then all devices and any sub-devices supported by the driver instance are visible to the context. otherwise, the context only has visibility to the devices and any sub-devices of the devices in this array. + phContext *ZeContextHandle, // phContext [out] pointer to handle of context object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextCreateEx", uintptr(hDriver), uintptr(unsafe.Pointer(desc)), uintptr(numDevices), uintptr(unsafe.Pointer(phDevices)), uintptr(unsafe.Pointer(phContext))) +} + +// ZeContextDestroy Destroys a context. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the context before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this context. +/// - The application must **not** call this function from simultaneous +/// threads with the same context handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeContextDestroy( + hContext ZeContextHandle, // hContext [in][release] handle of context object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextDestroy", uintptr(hContext)) +} + +// ZeContextGetStatus Returns current status of the context. +/// +/// @details +/// - The application may call this function from simultaneous threads with +/// the same context handle. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_SUCCESS +/// + Context is available for use. +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// + Context is invalid; due to device lost or reset. +func ZeContextGetStatus( + hContext ZeContextHandle, // hContext [in] handle of context object +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextGetStatus", uintptr(hContext)) +} + diff --git a/core/copy.go b/core/copy.go new file mode 100644 index 0000000..91ddc80 --- /dev/null +++ b/core/copy.go @@ -0,0 +1,619 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeCommandListAppendMemoryCopy Copies host, device, or shared memory. +/// +/// @details +/// - The application must ensure the memory pointed to by dstptr and srcptr +/// is accessible by the device on which the command list was created. +/// - The implementation must not access the memory pointed to by dstptr and +/// srcptr as they are free to be modified by either the Host or device up +/// until execution. +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The application must ensure the command list and events were created, +/// and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clEnqueueCopyBuffer** +/// - **clEnqueueReadBuffer** +/// - **clEnqueueWriteBuffer** +/// - **clEnqueueSVMMemcpy** +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == dstptr` +/// + `nullptr == srcptr` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendMemoryCopy( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + dstptr unsafe.Pointer, // dstptr [in] pointer to destination memory to copy to + srcptr unsafe.Pointer, // srcptr [in] pointer to source memory to copy from + size uintptr, // size [in] size in bytes to copy + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendMemoryCopy", uintptr(hCommandList), uintptr(unsafe.Pointer(dstptr)), uintptr(unsafe.Pointer(srcptr)), uintptr(size), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendMemoryFill Initializes host, device, or shared memory. +/// +/// @details +/// - The application must ensure the memory pointed to by ptr is accessible +/// by the device on which the command list was created. +/// - The implementation must not access the memory pointed to by ptr as it +/// is free to be modified by either the Host or device up until +/// execution. +/// - The ptr must be aligned to pattern_size +/// - The value to initialize memory to is described by the pattern and the +/// pattern size. +/// - The pattern size must be a power-of-two and less than or equal to the +/// `maxMemoryFillPatternSize` member of +/// ::ze_command_queue_group_properties_t. +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The application must ensure the command list and events were created, +/// and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clEnqueueFillBuffer** +/// - **clEnqueueSVMMemFill** +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// + `nullptr == pattern` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendMemoryFill( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + ptr unsafe.Pointer, // ptr [in] pointer to memory to initialize + pattern unsafe.Pointer, // pattern [in] pointer to value to initialize memory to + pattern_size uintptr, // pattern_size [in] size in bytes of the value to initialize memory to + size uintptr, // size [in] size in bytes to initialize + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendMemoryFill", uintptr(hCommandList), uintptr(unsafe.Pointer(ptr)), uintptr(unsafe.Pointer(pattern)), uintptr(pattern_size), uintptr(size), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCopyRegion (ze_copy_region_t) Copy region descriptor +type ZeCopyRegion struct { + Originx uint32 // Originx [in] The origin x offset for region in bytes + Originy uint32 // Originy [in] The origin y offset for region in rows + Originz uint32 // Originz [in] The origin z offset for region in slices + Width uint32 // Width [in] The region width relative to origin in bytes + Height uint32 // Height [in] The region height relative to origin in rows + Depth uint32 // Depth [in] The region depth relative to origin in slices. Set this to 0 for 2D copy. + +} + +// ZeCommandListAppendMemoryCopyRegion Copies a region from a 2D or 3D array of host, device, or shared +/// memory. +/// +/// @details +/// - The application must ensure the memory pointed to by dstptr and srcptr +/// is accessible by the device on which the command list was created. +/// - The implementation must not access the memory pointed to by dstptr and +/// srcptr as they are free to be modified by either the Host or device up +/// until execution. +/// - The region width, height, and depth for both src and dst must be same. +/// The origins can be different. +/// - The src and dst regions cannot be overlapping. +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The application must ensure the command list and events were created, +/// and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == dstptr` +/// + `nullptr == dstRegion` +/// + `nullptr == srcptr` +/// + `nullptr == srcRegion` +/// - ::ZE_RESULT_ERROR_OVERLAPPING_REGIONS +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendMemoryCopyRegion( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + dstptr unsafe.Pointer, // dstptr [in] pointer to destination memory to copy to + dstRegion *ZeCopyRegion, // dstRegion [in] pointer to destination region to copy to + dstPitch uint32, // dstPitch [in] destination pitch in bytes + dstSlicePitch uint32, // dstSlicePitch [in] destination slice pitch in bytes. This is required for 3D region copies where the `depth` member of ::ze_copy_region_t is not 0, otherwise it's ignored. + srcptr unsafe.Pointer, // srcptr [in] pointer to source memory to copy from + srcRegion *ZeCopyRegion, // srcRegion [in] pointer to source region to copy from + srcPitch uint32, // srcPitch [in] source pitch in bytes + srcSlicePitch uint32, // srcSlicePitch [in] source slice pitch in bytes. This is required for 3D region copies where the `depth` member of ::ze_copy_region_t is not 0, otherwise it's ignored. + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendMemoryCopyRegion", uintptr(hCommandList), uintptr(unsafe.Pointer(dstptr)), uintptr(unsafe.Pointer(dstRegion)), uintptr(dstPitch), uintptr(dstSlicePitch), uintptr(unsafe.Pointer(srcptr)), uintptr(unsafe.Pointer(srcRegion)), uintptr(srcPitch), uintptr(srcSlicePitch), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendMemoryCopyFromContext Copies host, device, or shared memory from another context. +/// +/// @details +/// - The current active and source context must be from the same driver. +/// - The application must ensure the memory pointed to by dstptr and srcptr +/// is accessible by the device on which the command list was created. +/// - The implementation must not access the memory pointed to by dstptr and +/// srcptr as they are free to be modified by either the Host or device up +/// until execution. +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The application must ensure the command list and events were created, +/// and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hContextSrc` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == dstptr` +/// + `nullptr == srcptr` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendMemoryCopyFromContext( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + dstptr unsafe.Pointer, // dstptr [in] pointer to destination memory to copy to + hContextSrc ZeContextHandle, // hContextSrc [in] handle of source context object + srcptr unsafe.Pointer, // srcptr [in] pointer to source memory to copy from + size uintptr, // size [in] size in bytes to copy + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendMemoryCopyFromContext", uintptr(hCommandList), uintptr(unsafe.Pointer(dstptr)), uintptr(hContextSrc), uintptr(unsafe.Pointer(srcptr)), uintptr(size), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendImageCopy Copies an image. +/// +/// @details +/// - The application must ensure the image and events are accessible by the +/// device on which the command list was created. +/// - The application must ensure the image format descriptors for both +/// source and destination images are the same. +/// - The application must ensure the command list, images and events were +/// created on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clEnqueueCopyImage** +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hDstImage` +/// + `nullptr == hSrcImage` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendImageCopy( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + hDstImage ZeImageHandle, // hDstImage [in] handle of destination image to copy to + hSrcImage ZeImageHandle, // hSrcImage [in] handle of source image to copy from + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendImageCopy", uintptr(hCommandList), uintptr(hDstImage), uintptr(hSrcImage), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeImageRegion (ze_image_region_t) Region descriptor +type ZeImageRegion struct { + Originx uint32 // Originx [in] The origin x offset for region in pixels + Originy uint32 // Originy [in] The origin y offset for region in pixels + Originz uint32 // Originz [in] The origin z offset for region in pixels + Width uint32 // Width [in] The region width relative to origin in pixels + Height uint32 // Height [in] The region height relative to origin in pixels + Depth uint32 // Depth [in] The region depth relative to origin. For 1D or 2D images, set this to 1. + +} + +// ZeCommandListAppendImageCopyRegion Copies a region of an image to another image. +/// +/// @details +/// - The application must ensure the image and events are accessible by the +/// device on which the command list was created. +/// - The region width and height for both src and dst must be same. The +/// origins can be different. +/// - The src and dst regions cannot be overlapping. +/// - The application must ensure the image format descriptors for both +/// source and destination images are the same. +/// - The application must ensure the command list, images and events were +/// created, and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hDstImage` +/// + `nullptr == hSrcImage` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_OVERLAPPING_REGIONS +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendImageCopyRegion( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + hDstImage ZeImageHandle, // hDstImage [in] handle of destination image to copy to + hSrcImage ZeImageHandle, // hSrcImage [in] handle of source image to copy from + pDstRegion *ZeImageRegion, // pDstRegion [in][optional] destination region descriptor + pSrcRegion *ZeImageRegion, // pSrcRegion [in][optional] source region descriptor + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendImageCopyRegion", uintptr(hCommandList), uintptr(hDstImage), uintptr(hSrcImage), uintptr(unsafe.Pointer(pDstRegion)), uintptr(unsafe.Pointer(pSrcRegion)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendImageCopyToMemory Copies from an image to device or shared memory. +/// +/// @details +/// - The application must ensure the memory pointed to by dstptr is +/// accessible by the device on which the command list was created. +/// - The implementation must not access the memory pointed to by dstptr as +/// it is free to be modified by either the Host or device up until +/// execution. +/// - The application must ensure the image and events are accessible by the +/// device on which the command list was created. +/// - The application must ensure the image format descriptor for the source +/// image is a single-planar format. +/// - The application must ensure the command list, image and events were +/// created, and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clEnqueueReadImage +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hSrcImage` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == dstptr` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendImageCopyToMemory( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + dstptr unsafe.Pointer, // dstptr [in] pointer to destination memory to copy to + hSrcImage ZeImageHandle, // hSrcImage [in] handle of source image to copy from + pSrcRegion *ZeImageRegion, // pSrcRegion [in][optional] source region descriptor + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendImageCopyToMemory", uintptr(hCommandList), uintptr(unsafe.Pointer(dstptr)), uintptr(hSrcImage), uintptr(unsafe.Pointer(pSrcRegion)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendImageCopyFromMemory Copies to an image from device or shared memory. +/// +/// @details +/// - The application must ensure the memory pointed to by srcptr is +/// accessible by the device on which the command list was created. +/// - The implementation must not access the memory pointed to by srcptr as +/// it is free to be modified by either the Host or device up until +/// execution. +/// - The application must ensure the image and events are accessible by the +/// device on which the command list was created. +/// - The application must ensure the image format descriptor for the +/// destination image is a single-planar format. +/// - The application must ensure the command list, image and events were +/// created, and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clEnqueueWriteImage +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hDstImage` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == srcptr` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendImageCopyFromMemory( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + hDstImage ZeImageHandle, // hDstImage [in] handle of destination image to copy to + srcptr unsafe.Pointer, // srcptr [in] pointer to source memory to copy from + pDstRegion *ZeImageRegion, // pDstRegion [in][optional] destination region descriptor + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendImageCopyFromMemory", uintptr(hCommandList), uintptr(hDstImage), uintptr(unsafe.Pointer(srcptr)), uintptr(unsafe.Pointer(pDstRegion)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendMemoryPrefetch Asynchronously prefetches shared memory to the device associated with +/// the specified command list +/// +/// @details +/// - This is a hint to improve performance only and is not required for +/// correctness. +/// - Only prefetching to the device associated with the specified command +/// list is supported. +/// Prefetching to the host or to a peer device is not supported. +/// - Prefetching may not be supported for all allocation types for all devices. +/// If memory prefetching is not supported for the specified memory range +/// the prefetch hint may be ignored. +/// - Prefetching may only be supported at a device-specific granularity, +/// such as at a page boundary. +/// In this case, the memory range may be expanded such that the start and +/// end of the range satisfy granularity requirements. +/// - The application must ensure the memory pointed to by ptr is accessible +/// by the device on which the command list was created. +/// - The application must ensure the command list was created, and the +/// memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clEnqueueSVMMigrateMem +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +func ZeCommandListAppendMemoryPrefetch( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + ptr unsafe.Pointer, // ptr [in] pointer to start of the memory range to prefetch + size uintptr, // size [in] size in bytes of the memory range to prefetch +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendMemoryPrefetch", uintptr(hCommandList), uintptr(unsafe.Pointer(ptr)), uintptr(size)) +} + +// ZeMemoryAdvice (ze_memory_advice_t) Supported memory advice hints +type ZeMemoryAdvice uintptr +const ( + ZE_MEMORY_ADVICE_SET_READ_MOSTLY ZeMemoryAdvice = 0 // ZE_MEMORY_ADVICE_SET_READ_MOSTLY hint that memory will be read from frequently and written to rarely + ZE_MEMORY_ADVICE_CLEAR_READ_MOSTLY ZeMemoryAdvice = 1 // ZE_MEMORY_ADVICE_CLEAR_READ_MOSTLY removes the effect of ::ZE_MEMORY_ADVICE_SET_READ_MOSTLY + ZE_MEMORY_ADVICE_SET_PREFERRED_LOCATION ZeMemoryAdvice = 2 // ZE_MEMORY_ADVICE_SET_PREFERRED_LOCATION hint that the preferred memory location is the specified device + ZE_MEMORY_ADVICE_CLEAR_PREFERRED_LOCATION ZeMemoryAdvice = 3 // ZE_MEMORY_ADVICE_CLEAR_PREFERRED_LOCATION removes the effect of ::ZE_MEMORY_ADVICE_SET_PREFERRED_LOCATION + ZE_MEMORY_ADVICE_SET_NON_ATOMIC_MOSTLY ZeMemoryAdvice = 4 // ZE_MEMORY_ADVICE_SET_NON_ATOMIC_MOSTLY hints that memory will mostly be accessed non-atomically + ZE_MEMORY_ADVICE_CLEAR_NON_ATOMIC_MOSTLY ZeMemoryAdvice = 5 // ZE_MEMORY_ADVICE_CLEAR_NON_ATOMIC_MOSTLY removes the effect of ::ZE_MEMORY_ADVICE_SET_NON_ATOMIC_MOSTLY + ZE_MEMORY_ADVICE_BIAS_CACHED ZeMemoryAdvice = 6 // ZE_MEMORY_ADVICE_BIAS_CACHED hints that memory should be cached + ZE_MEMORY_ADVICE_BIAS_UNCACHED ZeMemoryAdvice = 7 // ZE_MEMORY_ADVICE_BIAS_UNCACHED hints that memory should be not be cached + ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION ZeMemoryAdvice = 8 // ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION hint that the preferred memory location is host memory + ZE_MEMORY_ADVICE_CLEAR_SYSTEM_MEMORY_PREFERRED_LOCATION ZeMemoryAdvice = 9 // ZE_MEMORY_ADVICE_CLEAR_SYSTEM_MEMORY_PREFERRED_LOCATION removes the effect of + + ///< ::ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION + + ZE_MEMORY_ADVICE_FORCE_UINT32 ZeMemoryAdvice = 0x7fffffff // ZE_MEMORY_ADVICE_FORCE_UINT32 Value marking end of ZE_MEMORY_ADVICE_* ENUMs + +) + +// ZeCommandListAppendMemAdvise Provides advice about the use of a shared memory range +/// +/// @details +/// - Memory advice is a performance hint only and is not required for +/// functional correctness. +/// - Memory advice can be used to override driver heuristics to explicitly +/// control shared memory behavior. +/// - Not all memory advice hints may be supported for all allocation types +/// for all devices. +/// If a memory advice hint is not supported by the device it will be ignored. +/// - Memory advice may only be supported at a device-specific granularity, +/// such as at a page boundary. +/// In this case, the memory range may be expanded such that the start and +/// end of the range satisfy granularity requirements. +/// - The application must ensure the memory pointed to by ptr is accessible +/// by the device on which the command list was created. +/// - The application must ensure the command list was created, and memory +/// was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle, and the memory was +/// allocated. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `::ZE_MEMORY_ADVICE_CLEAR_SYSTEM_MEMORY_PREFERRED_LOCATION < advice` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeCommandListAppendMemAdvise( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of command list + hDevice ZeDeviceHandle, // hDevice [in] device associated with the memory advice + ptr unsafe.Pointer, // ptr [in] Pointer to the start of the memory range + size uintptr, // size [in] Size in bytes of the memory range + advice ZeMemoryAdvice, // advice [in] Memory advice for the memory range +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendMemAdvise", uintptr(hCommandList), uintptr(hDevice), uintptr(unsafe.Pointer(ptr)), uintptr(size), uintptr(advice)) +} + diff --git a/core/device.go b/core/device.go new file mode 100644 index 0000000..86e2100 --- /dev/null +++ b/core/device.go @@ -0,0 +1,974 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeDeviceGet Retrieves devices within a driver +/// +/// @details +/// - Multiple calls to this function will return identical device handles, +/// in the same order. +/// - The number and order of handles returned from this function is +/// affected by the `ZE_AFFINITY_MASK` and `ZE_ENABLE_PCI_ID_DEVICE_ORDER` +/// environment variables. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +func ZeDeviceGet( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance + pCount *uint32, // pCount [in,out] pointer to the number of devices. if count is zero, then the driver shall update the value with the total number of devices available. if count is greater than the number of devices available, then the driver shall update the value with the correct number of devices available. + phDevices *ZeDeviceHandle, // phDevices [in,out][optional][range(0, *pCount)] array of handle of devices. if count is less than the number of devices available, then driver shall only retrieve that number of devices. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGet", uintptr(hDriver), uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(phDevices))) +} + +// ZeDeviceGetRootDevice Retrieves the root-device of a device handle +/// +/// @details +/// - When the device handle passed does not belong to any root-device, +/// nullptr is returned. +/// - Multiple calls to this function will return the same device handle. +/// - The root-device handle returned by this function does not have access +/// automatically to the resources +/// created with the associated sub-device, unless those resources have +/// been created with a context +/// explicitly containing both handles. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phRootDevice` +func ZeDeviceGetRootDevice( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object + phRootDevice *ZeDeviceHandle, // phRootDevice [in,out] parent root device. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetRootDevice", uintptr(hDevice), uintptr(unsafe.Pointer(phRootDevice))) +} + +// ZeDeviceGetSubDevices Retrieves a sub-device from a device +/// +/// @details +/// - When the device handle passed does not contain any sub-device, a +/// pCount of 0 is returned. +/// - Multiple calls to this function will return identical device handles, +/// in the same order. +/// - The number of handles returned from this function is affected by the +/// `ZE_AFFINITY_MASK` environment variable. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clCreateSubDevices +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +func ZeDeviceGetSubDevices( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object + pCount *uint32, // pCount [in,out] pointer to the number of sub-devices. if count is zero, then the driver shall update the value with the total number of sub-devices available. if count is greater than the number of sub-devices available, then the driver shall update the value with the correct number of sub-devices available. + phSubdevices *ZeDeviceHandle, // phSubdevices [in,out][optional][range(0, *pCount)] array of handle of sub-devices. if count is less than the number of sub-devices available, then driver shall only retrieve that number of sub-devices. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetSubDevices", uintptr(hDevice), uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(phSubdevices))) +} + +// ZeDeviceType (ze_device_type_t) Supported device types +type ZeDeviceType uintptr +const ( + ZE_DEVICE_TYPE_GPU ZeDeviceType = 1 // ZE_DEVICE_TYPE_GPU Graphics Processing Unit + ZE_DEVICE_TYPE_CPU ZeDeviceType = 2 // ZE_DEVICE_TYPE_CPU Central Processing Unit + ZE_DEVICE_TYPE_FPGA ZeDeviceType = 3 // ZE_DEVICE_TYPE_FPGA Field Programmable Gate Array + ZE_DEVICE_TYPE_MCA ZeDeviceType = 4 // ZE_DEVICE_TYPE_MCA Memory Copy Accelerator + ZE_DEVICE_TYPE_VPU ZeDeviceType = 5 // ZE_DEVICE_TYPE_VPU Vision Processing Unit + ZE_DEVICE_TYPE_FORCE_UINT32 ZeDeviceType = 0x7fffffff // ZE_DEVICE_TYPE_FORCE_UINT32 Value marking end of ZE_DEVICE_TYPE_* ENUMs + +) + +// ZE_MAX_DEVICE_UUID_SIZE Maximum device universal unique id (UUID) size in bytes +const ZE_MAX_DEVICE_UUID_SIZE = 16 + +// ZeDeviceUuid (ze_device_uuid_t) Device universal unique id (UUID) +type ZeDeviceUuid struct { + Id [ZE_MAX_DEVICE_UUID_SIZE]uint8 // Id [out] opaque data representing a device UUID + +} + +// ZE_MAX_DEVICE_NAME Maximum device name string size +const ZE_MAX_DEVICE_NAME = 256 + +// ZeDevicePropertyFlags (ze_device_property_flags_t) Supported device property flags +type ZeDevicePropertyFlags uint32 +const ( + ZE_DEVICE_PROPERTY_FLAG_INTEGRATED ZeDevicePropertyFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_PROPERTY_FLAG_INTEGRATED Device is integrated with the Host. + ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE ZeDevicePropertyFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE Device handle used for query represents a sub-device. + ZE_DEVICE_PROPERTY_FLAG_ECC ZeDevicePropertyFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_DEVICE_PROPERTY_FLAG_ECC Device supports error correction memory access. + ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING ZeDevicePropertyFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING Device supports on-demand page-faulting. + ZE_DEVICE_PROPERTY_FLAG_FORCE_UINT32 ZeDevicePropertyFlags = 0x7fffffff // ZE_DEVICE_PROPERTY_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_PROPERTY_FLAG_* ENUMs + +) + +// ZeDeviceProperties (ze_device_properties_t) Device properties queried using ::zeDeviceGetProperties +type ZeDeviceProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Type ZeDeviceType // Type [out] generic device type + Vendorid uint32 // Vendorid [out] vendor id from PCI configuration + Deviceid uint32 // Deviceid [out] device id from PCI configuration. Note, the device id uses little-endian format. + Flags ZeDevicePropertyFlags // Flags [out] 0 (none) or a valid combination of ::ze_device_property_flag_t + Subdeviceid uint32 // Subdeviceid [out] sub-device id. Only valid if ::ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE is set. + Coreclockrate uint32 // Coreclockrate [out] Clock rate for device core. + Maxmemallocsize uint64 // Maxmemallocsize [out] Maximum memory allocation size. + Maxhardwarecontexts uint32 // Maxhardwarecontexts [out] Maximum number of logical hardware contexts. + Maxcommandqueuepriority uint32 // Maxcommandqueuepriority [out] Maximum priority for command queues. Higher value is higher priority. + Numthreadspereu uint32 // Numthreadspereu [out] Maximum number of threads per EU. + Physicaleusimdwidth uint32 // Physicaleusimdwidth [out] The physical EU simd width. + Numeuspersubslice uint32 // Numeuspersubslice [out] Maximum number of EUs per sub-slice. + Numsubslicesperslice uint32 // Numsubslicesperslice [out] Maximum number of sub-slices per slice. + Numslices uint32 // Numslices [out] Maximum number of slices. + Timerresolution uint64 // Timerresolution [out] Returns the resolution of device timer used for profiling, timestamps, etc. When stype==::ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES the units are in nanoseconds. When stype==::ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2 units are in cycles/sec + Timestampvalidbits uint32 // Timestampvalidbits [out] Returns the number of valid bits in the timestamp value. + Kerneltimestampvalidbits uint32 // Kerneltimestampvalidbits [out] Returns the number of valid bits in the kernel timestamp values + Uuid ZeDeviceUuid // Uuid [out] universal unique identifier. Note: Subdevices will have their own uuid. + Name [ZE_MAX_DEVICE_NAME]byte // Name [out] Device name + +} + +// ZeDeviceThread (ze_device_thread_t) Device thread identifier. +type ZeDeviceThread struct { + Slice uint32 // Slice [in,out] the slice number. Must be `UINT32_MAX` (all) or less than the `numSlices` member of ::ze_device_properties_t. + Subslice uint32 // Subslice [in,out] the sub-slice number within its slice. Must be `UINT32_MAX` (all) or less than the `numSubslicesPerSlice` member of ::ze_device_properties_t. + Eu uint32 // Eu [in,out] the EU number within its sub-slice. Must be `UINT32_MAX` (all) or less than the `numEUsPerSubslice` member of ::ze_device_properties_t. + Thread uint32 // Thread [in,out] the thread number within its EU. Must be `UINT32_MAX` (all) or less than the `numThreadsPerEU` member of ::ze_device_properties_t. + +} + +// ZeDeviceGetProperties Retrieves properties of the device. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clGetDeviceInfo +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pDeviceProperties` +func ZeDeviceGetProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pDeviceProperties *ZeDeviceProperties, // pDeviceProperties [in,out] query result for device properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pDeviceProperties))) +} + +// ZE_SUBGROUPSIZE_COUNT Maximum number of subgroup sizes supported. +const ZE_SUBGROUPSIZE_COUNT = 8 + +// ZeDeviceComputeProperties (ze_device_compute_properties_t) Device compute properties queried using ::zeDeviceGetComputeProperties +type ZeDeviceComputeProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Maxtotalgroupsize uint32 // Maxtotalgroupsize [out] Maximum items per compute group. (groupSizeX * groupSizeY * groupSizeZ) <= maxTotalGroupSize + Maxgroupsizex uint32 // Maxgroupsizex [out] Maximum items for X dimension in group + Maxgroupsizey uint32 // Maxgroupsizey [out] Maximum items for Y dimension in group + Maxgroupsizez uint32 // Maxgroupsizez [out] Maximum items for Z dimension in group + Maxgroupcountx uint32 // Maxgroupcountx [out] Maximum groups that can be launched for x dimension + Maxgroupcounty uint32 // Maxgroupcounty [out] Maximum groups that can be launched for y dimension + Maxgroupcountz uint32 // Maxgroupcountz [out] Maximum groups that can be launched for z dimension + Maxsharedlocalmemory uint32 // Maxsharedlocalmemory [out] Maximum shared local memory per group. + Numsubgroupsizes uint32 // Numsubgroupsizes [out] Number of subgroup sizes supported. This indicates number of entries in subGroupSizes. + Subgroupsizes [ZE_SUBGROUPSIZE_COUNT]uint32 // Subgroupsizes [out] Size group sizes supported. + +} + +// ZeDeviceGetComputeProperties Retrieves compute properties of the device. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clGetDeviceInfo +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pComputeProperties` +func ZeDeviceGetComputeProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pComputeProperties *ZeDeviceComputeProperties, // pComputeProperties [in,out] query result for compute properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetComputeProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pComputeProperties))) +} + +// ZE_MAX_NATIVE_KERNEL_UUID_SIZE Maximum native kernel universal unique id (UUID) size in bytes +const ZE_MAX_NATIVE_KERNEL_UUID_SIZE = 16 + +// ZeNativeKernelUuid (ze_native_kernel_uuid_t) Native kernel universal unique id (UUID) +type ZeNativeKernelUuid struct { + Id [ZE_MAX_NATIVE_KERNEL_UUID_SIZE]uint8 // Id [out] opaque data representing a native kernel UUID + +} + +// ZeDeviceModuleFlags (ze_device_module_flags_t) Supported device module flags +type ZeDeviceModuleFlags uint32 +const ( + ZE_DEVICE_MODULE_FLAG_FP16 ZeDeviceModuleFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_MODULE_FLAG_FP16 Device supports 16-bit floating-point operations + ZE_DEVICE_MODULE_FLAG_FP64 ZeDeviceModuleFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_DEVICE_MODULE_FLAG_FP64 Device supports 64-bit floating-point operations + ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS ZeDeviceModuleFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS Device supports 64-bit atomic operations + ZE_DEVICE_MODULE_FLAG_DP4A ZeDeviceModuleFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_DEVICE_MODULE_FLAG_DP4A Device supports four component dot product and accumulate operations + ZE_DEVICE_MODULE_FLAG_FORCE_UINT32 ZeDeviceModuleFlags = 0x7fffffff // ZE_DEVICE_MODULE_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_MODULE_FLAG_* ENUMs + +) + +// ZeDeviceFpFlags (ze_device_fp_flags_t) Supported floating-Point capability flags +type ZeDeviceFpFlags uint32 +const ( + ZE_DEVICE_FP_FLAG_DENORM ZeDeviceFpFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_FP_FLAG_DENORM Supports denorms + ZE_DEVICE_FP_FLAG_INF_NAN ZeDeviceFpFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_DEVICE_FP_FLAG_INF_NAN Supports INF and quiet NaNs + ZE_DEVICE_FP_FLAG_ROUND_TO_NEAREST ZeDeviceFpFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_DEVICE_FP_FLAG_ROUND_TO_NEAREST Supports rounding to nearest even rounding mode + ZE_DEVICE_FP_FLAG_ROUND_TO_ZERO ZeDeviceFpFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_DEVICE_FP_FLAG_ROUND_TO_ZERO Supports rounding to zero. + ZE_DEVICE_FP_FLAG_ROUND_TO_INF ZeDeviceFpFlags = /* ZE_BIT(4) */(( 1 << 4 )) // ZE_DEVICE_FP_FLAG_ROUND_TO_INF Supports rounding to both positive and negative INF. + ZE_DEVICE_FP_FLAG_FMA ZeDeviceFpFlags = /* ZE_BIT(5) */(( 1 << 5 )) // ZE_DEVICE_FP_FLAG_FMA Supports IEEE754-2008 fused multiply-add. + ZE_DEVICE_FP_FLAG_ROUNDED_DIVIDE_SQRT ZeDeviceFpFlags = /* ZE_BIT(6) */(( 1 << 6 )) // ZE_DEVICE_FP_FLAG_ROUNDED_DIVIDE_SQRT Supports rounding as defined by IEEE754 for divide and sqrt + + ///< operations. + + ZE_DEVICE_FP_FLAG_SOFT_FLOAT ZeDeviceFpFlags = /* ZE_BIT(7) */(( 1 << 7 )) // ZE_DEVICE_FP_FLAG_SOFT_FLOAT Uses software implementation for basic floating-point operations. + ZE_DEVICE_FP_FLAG_FORCE_UINT32 ZeDeviceFpFlags = 0x7fffffff // ZE_DEVICE_FP_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_FP_FLAG_* ENUMs + +) + +// ZeDeviceModuleProperties (ze_device_module_properties_t) Device module properties queried using ::zeDeviceGetModuleProperties +type ZeDeviceModuleProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Spirvversionsupported uint32 // Spirvversionsupported [out] Maximum supported SPIR-V version. Returns zero if SPIR-V is not supported. Contains major and minor attributes, use ::ZE_MAJOR_VERSION and ::ZE_MINOR_VERSION. + Flags ZeDeviceModuleFlags // Flags [out] 0 or a valid combination of ::ze_device_module_flag_t + Fp16flags ZeDeviceFpFlags // Fp16flags [out] Capabilities for half-precision floating-point operations. returns 0 (if ::ZE_DEVICE_MODULE_FLAG_FP16 is not set) or a combination of ::ze_device_fp_flag_t. + Fp32flags ZeDeviceFpFlags // Fp32flags [out] Capabilities for single-precision floating-point operations. returns a combination of ::ze_device_fp_flag_t. + Fp64flags ZeDeviceFpFlags // Fp64flags [out] Capabilities for double-precision floating-point operations. returns 0 (if ::ZE_DEVICE_MODULE_FLAG_FP64 is not set) or a combination of ::ze_device_fp_flag_t. + Maxargumentssize uint32 // Maxargumentssize [out] Maximum kernel argument size that is supported. + Printfbuffersize uint32 // Printfbuffersize [out] Maximum size of internal buffer that holds output of printf calls from kernel. + Nativekernelsupported ZeNativeKernelUuid // Nativekernelsupported [out] Compatibility UUID of supported native kernel. UUID may or may not be the same across driver release, devices, or operating systems. Application is responsible for ensuring UUID matches before creating module using previously created native kernel. + +} + +// ZeDeviceGetModuleProperties Retrieves module properties of the device +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pModuleProperties` +func ZeDeviceGetModuleProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pModuleProperties *ZeDeviceModuleProperties, // pModuleProperties [in,out] query result for module properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetModuleProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pModuleProperties))) +} + +// ZeCommandQueueGroupPropertyFlags (ze_command_queue_group_property_flags_t) Supported command queue group property flags +type ZeCommandQueueGroupPropertyFlags uint32 +const ( + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE ZeCommandQueueGroupPropertyFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE Command queue group supports enqueing compute commands. + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY ZeCommandQueueGroupPropertyFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY Command queue group supports enqueing copy commands. + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS ZeCommandQueueGroupPropertyFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS Command queue group supports cooperative kernels. + + ///< See ::zeCommandListAppendLaunchCooperativeKernel for more details. + + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS ZeCommandQueueGroupPropertyFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS Command queue groups supports metric queries. + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_FORCE_UINT32 ZeCommandQueueGroupPropertyFlags = 0x7fffffff // ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_FORCE_UINT32 Value marking end of ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_* ENUMs + +) + +// ZeCommandQueueGroupProperties (ze_command_queue_group_properties_t) Command queue group properties queried using +/// ::zeDeviceGetCommandQueueGroupProperties +type ZeCommandQueueGroupProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeCommandQueueGroupPropertyFlags // Flags [out] 0 (none) or a valid combination of ::ze_command_queue_group_property_flag_t + Maxmemoryfillpatternsize uintptr // Maxmemoryfillpatternsize [out] maximum `pattern_size` supported by command queue group. See ::zeCommandListAppendMemoryFill for more details. + Numqueues uint32 // Numqueues [out] the number of physical engines within the group. + +} + +// ZeDeviceGetCommandQueueGroupProperties Retrieves command queue group properties of the device. +/// +/// @details +/// - Properties are reported for each physical command queue group +/// available on the device. +/// - Multiple calls to this function will return properties in the same +/// order. +/// - The order in which the properties are returned is defined by the +/// command queue group's ordinal. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **vkGetPhysicalDeviceQueueFamilyProperties** +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +func ZeDeviceGetCommandQueueGroupProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pCount *uint32, // pCount [in,out] pointer to the number of available command queue groups. If count is zero, then the driver shall update the value with the total number of command queue groups available. If count is less than the number of command queue groups available, then the driver shall only retrieve command queue group properties for the given number of command queue groups. If count is greater than or equal to the number of command queue groups available, then the driver shall retrieve command queue group properties for all available command queue groups. + pCommandQueueGroupProperties *ZeCommandQueueGroupProperties, // pCommandQueueGroupProperties [in,out][optional][range(0, *pCount)] array of query results for command queue group properties. If count is less than the number of command queue groups available, then the driver shall only retrieve that number of command queue group properties. The order of properties in the array corresponds to the command queue group ordinal. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetCommandQueueGroupProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(pCommandQueueGroupProperties))) +} + +// ZeDeviceMemoryPropertyFlags (ze_device_memory_property_flags_t) Supported device memory property flags +type ZeDeviceMemoryPropertyFlags uint32 +const ( + ZE_DEVICE_MEMORY_PROPERTY_FLAG_TBD ZeDeviceMemoryPropertyFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_MEMORY_PROPERTY_FLAG_TBD reserved for future use + ZE_DEVICE_MEMORY_PROPERTY_FLAG_FORCE_UINT32 ZeDeviceMemoryPropertyFlags = 0x7fffffff // ZE_DEVICE_MEMORY_PROPERTY_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_MEMORY_PROPERTY_FLAG_* ENUMs + +) + +// ZeDeviceMemoryProperties (ze_device_memory_properties_t) Device local memory properties queried using +/// ::zeDeviceGetMemoryProperties +type ZeDeviceMemoryProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeDeviceMemoryPropertyFlags // Flags [out] 0 (none) or a valid combination of ::ze_device_memory_property_flag_t + Maxclockrate uint32 // Maxclockrate [out] Maximum clock rate for device memory. + Maxbuswidth uint32 // Maxbuswidth [out] Maximum bus width between device and memory. + Totalsize uint64 // Totalsize [out] Total memory size in bytes that is available to the device. + Name [ZE_MAX_DEVICE_NAME]byte // Name [out] Memory name + +} + +// ZeDeviceGetMemoryProperties Retrieves local memory properties of the device. +/// +/// @details +/// - Properties are reported for each physical memory type supported by the +/// device. +/// - Multiple calls to this function will return properties in the same +/// order. +/// - The order in which the properties are returned defines the device's +/// local memory ordinal. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clGetDeviceInfo +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +func ZeDeviceGetMemoryProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pCount *uint32, // pCount [in,out] pointer to the number of memory properties. if count is zero, then the driver shall update the value with the total number of memory properties available. if count is greater than the number of memory properties available, then the driver shall update the value with the correct number of memory properties available. + pMemProperties *ZeDeviceMemoryProperties, // pMemProperties [in,out][optional][range(0, *pCount)] array of query results for memory properties. if count is less than the number of memory properties available, then driver shall only retrieve that number of memory properties. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetMemoryProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(pMemProperties))) +} + +// ZeMemoryAccessCapFlags (ze_memory_access_cap_flags_t) Memory access capability flags +/// +/// @details +/// - Supported access capabilities for different types of memory +/// allocations +type ZeMemoryAccessCapFlags uint32 +const ( + ZE_MEMORY_ACCESS_CAP_FLAG_RW ZeMemoryAccessCapFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_MEMORY_ACCESS_CAP_FLAG_RW Supports load/store access + ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC ZeMemoryAccessCapFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC Supports atomic access + ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT ZeMemoryAccessCapFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT Supports concurrent access + ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC ZeMemoryAccessCapFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC Supports concurrent atomic access + ZE_MEMORY_ACCESS_CAP_FLAG_FORCE_UINT32 ZeMemoryAccessCapFlags = 0x7fffffff // ZE_MEMORY_ACCESS_CAP_FLAG_FORCE_UINT32 Value marking end of ZE_MEMORY_ACCESS_CAP_FLAG_* ENUMs + +) + +// ZeDeviceMemoryAccessProperties (ze_device_memory_access_properties_t) Device memory access properties queried using +/// ::zeDeviceGetMemoryAccessProperties +type ZeDeviceMemoryAccessProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Hostalloccapabilities ZeMemoryAccessCapFlags // Hostalloccapabilities [out] host memory capabilities. returns 0 (unsupported) or a combination of ::ze_memory_access_cap_flag_t. + Devicealloccapabilities ZeMemoryAccessCapFlags // Devicealloccapabilities [out] device memory capabilities. returns 0 (unsupported) or a combination of ::ze_memory_access_cap_flag_t. + Sharedsingledevicealloccapabilities ZeMemoryAccessCapFlags // Sharedsingledevicealloccapabilities [out] shared, single-device memory capabilities. returns 0 (unsupported) or a combination of ::ze_memory_access_cap_flag_t. + Sharedcrossdevicealloccapabilities ZeMemoryAccessCapFlags // Sharedcrossdevicealloccapabilities [out] shared, cross-device memory capabilities. returns 0 (unsupported) or a combination of ::ze_memory_access_cap_flag_t. + Sharedsystemalloccapabilities ZeMemoryAccessCapFlags // Sharedsystemalloccapabilities [out] shared, system memory capabilities. returns 0 (unsupported) or a combination of ::ze_memory_access_cap_flag_t. + +} + +// ZeDeviceGetMemoryAccessProperties Retrieves memory access properties of the device. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clGetDeviceInfo +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pMemAccessProperties` +func ZeDeviceGetMemoryAccessProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pMemAccessProperties *ZeDeviceMemoryAccessProperties, // pMemAccessProperties [in,out] query result for memory access properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetMemoryAccessProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pMemAccessProperties))) +} + +// ZeDeviceCachePropertyFlags (ze_device_cache_property_flags_t) Supported cache control property flags +type ZeDeviceCachePropertyFlags uint32 +const ( + ZE_DEVICE_CACHE_PROPERTY_FLAG_USER_CONTROL ZeDeviceCachePropertyFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_CACHE_PROPERTY_FLAG_USER_CONTROL Device support User Cache Control (i.e. SLM section vs Generic Cache) + ZE_DEVICE_CACHE_PROPERTY_FLAG_FORCE_UINT32 ZeDeviceCachePropertyFlags = 0x7fffffff // ZE_DEVICE_CACHE_PROPERTY_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_CACHE_PROPERTY_FLAG_* ENUMs + +) + +// ZeDeviceCacheProperties (ze_device_cache_properties_t) Device cache properties queried using ::zeDeviceGetCacheProperties +type ZeDeviceCacheProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeDeviceCachePropertyFlags // Flags [out] 0 (none) or a valid combination of ::ze_device_cache_property_flag_t + Cachesize uintptr // Cachesize [out] Per-cache size, in bytes + +} + +// ZeDeviceGetCacheProperties Retrieves cache properties of the device +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clGetDeviceInfo +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +func ZeDeviceGetCacheProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pCount *uint32, // pCount [in,out] pointer to the number of cache properties. if count is zero, then the driver shall update the value with the total number of cache properties available. if count is greater than the number of cache properties available, then the driver shall update the value with the correct number of cache properties available. + pCacheProperties *ZeDeviceCacheProperties, // pCacheProperties [in,out][optional][range(0, *pCount)] array of query results for cache properties. if count is less than the number of cache properties available, then driver shall only retrieve that number of cache properties. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetCacheProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(pCacheProperties))) +} + +// ZeDeviceImageProperties (ze_device_image_properties_t) Device image properties queried using ::zeDeviceGetImageProperties +type ZeDeviceImageProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Maximagedims1d uint32 // Maximagedims1d [out] Maximum image dimensions for 1D resources. if 0, then 1D images are unsupported. + Maximagedims2d uint32 // Maximagedims2d [out] Maximum image dimensions for 2D resources. if 0, then 2D images are unsupported. + Maximagedims3d uint32 // Maximagedims3d [out] Maximum image dimensions for 3D resources. if 0, then 3D images are unsupported. + Maximagebuffersize uint64 // Maximagebuffersize [out] Maximum image buffer size in bytes. if 0, then buffer images are unsupported. + Maximagearrayslices uint32 // Maximagearrayslices [out] Maximum image array slices. if 0, then image arrays are unsupported. + Maxsamplers uint32 // Maxsamplers [out] Max samplers that can be used in kernel. if 0, then sampling is unsupported. + Maxreadimageargs uint32 // Maxreadimageargs [out] Returns the maximum number of simultaneous image objects that can be read from by a kernel. if 0, then reading images is unsupported. + Maxwriteimageargs uint32 // Maxwriteimageargs [out] Returns the maximum number of simultaneous image objects that can be written to by a kernel. if 0, then writing images is unsupported. + +} + +// ZeDeviceGetImageProperties Retrieves image properties of the device +/// +/// @details +/// - See ::zeImageGetProperties for format-specific capabilities. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pImageProperties` +func ZeDeviceGetImageProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pImageProperties *ZeDeviceImageProperties, // pImageProperties [in,out] query result for image properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetImageProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pImageProperties))) +} + +// ZeDeviceExternalMemoryProperties (ze_device_external_memory_properties_t) Device external memory import and export properties +type ZeDeviceExternalMemoryProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Memoryallocationimporttypes ZeExternalMemoryTypeFlags // Memoryallocationimporttypes [out] Supported external memory import types for memory allocations. + Memoryallocationexporttypes ZeExternalMemoryTypeFlags // Memoryallocationexporttypes [out] Supported external memory export types for memory allocations. + Imageimporttypes ZeExternalMemoryTypeFlags // Imageimporttypes [out] Supported external memory import types for images. + Imageexporttypes ZeExternalMemoryTypeFlags // Imageexporttypes [out] Supported external memory export types for images. + +} + +// ZeDeviceGetExternalMemoryProperties Retrieves external memory import and export of the device +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pExternalMemoryProperties` +func ZeDeviceGetExternalMemoryProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pExternalMemoryProperties *ZeDeviceExternalMemoryProperties, // pExternalMemoryProperties [in,out] query result for external memory properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetExternalMemoryProperties", uintptr(hDevice), uintptr(unsafe.Pointer(pExternalMemoryProperties))) +} + +// ZeDeviceP2pPropertyFlags (ze_device_p2p_property_flags_t) Supported device peer-to-peer property flags +type ZeDeviceP2pPropertyFlags uint32 +const ( + ZE_DEVICE_P2P_PROPERTY_FLAG_ACCESS ZeDeviceP2pPropertyFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_P2P_PROPERTY_FLAG_ACCESS Device supports access between peer devices. + ZE_DEVICE_P2P_PROPERTY_FLAG_ATOMICS ZeDeviceP2pPropertyFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_DEVICE_P2P_PROPERTY_FLAG_ATOMICS Device supports atomics between peer devices. + ZE_DEVICE_P2P_PROPERTY_FLAG_FORCE_UINT32 ZeDeviceP2pPropertyFlags = 0x7fffffff // ZE_DEVICE_P2P_PROPERTY_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_P2P_PROPERTY_FLAG_* ENUMs + +) + +// ZeDeviceP2pProperties (ze_device_p2p_properties_t) Device peer-to-peer properties queried using +/// ::zeDeviceGetP2PProperties +type ZeDeviceP2pProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeDeviceP2pPropertyFlags // Flags [out] 0 (none) or a valid combination of ::ze_device_p2p_property_flag_t + +} + +// ZeDeviceGetP2PProperties Retrieves peer-to-peer properties between one device and a peer +/// devices +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// + `nullptr == hPeerDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pP2PProperties` +func ZeDeviceGetP2PProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device performing the access + hPeerDevice ZeDeviceHandle, // hPeerDevice [in] handle of the peer device with the allocation + pP2PProperties *ZeDeviceP2pProperties, // pP2PProperties [in,out] Peer-to-Peer properties between source and peer device +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetP2PProperties", uintptr(hDevice), uintptr(hPeerDevice), uintptr(unsafe.Pointer(pP2PProperties))) +} + +// ZeDeviceCanAccessPeer Queries if one device can directly access peer device allocations +/// +/// @details +/// - Any device can access any other device within a node through a +/// scale-up fabric. +/// - The following are conditions for CanAccessPeer query. +/// + If both device and peer device are the same then return true. +/// + If both sub-device and peer sub-device are the same then return +/// true. +/// + If both are sub-devices and share the same parent device then +/// return true. +/// + If both device and remote device are connected by a direct or +/// indirect scale-up fabric or over PCIe (same root complex or shared +/// PCIe switch) then true. +/// + If both sub-device and remote parent device (and vice-versa) are +/// connected by a direct or indirect scale-up fabric or over PCIe +/// (same root complex or shared PCIe switch) then true. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// + `nullptr == hPeerDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == value` +func ZeDeviceCanAccessPeer( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device performing the access + hPeerDevice ZeDeviceHandle, // hPeerDevice [in] handle of the peer device with the allocation + value *ZeBool, // value [out] returned access capability +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceCanAccessPeer", uintptr(hDevice), uintptr(hPeerDevice), uintptr(unsafe.Pointer(value))) +} + +// ZeDeviceGetStatus Returns current status of the device. +/// +/// @details +/// - Once a device is reset, this call will update the OS handle attached +/// to the device handle. +/// - The application may call this function from simultaneous threads with +/// the same device handle. +/// - The implementation of this function must be thread-safe. +/// +/// @returns +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_SUCCESS +/// + Device is available for use. +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// + Device is lost; must be reset for use. +func ZeDeviceGetStatus( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetStatus", uintptr(hDevice)) +} + +// ZeDeviceGetGlobalTimestamps Returns synchronized Host and device global timestamps. +/// +/// @details +/// - The application may call this function from simultaneous threads with +/// the same device handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == hostTimestamp` +/// + `nullptr == deviceTimestamp` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + The feature is not supported by the underlying platform. +func ZeDeviceGetGlobalTimestamps( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + hostTimestamp *uint64, // hostTimestamp [out] value of the Host's global timestamp that correlates with the Device's global timestamp value. + deviceTimestamp *uint64, // deviceTimestamp [out] value of the Device's global timestamp that correlates with the Host's global timestamp value. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetGlobalTimestamps", uintptr(hDevice), uintptr(unsafe.Pointer(hostTimestamp)), uintptr(unsafe.Pointer(deviceTimestamp))) +} + +// ZeDeviceSynchronize Synchronizes all command queues related to the device. +/// +/// @details +/// - The application may call this function from simultaneous threads with +/// the same device handle. +/// - The implementation of this function should be thread-safe. +/// - This function blocks until all preceding submissions to all queues on +/// the device are completed. +/// - This function returns an error if device execution fails. +/// - This function hangs indefinitely if the device is blocked on a +/// non-signaled event. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +func ZeDeviceSynchronize( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceSynchronize", uintptr(hDevice)) +} + +// ZeDeviceEventPropertiesFlags (ze_device_event_properties_flags_t) Supported Event properties flags +type ZeDeviceEventPropertiesFlags uint32 +const ( + ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_EXTERNAL_AGGREGATE_STORAGE ZeDeviceEventPropertiesFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_EXTERNAL_AGGREGATE_STORAGE Counter-based Event with external aggregate storage supported + ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_IPC ZeDeviceEventPropertiesFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_IPC Counter-based Event IPC sharing supported + ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_EXTERNAL_SYNC_ALLOCATION ZeDeviceEventPropertiesFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_EXTERNAL_SYNC_ALLOCATION Counter-based Event with external sync allocation supported + ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_EXTERNAL_INTERRUPT_WAIT ZeDeviceEventPropertiesFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_DEVICE_EVENT_PROPERTIES_FLAG_COUNTER_BASED_EXTERNAL_INTERRUPT_WAIT Counter-based Event waiting for external interrupt id supported + ZE_DEVICE_EVENT_PROPERTIES_FLAG_FORCE_UINT32 ZeDeviceEventPropertiesFlags = 0x7fffffff // ZE_DEVICE_EVENT_PROPERTIES_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_EVENT_PROPERTIES_FLAG_* ENUMs + +) + +// ZeDeviceEventProperties (ze_device_event_properties_t) Device Event properties struct. Can be passed as pNext to +/// ::ze_device_properties_t to obtain properties +type ZeDeviceEventProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeDeviceEventPropertiesFlags // Flags [out] Supported Event properties. Valid combination of ::ze_device_event_properties_flag_t. + +} + +// ZeDeviceGetAggregatedCopyOffloadIncrementValue Returns unified increment value that can be used for Counter Based +/// Events created with +/// ::ze_event_counter_based_external_aggregate_storage_desc_t +/// +/// @details +/// - Value is applicable only to this specific device +/// - It may be used, when user is not able define number of internal driver +/// operations during given append call, for example dividing copy into +/// multiple engines. More details can be found in programming guide. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == incrementValue` +func ZeDeviceGetAggregatedCopyOffloadIncrementValue( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + incrementValue *uint32, // incrementValue [out] increment value that can be used for Event creation +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceGetAggregatedCopyOffloadIncrementValue", uintptr(hDevice), uintptr(unsafe.Pointer(incrementValue))) +} + diff --git a/core/driver.go b/core/driver.go index ef1a200..728a50c 100644 --- a/core/driver.go +++ b/core/driver.go @@ -15,6 +15,8 @@ package core import ( "unsafe" + + "github.com/fumiama/gozel/internal/zecall" ) // ZeInitFlags (ze_init_flags_t) Supported initialization flags @@ -26,3 +28,486 @@ const ( ) +// ZeInit Initialize the 'oneAPI' driver(s) +/// +/// @details +/// - @deprecated since 1.10. Please use zeInitDrivers() +/// - The application must call this function or zeInitDrivers before +/// calling any other function. +/// - If this function is not called then all other functions will return +/// ::ZE_RESULT_ERROR_UNINITIALIZED. +/// - Only one instance of each driver will be initialized per process. +/// - The application may call this function multiple times with different +/// flags or environment variables enabled. +/// - The application must call this function after forking new processes. +/// Each forked process must call this function. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe for scenarios +/// where multiple libraries may initialize the driver(s) simultaneously. +/// +/// @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_ENUMERATION +/// + `0x3 < flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeInit( + flags ZeInitFlags, // flags [in] initialization flags. must be 0 (default) or a combination of ::ze_init_flag_t. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeInit", uintptr(flags)) +} + +// ZeDriverGet Retrieves driver instances +/// +/// @details +/// - @deprecated since 1.10. Please use zeInitDrivers() +/// - Usage of zeInitDrivers and zeDriverGet is mutually exclusive and +/// should not be used together. Usage of them together will result in +/// undefined behavior. +/// - A driver represents a collection of physical devices. +/// - Multiple calls to this function will return identical driver handles, +/// in the same order. +/// - The application may pass nullptr for pDrivers when only querying the +/// number of drivers. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clGetPlatformIDs +/// +/// @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 == pCount` +func ZeDriverGet( + pCount *uint32, // pCount [in,out] pointer to the number of driver instances. if count is zero, then the loader shall update the value with the total number of drivers available. if count is greater than the number of drivers available, then the loader shall update the value with the correct number of drivers available. + phDrivers *ZeDriverHandle, // phDrivers [in,out][optional][range(0, *pCount)] array of driver instance handles. if count is less than the number of drivers available, then the loader shall only retrieve that number of drivers. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDriverGet", uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(phDrivers))) +} + +// ZeInitDriverTypeFlags (ze_init_driver_type_flags_t) Supported driver initialization type flags +/// +/// @details +/// - Bit Field which details the driver types to be initialized and +/// returned to the user. +/// - Value Definition: +/// - 0, do not init or retrieve any drivers. +/// - ZE_INIT_DRIVER_TYPE_FLAG_GPU, GPU Drivers are Init and driver handles +/// retrieved. +/// - ZE_INIT_DRIVER_TYPE_FLAG_NPU, NPU Drivers are Init and driver handles +/// retrieved. +/// - ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU, NPU & GPU +/// Drivers are Init and driver handles retrieved. +/// - UINT32_MAX All Drivers of any type are Init and driver handles +/// retrieved. +type ZeInitDriverTypeFlags uint32 +const ( + ZE_INIT_DRIVER_TYPE_FLAG_GPU ZeInitDriverTypeFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_INIT_DRIVER_TYPE_FLAG_GPU initialize and retrieve GPU drivers + ZE_INIT_DRIVER_TYPE_FLAG_NPU ZeInitDriverTypeFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_INIT_DRIVER_TYPE_FLAG_NPU initialize and retrieve NPU drivers + ZE_INIT_DRIVER_TYPE_FLAG_FORCE_UINT32 ZeInitDriverTypeFlags = 0x7fffffff // ZE_INIT_DRIVER_TYPE_FLAG_FORCE_UINT32 Value marking end of ZE_INIT_DRIVER_TYPE_FLAG_* ENUMs + +) + +// ZeInitDriverTypeDesc (ze_init_driver_type_desc_t) Init Driver Type descriptor +type ZeInitDriverTypeDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeInitDriverTypeFlags // Flags [in] driver type init flags. must be a valid combination of ::ze_init_driver_type_flag_t or UINT32_MAX; driver types are init and retrieved based on these init flags in zeInitDrivers(). + +} + +// ZeInitDrivers Initialize the 'oneAPI' driver(s) based on the driver types requested +/// and retrieve the driver handles. +/// +/// @details +/// - The application must call this function or zeInit before calling any +/// other function. (zeInit is [Deprecated] and is replaced by +/// zeInitDrivers) +/// - Calls to zeInit[Deprecated] or InitDrivers will not alter the drivers +/// retrieved through either api. +/// - Drivers init through zeInit[Deprecated] or InitDrivers will not be +/// reInitialized once init in an application. The Loader will determine +/// if the already init driver needs to be delivered to the user through +/// the init type flags. +/// - Already init Drivers will not be uninitialized if the call to +/// InitDrivers does not include that driver's type. Those init drivers +/// which don't match the init flags will not have their driver handles +/// returned to the user in that InitDrivers call. +/// - If this function or zeInit[Deprecated] is not called, then all other +/// functions will return ::ZE_RESULT_ERROR_UNINITIALIZED. +/// - Only one instance of each driver will be initialized per process. +/// - A driver represents a collection of physical devices. +/// - Multiple calls to this function will return identical driver handles, +/// in the same order. +/// - The drivers returned to the caller will be based on the init types +/// which state the drivers to be included. +/// - The application may pass nullptr for pDrivers when only querying the +/// number of drivers. +/// - The application may call this function multiple times with different +/// flags or environment variables enabled. +/// - The application must call this function after forking new processes. +/// Each forked process must call this function. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe for scenarios +/// where multiple libraries may initialize the driver(s) simultaneously. +/// +/// @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 == pCount` +/// + `nullptr == desc` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x0 == desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeInitDrivers( + pCount *uint32, // pCount [in,out] pointer to the number of driver instances. if count is zero, then the loader shall update the value with the total number of drivers available. if count is greater than the number of drivers available, then the loader shall update the value with the correct number of drivers available. + phDrivers *ZeDriverHandle, // phDrivers [in,out][optional][range(0, *pCount)] array of driver instance handles. if count is less than the number of drivers available, then the loader shall only retrieve that number of drivers. + desc *ZeInitDriverTypeDesc, // desc [in] descriptor containing the driver type initialization details including ::ze_init_driver_type_flag_t combinations. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeInitDrivers", uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(phDrivers)), uintptr(unsafe.Pointer(desc))) +} + +// ZeApiVersion (ze_api_version_t) Supported API versions +/// +/// @details +/// - API versions contain major and minor attributes, use +/// ::ZE_MAJOR_VERSION and ::ZE_MINOR_VERSION +type ZeApiVersion uintptr +const ( + ZE_API_VERSION_1_0 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_API_VERSION_1_0 version 1.0 + ZE_API_VERSION_1_1 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 1 ) */((( 1 << 16 )|( 1 & 0x0000ffff))) // ZE_API_VERSION_1_1 version 1.1 + ZE_API_VERSION_1_2 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 2 ) */((( 1 << 16 )|( 2 & 0x0000ffff))) // ZE_API_VERSION_1_2 version 1.2 + ZE_API_VERSION_1_3 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 3 ) */((( 1 << 16 )|( 3 & 0x0000ffff))) // ZE_API_VERSION_1_3 version 1.3 + ZE_API_VERSION_1_4 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 4 ) */((( 1 << 16 )|( 4 & 0x0000ffff))) // ZE_API_VERSION_1_4 version 1.4 + ZE_API_VERSION_1_5 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 5 ) */((( 1 << 16 )|( 5 & 0x0000ffff))) // ZE_API_VERSION_1_5 version 1.5 + ZE_API_VERSION_1_6 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 6 ) */((( 1 << 16 )|( 6 & 0x0000ffff))) // ZE_API_VERSION_1_6 version 1.6 + ZE_API_VERSION_1_7 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 7 ) */((( 1 << 16 )|( 7 & 0x0000ffff))) // ZE_API_VERSION_1_7 version 1.7 + ZE_API_VERSION_1_8 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 8 ) */((( 1 << 16 )|( 8 & 0x0000ffff))) // ZE_API_VERSION_1_8 version 1.8 + ZE_API_VERSION_1_9 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 9 ) */((( 1 << 16 )|( 9 & 0x0000ffff))) // ZE_API_VERSION_1_9 version 1.9 + ZE_API_VERSION_1_10 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 10 ) */((( 1 << 16 )|( 10 & 0x0000ffff))) // ZE_API_VERSION_1_10 version 1.10 + ZE_API_VERSION_1_11 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 11 ) */((( 1 << 16 )|( 11 & 0x0000ffff))) // ZE_API_VERSION_1_11 version 1.11 + ZE_API_VERSION_1_12 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 12 ) */((( 1 << 16 )|( 12 & 0x0000ffff))) // ZE_API_VERSION_1_12 version 1.12 + ZE_API_VERSION_1_13 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 13 ) */((( 1 << 16 )|( 13 & 0x0000ffff))) // ZE_API_VERSION_1_13 version 1.13 + ZE_API_VERSION_1_14 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 14 ) */((( 1 << 16 )|( 14 & 0x0000ffff))) // ZE_API_VERSION_1_14 version 1.14 + ZE_API_VERSION_1_15 ZeApiVersion = /* ZE_MAKE_VERSION( 1, 15 ) */((( 1 << 16 )|( 15 & 0x0000ffff))) // ZE_API_VERSION_1_15 version 1.15 + ZE_API_VERSION_CURRENT ZeApiVersion = /* ZE_MAKE_VERSION( 1, 15 ) */((( 1 << 16 )|( 15 & 0x0000ffff))) // ZE_API_VERSION_CURRENT latest known version + ZE_API_VERSION_FORCE_UINT32 ZeApiVersion = 0x7fffffff // ZE_API_VERSION_FORCE_UINT32 Value marking end of ZE_API_VERSION_* ENUMs + +) + +// ZE_API_VERSION_CURRENT_M Current API version as a macro +const ZE_API_VERSION_CURRENT_M = /* ZE_MAKE_VERSION( 1, 15 ) */((( 1 << 16 )|( 15 & 0x0000ffff))) + +// ZeDriverGetApiVersion Returns the API version supported by the specified driver +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == version` +func ZeDriverGetApiVersion( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance + version *ZeApiVersion, // version [out] api version +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDriverGetApiVersion", uintptr(hDriver), uintptr(unsafe.Pointer(version))) +} + +// ZE_MAX_DRIVER_UUID_SIZE Maximum driver universal unique id (UUID) size in bytes +const ZE_MAX_DRIVER_UUID_SIZE = 16 + +// ZeDriverUuid (ze_driver_uuid_t) Driver universal unique id (UUID) +type ZeDriverUuid struct { + Id [ZE_MAX_DRIVER_UUID_SIZE]uint8 // Id [out] opaque data representing a driver UUID + +} + +// ZeDriverProperties (ze_driver_properties_t) Driver properties queried using ::zeDriverGetProperties +type ZeDriverProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Uuid ZeDriverUuid // Uuid [out] universal unique identifier. + Driverversion uint32 // Driverversion [out] driver version The driver version is a non-zero, monotonically increasing value where higher values always indicate a more recent version. + +} + +// ZeDriverGetProperties Retrieves properties of the driver. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clGetPlatformInfo** +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pDriverProperties` +func ZeDriverGetProperties( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance + pDriverProperties *ZeDriverProperties, // pDriverProperties [in,out] query result for driver properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDriverGetProperties", uintptr(hDriver), uintptr(unsafe.Pointer(pDriverProperties))) +} + +// ZeIpcPropertyFlags (ze_ipc_property_flags_t) Supported IPC property flags +type ZeIpcPropertyFlags uint32 +const ( + ZE_IPC_PROPERTY_FLAG_MEMORY ZeIpcPropertyFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_IPC_PROPERTY_FLAG_MEMORY Supports passing memory allocations between processes. See + + ///< ::zeMemGetIpcHandle. + + ZE_IPC_PROPERTY_FLAG_EVENT_POOL ZeIpcPropertyFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_IPC_PROPERTY_FLAG_EVENT_POOL Supports passing event pools between processes. See + + ///< ::zeEventPoolGetIpcHandle. + + ZE_IPC_PROPERTY_FLAG_FORCE_UINT32 ZeIpcPropertyFlags = 0x7fffffff // ZE_IPC_PROPERTY_FLAG_FORCE_UINT32 Value marking end of ZE_IPC_PROPERTY_FLAG_* ENUMs + +) + +// ZeDriverIpcProperties (ze_driver_ipc_properties_t) IPC properties queried using ::zeDriverGetIpcProperties +type ZeDriverIpcProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeIpcPropertyFlags // Flags [out] 0 (none) or a valid combination of ::ze_ipc_property_flag_t + +} + +// ZeDriverGetIpcProperties Retrieves IPC attributes of the driver +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pIpcProperties` +func ZeDriverGetIpcProperties( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance + pIpcProperties *ZeDriverIpcProperties, // pIpcProperties [in,out] query result for IPC properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDriverGetIpcProperties", uintptr(hDriver), uintptr(unsafe.Pointer(pIpcProperties))) +} + +// ZE_MAX_EXTENSION_NAME Maximum extension name string size +const ZE_MAX_EXTENSION_NAME = 256 + +// ZeDriverExtensionProperties (ze_driver_extension_properties_t) Extension properties queried using ::zeDriverGetExtensionProperties +type ZeDriverExtensionProperties struct { + Name [ZE_MAX_EXTENSION_NAME]byte // Name [out] extension name + Version uint32 // Version [out] extension version using ::ZE_MAKE_VERSION + +} + +// ZeDriverGetExtensionProperties Retrieves extension properties +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **vkEnumerateInstanceExtensionProperties** +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +func ZeDriverGetExtensionProperties( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance + pCount *uint32, // pCount [in,out] pointer to the number of extension properties. if count is zero, then the driver shall update the value with the total number of extension properties available. if count is greater than the number of extension properties available, then the driver shall update the value with the correct number of extension properties available. + pExtensionProperties *ZeDriverExtensionProperties, // pExtensionProperties [in,out][optional][range(0, *pCount)] array of query results for extension properties. if count is less than the number of extension properties available, then driver shall only retrieve that number of extension properties. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDriverGetExtensionProperties", uintptr(hDriver), uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(pExtensionProperties))) +} + +// ZeDriverGetExtensionFunctionAddress Retrieves function pointer for vendor-specific or experimental +/// extensions +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == name` +/// + `nullptr == ppFunctionAddress` +func ZeDriverGetExtensionFunctionAddress( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance + name *byte, // name [in] extension function name + ppFunctionAddress *unsafe.Pointer, // ppFunctionAddress [out] pointer to function pointer +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDriverGetExtensionFunctionAddress", uintptr(hDriver), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(ppFunctionAddress))) +} + +// ZeDriverGetLastErrorDescription Retrieves a string describing the last error code returned by the +/// 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 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_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ppString` +func ZeDriverGetLastErrorDescription( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance + ppString **byte, // ppString [in,out] pointer to a null-terminated array of characters describing cause of error. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDriverGetLastErrorDescription", uintptr(hDriver), uintptr(unsafe.Pointer(ppString))) +} + +// ZeDriverGetDefaultContext Retrieves handle to default context from the driver. +/// +/// @details +/// - The implementation of this function should be lock-free. +/// - This returned context contains all the devices available in the +/// driver. +/// - This function does not return error code, to get info about failure +/// user may use ::zeDriverGetLastErrorDescription function. +/// - In case of failure, this function returns null. +/// - Details on the error can be retrieved using +/// ::zeDriverGetLastErrorDescription function. +/// +/// @returns +/// - handle of the default context +/// - nullptr +func ZeDriverGetDefaultContext( + hDriver ZeDriverHandle, // hDriver [in] handle of the driver instance +) (ZeContextHandle, error) { + return zecall.Call[ZeContextHandle]("zeDriverGetDefaultContext", uintptr(hDriver)) +} + diff --git a/core/driverDDIHandles.go b/core/driverDDIHandles.go new file mode 100644 index 0000000..259d756 --- /dev/null +++ b/core/driverDDIHandles.go @@ -0,0 +1,52 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" +) + +// ZE_DRIVER_DDI_HANDLES_EXT_NAME Driver Direct Device Interface (DDI) Handles Extension Name +const ZE_DRIVER_DDI_HANDLES_EXT_NAME = "ZE_extension_driver_ddi_handles" + +// ZeDriverDdiHandlesExtVersion (ze_driver_ddi_handles_ext_version_t) Driver Direct Device Interface (DDI) Handles Extension Version(s) +type ZeDriverDdiHandlesExtVersion uintptr +const ( + ZE_DRIVER_DDI_HANDLES_EXT_VERSION_1_0 ZeDriverDdiHandlesExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_DRIVER_DDI_HANDLES_EXT_VERSION_1_0 version 1.0 + ZE_DRIVER_DDI_HANDLES_EXT_VERSION_1_1 ZeDriverDdiHandlesExtVersion = /* ZE_MAKE_VERSION( 1, 1 ) */((( 1 << 16 )|( 1 & 0x0000ffff))) // ZE_DRIVER_DDI_HANDLES_EXT_VERSION_1_1 version 1.1 + ZE_DRIVER_DDI_HANDLES_EXT_VERSION_CURRENT ZeDriverDdiHandlesExtVersion = /* ZE_MAKE_VERSION( 1, 1 ) */((( 1 << 16 )|( 1 & 0x0000ffff))) // ZE_DRIVER_DDI_HANDLES_EXT_VERSION_CURRENT latest known version + ZE_DRIVER_DDI_HANDLES_EXT_VERSION_FORCE_UINT32 ZeDriverDdiHandlesExtVersion = 0x7fffffff // ZE_DRIVER_DDI_HANDLES_EXT_VERSION_FORCE_UINT32 Value marking end of ZE_DRIVER_DDI_HANDLES_EXT_VERSION_* ENUMs + +) + +// ZeDriverDdiHandleExtFlags (ze_driver_ddi_handle_ext_flags_t) Driver Direct Device Interface (DDI) Handle Extension Flags +type ZeDriverDdiHandleExtFlags uint32 +const ( + ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED ZeDriverDdiHandleExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED Driver Supports DDI Handles Extension + ZE_DRIVER_DDI_HANDLE_EXT_FLAG_FORCE_UINT32 ZeDriverDdiHandleExtFlags = 0x7fffffff // ZE_DRIVER_DDI_HANDLE_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_DRIVER_DDI_HANDLE_EXT_FLAG_* ENUMs + +) + +// ZeDriverDdiHandlesExtProperties (ze_driver_ddi_handles_ext_properties_t) Driver DDI Handles properties queried using ::zeDriverGetProperties +/// +/// @details +/// - This structure may be returned from ::zeDriverGetProperties, via the +/// `pNext` member of ::ze_driver_properties_t. +type ZeDriverDdiHandlesExtProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeDriverDdiHandleExtFlags // Flags [out] 0 (none) or a valid combination of ::ze_driver_ddi_handle_ext_flags_t + +} + diff --git a/core/event.go b/core/event.go new file mode 100644 index 0000000..0738a0a --- /dev/null +++ b/core/event.go @@ -0,0 +1,1155 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeEventPoolFlags (ze_event_pool_flags_t) Supported event pool creation flags +type ZeEventPoolFlags uint32 +const ( + ZE_EVENT_POOL_FLAG_HOST_VISIBLE ZeEventPoolFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_EVENT_POOL_FLAG_HOST_VISIBLE signals and waits are also visible to host + ZE_EVENT_POOL_FLAG_IPC ZeEventPoolFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_EVENT_POOL_FLAG_IPC signals and waits may be shared across processes + ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP ZeEventPoolFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP Indicates all events in pool will contain kernel timestamps + ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP ZeEventPoolFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP Indicates all events in pool will contain kernel timestamps + + ///< synchronized to host time domain; cannot be combined with + ///< ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP + + ZE_EVENT_POOL_FLAG_FORCE_UINT32 ZeEventPoolFlags = 0x7fffffff // ZE_EVENT_POOL_FLAG_FORCE_UINT32 Value marking end of ZE_EVENT_POOL_FLAG_* ENUMs + +) + +// ZeEventPoolDesc (ze_event_pool_desc_t) Event pool descriptor +type ZeEventPoolDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeEventPoolFlags // Flags [in] creation flags. must be 0 (default) or a valid combination of ::ze_event_pool_flag_t; default behavior is signals and waits are visible to the entire device and peer devices. + Count uint32 // Count [in] number of events within the pool; must be greater than 0 + +} + +// ZeEventPoolCreate Creates a pool of events on the context. +/// +/// @details +/// - The application must only use events within the pool for the +/// device(s), or their sub-devices, which were provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phEventPool` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0xf < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `0 == desc->count` +/// + `(nullptr == phDevices) && (0 < numDevices)` +func ZeEventPoolCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + desc *ZeEventPoolDesc, // desc [in] pointer to event pool descriptor + numDevices uint32, // numDevices [in][optional] number of device handles; must be 0 if `nullptr == phDevices` + phDevices *ZeDeviceHandle, // phDevices [in][optional][range(0, numDevices)] array of device handles which have visibility to the event pool. if nullptr, then event pool is visible to all devices supported by the driver instance. + phEventPool *ZeEventPoolHandle, // phEventPool [out] pointer handle of event pool object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolCreate", uintptr(hContext), uintptr(unsafe.Pointer(desc)), uintptr(numDevices), uintptr(unsafe.Pointer(phDevices)), uintptr(unsafe.Pointer(phEventPool))) +} + +// ZeEventPoolDestroy Deletes an event pool object. +/// +/// @details +/// - The application must destroy all event handles created from the pool +/// before destroying the pool itself. +/// - The application must ensure the device is not currently referencing +/// the any event within the pool before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this event pool. +/// - The application must **not** call this function from simultaneous +/// threads with the same event pool handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hEventPool` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeEventPoolDestroy( + hEventPool ZeEventPoolHandle, // hEventPool [in][release] handle of event pool object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolDestroy", uintptr(hEventPool)) +} + +// ZeEventScopeFlags (ze_event_scope_flags_t) Supported event scope flags +type ZeEventScopeFlags uint32 +const ( + ZE_EVENT_SCOPE_FLAG_SUBDEVICE ZeEventScopeFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_EVENT_SCOPE_FLAG_SUBDEVICE cache hierarchies are flushed or invalidated sufficient for local + + ///< sub-device access + + ZE_EVENT_SCOPE_FLAG_DEVICE ZeEventScopeFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_EVENT_SCOPE_FLAG_DEVICE cache hierarchies are flushed or invalidated sufficient for global + + ///< device access and peer device access + + ZE_EVENT_SCOPE_FLAG_HOST ZeEventScopeFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_EVENT_SCOPE_FLAG_HOST cache hierarchies are flushed or invalidated sufficient for device and + + ///< host access + + ZE_EVENT_SCOPE_FLAG_FORCE_UINT32 ZeEventScopeFlags = 0x7fffffff // ZE_EVENT_SCOPE_FLAG_FORCE_UINT32 Value marking end of ZE_EVENT_SCOPE_FLAG_* ENUMs + +) + +// ZeEventCounterBasedFlags (ze_event_counter_based_flags_t) Supported flags for defining counter based event +type ZeEventCounterBasedFlags uint32 +const ( + ZE_EVENT_COUNTER_BASED_FLAG_IMMEDIATE ZeEventCounterBasedFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_EVENT_COUNTER_BASED_FLAG_IMMEDIATE Counter-based event is used for immediate command lists (default) + ZE_EVENT_COUNTER_BASED_FLAG_NON_IMMEDIATE ZeEventCounterBasedFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_EVENT_COUNTER_BASED_FLAG_NON_IMMEDIATE Counter-based event is used for non-immediate command lists + ZE_EVENT_COUNTER_BASED_FLAG_HOST_VISIBLE ZeEventCounterBasedFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_EVENT_COUNTER_BASED_FLAG_HOST_VISIBLE Signals and waits are also visible to host + ZE_EVENT_COUNTER_BASED_FLAG_IPC ZeEventCounterBasedFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_EVENT_COUNTER_BASED_FLAG_IPC Event can be shared across processes for waiting + ZE_EVENT_COUNTER_BASED_FLAG_DEVICE_TIMESTAMP ZeEventCounterBasedFlags = /* ZE_BIT(4) */(( 1 << 4 )) // ZE_EVENT_COUNTER_BASED_FLAG_DEVICE_TIMESTAMP Event contains timestamps populated in the device time domain. + + ///< Implementation of this can be vendor specific, but typically pulled + ///< from timers on the offload device and not the host. + ///< Cannot be combined with ::ZE_EVENT_COUNTER_BASED_FLAG_HOST_TIMESTAMP + + ZE_EVENT_COUNTER_BASED_FLAG_HOST_TIMESTAMP ZeEventCounterBasedFlags = /* ZE_BIT(5) */(( 1 << 5 )) // ZE_EVENT_COUNTER_BASED_FLAG_HOST_TIMESTAMP Indicates that event will contain timestamps converted to the host + + ///< time domain + ///< Cannot be combined with ::ZE_EVENT_COUNTER_BASED_FLAG_DEVICE_TIMESTAMP + ///< It is recommended to use this flag for most users that want to + ///< correlate timestamps from the host and device into a single timeline. + ///< For host timestamps see ::zeDeviceGetGlobalTimestamps. + + ZE_EVENT_COUNTER_BASED_FLAG_FORCE_UINT32 ZeEventCounterBasedFlags = 0x7fffffff // ZE_EVENT_COUNTER_BASED_FLAG_FORCE_UINT32 Value marking end of ZE_EVENT_COUNTER_BASED_FLAG_* ENUMs + +) + +// ZeEventSyncModeFlags (ze_event_sync_mode_flags_t) Supported event sync mode flags +type ZeEventSyncModeFlags uint32 +const ( + ZE_EVENT_SYNC_MODE_FLAG_LOW_POWER_WAIT ZeEventSyncModeFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_EVENT_SYNC_MODE_FLAG_LOW_POWER_WAIT Low power host synchronization mode, for better CPU utilization + ZE_EVENT_SYNC_MODE_FLAG_SIGNAL_INTERRUPT ZeEventSyncModeFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_EVENT_SYNC_MODE_FLAG_SIGNAL_INTERRUPT Generate interrupt when Event is signalled on Device. It may be used + + ///< to optimize low power CPU synchronization + + ZE_EVENT_SYNC_MODE_FLAG_EXTERNAL_INTERRUPT_WAIT ZeEventSyncModeFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_EVENT_SYNC_MODE_FLAG_EXTERNAL_INTERRUPT_WAIT Host synchronization APIs wait for external interrupt id. Can be used + + ///< only for Counter Based Events + + ZE_EVENT_SYNC_MODE_FLAG_FORCE_UINT32 ZeEventSyncModeFlags = 0x7fffffff // ZE_EVENT_SYNC_MODE_FLAG_FORCE_UINT32 Value marking end of ZE_EVENT_SYNC_MODE_FLAG_* ENUMs + +) + +// ZeEventSyncModeDesc (ze_event_sync_mode_desc_t) Event sync mode descriptor +type ZeEventSyncModeDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Syncmodeflags ZeEventSyncModeFlags // Syncmodeflags [in] valid combination of ::ze_event_sync_mode_flag_t + Externalinterruptid uint32 // Externalinterruptid [in] External interrupt id. Used only when ::ZE_EVENT_SYNC_MODE_FLAG_EXTERNAL_INTERRUPT_WAIT flag is set + +} + +// ZeEventDesc (ze_event_desc_t) Event descriptor +type ZeEventDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Index uint32 // Index [in] index of the event within the pool; must be less than the count specified during pool creation + Signal ZeEventScopeFlags // Signal [in] defines the scope of relevant cache hierarchies to flush on a signal action before the event is triggered. must be 0 (default) or a valid combination of ::ze_event_scope_flag_t; default behavior is synchronization within the command list only, no additional cache hierarchies are flushed. + Wait ZeEventScopeFlags // Wait [in] defines the scope of relevant cache hierarchies to invalidate on a wait action after the event is complete. must be 0 (default) or a valid combination of ::ze_event_scope_flag_t; default behavior is synchronization within the command list only, no additional cache hierarchies are invalidated. + +} + +// ZeEventCounterBasedDesc (ze_event_counter_based_desc_t) Counter Based Event descriptor +type ZeEventCounterBasedDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeEventCounterBasedFlags // Flags [in] counter based event flags. Must be 0 (default) or a valid combination of ::ze_event_counter_based_flag_t + Signal ZeEventScopeFlags // Signal [in] defines the scope of relevant cache hierarchies to flush on a signal action before the event is triggered. must be 0 (default) or a valid combination of ::ze_event_scope_flag_t; default behavior is synchronization within the command list only, no additional cache hierarchies are flushed. + Wait ZeEventScopeFlags // Wait [in] defines the scope of relevant cache hierarchies to invalidate on a wait action after the event is complete. must be 0 (default) or a valid combination of ::ze_event_scope_flag_t; default behavior is synchronization within the command list only, no additional cache hierarchies are invalidated. + +} + +// ZeEventCounterBasedExternalSyncAllocationDesc (ze_event_counter_based_external_sync_allocation_desc_t) Counter Based Event external sync allocation descriptor. Passed as +/// pNext to ::ze_event_counter_based_desc_t +type ZeEventCounterBasedExternalSyncAllocationDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Deviceaddress *uint64 // Deviceaddress [in] device address for external synchronization allocation + Hostaddress *uint64 // Hostaddress [in] host address for external synchronization allocation + Completionvalue uint64 // Completionvalue [in] completion value for external synchronization allocation + +} + +// ZeEventCounterBasedExternalAggregateStorageDesc (ze_event_counter_based_external_aggregate_storage_desc_t) Counter Based Event external aggregate storage. Passed as pNext to +/// ::ze_event_counter_based_desc_t +type ZeEventCounterBasedExternalAggregateStorageDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Deviceaddress *uint64 // Deviceaddress [in] device address that would be updated with atomic_add upon signaling of this event, must be device USM memory + Incrementvalue uint64 // Incrementvalue [in] value which would by atomically added upon each completion + Completionvalue uint64 // Completionvalue [in] final completion value, when value under deviceAddress is equal or greater then this value then event is considered as completed + +} + +// ZeEventCreate Creates an event from the pool. +/// +/// @details +/// - An event is used to communicate fine-grain host-to-device, +/// device-to-host or device-to-device dependencies have completed. +/// - The application must ensure the location in the pool is not being used +/// by another event. +/// - The application must **not** call this function from simultaneous +/// threads with the same event pool handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clCreateUserEvent** +/// - vkCreateEvent +/// +/// @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_HANDLE +/// + `nullptr == hEventPool` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phEvent` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x7 < desc->signal` +/// + `0x7 < desc->wait` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeEventCreate( + hEventPool ZeEventPoolHandle, // hEventPool [in] handle of the event pool + desc *ZeEventDesc, // desc [in] pointer to event descriptor + phEvent *ZeEventHandle, // phEvent [out] pointer to handle of event object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventCreate", uintptr(hEventPool), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phEvent))) +} + +// ZeEventCounterBasedCreate Creates Counter Based Event +/// +/// @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_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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phEvent` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3f < desc->flags` +/// + `0x7 < desc->signal` +/// + `0x7 < desc->wait` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +func ZeEventCounterBasedCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object + desc *ZeEventCounterBasedDesc, // desc [in] pointer to counter based event descriptor + phEvent *ZeEventHandle, // phEvent [out] pointer to handle of event object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventCounterBasedCreate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phEvent))) +} + +// ZeEventDestroy Deletes an event object. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the event before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this event. +/// - The application must **not** call this function from simultaneous +/// threads with the same event handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clReleaseEvent** +/// - vkDestroyEvent +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeEventDestroy( + hEvent ZeEventHandle, // hEvent [in][release] handle of event object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventDestroy", uintptr(hEvent)) +} + +// ZeEventPoolGetIpcHandle Gets an IPC event pool handle for the specified event handle that can +/// be shared with another process. +/// +/// @details +/// - Event pool must have been created with ::ZE_EVENT_POOL_FLAG_IPC. +/// - The application may call this function from simultaneous threads. +/// +/// @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_HANDLE +/// + `nullptr == hEventPool` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phIpc` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeEventPoolGetIpcHandle( + hEventPool ZeEventPoolHandle, // hEventPool [in] handle of event pool object + phIpc *ZeIpcEventPoolHandle, // phIpc [out] Returned IPC event handle +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolGetIpcHandle", uintptr(hEventPool), uintptr(unsafe.Pointer(phIpc))) +} + +// ZeEventPoolPutIpcHandle Returns an IPC event pool handle to the driver +/// +/// @details +/// - This call must be used for IPC handles previously obtained with +/// ::zeEventPoolGetIpcHandle. +/// - Upon call, driver may release any underlying resources associated with +/// the IPC handle. +/// For instance, it may close the file descriptor contained in the IPC +/// handle, if such type of handle is being used by the driver. +/// - This call does not destroy the original event pool for which the IPC +/// handle was created. +/// - This function may **not** be called from simultaneous threads with the +/// same IPC handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +func ZeEventPoolPutIpcHandle( + hContext ZeContextHandle, // hContext [in] handle of the context object associated with the IPC event pool handle + hIpc *ZeIpcEventPoolHandle, // hIpc [in] IPC event pool handle (gozel hack: converted to a hidden pointer from a struct value) +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolPutIpcHandle", uintptr(hContext), uintptr(unsafe.Pointer(hIpc))) +} + +// ZeEventPoolOpenIpcHandle Opens an IPC event pool handle to retrieve an event pool handle from +/// another process. +/// +/// @details +/// - Multiple calls to this function with the same IPC handle will return +/// unique event pool handles. +/// - The event handle in this process should not be freed with +/// ::zeEventPoolDestroy, but rather with ::zeEventPoolCloseIpcHandle. +/// - If the original event pool has been created for a device containing a +/// number of sub-devices, then the event pool +/// returned by this call may be used on a device containing the same +/// number of sub-devices, or on any of +/// those sub-devices. +/// - However, if the original event pool has been created for a sub-device, +/// then the event pool returned by this call +/// cannot be used on a device containing any number of sub-devices, and +/// must be used only in a sub-device. This ensures +/// functional correctness for any implementation or optimizations the +/// underlying Level Zero driver may do on +/// event pools and events. +/// - The application may call this function from simultaneous threads. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phEventPool` +func ZeEventPoolOpenIpcHandle( + hContext ZeContextHandle, // hContext [in] handle of the context object to associate with the IPC event pool handle + hIpc *ZeIpcEventPoolHandle, // hIpc [in] IPC event pool handle (gozel hack: converted to a hidden pointer from a struct value) + phEventPool *ZeEventPoolHandle, // phEventPool [out] pointer handle of event pool object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolOpenIpcHandle", uintptr(hContext), uintptr(unsafe.Pointer(hIpc)), uintptr(unsafe.Pointer(phEventPool))) +} + +// ZeEventPoolCloseIpcHandle Closes an IPC event handle in the current process. +/// +/// @details +/// - Closes an IPC event handle by destroying events that were opened in +/// this process using ::zeEventPoolOpenIpcHandle. +/// - The application must **not** call this function from simultaneous +/// threads with the same event pool handle. +/// +/// @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_HANDLE +/// + `nullptr == hEventPool` +func ZeEventPoolCloseIpcHandle( + hEventPool ZeEventPoolHandle, // hEventPool [in][release] handle of event pool object +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolCloseIpcHandle", uintptr(hEventPool)) +} + +// ZeEventCounterBasedGetIpcHandle Gets an IPC counter based event handle that can be shared with another +/// process. +/// +/// @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_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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phIpc` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +func ZeEventCounterBasedGetIpcHandle( + hEvent ZeEventHandle, // hEvent [in] handle of event object + phIpc *ZeIpcEventCounterBasedHandle, // phIpc [out] Returned IPC event handle +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventCounterBasedGetIpcHandle", uintptr(hEvent), uintptr(unsafe.Pointer(phIpc))) +} + +// ZeEventCounterBasedOpenIpcHandle Opens an IPC event handle to retrieve from another process. +/// +/// @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_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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phEvent` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +func ZeEventCounterBasedOpenIpcHandle( + hContext ZeContextHandle, // hContext [in] handle of the context object to associate with the IPC event handle + hIpc *ZeIpcEventCounterBasedHandle, // hIpc [in] IPC event handle (gozel hack: converted to a hidden pointer from a struct value) + phEvent *ZeEventHandle, // phEvent [out] pointer handle of event object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventCounterBasedOpenIpcHandle", uintptr(hContext), uintptr(unsafe.Pointer(hIpc)), uintptr(unsafe.Pointer(phEvent))) +} + +// ZeEventCounterBasedCloseIpcHandle Closes an IPC event handle in the current process. +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeEventCounterBasedCloseIpcHandle( + hEvent ZeEventHandle, // hEvent [in][release] handle of event object +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventCounterBasedCloseIpcHandle", uintptr(hEvent)) +} + +// ZeEventCounterBasedGetDeviceAddress Returns Counter Based Event completion value (counter) and its device +/// address +/// +/// @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_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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == completionValue` +/// + `nullptr == deviceAddress` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +func ZeEventCounterBasedGetDeviceAddress( + hEvent ZeEventHandle, // hEvent [in] handle of event object + completionValue *uint64, // completionValue [in][out] completion value + deviceAddress *uint64, // deviceAddress [in][out] counter device address +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventCounterBasedGetDeviceAddress", uintptr(hEvent), uintptr(unsafe.Pointer(completionValue)), uintptr(unsafe.Pointer(deviceAddress))) +} + +// ZeCommandListAppendSignalEvent Appends a signal of the event from the device into a command list. +/// +/// @details +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The duration of an event created from an event pool that was created +/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. +/// However, for consistency and orthogonality the event will report +/// correctly as signaled when used by other event API functionality. +/// - The application must ensure the command list and events were created +/// on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clSetUserEventStatus** +/// - vkCmdSetEvent +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeCommandListAppendSignalEvent( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hEvent ZeEventHandle, // hEvent [in] handle of the event +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendSignalEvent", uintptr(hCommandList), uintptr(hEvent)) +} + +// ZeCommandListAppendWaitOnEvents Appends wait on event(s) on the device into a command list. +/// +/// @details +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The application must ensure the command list and events were created +/// on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phEvents` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeCommandListAppendWaitOnEvents( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + numEvents uint32, // numEvents [in] number of events to wait on before continuing + phEvents *ZeEventHandle, // phEvents [in][range(0, numEvents)] handles of the events to wait on before continuing +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendWaitOnEvents", uintptr(hCommandList), uintptr(numEvents), uintptr(unsafe.Pointer(phEvents))) +} + +// ZeEventHostSignal Signals a event from host. +/// +/// @details +/// - The duration of an event created from an event pool that was created +/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. +/// However, for consistency and orthogonality the event will report +/// correctly as signaled when used by other event API functionality. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clSetUserEventStatus +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeEventHostSignal( + hEvent ZeEventHandle, // hEvent [in] handle of the event +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventHostSignal", uintptr(hEvent)) +} + +// ZeEventHostSynchronize The current host thread waits on an event to be signaled. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - clWaitForEvents +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_NOT_READY +/// + timeout expired +func ZeEventHostSynchronize( + hEvent ZeEventHandle, // hEvent [in] handle of the event + timeout uint64, // timeout [in] if non-zero, then indicates the maximum time (in nanoseconds) to yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; if zero, then operates exactly like ::zeEventQueryStatus; if `UINT64_MAX`, then function will not return until complete or device is lost. Due to external dependencies, timeout may be rounded to the closest value allowed by the accuracy of those dependencies. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventHostSynchronize", uintptr(hEvent), uintptr(timeout)) +} + +// ZeEventQueryStatus Queries an event object's status on the host. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **clGetEventInfo** +/// - vkGetEventStatus +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_NOT_READY +/// + not signaled +func ZeEventQueryStatus( + hEvent ZeEventHandle, // hEvent [in] handle of the event +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventQueryStatus", uintptr(hEvent)) +} + +// ZeCommandListAppendEventReset Appends a reset of an event back to not signaled state into a command +/// list. +/// +/// @details +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The application must ensure the command list and events were created +/// on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - vkResetEvent +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeCommandListAppendEventReset( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hEvent ZeEventHandle, // hEvent [in] handle of the event +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendEventReset", uintptr(hCommandList), uintptr(hEvent)) +} + +// ZeEventHostReset The current host thread resets an event back to not signaled state. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - vkResetEvent +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +func ZeEventHostReset( + hEvent ZeEventHandle, // hEvent [in] handle of the event +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventHostReset", uintptr(hEvent)) +} + +// ZeKernelTimestampData (ze_kernel_timestamp_data_t) Kernel timestamp clock data +/// +/// @details +/// - The timestamp frequency can be queried from the `timerResolution` +/// member of ::ze_device_properties_t. +/// - The number of valid bits in the timestamp value can be queried from +/// the `kernelTimestampValidBits` member of ::ze_device_properties_t. +type ZeKernelTimestampData struct { + Kernelstart uint64 // Kernelstart [out] device clock at start of kernel execution + Kernelend uint64 // Kernelend [out] device clock at end of kernel execution + +} + +// ZeKernelTimestampResult (ze_kernel_timestamp_result_t) Kernel timestamp result +type ZeKernelTimestampResult struct { + Global ZeKernelTimestampData // Global [out] wall-clock data + Context ZeKernelTimestampData // Context [out] context-active data; only includes clocks while device context was actively executing. + +} + +// ZeEventQueryKernelTimestamp Queries an event's timestamp value on the host. +/// +/// @details +/// - The application must ensure the event was created from an event pool +/// that was created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag. +/// - The destination memory will be unmodified if the event has not been +/// signaled. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == dstptr` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_NOT_READY +/// + not signaled +func ZeEventQueryKernelTimestamp( + hEvent ZeEventHandle, // hEvent [in] handle of the event + dstptr *ZeKernelTimestampResult, // dstptr [in,out] pointer to memory for where timestamp result will be written. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventQueryKernelTimestamp", uintptr(hEvent), uintptr(unsafe.Pointer(dstptr))) +} + +// ZeCommandListAppendQueryKernelTimestamps Appends a query of an events' timestamp value(s) into a command list. +/// +/// @details +/// - The application must ensure the events are accessible by the device on +/// which the command list was created. +/// - The application must ensure the events were created from an event pool +/// that was created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag. +/// - The application must ensure the memory pointed to by both dstptr and +/// pOffsets is accessible by the device on which the command list was +/// created. +/// - The value(s) written to the destination buffer are undefined if any +/// timestamp event has not been signaled. +/// - If pOffsets is nullptr, then multiple results will be appended +/// sequentially into memory in the same order as phEvents. +/// - The application must ensure the command list and events were created, +/// and the memory was allocated, on the same context. +/// - The application must **not** call this function from simultaneous +/// threads with the same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phEvents` +/// + `nullptr == dstptr` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendQueryKernelTimestamps( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + numEvents uint32, // numEvents [in] the number of timestamp events to query + phEvents *ZeEventHandle, // phEvents [in][range(0, numEvents)] handles of timestamp events to query + dstptr unsafe.Pointer, // dstptr [in,out] pointer to memory where ::ze_kernel_timestamp_result_t will be written; must be size-aligned. + pOffsets *uintptr, // pOffsets [in][optional][range(0, numEvents)] offset, in bytes, to write results; address must be 4byte-aligned and offsets must be size-aligned. + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before executing query; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before executing query +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendQueryKernelTimestamps", uintptr(hCommandList), uintptr(numEvents), uintptr(unsafe.Pointer(phEvents)), uintptr(unsafe.Pointer(dstptr)), uintptr(unsafe.Pointer(pOffsets)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeEventGetEventPool Gets the handle of the event pool for the event. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phEventPool` +func ZeEventGetEventPool( + hEvent ZeEventHandle, // hEvent [in] handle of the event + phEventPool *ZeEventPoolHandle, // phEventPool [out] handle of the event pool for the event +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventGetEventPool", uintptr(hEvent), uintptr(unsafe.Pointer(phEventPool))) +} + +// ZeEventGetSignalScope Gets the signal event scope. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pSignalScope` +func ZeEventGetSignalScope( + hEvent ZeEventHandle, // hEvent [in] handle of the event + pSignalScope *ZeEventScopeFlags, // pSignalScope [out] signal event scope. This is the scope of relevant cache hierarchies that are flushed on a signal action before the event is triggered. May be 0 or a valid combination of ::ze_event_scope_flag_t. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventGetSignalScope", uintptr(hEvent), uintptr(unsafe.Pointer(pSignalScope))) +} + +// ZeEventGetWaitScope Gets the wait event scope. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hEvent` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pWaitScope` +func ZeEventGetWaitScope( + hEvent ZeEventHandle, // hEvent [in] handle of the event + pWaitScope *ZeEventScopeFlags, // pWaitScope [out] wait event scope. This is the scope of relevant cache hierarchies invalidated on a wait action after the event is complete. May be 0 or a valid combination of ::ze_event_scope_flag_t. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventGetWaitScope", uintptr(hEvent), uintptr(unsafe.Pointer(pWaitScope))) +} + +// ZeEventPoolGetContextHandle Gets the handle of the context on which the event pool was created. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hEventPool` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phContext` +func ZeEventPoolGetContextHandle( + hEventPool ZeEventPoolHandle, // hEventPool [in] handle of the event pool + phContext *ZeContextHandle, // phContext [out] handle of the context on which the event pool was created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolGetContextHandle", uintptr(hEventPool), uintptr(unsafe.Pointer(phContext))) +} + +// ZeEventPoolGetFlags Gets the creation flags used to create the event pool. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hEventPool` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pFlags` +func ZeEventPoolGetFlags( + hEventPool ZeEventPoolHandle, // hEventPool [in] handle of the event pool + pFlags *ZeEventPoolFlags, // pFlags [out] creation flags used to create the event pool; may be 0 or a valid combination of ::ze_event_pool_flag_t +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeEventPoolGetFlags", uintptr(hEventPool), uintptr(unsafe.Pointer(pFlags))) +} + diff --git a/core/externalSemaphores.go b/core/externalSemaphores.go new file mode 100644 index 0000000..892384c --- /dev/null +++ b/core/externalSemaphores.go @@ -0,0 +1,255 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME External Semaphores Extension Name +const ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME = "ZE_extension_external_semaphores" + +// ZeExternalSemaphoreExtVersion (ze_external_semaphore_ext_version_t) External Semaphores Extension Version +type ZeExternalSemaphoreExtVersion uintptr +const ( + ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_1_0 ZeExternalSemaphoreExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_1_0 version 1.0 + ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_CURRENT ZeExternalSemaphoreExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_CURRENT latest known version + ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_FORCE_UINT32 ZeExternalSemaphoreExtVersion = 0x7fffffff // ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_FORCE_UINT32 Value marking end of ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_* ENUMs + +) + +// ZeExternalSemaphoreExtHandle (ze_external_semaphore_ext_handle_t) Handle of external semaphore object +type ZeExternalSemaphoreExtHandle uintptr + +// ZeExternalSemaphoreExtFlags (ze_external_semaphore_ext_flags_t) External Semaphores Type Flags +type ZeExternalSemaphoreExtFlags uint32 +const ( + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_FD ZeExternalSemaphoreExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_FD Semaphore is an Linux opaque file descriptor + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_WIN32 ZeExternalSemaphoreExtFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_WIN32 Semaphore is an opaque Win32 handle for monitored fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_WIN32_KMT ZeExternalSemaphoreExtFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_WIN32_KMT Semaphore is an opaque Win32 KMT handle for monitored fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE ZeExternalSemaphoreExtFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE Semaphore is a D3D12 fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D11_FENCE ZeExternalSemaphoreExtFlags = /* ZE_BIT(4) */(( 1 << 4 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D11_FENCE Semaphore is a D3D11 fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_KEYED_MUTEX ZeExternalSemaphoreExtFlags = /* ZE_BIT(5) */(( 1 << 5 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_KEYED_MUTEX Semaphore is a keyed mutex for Win32 + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_KEYED_MUTEX_KMT ZeExternalSemaphoreExtFlags = /* ZE_BIT(6) */(( 1 << 6 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_KEYED_MUTEX_KMT Semaphore is a keyed mutex for Win32 KMT + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_VK_TIMELINE_SEMAPHORE_FD ZeExternalSemaphoreExtFlags = /* ZE_BIT(7) */(( 1 << 7 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_VK_TIMELINE_SEMAPHORE_FD Semaphore is a Vulkan Timeline semaphore for Linux + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_VK_TIMELINE_SEMAPHORE_WIN32 ZeExternalSemaphoreExtFlags = /* ZE_BIT(8) */(( 1 << 8 )) // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_VK_TIMELINE_SEMAPHORE_WIN32 Semaphore is a Vulkan Timeline semaphore for Win32 + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_FORCE_UINT32 ZeExternalSemaphoreExtFlags = 0x7fffffff // ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_* ENUMs + +) + +// ZeExternalSemaphoreExtDesc (ze_external_semaphore_ext_desc_t) External Semaphore Descriptor +type ZeExternalSemaphoreExtDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeExternalSemaphoreExtFlags // Flags [in] The flags describing the type of the semaphore. must be 0 (default) or a valid combination of ::ze_external_semaphore_ext_flag_t. When importing a semaphore, pNext should be pointing to one of the following structures: ::ze_external_semaphore_win32_ext_desc_t or ::ze_external_semaphore_fd_ext_desc_t. + +} + +// ZeExternalSemaphoreWin32ExtDesc (ze_external_semaphore_win32_ext_desc_t) External Semaphore Win32 Descriptor +type ZeExternalSemaphoreWin32ExtDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Handle unsafe.Pointer // Handle [in] Win32 handle of the semaphore. Must be a valid Win32 handle. + Name *byte // Name [in] Name of the semaphore. Must be a valid null-terminated string. + +} + +// ZeExternalSemaphoreFdExtDesc (ze_external_semaphore_fd_ext_desc_t) External Semaphore FD Descriptor +type ZeExternalSemaphoreFdExtDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Fd int32 // Fd [in] File descriptor of the semaphore. Must be a valid file descriptor. + +} + +// ZeExternalSemaphoreSignalParamsExt (ze_external_semaphore_signal_params_ext_t) External Semaphore Signal parameters +type ZeExternalSemaphoreSignalParamsExt struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Value uint64 // Value [in] [optional] Value to signal. Specified by user as an expected value with some of semaphore types, such as ::ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE. + +} + +// ZeExternalSemaphoreWaitParamsExt (ze_external_semaphore_wait_params_ext_t) External Semaphore Wait parameters +type ZeExternalSemaphoreWaitParamsExt struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Value uint64 // Value [in] [optional] Value to wait for. Specified by user as an expected value with some of semaphore types, such as ::ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE. + +} + +// ZeDeviceImportExternalSemaphoreExt Import an external semaphore +/// +/// @details +/// - Imports an external semaphore. +/// - This function may be called from simultaneous threads with the same +/// device handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phSemaphore` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x1ff < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeDeviceImportExternalSemaphoreExt( + hDevice ZeDeviceHandle, // hDevice [in] The device handle. + desc *ZeExternalSemaphoreExtDesc, // desc [in] The pointer to external semaphore descriptor. + phSemaphore *ZeExternalSemaphoreExtHandle, // phSemaphore [out] The handle of the external semaphore imported. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceImportExternalSemaphoreExt", uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phSemaphore))) +} + +// ZeDeviceReleaseExternalSemaphoreExt Release an external semaphore +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the semaphore before it is released. +/// - The application must **not** call this function from simultaneous +/// threads with the same semaphore handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hSemaphore` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeDeviceReleaseExternalSemaphoreExt( + hSemaphore ZeExternalSemaphoreExtHandle, // hSemaphore [in] The handle of the external semaphore. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeDeviceReleaseExternalSemaphoreExt", uintptr(hSemaphore)) +} + +// ZeCommandListAppendSignalExternalSemaphoreExt Signal an external semaphore +/// +/// @details +/// - Signals an external semaphore. +/// - This function must only be used with an immediate command list. +/// - This function may be called from simultaneous threads with the same +/// command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phSemaphores` +/// + `nullptr == signalParams` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// + `(nullptr == phSemaphores) && (0 < numSemaphores)` +/// + `(nullptr == signalParams) && (0 < numSemaphores)` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Commandlist handle does not correspond to an immediate command list +func ZeCommandListAppendSignalExternalSemaphoreExt( + hCommandList ZeCommandListHandle, // hCommandList [in] The command list handle. + numSemaphores uint32, // numSemaphores [in] The number of external semaphores. + phSemaphores *ZeExternalSemaphoreExtHandle, // phSemaphores [in][range(0, numSemaphores)] The array of pointers to external semaphore handles to be appended into command list. + signalParams *ZeExternalSemaphoreSignalParamsExt, // signalParams [in][range(0, numSemaphores)] The array of pointers to external semaphore signal parameters. + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendSignalExternalSemaphoreExt", uintptr(hCommandList), uintptr(numSemaphores), uintptr(unsafe.Pointer(phSemaphores)), uintptr(unsafe.Pointer(signalParams)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendWaitExternalSemaphoreExt Wait on external semaphores +/// +/// @details +/// - Waits on external semaphores. +/// - This function must only be used with an immediate command list. +/// - This function may be called from simultaneous threads with the same +/// command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phSemaphores` +/// + `nullptr == waitParams` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// + `(nullptr == phSemaphores) && (0 < numSemaphores)` +/// + `(nullptr == waitParams) && (0 < numSemaphores)` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Commandlist handle does not correspond to an immediate command list +func ZeCommandListAppendWaitExternalSemaphoreExt( + hCommandList ZeCommandListHandle, // hCommandList [in] The command list handle. + numSemaphores uint32, // numSemaphores [in] The number of external semaphores. + phSemaphores *ZeExternalSemaphoreExtHandle, // phSemaphores [in][range(0,numSemaphores)] The array of pointers to external semaphore handles to append into command list. + waitParams *ZeExternalSemaphoreWaitParamsExt, // waitParams [in][range(0,numSemaphores)] The array of pointers to external semaphore wait parameters. + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendWaitExternalSemaphoreExt", uintptr(hCommandList), uintptr(numSemaphores), uintptr(unsafe.Pointer(phSemaphores)), uintptr(unsafe.Pointer(waitParams)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + diff --git a/core/fence.go b/core/fence.go new file mode 100644 index 0000000..c78b941 --- /dev/null +++ b/core/fence.go @@ -0,0 +1,222 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeFenceFlags (ze_fence_flags_t) Supported fence creation flags +type ZeFenceFlags uint32 +const ( + ZE_FENCE_FLAG_SIGNALED ZeFenceFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_FENCE_FLAG_SIGNALED fence is created in the signaled state, otherwise not signaled. + ZE_FENCE_FLAG_FORCE_UINT32 ZeFenceFlags = 0x7fffffff // ZE_FENCE_FLAG_FORCE_UINT32 Value marking end of ZE_FENCE_FLAG_* ENUMs + +) + +// ZeFenceDesc (ze_fence_desc_t) Fence descriptor +type ZeFenceDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeFenceFlags // Flags [in] creation flags. must be 0 (default) or a valid combination of ::ze_fence_flag_t. + +} + +// ZeFenceCreate Creates a fence for the command queue. +/// +/// @details +/// - A fence is a heavyweight synchronization primitive used to communicate +/// to the host that command list execution has completed. +/// - The application must only use the fence for the command queue which +/// was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @remarks +/// _Analogues_ +/// - **vkCreateFence** +/// +/// @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_HANDLE +/// + `nullptr == hCommandQueue` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phFence` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x1 < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeFenceCreate( + hCommandQueue ZeCommandQueueHandle, // hCommandQueue [in] handle of command queue + desc *ZeFenceDesc, // desc [in] pointer to fence descriptor + phFence *ZeFenceHandle, // phFence [out] pointer to handle of fence object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeFenceCreate", uintptr(hCommandQueue), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phFence))) +} + +// ZeFenceDestroy Deletes a fence object. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the fence before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this fence. +/// - The application must **not** call this function from simultaneous +/// threads with the same fence handle. +/// - The implementation of this function must be thread-safe. +/// +/// @remarks +/// _Analogues_ +/// - **vkDestroyFence** +/// +/// @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_HANDLE +/// + `nullptr == hFence` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeFenceDestroy( + hFence ZeFenceHandle, // hFence [in][release] handle of fence object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeFenceDestroy", uintptr(hFence)) +} + +// ZeFenceHostSynchronize The current host thread waits on a fence to be signaled. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **vkWaitForFences** +/// +/// @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_HANDLE +/// + `nullptr == hFence` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_NOT_READY +/// + timeout expired +func ZeFenceHostSynchronize( + hFence ZeFenceHandle, // hFence [in] handle of the fence + timeout uint64, // timeout [in] if non-zero, then indicates the maximum time (in nanoseconds) to yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; if zero, then operates exactly like ::zeFenceQueryStatus; if `UINT64_MAX`, then function will not return until complete or device is lost. Due to external dependencies, timeout may be rounded to the closest value allowed by the accuracy of those dependencies. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeFenceHostSynchronize", uintptr(hFence), uintptr(timeout)) +} + +// ZeFenceQueryStatus Queries a fence object's status. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **vkGetFenceStatus** +/// +/// @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_HANDLE +/// + `nullptr == hFence` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_NOT_READY +/// + not signaled +func ZeFenceQueryStatus( + hFence ZeFenceHandle, // hFence [in] handle of the fence +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeFenceQueryStatus", uintptr(hFence)) +} + +// ZeFenceReset Reset a fence back to the not signaled state. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **vkResetFences** +/// +/// @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_HANDLE +/// + `nullptr == hFence` +func ZeFenceReset( + hFence ZeFenceHandle, // hFence [in] handle of the fence +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeFenceReset", uintptr(hFence)) +} + diff --git a/core/floatAtomics.go b/core/floatAtomics.go new file mode 100644 index 0000000..5b9b89d --- /dev/null +++ b/core/floatAtomics.go @@ -0,0 +1,59 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" +) + +// ZE_FLOAT_ATOMICS_EXT_NAME Floating-Point Atomics Extension Name +const ZE_FLOAT_ATOMICS_EXT_NAME = "ZE_extension_float_atomics" + +// ZeFloatAtomicsExtVersion (ze_float_atomics_ext_version_t) Floating-Point Atomics Extension Version(s) +type ZeFloatAtomicsExtVersion uintptr +const ( + ZE_FLOAT_ATOMICS_EXT_VERSION_1_0 ZeFloatAtomicsExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_FLOAT_ATOMICS_EXT_VERSION_1_0 version 1.0 + ZE_FLOAT_ATOMICS_EXT_VERSION_CURRENT ZeFloatAtomicsExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_FLOAT_ATOMICS_EXT_VERSION_CURRENT latest known version + ZE_FLOAT_ATOMICS_EXT_VERSION_FORCE_UINT32 ZeFloatAtomicsExtVersion = 0x7fffffff // ZE_FLOAT_ATOMICS_EXT_VERSION_FORCE_UINT32 Value marking end of ZE_FLOAT_ATOMICS_EXT_VERSION_* ENUMs + +) + +// ZeDeviceFpAtomicExtFlags (ze_device_fp_atomic_ext_flags_t) Supported floating-point atomic capability flags +type ZeDeviceFpAtomicExtFlags uint32 +const ( + ZE_DEVICE_FP_ATOMIC_EXT_FLAG_GLOBAL_LOAD_STORE ZeDeviceFpAtomicExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_FP_ATOMIC_EXT_FLAG_GLOBAL_LOAD_STORE Supports atomic load, store, and exchange + ZE_DEVICE_FP_ATOMIC_EXT_FLAG_GLOBAL_ADD ZeDeviceFpAtomicExtFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_DEVICE_FP_ATOMIC_EXT_FLAG_GLOBAL_ADD Supports atomic add and subtract + ZE_DEVICE_FP_ATOMIC_EXT_FLAG_GLOBAL_MIN_MAX ZeDeviceFpAtomicExtFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_DEVICE_FP_ATOMIC_EXT_FLAG_GLOBAL_MIN_MAX Supports atomic min and max + ZE_DEVICE_FP_ATOMIC_EXT_FLAG_LOCAL_LOAD_STORE ZeDeviceFpAtomicExtFlags = /* ZE_BIT(16) */(( 1 << 16 )) // ZE_DEVICE_FP_ATOMIC_EXT_FLAG_LOCAL_LOAD_STORE Supports atomic load, store, and exchange + ZE_DEVICE_FP_ATOMIC_EXT_FLAG_LOCAL_ADD ZeDeviceFpAtomicExtFlags = /* ZE_BIT(17) */(( 1 << 17 )) // ZE_DEVICE_FP_ATOMIC_EXT_FLAG_LOCAL_ADD Supports atomic add and subtract + ZE_DEVICE_FP_ATOMIC_EXT_FLAG_LOCAL_MIN_MAX ZeDeviceFpAtomicExtFlags = /* ZE_BIT(18) */(( 1 << 18 )) // ZE_DEVICE_FP_ATOMIC_EXT_FLAG_LOCAL_MIN_MAX Supports atomic min and max + ZE_DEVICE_FP_ATOMIC_EXT_FLAG_FORCE_UINT32 ZeDeviceFpAtomicExtFlags = 0x7fffffff // ZE_DEVICE_FP_ATOMIC_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_FP_ATOMIC_EXT_FLAG_* ENUMs + +) + +// ZeFloatAtomicExtProperties (ze_float_atomic_ext_properties_t) Device floating-point atomic properties queried using +/// ::zeDeviceGetModuleProperties +/// +/// @details +/// - This structure may be returned from ::zeDeviceGetModuleProperties, via +/// the `pNext` member of ::ze_device_module_properties_t. +type ZeFloatAtomicExtProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Fp16flags ZeDeviceFpAtomicExtFlags // Fp16flags [out] Capabilities for half-precision floating-point atomic operations + Fp32flags ZeDeviceFpAtomicExtFlags // Fp32flags [out] Capabilities for single-precision floating-point atomic operations + Fp64flags ZeDeviceFpAtomicExtFlags // Fp64flags [out] Capabilities for double-precision floating-point atomic operations + +} + diff --git a/core/globaloffset.go b/core/globaloffset.go new file mode 100644 index 0000000..80519f5 --- /dev/null +++ b/core/globaloffset.go @@ -0,0 +1,65 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "github.com/fumiama/gozel/internal/zecall" +) + +// ZE_GLOBAL_OFFSET_EXP_NAME Global Offset Extension Name +const ZE_GLOBAL_OFFSET_EXP_NAME = "ZE_experimental_global_offset" + +// ZeGlobalOffsetExpVersion (ze_global_offset_exp_version_t) Global Offset Extension Version(s) +type ZeGlobalOffsetExpVersion uintptr +const ( + ZE_GLOBAL_OFFSET_EXP_VERSION_1_0 ZeGlobalOffsetExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_GLOBAL_OFFSET_EXP_VERSION_1_0 version 1.0 + ZE_GLOBAL_OFFSET_EXP_VERSION_CURRENT ZeGlobalOffsetExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_GLOBAL_OFFSET_EXP_VERSION_CURRENT latest known version + ZE_GLOBAL_OFFSET_EXP_VERSION_FORCE_UINT32 ZeGlobalOffsetExpVersion = 0x7fffffff // ZE_GLOBAL_OFFSET_EXP_VERSION_FORCE_UINT32 Value marking end of ZE_GLOBAL_OFFSET_EXP_VERSION_* ENUMs + +) + +// ZeKernelSetGlobalOffsetExp Set global work offset for a kernel. +/// +/// @details +/// - The global work offset will be used when a +/// ::zeCommandListAppendLaunchKernel() variant is called. +/// - The application must **not** call this function from simultaneous +/// threads with the same kernel handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +func ZeKernelSetGlobalOffsetExp( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + offsetX uint32, // offsetX [in] global offset for X dimension to use for this kernel + offsetY uint32, // offsetY [in] global offset for Y dimension to use for this kernel + offsetZ uint32, // offsetZ [in] global offset for Z dimension to use for this kernel +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelSetGlobalOffsetExp", uintptr(hKernel), uintptr(offsetX), uintptr(offsetY), uintptr(offsetZ)) +} + diff --git a/core/image.go b/core/image.go new file mode 100644 index 0000000..fd0ba59 --- /dev/null +++ b/core/image.go @@ -0,0 +1,283 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeImageFlags (ze_image_flags_t) Supported image creation flags +type ZeImageFlags uint32 +const ( + ZE_IMAGE_FLAG_KERNEL_WRITE ZeImageFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_IMAGE_FLAG_KERNEL_WRITE kernels will write contents + ZE_IMAGE_FLAG_BIAS_UNCACHED ZeImageFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_IMAGE_FLAG_BIAS_UNCACHED device should not cache contents + ZE_IMAGE_FLAG_FORCE_UINT32 ZeImageFlags = 0x7fffffff // ZE_IMAGE_FLAG_FORCE_UINT32 Value marking end of ZE_IMAGE_FLAG_* ENUMs + +) + +// ZeImageType (ze_image_type_t) Supported image types +type ZeImageType uintptr +const ( + ZE_IMAGE_TYPE_1D ZeImageType = 0 // ZE_IMAGE_TYPE_1D 1D + ZE_IMAGE_TYPE_1DARRAY ZeImageType = 1 // ZE_IMAGE_TYPE_1DARRAY 1D array + ZE_IMAGE_TYPE_2D ZeImageType = 2 // ZE_IMAGE_TYPE_2D 2D + ZE_IMAGE_TYPE_2DARRAY ZeImageType = 3 // ZE_IMAGE_TYPE_2DARRAY 2D array + ZE_IMAGE_TYPE_3D ZeImageType = 4 // ZE_IMAGE_TYPE_3D 3D + ZE_IMAGE_TYPE_BUFFER ZeImageType = 5 // ZE_IMAGE_TYPE_BUFFER Buffer + ZE_IMAGE_TYPE_FORCE_UINT32 ZeImageType = 0x7fffffff // ZE_IMAGE_TYPE_FORCE_UINT32 Value marking end of ZE_IMAGE_TYPE_* ENUMs + +) + +// ZeImageFormatLayout (ze_image_format_layout_t) Supported image format layouts +type ZeImageFormatLayout uintptr +const ( + ZE_IMAGE_FORMAT_LAYOUT_8 ZeImageFormatLayout = 0 // ZE_IMAGE_FORMAT_LAYOUT_8 8-bit single component layout + ZE_IMAGE_FORMAT_LAYOUT_16 ZeImageFormatLayout = 1 // ZE_IMAGE_FORMAT_LAYOUT_16 16-bit single component layout + ZE_IMAGE_FORMAT_LAYOUT_32 ZeImageFormatLayout = 2 // ZE_IMAGE_FORMAT_LAYOUT_32 32-bit single component layout + ZE_IMAGE_FORMAT_LAYOUT_8_8 ZeImageFormatLayout = 3 // ZE_IMAGE_FORMAT_LAYOUT_8_8 2-component 8-bit layout + ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8 ZeImageFormatLayout = 4 // ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8 4-component 8-bit layout + ZE_IMAGE_FORMAT_LAYOUT_16_16 ZeImageFormatLayout = 5 // ZE_IMAGE_FORMAT_LAYOUT_16_16 2-component 16-bit layout + ZE_IMAGE_FORMAT_LAYOUT_16_16_16_16 ZeImageFormatLayout = 6 // ZE_IMAGE_FORMAT_LAYOUT_16_16_16_16 4-component 16-bit layout + ZE_IMAGE_FORMAT_LAYOUT_32_32 ZeImageFormatLayout = 7 // ZE_IMAGE_FORMAT_LAYOUT_32_32 2-component 32-bit layout + ZE_IMAGE_FORMAT_LAYOUT_32_32_32_32 ZeImageFormatLayout = 8 // ZE_IMAGE_FORMAT_LAYOUT_32_32_32_32 4-component 32-bit layout + ZE_IMAGE_FORMAT_LAYOUT_10_10_10_2 ZeImageFormatLayout = 9 // ZE_IMAGE_FORMAT_LAYOUT_10_10_10_2 4-component 10_10_10_2 layout + ZE_IMAGE_FORMAT_LAYOUT_11_11_10 ZeImageFormatLayout = 10 // ZE_IMAGE_FORMAT_LAYOUT_11_11_10 3-component 11_11_10 layout + ZE_IMAGE_FORMAT_LAYOUT_5_6_5 ZeImageFormatLayout = 11 // ZE_IMAGE_FORMAT_LAYOUT_5_6_5 3-component 5_6_5 layout + ZE_IMAGE_FORMAT_LAYOUT_5_5_5_1 ZeImageFormatLayout = 12 // ZE_IMAGE_FORMAT_LAYOUT_5_5_5_1 4-component 5_5_5_1 layout + ZE_IMAGE_FORMAT_LAYOUT_4_4_4_4 ZeImageFormatLayout = 13 // ZE_IMAGE_FORMAT_LAYOUT_4_4_4_4 4-component 4_4_4_4 layout + ZE_IMAGE_FORMAT_LAYOUT_Y8 ZeImageFormatLayout = 14 // ZE_IMAGE_FORMAT_LAYOUT_Y8 Media Format: Y8. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_NV12 ZeImageFormatLayout = 15 // ZE_IMAGE_FORMAT_LAYOUT_NV12 Media Format: NV12. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_YUYV ZeImageFormatLayout = 16 // ZE_IMAGE_FORMAT_LAYOUT_YUYV Media Format: YUYV. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_VYUY ZeImageFormatLayout = 17 // ZE_IMAGE_FORMAT_LAYOUT_VYUY Media Format: VYUY. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_YVYU ZeImageFormatLayout = 18 // ZE_IMAGE_FORMAT_LAYOUT_YVYU Media Format: YVYU. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_UYVY ZeImageFormatLayout = 19 // ZE_IMAGE_FORMAT_LAYOUT_UYVY Media Format: UYVY. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_AYUV ZeImageFormatLayout = 20 // ZE_IMAGE_FORMAT_LAYOUT_AYUV Media Format: AYUV. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_P010 ZeImageFormatLayout = 21 // ZE_IMAGE_FORMAT_LAYOUT_P010 Media Format: P010. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_Y410 ZeImageFormatLayout = 22 // ZE_IMAGE_FORMAT_LAYOUT_Y410 Media Format: Y410. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_P012 ZeImageFormatLayout = 23 // ZE_IMAGE_FORMAT_LAYOUT_P012 Media Format: P012. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_Y16 ZeImageFormatLayout = 24 // ZE_IMAGE_FORMAT_LAYOUT_Y16 Media Format: Y16. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_P016 ZeImageFormatLayout = 25 // ZE_IMAGE_FORMAT_LAYOUT_P016 Media Format: P016. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_Y216 ZeImageFormatLayout = 26 // ZE_IMAGE_FORMAT_LAYOUT_Y216 Media Format: Y216. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_P216 ZeImageFormatLayout = 27 // ZE_IMAGE_FORMAT_LAYOUT_P216 Media Format: P216. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_P8 ZeImageFormatLayout = 28 // ZE_IMAGE_FORMAT_LAYOUT_P8 Media Format: P8. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_YUY2 ZeImageFormatLayout = 29 // ZE_IMAGE_FORMAT_LAYOUT_YUY2 Media Format: YUY2. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_A8P8 ZeImageFormatLayout = 30 // ZE_IMAGE_FORMAT_LAYOUT_A8P8 Media Format: A8P8. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_IA44 ZeImageFormatLayout = 31 // ZE_IMAGE_FORMAT_LAYOUT_IA44 Media Format: IA44. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_AI44 ZeImageFormatLayout = 32 // ZE_IMAGE_FORMAT_LAYOUT_AI44 Media Format: AI44. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_Y416 ZeImageFormatLayout = 33 // ZE_IMAGE_FORMAT_LAYOUT_Y416 Media Format: Y416. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_Y210 ZeImageFormatLayout = 34 // ZE_IMAGE_FORMAT_LAYOUT_Y210 Media Format: Y210. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_I420 ZeImageFormatLayout = 35 // ZE_IMAGE_FORMAT_LAYOUT_I420 Media Format: I420. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_YV12 ZeImageFormatLayout = 36 // ZE_IMAGE_FORMAT_LAYOUT_YV12 Media Format: YV12. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_400P ZeImageFormatLayout = 37 // ZE_IMAGE_FORMAT_LAYOUT_400P Media Format: 400P. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_422H ZeImageFormatLayout = 38 // ZE_IMAGE_FORMAT_LAYOUT_422H Media Format: 422H. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_422V ZeImageFormatLayout = 39 // ZE_IMAGE_FORMAT_LAYOUT_422V Media Format: 422V. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_444P ZeImageFormatLayout = 40 // ZE_IMAGE_FORMAT_LAYOUT_444P Media Format: 444P. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_RGBP ZeImageFormatLayout = 41 // ZE_IMAGE_FORMAT_LAYOUT_RGBP Media Format: RGBP. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_BRGP ZeImageFormatLayout = 42 // ZE_IMAGE_FORMAT_LAYOUT_BRGP Media Format: BRGP. Format type and swizzle is ignored for this. + ZE_IMAGE_FORMAT_LAYOUT_8_8_8 ZeImageFormatLayout = 43 // ZE_IMAGE_FORMAT_LAYOUT_8_8_8 3-component 8-bit layout + ZE_IMAGE_FORMAT_LAYOUT_16_16_16 ZeImageFormatLayout = 44 // ZE_IMAGE_FORMAT_LAYOUT_16_16_16 3-component 16-bit layout + ZE_IMAGE_FORMAT_LAYOUT_32_32_32 ZeImageFormatLayout = 45 // ZE_IMAGE_FORMAT_LAYOUT_32_32_32 3-component 32-bit layout + ZE_IMAGE_FORMAT_LAYOUT_FORCE_UINT32 ZeImageFormatLayout = 0x7fffffff // ZE_IMAGE_FORMAT_LAYOUT_FORCE_UINT32 Value marking end of ZE_IMAGE_FORMAT_LAYOUT_* ENUMs + +) + +// ZeImageFormatType (ze_image_format_type_t) Supported image format types +type ZeImageFormatType uintptr +const ( + ZE_IMAGE_FORMAT_TYPE_UINT ZeImageFormatType = 0 // ZE_IMAGE_FORMAT_TYPE_UINT Unsigned integer + ZE_IMAGE_FORMAT_TYPE_SINT ZeImageFormatType = 1 // ZE_IMAGE_FORMAT_TYPE_SINT Signed integer + ZE_IMAGE_FORMAT_TYPE_UNORM ZeImageFormatType = 2 // ZE_IMAGE_FORMAT_TYPE_UNORM Unsigned normalized integer + ZE_IMAGE_FORMAT_TYPE_SNORM ZeImageFormatType = 3 // ZE_IMAGE_FORMAT_TYPE_SNORM Signed normalized integer + ZE_IMAGE_FORMAT_TYPE_FLOAT ZeImageFormatType = 4 // ZE_IMAGE_FORMAT_TYPE_FLOAT Float + ZE_IMAGE_FORMAT_TYPE_FORCE_UINT32 ZeImageFormatType = 0x7fffffff // ZE_IMAGE_FORMAT_TYPE_FORCE_UINT32 Value marking end of ZE_IMAGE_FORMAT_TYPE_* ENUMs + +) + +// ZeImageFormatSwizzle (ze_image_format_swizzle_t) Supported image format component swizzle into channel +type ZeImageFormatSwizzle uintptr +const ( + ZE_IMAGE_FORMAT_SWIZZLE_R ZeImageFormatSwizzle = 0 // ZE_IMAGE_FORMAT_SWIZZLE_R Red component + ZE_IMAGE_FORMAT_SWIZZLE_G ZeImageFormatSwizzle = 1 // ZE_IMAGE_FORMAT_SWIZZLE_G Green component + ZE_IMAGE_FORMAT_SWIZZLE_B ZeImageFormatSwizzle = 2 // ZE_IMAGE_FORMAT_SWIZZLE_B Blue component + ZE_IMAGE_FORMAT_SWIZZLE_A ZeImageFormatSwizzle = 3 // ZE_IMAGE_FORMAT_SWIZZLE_A Alpha component + ZE_IMAGE_FORMAT_SWIZZLE_0 ZeImageFormatSwizzle = 4 // ZE_IMAGE_FORMAT_SWIZZLE_0 Zero + ZE_IMAGE_FORMAT_SWIZZLE_1 ZeImageFormatSwizzle = 5 // ZE_IMAGE_FORMAT_SWIZZLE_1 One + ZE_IMAGE_FORMAT_SWIZZLE_X ZeImageFormatSwizzle = 6 // ZE_IMAGE_FORMAT_SWIZZLE_X Don't care + ZE_IMAGE_FORMAT_SWIZZLE_D ZeImageFormatSwizzle = 7 // ZE_IMAGE_FORMAT_SWIZZLE_D Depth Component + ZE_IMAGE_FORMAT_SWIZZLE_FORCE_UINT32 ZeImageFormatSwizzle = 0x7fffffff // ZE_IMAGE_FORMAT_SWIZZLE_FORCE_UINT32 Value marking end of ZE_IMAGE_FORMAT_SWIZZLE_* ENUMs + +) + +// ZeImageFormat (ze_image_format_t) Image format +type ZeImageFormat struct { + Layout ZeImageFormatLayout // Layout [in] image format component layout (e.g. N-component layouts and media formats) + Type ZeImageFormatType // Type [in] image format type + X ZeImageFormatSwizzle // X [in] image component swizzle into channel x + Y ZeImageFormatSwizzle // Y [in] image component swizzle into channel y + Z ZeImageFormatSwizzle // Z [in] image component swizzle into channel z + W ZeImageFormatSwizzle // W [in] image component swizzle into channel w + +} + +// ZeImageDesc (ze_image_desc_t) Image descriptor +type ZeImageDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeImageFlags // Flags [in] creation flags. must be 0 (default) or a valid combination of ::ze_image_flag_t; default is read-only, cached access. + Type ZeImageType // Type [in] image type. Media format layouts are unsupported for ::ZE_IMAGE_TYPE_BUFFER + Format ZeImageFormat // Format [in] image format + Width uint64 // Width [in] width dimension. ::ZE_IMAGE_TYPE_BUFFER: size in bytes; see the `maxImageBufferSize` member of ::ze_device_image_properties_t for limits. ::ZE_IMAGE_TYPE_1D, ::ZE_IMAGE_TYPE_1DARRAY: width in pixels; see the `maxImageDims1D` member of ::ze_device_image_properties_t for limits. ::ZE_IMAGE_TYPE_2D, ::ZE_IMAGE_TYPE_2DARRAY: width in pixels; see the `maxImageDims2D` member of ::ze_device_image_properties_t for limits. ::ZE_IMAGE_TYPE_3D: width in pixels; see the `maxImageDims3D` member of ::ze_device_image_properties_t for limits. + Height uint32 // Height [in] height dimension. ::ZE_IMAGE_TYPE_2D, ::ZE_IMAGE_TYPE_2DARRAY: height in pixels; see the `maxImageDims2D` member of ::ze_device_image_properties_t for limits. ::ZE_IMAGE_TYPE_3D: height in pixels; see the `maxImageDims3D` member of ::ze_device_image_properties_t for limits. other: ignored. + Depth uint32 // Depth [in] depth dimension. ::ZE_IMAGE_TYPE_3D: depth in pixels; see the `maxImageDims3D` member of ::ze_device_image_properties_t for limits. other: ignored. + Arraylevels uint32 // Arraylevels [in] array levels. ::ZE_IMAGE_TYPE_1DARRAY, ::ZE_IMAGE_TYPE_2DARRAY: see the `maxImageArraySlices` member of ::ze_device_image_properties_t for limits. other: ignored. + Miplevels uint32 // Miplevels [in] mipmap levels (must be 0) + +} + +// ZeImageSamplerFilterFlags (ze_image_sampler_filter_flags_t) Supported sampler filtering flags +type ZeImageSamplerFilterFlags uint32 +const ( + ZE_IMAGE_SAMPLER_FILTER_FLAG_POINT ZeImageSamplerFilterFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_IMAGE_SAMPLER_FILTER_FLAG_POINT device supports point filtering + ZE_IMAGE_SAMPLER_FILTER_FLAG_LINEAR ZeImageSamplerFilterFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_IMAGE_SAMPLER_FILTER_FLAG_LINEAR device supports linear filtering + ZE_IMAGE_SAMPLER_FILTER_FLAG_FORCE_UINT32 ZeImageSamplerFilterFlags = 0x7fffffff // ZE_IMAGE_SAMPLER_FILTER_FLAG_FORCE_UINT32 Value marking end of ZE_IMAGE_SAMPLER_FILTER_FLAG_* ENUMs + +) + +// ZeImageProperties (ze_image_properties_t) Image properties +type ZeImageProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Samplerfilterflags ZeImageSamplerFilterFlags // Samplerfilterflags [out] supported sampler filtering. returns 0 (unsupported) or a combination of ::ze_image_sampler_filter_flag_t. + +} + +// ZeImageGetProperties Retrieves supported properties of an image. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == pImageProperties` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3 < desc->flags` +/// + `::ZE_IMAGE_TYPE_BUFFER < desc->type` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeImageGetProperties( + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + desc *ZeImageDesc, // desc [in] pointer to image descriptor + pImageProperties *ZeImageProperties, // pImageProperties [out] pointer to image properties +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeImageGetProperties", uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(pImageProperties))) +} + +// ZeImageCreate Creates an image on the context. +/// +/// @details +/// - The application must only use the image for the device, or its +/// sub-devices, which was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @remarks +/// _Analogues_ +/// - clCreateImage +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phImage` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3 < desc->flags` +/// + `::ZE_IMAGE_TYPE_BUFFER < desc->type` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT +func ZeImageCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + desc *ZeImageDesc, // desc [in] pointer to image descriptor + phImage *ZeImageHandle, // phImage [out] pointer to handle of image object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeImageCreate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phImage))) +} + +// ZeImageDestroy Deletes an image object. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the image before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this image. +/// - The application must **not** call this function from simultaneous +/// threads with the same image handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hImage` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeImageDestroy( + hImage ZeImageHandle, // hImage [in][release] handle of image object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeImageDestroy", uintptr(hImage)) +} + diff --git a/core/kernelBinary.go b/core/kernelBinary.go new file mode 100644 index 0000000..650cae6 --- /dev/null +++ b/core/kernelBinary.go @@ -0,0 +1,69 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZE_GET_KERNEL_BINARY_EXP_NAME Get Kernel Binary Extension Name +const ZE_GET_KERNEL_BINARY_EXP_NAME = "ZE_extension_kernel_binary_exp" + +// ZeKernelGetBinaryExpVersion (ze_kernel_get_binary_exp_version_t) Get Kernel Binary Extension Version(s) +type ZeKernelGetBinaryExpVersion uintptr +const ( + ZE_KERNEL_GET_BINARY_EXP_VERSION_1_0 ZeKernelGetBinaryExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_KERNEL_GET_BINARY_EXP_VERSION_1_0 version 1.0 + ZE_KERNEL_GET_BINARY_EXP_VERSION_CURRENT ZeKernelGetBinaryExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_KERNEL_GET_BINARY_EXP_VERSION_CURRENT latest known version + ZE_KERNEL_GET_BINARY_EXP_VERSION_FORCE_UINT32 ZeKernelGetBinaryExpVersion = 0x7fffffff // ZE_KERNEL_GET_BINARY_EXP_VERSION_FORCE_UINT32 Value marking end of ZE_KERNEL_GET_BINARY_EXP_VERSION_* ENUMs + +) + +// ZeKernelGetBinaryExp Retrieves kernel binary program data (ISA GEN format). +/// +/// @details +/// - A valid kernel handle must be created with ::zeKernelCreate. +/// - Returns Intel Graphics Assembly (GEN ISA) format binary program data +/// for kernel handle. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pSize` +/// + `nullptr == pKernelBinary` +func ZeKernelGetBinaryExp( + hKernel ZeKernelHandle, // hKernel [in] Kernel handle. + pSize *uintptr, // pSize [in,out] pointer to variable with size of GEN ISA binary. + pKernelBinary *uint8, // pKernelBinary [in,out] pointer to storage area for GEN ISA binary function. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelGetBinaryExp", uintptr(hKernel), uintptr(unsafe.Pointer(pSize)), uintptr(unsafe.Pointer(pKernelBinary))) +} + diff --git a/core/memory.go b/core/memory.go new file mode 100644 index 0000000..86bbb48 --- /dev/null +++ b/core/memory.go @@ -0,0 +1,818 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeDeviceMemAllocFlags (ze_device_mem_alloc_flags_t) Supported memory allocation flags +type ZeDeviceMemAllocFlags uint32 +const ( + ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_CACHED ZeDeviceMemAllocFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_CACHED device should cache allocation + ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED ZeDeviceMemAllocFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED device should not cache allocation (UC) + ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_INITIAL_PLACEMENT ZeDeviceMemAllocFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_INITIAL_PLACEMENT optimize shared allocation for first access on the device + ZE_DEVICE_MEM_ALLOC_FLAG_FORCE_UINT32 ZeDeviceMemAllocFlags = 0x7fffffff // ZE_DEVICE_MEM_ALLOC_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_MEM_ALLOC_FLAG_* ENUMs + +) + +// ZeDeviceMemAllocDesc (ze_device_mem_alloc_desc_t) Device memory allocation descriptor +type ZeDeviceMemAllocDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeDeviceMemAllocFlags // Flags [in] flags specifying additional allocation controls. must be 0 (default) or a valid combination of ::ze_device_mem_alloc_flag_t; default behavior may use implicit driver-based heuristics. + Ordinal uint32 // Ordinal [in] ordinal of the device's local memory to allocate from. must be less than the count returned from ::zeDeviceGetMemoryProperties. + +} + +// ZeHostMemAllocFlags (ze_host_mem_alloc_flags_t) Supported host memory allocation flags +type ZeHostMemAllocFlags uint32 +const ( + ZE_HOST_MEM_ALLOC_FLAG_BIAS_CACHED ZeHostMemAllocFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_HOST_MEM_ALLOC_FLAG_BIAS_CACHED host should cache allocation + ZE_HOST_MEM_ALLOC_FLAG_BIAS_UNCACHED ZeHostMemAllocFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_HOST_MEM_ALLOC_FLAG_BIAS_UNCACHED host should not cache allocation (UC) + ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED ZeHostMemAllocFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_HOST_MEM_ALLOC_FLAG_BIAS_WRITE_COMBINED host memory should be allocated write-combined (WC) + ZE_HOST_MEM_ALLOC_FLAG_BIAS_INITIAL_PLACEMENT ZeHostMemAllocFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_HOST_MEM_ALLOC_FLAG_BIAS_INITIAL_PLACEMENT optimize shared allocation for first access on the host + ZE_HOST_MEM_ALLOC_FLAG_FORCE_UINT32 ZeHostMemAllocFlags = 0x7fffffff // ZE_HOST_MEM_ALLOC_FLAG_FORCE_UINT32 Value marking end of ZE_HOST_MEM_ALLOC_FLAG_* ENUMs + +) + +// ZeHostMemAllocDesc (ze_host_mem_alloc_desc_t) Host memory allocation descriptor +type ZeHostMemAllocDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeHostMemAllocFlags // Flags [in] flags specifying additional allocation controls. must be 0 (default) or a valid combination of ::ze_host_mem_alloc_flag_t; default behavior may use implicit driver-based heuristics. + +} + +// ZeMemAllocShared Allocates shared memory on the context. +/// +/// @details +/// - Shared allocations share ownership between the host and one or more +/// devices. +/// - Shared allocations may optionally be associated with a device by +/// passing a handle to the device. +/// - Devices supporting only single-device shared access capabilities may +/// access shared memory associated with the device. +/// For these devices, ownership of the allocation is shared between the +/// host and the associated device only. +/// - Passing nullptr as the device handle does not associate the shared +/// allocation with any device. +/// For allocations with no associated device, ownership of the allocation +/// is shared between the host and all devices supporting cross-device +/// shared access capabilities. +/// - The application must only use the memory allocation for the context +/// and device, or its sub-devices, which was provided during allocation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == device_desc` +/// + `nullptr == host_desc` +/// + `nullptr == pptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x7 < device_desc->flags` +/// + `0xf < host_desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +/// + Must be zero or a power-of-two +/// + `0 != (alignment & (alignment - 1))` +func ZeMemAllocShared( + hContext ZeContextHandle, // hContext [in] handle of the context object + device_desc *ZeDeviceMemAllocDesc, // device_desc [in] pointer to device memory allocation descriptor + host_desc *ZeHostMemAllocDesc, // host_desc [in] pointer to host memory allocation descriptor + size uintptr, // size [in] size in bytes to allocate; must be less than or equal to the `maxMemAllocSize` member of ::ze_device_properties_t + alignment uintptr, // alignment [in] minimum alignment in bytes for the allocation; must be a power of two + hDevice ZeDeviceHandle, // hDevice [in][optional] device handle to associate with + pptr *unsafe.Pointer, // pptr [out] pointer to shared allocation +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemAllocShared", uintptr(hContext), uintptr(unsafe.Pointer(device_desc)), uintptr(unsafe.Pointer(host_desc)), uintptr(size), uintptr(alignment), uintptr(hDevice), uintptr(unsafe.Pointer(pptr))) +} + +// ZeMemAllocDevice Allocates device memory on the context. +/// +/// @details +/// - Device allocations are owned by a specific device. +/// - In general, a device allocation may only be accessed by the device +/// that owns it. +/// - The application must only use the memory allocation for the context +/// and device, or its sub-devices, which was provided during allocation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == device_desc` +/// + `nullptr == pptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x7 < device_desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +/// + Must be zero or a power-of-two +/// + `0 != (alignment & (alignment - 1))` +func ZeMemAllocDevice( + hContext ZeContextHandle, // hContext [in] handle of the context object + device_desc *ZeDeviceMemAllocDesc, // device_desc [in] pointer to device memory allocation descriptor + size uintptr, // size [in] size in bytes to allocate; must be less than or equal to the `maxMemAllocSize` member of ::ze_device_properties_t + alignment uintptr, // alignment [in] minimum alignment in bytes for the allocation; must be a power of two + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + pptr *unsafe.Pointer, // pptr [out] pointer to device allocation +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemAllocDevice", uintptr(hContext), uintptr(unsafe.Pointer(device_desc)), uintptr(size), uintptr(alignment), uintptr(hDevice), uintptr(unsafe.Pointer(pptr))) +} + +// ZeMemAllocHost Allocates host memory on the context. +/// +/// @details +/// - Host allocations are owned by the host process. +/// - Host allocations are accessible by the host and all devices within the +/// driver's context. +/// - Host allocations are frequently used as staging areas to transfer data +/// to or from devices. +/// - The application must only use the memory allocation for the context +/// which was provided during allocation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == host_desc` +/// + `nullptr == pptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0xf < host_desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +/// + Must be zero or a power-of-two +/// + `0 != (alignment & (alignment - 1))` +func ZeMemAllocHost( + hContext ZeContextHandle, // hContext [in] handle of the context object + host_desc *ZeHostMemAllocDesc, // host_desc [in] pointer to host memory allocation descriptor + size uintptr, // size [in] size in bytes to allocate; must be less than or equal to the `maxMemAllocSize` member of ::ze_device_properties_t + alignment uintptr, // alignment [in] minimum alignment in bytes for the allocation; must be a power of two + pptr *unsafe.Pointer, // pptr [out] pointer to host allocation +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemAllocHost", uintptr(hContext), uintptr(unsafe.Pointer(host_desc)), uintptr(size), uintptr(alignment), uintptr(unsafe.Pointer(pptr))) +} + +// ZeMemFree Frees allocated host memory, device memory, or shared memory on the +/// context. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the memory before it is freed +/// - The implementation will use the default and immediate policy to +/// schedule all Host and Device allocations associated with this memory +/// to be freed, without any safety checking. Actual freeing of memory is +/// specific to user mode driver and kernel mode driver implementation and +/// may be done asynchronously. +/// - The application must **not** call this function from simultaneous +/// threads with the same pointer. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +func ZeMemFree( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in][release] pointer to memory to free +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemFree", uintptr(hContext), uintptr(unsafe.Pointer(ptr))) +} + +// ZeMemoryType (ze_memory_type_t) Memory allocation type +type ZeMemoryType uintptr +const ( + ZE_MEMORY_TYPE_UNKNOWN ZeMemoryType = 0 // ZE_MEMORY_TYPE_UNKNOWN the memory pointed to is of unknown type + ZE_MEMORY_TYPE_HOST ZeMemoryType = 1 // ZE_MEMORY_TYPE_HOST the memory pointed to is a host allocation + ZE_MEMORY_TYPE_DEVICE ZeMemoryType = 2 // ZE_MEMORY_TYPE_DEVICE the memory pointed to is a device allocation + ZE_MEMORY_TYPE_SHARED ZeMemoryType = 3 // ZE_MEMORY_TYPE_SHARED the memory pointed to is a shared ownership allocation + ZE_MEMORY_TYPE_HOST_IMPORTED ZeMemoryType = 4 // ZE_MEMORY_TYPE_HOST_IMPORTED the memory pointed to is a host allocation created from external + + ///< system memory + + ZE_MEMORY_TYPE_FORCE_UINT32 ZeMemoryType = 0x7fffffff // ZE_MEMORY_TYPE_FORCE_UINT32 Value marking end of ZE_MEMORY_TYPE_* ENUMs + +) + +// ZeMemoryAllocationProperties (ze_memory_allocation_properties_t) Memory allocation properties queried using ::zeMemGetAllocProperties +type ZeMemoryAllocationProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Type ZeMemoryType // Type [out] type of allocated memory + Id uint64 // Id [out] identifier for this allocation + Pagesize uint64 // Pagesize [out] page size used for allocation + +} + +// ZeMemGetAllocProperties Retrieves attributes of a memory allocation +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The application may query attributes of a memory allocation unrelated +/// to the context. +/// When this occurs, the returned allocation type will be +/// ::ZE_MEMORY_TYPE_UNKNOWN, and the returned identifier and associated +/// device is unspecified. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// + `nullptr == pMemAllocProperties` +func ZeMemGetAllocProperties( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] memory pointer to query + pMemAllocProperties *ZeMemoryAllocationProperties, // pMemAllocProperties [in,out] query result for memory allocation properties + phDevice *ZeDeviceHandle, // phDevice [out][optional] device associated with this allocation +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemGetAllocProperties", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(unsafe.Pointer(pMemAllocProperties)), uintptr(unsafe.Pointer(phDevice))) +} + +// ZeMemGetAddressRange Retrieves the base address and/or size of an allocation +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_ADDRESS_NOT_FOUND +func ZeMemGetAddressRange( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] memory pointer to query + pBase *unsafe.Pointer, // pBase [in,out][optional] base address of the allocation + pSize *uintptr, // pSize [in,out][optional] size of the allocation +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemGetAddressRange", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(unsafe.Pointer(pBase)), uintptr(unsafe.Pointer(pSize))) +} + +// ZeMemGetIpcHandle Creates an IPC memory handle for the specified allocation +/// +/// @details +/// - Takes a pointer to a device memory allocation and creates an IPC +/// memory handle for exporting it for use in another process. +/// - The pointer must be base pointer of a device or host memory +/// allocation; i.e. the value returned from ::zeMemAllocDevice or from +/// ::zeMemAllocHost, respectively. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// + `nullptr == pIpcHandle` +func ZeMemGetIpcHandle( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] pointer to the device memory allocation + pIpcHandle *ZeIpcMemHandle, // pIpcHandle [out] Returned IPC memory handle +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemGetIpcHandle", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(unsafe.Pointer(pIpcHandle))) +} + +// ZeMemGetIpcHandleFromFileDescriptorExp Creates an IPC memory handle out of a file descriptor +/// +/// @details +/// - Handle passed must be a valid file descriptor obtained with +/// ::ze_external_memory_export_fd_t via ::zeMemGetAllocProperties or +/// ::zePhysicalMemGetProperties. +/// - Returned IPC handle may contain metadata in addition to the file +/// descriptor. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pIpcHandle` +func ZeMemGetIpcHandleFromFileDescriptorExp( + hContext ZeContextHandle, // hContext [in] handle of the context object + handle uint64, // handle [in] file descriptor + pIpcHandle *ZeIpcMemHandle, // pIpcHandle [out] Returned IPC memory handle +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemGetIpcHandleFromFileDescriptorExp", uintptr(hContext), uintptr(handle), uintptr(unsafe.Pointer(pIpcHandle))) +} + +// ZeMemGetFileDescriptorFromIpcHandleExp Gets the file descriptor contained in an IPC memory handle +/// +/// @details +/// - IPC memory handle must be a valid handle obtained with +/// ::zeMemGetIpcHandle. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pHandle` +func ZeMemGetFileDescriptorFromIpcHandleExp( + hContext ZeContextHandle, // hContext [in] handle of the context object + ipcHandle *ZeIpcMemHandle, // ipcHandle [in] IPC memory handle (gozel hack: converted to a hidden pointer from a struct value) + pHandle *uint64, // pHandle [out] Returned file descriptor +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemGetFileDescriptorFromIpcHandleExp", uintptr(hContext), uintptr(unsafe.Pointer(ipcHandle)), uintptr(unsafe.Pointer(pHandle))) +} + +// ZeMemPutIpcHandle Returns an IPC memory handle to the driver +/// +/// @details +/// - This call may be used for IPC handles previously obtained with either +/// ::zeMemGetIpcHandle or with ::ze_external_memory_export_fd_t via +/// ::zeMemGetAllocProperties or ::zePhysicalMemGetProperties. +/// - Upon call, driver may release any underlying resources associated with +/// the IPC handle. +/// For instance, it may close the file descriptor contained in the IPC +/// handle, if such type of handle is being used by the driver. +/// - This call does not free the original allocation for which the IPC +/// handle was created. +/// - This function may **not** be called from simultaneous threads with the +/// same IPC handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +func ZeMemPutIpcHandle( + hContext ZeContextHandle, // hContext [in] handle of the context object + handle *ZeIpcMemHandle, // handle [in] IPC memory handle (gozel hack: converted to a hidden pointer from a struct value) +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemPutIpcHandle", uintptr(hContext), uintptr(unsafe.Pointer(handle))) +} + +// ZeIpcMemoryFlags (ze_ipc_memory_flags_t) Supported IPC memory flags +type ZeIpcMemoryFlags uint32 +const ( + ZE_IPC_MEMORY_FLAG_BIAS_CACHED ZeIpcMemoryFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_IPC_MEMORY_FLAG_BIAS_CACHED device should cache allocation + ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED ZeIpcMemoryFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED device should not cache allocation (UC) + ZE_IPC_MEMORY_FLAG_FORCE_UINT32 ZeIpcMemoryFlags = 0x7fffffff // ZE_IPC_MEMORY_FLAG_FORCE_UINT32 Value marking end of ZE_IPC_MEMORY_FLAG_* ENUMs + +) + +// ZeMemOpenIpcHandle Opens an IPC memory handle to retrieve a device pointer on the +/// context. +/// +/// @details +/// - Takes an IPC memory handle from a remote process and associates it +/// with a device pointer usable in this process. +/// - The device pointer in this process should not be freed with +/// ::zeMemFree, but rather with ::zeMemCloseIpcHandle. +/// - Multiple calls to this function with the same IPC handle will return +/// unique pointers. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3 < flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pptr` +func ZeMemOpenIpcHandle( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device to associate with the IPC memory handle + handle *ZeIpcMemHandle, // handle [in] IPC memory handle (gozel hack: converted to a hidden pointer from a struct value) + flags ZeIpcMemoryFlags, // flags [in] flags controlling the operation. must be 0 (default) or a valid combination of ::ze_ipc_memory_flag_t. + pptr *unsafe.Pointer, // pptr [out] pointer to device allocation in this process +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemOpenIpcHandle", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(handle)), uintptr(flags), uintptr(unsafe.Pointer(pptr))) +} + +// ZeMemCloseIpcHandle Closes an IPC memory handle +/// +/// @details +/// - Closes an IPC memory handle by unmapping memory that was opened in +/// this process using ::zeMemOpenIpcHandle. +/// - The application must **not** call this function from simultaneous +/// threads with the same pointer. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +func ZeMemCloseIpcHandle( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in][release] pointer to device allocation in this process +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemCloseIpcHandle", uintptr(hContext), uintptr(unsafe.Pointer(ptr))) +} + +// ZeExternalMemoryExportDesc (ze_external_memory_export_desc_t) Additional allocation descriptor for exporting external memory +/// +/// @details +/// - This structure may be passed to ::zeMemAllocDevice, ::zeMemAllocHost, +/// or ::zePhysicalMemCreate, via the `pNext` member of +/// ::ze_device_mem_alloc_desc_t or ::ze_host_mem_alloc_desc_t, or +/// ::ze_physical_mem_desc_t, respectively, to indicate an exportable +/// memory allocation. +/// - This structure may be passed to ::zeImageCreate, via the `pNext` +/// member of ::ze_image_desc_t, to indicate an exportable image. +type ZeExternalMemoryExportDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeExternalMemoryTypeFlags // Flags [in] flags specifying memory export types for this allocation. must be 0 (default) or a valid combination of ::ze_external_memory_type_flags_t + +} + +// ZeExternalMemoryImportFd (ze_external_memory_import_fd_t) Additional allocation descriptor for importing external memory as a +/// file descriptor +/// +/// @details +/// - This structure may be passed to ::zeMemAllocDevice, ::zeMemAllocHost, +/// or ::zePhysicalMemCreate, via the `pNext` member of +/// ::ze_device_mem_alloc_desc_t or ::ze_host_mem_alloc_desc_t, or +/// ::ze_physical_mem_desc_t, respectively, to import memory from a file +/// descriptor. +/// - This structure may be passed to ::zeImageCreate, via the `pNext` +/// member of ::ze_image_desc_t, to import memory from a file descriptor. +type ZeExternalMemoryImportFd struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeExternalMemoryTypeFlags // Flags [in] flags specifying the memory import type for the file descriptor. must be 0 (default) or a valid combination of ::ze_external_memory_type_flags_t + Fd int32 // Fd [in] the file descriptor handle to import + +} + +// ZeExternalMemoryExportFd (ze_external_memory_export_fd_t) Exports an allocation as a file descriptor +/// +/// @details +/// - This structure may be passed to ::zeMemGetAllocProperties, via the +/// `pNext` member of ::ze_memory_allocation_properties_t, to export a +/// memory allocation as a file descriptor. +/// - This structure may be passed to ::zeImageGetAllocPropertiesExt, via +/// the `pNext` member of ::ze_image_allocation_ext_properties_t, to +/// export an image as a file descriptor. +/// - This structure may be passed to ::zePhysicalMemGetProperties, via the +/// `pNext` member of ::ze_physical_mem_properties_t, to export physical +/// memory as a file descriptor. +/// - The requested memory export type must have been specified when the +/// allocation was made. +type ZeExternalMemoryExportFd struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeExternalMemoryTypeFlags // Flags [in] flags specifying the memory export type for the file descriptor. must be 0 (default) or a valid combination of ::ze_external_memory_type_flags_t + Fd int32 // Fd [out] the exported file descriptor handle representing the allocation. + +} + +// ZeExternalMemoryImportWin32Handle (ze_external_memory_import_win32_handle_t) Additional allocation descriptor for importing external memory as a +/// Win32 handle +/// +/// @details +/// - When `handle` is `nullptr`, `name` must not be `nullptr`. +/// - When `name` is `nullptr`, `handle` must not be `nullptr`. +/// - When `flags` is ::ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_WIN32_KMT, +/// `name` must be `nullptr`. +/// - This structure may be passed to ::zeMemAllocDevice, ::zeMemAllocHost, +/// or ::zePhysicalMemCreate, via the `pNext` member of +/// ::ze_device_mem_alloc_desc_t or ::ze_host_mem_alloc_desc_t, or +/// ::ze_physical_mem_desc_t, respectively, to import memory from a Win32 +/// handle. +/// - This structure may be passed to ::zeImageCreate, via the `pNext` +/// member of ::ze_image_desc_t, to import memory from a Win32 handle. +type ZeExternalMemoryImportWin32Handle struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeExternalMemoryTypeFlags // Flags [in] flags specifying the memory import type for the Win32 handle. must be 0 (default) or a valid combination of ::ze_external_memory_type_flags_t + Handle unsafe.Pointer // Handle [in][optional] the Win32 handle to import + Name unsafe.Pointer // Name [in][optional] name of a memory object to import + +} + +// ZeExternalMemoryExportWin32Handle (ze_external_memory_export_win32_handle_t) Exports an allocation as a Win32 handle +/// +/// @details +/// - This structure may be passed to ::zeMemGetAllocProperties, via the +/// `pNext` member of ::ze_memory_allocation_properties_t, to export a +/// memory allocation as a Win32 handle. +/// - This structure may be passed to ::zeImageGetAllocPropertiesExt, via +/// the `pNext` member of ::ze_image_allocation_ext_properties_t, to +/// export an image as a Win32 handle. +/// - This structure may be passed to ::zePhysicalMemGetProperties, via the +/// `pNext` member of ::ze_physical_mem_properties_t, to export physical +/// memory as a Win32 handle. +/// - The requested memory export type must have been specified when the +/// allocation was made. +type ZeExternalMemoryExportWin32Handle struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeExternalMemoryTypeFlags // Flags [in] flags specifying the memory export type for the Win32 handle. must be 0 (default) or a valid combination of ::ze_external_memory_type_flags_t + Handle unsafe.Pointer // Handle [out] the exported Win32 handle representing the allocation. + +} + +// ZeMemoryAtomicAttrExpFlags (ze_memory_atomic_attr_exp_flags_t) atomic access attribute flags +type ZeMemoryAtomicAttrExpFlags uint32 +const ( + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_ATOMICS ZeMemoryAtomicAttrExpFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_ATOMICS Atomics on the pointer are not allowed + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_HOST_ATOMICS ZeMemoryAtomicAttrExpFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_HOST_ATOMICS Host atomics on the pointer are not allowed + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_HOST_ATOMICS ZeMemoryAtomicAttrExpFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_HOST_ATOMICS Host atomics on the pointer are allowed. Requires + + ///< ::ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC returned by + ///< ::zeDeviceGetMemoryAccessProperties. + + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_DEVICE_ATOMICS ZeMemoryAtomicAttrExpFlags = /* ZE_BIT(3) */(( 1 << 3 )) // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_DEVICE_ATOMICS Device atomics on the pointer are not allowed + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_DEVICE_ATOMICS ZeMemoryAtomicAttrExpFlags = /* ZE_BIT(4) */(( 1 << 4 )) // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_DEVICE_ATOMICS Device atomics on the pointer are allowed. Requires + + ///< ::ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC returned by + ///< ::zeDeviceGetMemoryAccessProperties. + + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_SYSTEM_ATOMICS ZeMemoryAtomicAttrExpFlags = /* ZE_BIT(5) */(( 1 << 5 )) // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_NO_SYSTEM_ATOMICS Concurrent atomics on the pointer from both host and device are not + + ///< allowed + + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_SYSTEM_ATOMICS ZeMemoryAtomicAttrExpFlags = /* ZE_BIT(6) */(( 1 << 6 )) // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_SYSTEM_ATOMICS Concurrent atomics on the pointer from both host and device are + + ///< allowed. Requires ::ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC + ///< returned by ::zeDeviceGetMemoryAccessProperties. + + ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_FORCE_UINT32 ZeMemoryAtomicAttrExpFlags = 0x7fffffff // ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_FORCE_UINT32 Value marking end of ZE_MEMORY_ATOMIC_ATTR_EXP_FLAG_* ENUMs + +) + +// ZeMemSetAtomicAccessAttributeExp Sets atomic access attributes for a shared allocation +/// +/// @details +/// - If the shared-allocation is owned by multiple devices (i.e. nullptr +/// was passed to ::zeMemAllocShared when creating it), then hDevice may be +/// passed to set the attributes in that specific device. If nullptr is +/// passed in hDevice, then the atomic attributes are set in all devices +/// associated with the allocation. +/// - If the atomic access attribute select is not supported by the driver, +/// ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. +/// - The atomic access attribute may be only supported at a device-specific +/// granularity, such as at a page boundary. In this case, the memory range +/// may be expanded such that the start and end of the range satisfy granularity +/// requirements. +/// - When calling this function multiple times with different flags, only the +/// attributes from last call are honored. +/// - The application must not call this function for shared-allocations currently +/// being used by the device. +/// - The application must **not** call this function from simultaneous threads +/// with the same pointer. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x7f < attr` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeMemSetAtomicAccessAttributeExp( + hContext ZeContextHandle, // hContext [in] handle of context + hDevice ZeDeviceHandle, // hDevice [in] device associated with the memory advice + ptr unsafe.Pointer, // ptr [in] Pointer to the start of the memory range + size uintptr, // size [in] Size in bytes of the memory range + attr ZeMemoryAtomicAttrExpFlags, // attr [in] Atomic access attributes to set for the specified range. Must be 0 (default) or a valid combination of ::ze_memory_atomic_attr_exp_flag_t. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemSetAtomicAccessAttributeExp", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(ptr)), uintptr(size), uintptr(attr)) +} + +// ZeMemGetAtomicAccessAttributeExp Retrieves the atomic access attributes previously set for a shared +/// allocation +/// +/// @details +/// - The application may call this function from simultaneous threads +/// with the same pointer. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// + `nullptr == pAttr` +func ZeMemGetAtomicAccessAttributeExp( + hContext ZeContextHandle, // hContext [in] handle of context + hDevice ZeDeviceHandle, // hDevice [in] device associated with the memory advice + ptr unsafe.Pointer, // ptr [in] Pointer to the start of the memory range + size uintptr, // size [in] Size in bytes of the memory range + pAttr *ZeMemoryAtomicAttrExpFlags, // pAttr [out] Atomic access attributes for the specified range +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeMemGetAtomicAccessAttributeExp", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(ptr)), uintptr(size), uintptr(unsafe.Pointer(pAttr))) +} + diff --git a/core/module.go b/core/module.go new file mode 100644 index 0000000..1c02b31 --- /dev/null +++ b/core/module.go @@ -0,0 +1,1316 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeModuleFormat (ze_module_format_t) Supported module creation input formats +type ZeModuleFormat uintptr +const ( + ZE_MODULE_FORMAT_IL_SPIRV ZeModuleFormat = 0 // ZE_MODULE_FORMAT_IL_SPIRV Format is SPIRV IL format + ZE_MODULE_FORMAT_NATIVE ZeModuleFormat = 1 // ZE_MODULE_FORMAT_NATIVE Format is device native format + ZE_MODULE_FORMAT_FORCE_UINT32 ZeModuleFormat = 0x7fffffff // ZE_MODULE_FORMAT_FORCE_UINT32 Value marking end of ZE_MODULE_FORMAT_* ENUMs + +) + +// ZeModuleConstants (ze_module_constants_t) Specialization constants - User defined constants +type ZeModuleConstants struct { + Numconstants uint32 // Numconstants [in] Number of specialization constants. + Pconstantids *uint32 // Pconstantids [in][range(0, numConstants)] Array of IDs that is sized to numConstants. + Pconstantvalues *unsafe.Pointer // Pconstantvalues [in][range(0, numConstants)] Array of pointers to values that is sized to numConstants. + +} + +// ZeModuleDesc (ze_module_desc_t) Module descriptor +type ZeModuleDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Format ZeModuleFormat // Format [in] Module format passed in with pInputModule + Inputsize uintptr // Inputsize [in] size of input IL or ISA from pInputModule. + Pinputmodule *uint8 // Pinputmodule [in] pointer to IL or ISA + Pbuildflags *byte // Pbuildflags [in][optional] string containing one or more (comma-separated) compiler flags. If unsupported, flag is ignored with a warning. - "-ze-opt-disable" - Disable optimizations - "-ze-opt-level" - Specifies optimization level for compiler. Levels are implementation specific. - 0 is no optimizations (equivalent to -ze-opt-disable) - 1 is optimize minimally (may be the same as 2) - 2 is optimize more (default) - "-ze-opt-greater-than-4GB-buffer-required" - Use 64-bit offset calculations for buffers. - "-ze-opt-large-register-file" - Increase number of registers available to threads. - "-ze-opt-has-buffer-offset-arg" - Extend stateless to stateful optimization to more cases with the use of additional offset (e.g. 64-bit pointer to binding table with 32-bit offset). - "-g" - Include debugging information. + Pconstants *ZeModuleConstants // Pconstants [in][optional] pointer to specialization constants. Valid only for SPIR-V input. This must be set to nullptr if no specialization constants are provided. + +} + +// ZeCommandListAppendLaunchKernelParamCooperativeDesc (ze_command_list_append_launch_kernel_param_cooperative_desc_t) Append launch kernel with parameters cooperative descriptor +type ZeCommandListAppendLaunchKernelParamCooperativeDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Iscooperative ZeBool // Iscooperative [in] When true, kernel is treated as cooperative. + +} + +// ZeModuleCreate Creates a module on the context. +/// +/// @details +/// - Compiles the module for execution on the device. +/// - The application must only use the module for the device, or its +/// sub-devices, which was provided during creation. +/// - The module can be copied to other devices and contexts within the same +/// driver instance by using ::zeModuleGetNativeBinary. +/// - A build log can optionally be returned to the caller. The caller is +/// responsible for destroying build log using ::zeModuleBuildLogDestroy. +/// - The module descriptor constants are only supported for SPIR-V +/// specialization constants. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == desc->pInputModule` +/// + `nullptr == phModule` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `::ZE_MODULE_FORMAT_NATIVE < desc->format` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_INVALID_NATIVE_BINARY +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `0 == desc->inputSize` +/// - ::ZE_RESULT_ERROR_MODULE_BUILD_FAILURE +func ZeModuleCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + desc *ZeModuleDesc, // desc [in] pointer to module descriptor + phModule *ZeModuleHandle, // phModule [out] pointer to handle of module object created + phBuildLog *ZeModuleBuildLogHandle, // phBuildLog [out][optional] pointer to handle of module's build log. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleCreate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phModule)), uintptr(unsafe.Pointer(phBuildLog))) +} + +// ZeModuleDestroy Destroys module +/// +/// @details +/// - The application must destroy all kernel handles created from the +/// module before destroying the module itself. +/// - The application must ensure the device is not currently referencing +/// the module before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this module. +/// - The application must **not** call this function from simultaneous +/// threads with the same module handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hModule` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeModuleDestroy( + hModule ZeModuleHandle, // hModule [in][release] handle of the module +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleDestroy", uintptr(hModule)) +} + +// ZeModuleDynamicLink Dynamically link modules together that share import/export linkage +/// dependencies. +/// +/// @details +/// - Modules support SPIR-V import and export linkage types for functions +/// and global variables. See the SPIR-V specification for linkage +/// details. +/// - Modules can have both import and export linkage. +/// - Modules that do not have any imports or exports do not need to be +/// linked. +/// - All module import requirements must be satisfied via linking before +/// kernel objects can be created from them. +/// - Modules cannot be partially linked. Unsatisfiable import dependencies +/// in the set of modules passed to ::zeModuleDynamicLink will result in +/// ::ZE_RESULT_ERROR_MODULE_LINK_FAILURE being returned. +/// - Modules will only be linked once. A module can be used in multiple +/// link calls if it has exports but its imports will not be re-linked. +/// - Ambiguous dependencies, where multiple modules satisfy the same import +/// dependencies for a module, are not allowed. +/// - The application must ensure the modules being linked were created on +/// the same context. +/// - The application may call this function from simultaneous threads as +/// long as the import modules being linked are not the same. +/// - ModuleGetNativeBinary can be called on any module regardless of +/// whether it is linked or not. +/// - A link log can optionally be returned to the caller. The caller is +/// responsible for destroying the link log using +/// ::zeModuleBuildLogDestroy. +/// - The link log may contain a list of the unresolved import dependencies +/// if present. +/// - The implementation of this function should be lock-free. +/// +/// @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 == phModules` +/// - ::ZE_RESULT_ERROR_MODULE_LINK_FAILURE +func ZeModuleDynamicLink( + numModules uint32, // numModules [in] number of modules to be linked pointed to by phModules. + phModules *ZeModuleHandle, // phModules [in][range(0, numModules)] pointer to an array of modules to dynamically link together. + phLinkLog *ZeModuleBuildLogHandle, // phLinkLog [out][optional] pointer to handle of dynamic link log. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleDynamicLink", uintptr(numModules), uintptr(unsafe.Pointer(phModules)), uintptr(unsafe.Pointer(phLinkLog))) +} + +// ZeModuleBuildLogDestroy Destroys module build log object +/// +/// @details +/// - The implementation of this function may immediately free all Host +/// allocations associated with this object. +/// - The application must **not** call this function from simultaneous +/// threads with the same build log handle. +/// - The implementation of this function should be lock-free. +/// - This function can be called before or after ::zeModuleDestroy for the +/// associated module. +/// +/// @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_HANDLE +/// + `nullptr == hModuleBuildLog` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeModuleBuildLogDestroy( + hModuleBuildLog ZeModuleBuildLogHandle, // hModuleBuildLog [in][release] handle of the module build log object. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleBuildLogDestroy", uintptr(hModuleBuildLog)) +} + +// ZeModuleBuildLogGetString Retrieves text string for build log. +/// +/// @details +/// - The caller can pass nullptr for pBuildLog when querying only for size. +/// - The caller must provide memory for build log. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hModuleBuildLog` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pSize` +func ZeModuleBuildLogGetString( + hModuleBuildLog ZeModuleBuildLogHandle, // hModuleBuildLog [in] handle of the module build log object. + pSize *uintptr, // pSize [in,out] size of build log string. + pBuildLog *byte, // pBuildLog [in,out][optional] pointer to null-terminated string of the log. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleBuildLogGetString", uintptr(hModuleBuildLog), uintptr(unsafe.Pointer(pSize)), uintptr(unsafe.Pointer(pBuildLog))) +} + +// ZeModuleGetNativeBinary Retrieve native binary from Module. +/// +/// @details +/// - The native binary output can be cached to disk and new modules can be +/// later constructed from the cached copy. +/// - The native binary will retain debugging information that is associated +/// with a module. +/// - The caller can pass nullptr for pModuleNativeBinary when querying only +/// for size. +/// - The implementation will copy the native binary into a buffer supplied +/// by the caller. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hModule` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pSize` +func ZeModuleGetNativeBinary( + hModule ZeModuleHandle, // hModule [in] handle of the module + pSize *uintptr, // pSize [in,out] size of native binary in bytes. + pModuleNativeBinary *uint8, // pModuleNativeBinary [in,out][optional] byte pointer to native binary +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleGetNativeBinary", uintptr(hModule), uintptr(unsafe.Pointer(pSize)), uintptr(unsafe.Pointer(pModuleNativeBinary))) +} + +// ZeModuleGetGlobalPointer Retrieve global variable pointer from Module. +/// +/// @details +/// - The application may query global pointer from any module that either +/// exports or imports it. +/// - The application must dynamically link a module that imports a global +/// before the global pointer can be queried from it. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hModule` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pGlobalName` +/// - ::ZE_RESULT_ERROR_INVALID_GLOBAL_NAME +func ZeModuleGetGlobalPointer( + hModule ZeModuleHandle, // hModule [in] handle of the module + pGlobalName *byte, // pGlobalName [in] name of global variable in module + pSize *uintptr, // pSize [in,out][optional] size of global variable + pptr *unsafe.Pointer, // pptr [in,out][optional] device visible pointer +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleGetGlobalPointer", uintptr(hModule), uintptr(unsafe.Pointer(pGlobalName)), uintptr(unsafe.Pointer(pSize)), uintptr(unsafe.Pointer(pptr))) +} + +// ZeModuleGetKernelNames Retrieve all kernel names in the module. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hModule` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +func ZeModuleGetKernelNames( + hModule ZeModuleHandle, // hModule [in] handle of the module + pCount *uint32, // pCount [in,out] pointer to the number of names. if count is zero, then the driver shall update the value with the total number of names available. if count is greater than the number of names available, then the driver shall update the value with the correct number of names available. + pNames **byte, // pNames [in,out][optional][range(0, *pCount)] array of names of functions. if count is less than the number of names available, then driver shall only retrieve that number of names. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleGetKernelNames", uintptr(hModule), uintptr(unsafe.Pointer(pCount)), uintptr(unsafe.Pointer(pNames))) +} + +// ZeModulePropertyFlags (ze_module_property_flags_t) Supported module property flags +type ZeModulePropertyFlags uint32 +const ( + ZE_MODULE_PROPERTY_FLAG_IMPORTS ZeModulePropertyFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_MODULE_PROPERTY_FLAG_IMPORTS Module has imports (i.e. imported global variables and/or kernels). + + ///< See ::zeModuleDynamicLink. + + ZE_MODULE_PROPERTY_FLAG_FORCE_UINT32 ZeModulePropertyFlags = 0x7fffffff // ZE_MODULE_PROPERTY_FLAG_FORCE_UINT32 Value marking end of ZE_MODULE_PROPERTY_FLAG_* ENUMs + +) + +// ZeModuleProperties (ze_module_properties_t) Module properties +type ZeModuleProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeModulePropertyFlags // Flags [out] 0 (none) or a valid combination of ::ze_module_property_flag_t + +} + +// ZeModuleGetProperties Retrieve module properties. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hModule` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pModuleProperties` +func ZeModuleGetProperties( + hModule ZeModuleHandle, // hModule [in] handle of the module + pModuleProperties *ZeModuleProperties, // pModuleProperties [in,out] query result for module properties. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleGetProperties", uintptr(hModule), uintptr(unsafe.Pointer(pModuleProperties))) +} + +// ZeKernelFlags (ze_kernel_flags_t) Supported kernel creation flags +type ZeKernelFlags uint32 +const ( + ZE_KERNEL_FLAG_FORCE_RESIDENCY ZeKernelFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_KERNEL_FLAG_FORCE_RESIDENCY force all device allocations to be resident during execution + ZE_KERNEL_FLAG_EXPLICIT_RESIDENCY ZeKernelFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_KERNEL_FLAG_EXPLICIT_RESIDENCY application is responsible for all residency of device allocations. + + ///< driver may disable implicit residency management. + + ZE_KERNEL_FLAG_FORCE_UINT32 ZeKernelFlags = 0x7fffffff // ZE_KERNEL_FLAG_FORCE_UINT32 Value marking end of ZE_KERNEL_FLAG_* ENUMs + +) + +// ZeKernelDesc (ze_kernel_desc_t) Kernel descriptor +type ZeKernelDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeKernelFlags // Flags [in] creation flags. must be 0 (default) or a valid combination of ::ze_kernel_flag_t; default behavior may use driver-based residency. + Pkernelname *byte // Pkernelname [in] null-terminated name of kernel in module + +} + +// ZeKernelCreate Create a kernel from the module. +/// +/// @details +/// - Modules that have unresolved imports need to be dynamically linked +/// before a kernel can be created from them. (See ::zeModuleDynamicLink) +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hModule` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == desc->pKernelName` +/// + `nullptr == phKernel` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3 < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_INVALID_KERNEL_NAME +/// - ::ZE_RESULT_ERROR_INVALID_MODULE_UNLINKED +func ZeKernelCreate( + hModule ZeModuleHandle, // hModule [in] handle of the module + desc *ZeKernelDesc, // desc [in] pointer to kernel descriptor + phKernel *ZeKernelHandle, // phKernel [out] handle of the Function object +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelCreate", uintptr(hModule), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phKernel))) +} + +// ZeKernelDestroy Destroys a kernel object +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the kernel before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this kernel. +/// - The application must **not** call this function from simultaneous +/// threads with the same kernel handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeKernelDestroy( + hKernel ZeKernelHandle, // hKernel [in][release] handle of the kernel object +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelDestroy", uintptr(hKernel)) +} + +// ZeModuleGetFunctionPointer Retrieve a function pointer from a module by name +/// +/// @details +/// - The function pointer is unique for the device on which the module was +/// created. +/// - The function pointer is no longer valid if module is destroyed. +/// - The function name should only refer to callable functions within the +/// module. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hModule` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pFunctionName` +/// + `nullptr == pfnFunction` +/// - ::ZE_RESULT_ERROR_INVALID_FUNCTION_NAME +func ZeModuleGetFunctionPointer( + hModule ZeModuleHandle, // hModule [in] handle of the module + pFunctionName *byte, // pFunctionName [in] Name of function to retrieve function pointer for. + pfnFunction *unsafe.Pointer, // pfnFunction [out] pointer to function. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeModuleGetFunctionPointer", uintptr(hModule), uintptr(unsafe.Pointer(pFunctionName)), uintptr(unsafe.Pointer(pfnFunction))) +} + +// ZeKernelSetGroupSize Set group size for a kernel. +/// +/// @details +/// - The group size will be used when a ::zeCommandListAppendLaunchKernel +/// variant is called. +/// - The application must **not** call this function from simultaneous +/// threads with the same kernel handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION +func ZeKernelSetGroupSize( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + groupSizeX uint32, // groupSizeX [in] group size for X dimension to use for this kernel + groupSizeY uint32, // groupSizeY [in] group size for Y dimension to use for this kernel + groupSizeZ uint32, // groupSizeZ [in] group size for Z dimension to use for this kernel +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelSetGroupSize", uintptr(hKernel), uintptr(groupSizeX), uintptr(groupSizeY), uintptr(groupSizeZ)) +} + +// ZeKernelSuggestGroupSize Query a suggested group size for a kernel given a global size for each +/// dimension. +/// +/// @details +/// - This function ignores the group size that is set using +/// ::zeKernelSetGroupSize. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == groupSizeX` +/// + `nullptr == groupSizeY` +/// + `nullptr == groupSizeZ` +/// - ::ZE_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION +func ZeKernelSuggestGroupSize( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + globalSizeX uint32, // globalSizeX [in] global width for X dimension + globalSizeY uint32, // globalSizeY [in] global width for Y dimension + globalSizeZ uint32, // globalSizeZ [in] global width for Z dimension + groupSizeX *uint32, // groupSizeX [out] recommended size of group for X dimension + groupSizeY *uint32, // groupSizeY [out] recommended size of group for Y dimension + groupSizeZ *uint32, // groupSizeZ [out] recommended size of group for Z dimension +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelSuggestGroupSize", uintptr(hKernel), uintptr(globalSizeX), uintptr(globalSizeY), uintptr(globalSizeZ), uintptr(unsafe.Pointer(groupSizeX)), uintptr(unsafe.Pointer(groupSizeY)), uintptr(unsafe.Pointer(groupSizeZ))) +} + +// ZeKernelSuggestMaxCooperativeGroupCount Query a suggested max group count for a cooperative kernel. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// - Applications are recommended to use ::zeKernelSuggestGroupSize and +/// ::zeKernelSetGroupSize first before calling this function and +/// launching cooperative kernels. Otherwise, implementation may return +/// ::ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == totalGroupCount` +func ZeKernelSuggestMaxCooperativeGroupCount( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + totalGroupCount *uint32, // totalGroupCount [out] recommended total group count. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelSuggestMaxCooperativeGroupCount", uintptr(hKernel), uintptr(unsafe.Pointer(totalGroupCount))) +} + +// ZeKernelSetArgumentValue Set kernel argument for a kernel. +/// +/// @details +/// - The argument values will be used when a +/// ::zeCommandListAppendLaunchKernel variant is called. +/// - The application must **not** call this function from simultaneous +/// threads with the same kernel handle. +/// - The implementation of this function should be lock-free. +/// - If argument is SLM (size), then SLM size in bytes for this resource is +/// provided as argument size and argument value is null +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX +/// - ::ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT +func ZeKernelSetArgumentValue( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + argIndex uint32, // argIndex [in] argument index in range [0, num args - 1] + argSize uintptr, // argSize [in] size of argument type + pArgValue unsafe.Pointer, // pArgValue [in][optional] argument value represented as matching arg type. If null then argument value is considered null. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelSetArgumentValue", uintptr(hKernel), uintptr(argIndex), uintptr(argSize), uintptr(unsafe.Pointer(pArgValue))) +} + +// ZeKernelIndirectAccessFlags (ze_kernel_indirect_access_flags_t) Kernel indirect access flags +type ZeKernelIndirectAccessFlags uint32 +const ( + ZE_KERNEL_INDIRECT_ACCESS_FLAG_HOST ZeKernelIndirectAccessFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_KERNEL_INDIRECT_ACCESS_FLAG_HOST Indicates that the kernel accesses host allocations indirectly. + ZE_KERNEL_INDIRECT_ACCESS_FLAG_DEVICE ZeKernelIndirectAccessFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_KERNEL_INDIRECT_ACCESS_FLAG_DEVICE Indicates that the kernel accesses device allocations indirectly. + ZE_KERNEL_INDIRECT_ACCESS_FLAG_SHARED ZeKernelIndirectAccessFlags = /* ZE_BIT(2) */(( 1 << 2 )) // ZE_KERNEL_INDIRECT_ACCESS_FLAG_SHARED Indicates that the kernel accesses shared allocations indirectly. + ZE_KERNEL_INDIRECT_ACCESS_FLAG_FORCE_UINT32 ZeKernelIndirectAccessFlags = 0x7fffffff // ZE_KERNEL_INDIRECT_ACCESS_FLAG_FORCE_UINT32 Value marking end of ZE_KERNEL_INDIRECT_ACCESS_FLAG_* ENUMs + +) + +// ZeKernelSetIndirectAccess Sets kernel indirect access flags. +/// +/// @details +/// - The application should specify which allocations will be indirectly +/// accessed by the kernel to allow driver to optimize which allocations +/// are made resident +/// - This function may **not** be called from simultaneous threads with the +/// same Kernel handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x7 < flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeKernelSetIndirectAccess( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + flags ZeKernelIndirectAccessFlags, // flags [in] kernel indirect access flags +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelSetIndirectAccess", uintptr(hKernel), uintptr(flags)) +} + +// ZeKernelGetIndirectAccess Retrieve kernel indirect access flags. +/// +/// @details +/// - This function may be called from simultaneous threads with the same +/// Kernel handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pFlags` +func ZeKernelGetIndirectAccess( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pFlags *ZeKernelIndirectAccessFlags, // pFlags [out] query result for kernel indirect access flags. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelGetIndirectAccess", uintptr(hKernel), uintptr(unsafe.Pointer(pFlags))) +} + +// ZeKernelGetSourceAttributes Retrieve all declared kernel attributes (i.e. can be specified with +/// __attribute__ in runtime language). +/// +/// @details +/// - This function may be called from simultaneous threads with the same +/// Kernel handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pSize` +func ZeKernelGetSourceAttributes( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pSize *uint32, // pSize [in,out] pointer to size of string in bytes, including null-terminating character. + pString **byte, // pString [in,out][optional] pointer to application-managed character array (string data). If NULL, the string length of the kernel source attributes, including a null-terminating character, is returned in pSize. Otherwise, pString must point to valid application memory that is greater than or equal to *pSize bytes in length, and on return the pointed-to string will contain a space-separated list of kernel source attributes. Note: This API was originally intended to ship with a char *pString, however this typo was introduced. Thus the API has to stay this way for backwards compatible reasons. It can be corrected in v2.0. Suggestion is to create your own char *pString and then pass to this API with &pString. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelGetSourceAttributes", uintptr(hKernel), uintptr(unsafe.Pointer(pSize)), uintptr(unsafe.Pointer(pString))) +} + +// ZeCacheConfigFlags (ze_cache_config_flags_t) Supported Cache Config flags +type ZeCacheConfigFlags uint32 +const ( + ZE_CACHE_CONFIG_FLAG_LARGE_SLM ZeCacheConfigFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_CACHE_CONFIG_FLAG_LARGE_SLM Large SLM size + ZE_CACHE_CONFIG_FLAG_LARGE_DATA ZeCacheConfigFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_CACHE_CONFIG_FLAG_LARGE_DATA Large General Data size + ZE_CACHE_CONFIG_FLAG_FORCE_UINT32 ZeCacheConfigFlags = 0x7fffffff // ZE_CACHE_CONFIG_FLAG_FORCE_UINT32 Value marking end of ZE_CACHE_CONFIG_FLAG_* ENUMs + +) + +// ZeKernelSetCacheConfig Sets the preferred cache configuration. +/// +/// @details +/// - The cache configuration will be used when a +/// ::zeCommandListAppendLaunchKernel variant is called. +/// - The application must **not** call this function from simultaneous +/// threads with the same kernel handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3 < flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_FEATURE +func ZeKernelSetCacheConfig( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + flags ZeCacheConfigFlags, // flags [in] cache configuration. must be 0 (default configuration) or a valid combination of ::ze_cache_config_flag_t. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelSetCacheConfig", uintptr(hKernel), uintptr(flags)) +} + +// ZE_MAX_KERNEL_UUID_SIZE Maximum kernel universal unique id (UUID) size in bytes +const ZE_MAX_KERNEL_UUID_SIZE = 16 + +// ZE_MAX_MODULE_UUID_SIZE Maximum module universal unique id (UUID) size in bytes +const ZE_MAX_MODULE_UUID_SIZE = 16 + +// ZeKernelUuid (ze_kernel_uuid_t) Kernel universal unique id (UUID) +type ZeKernelUuid struct { + Kid [ZE_MAX_KERNEL_UUID_SIZE]uint8 // Kid [out] opaque data representing a kernel UUID + Mid [ZE_MAX_MODULE_UUID_SIZE]uint8 // Mid [out] opaque data representing the kernel's module UUID + +} + +// ZeKernelProperties (ze_kernel_properties_t) Kernel properties +type ZeKernelProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Numkernelargs uint32 // Numkernelargs [out] number of kernel arguments. + Requiredgroupsizex uint32 // Requiredgroupsizex [out] required group size in the X dimension, or zero if there is no required group size + Requiredgroupsizey uint32 // Requiredgroupsizey [out] required group size in the Y dimension, or zero if there is no required group size + Requiredgroupsizez uint32 // Requiredgroupsizez [out] required group size in the Z dimension, or zero if there is no required group size + Requirednumsubgroups uint32 // Requirednumsubgroups [out] required number of subgroups per thread group, or zero if there is no required number of subgroups + Requiredsubgroupsize uint32 // Requiredsubgroupsize [out] required subgroup size, or zero if there is no required subgroup size + Maxsubgroupsize uint32 // Maxsubgroupsize [out] maximum subgroup size + Maxnumsubgroups uint32 // Maxnumsubgroups [out] maximum number of subgroups per thread group + Localmemsize uint32 // Localmemsize [out] local memory size used by each thread group + Privatememsize uint32 // Privatememsize [out] private memory size allocated by compiler used by each thread + Spillmemsize uint32 // Spillmemsize [out] spill memory size allocated by compiler + Uuid ZeKernelUuid // Uuid [out] universal unique identifier. + +} + +// ZeKernelPreferredGroupSizeProperties (ze_kernel_preferred_group_size_properties_t) Additional kernel preferred group size properties +/// +/// @details +/// - This structure may be passed to ::zeKernelGetProperties, via the +/// `pNext` member of ::ze_kernel_properties_t, to query additional kernel +/// preferred group size properties. +type ZeKernelPreferredGroupSizeProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Preferredmultiple uint32 // Preferredmultiple [out] preferred group size multiple + +} + +// ZeKernelGetProperties Retrieve kernel properties. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pKernelProperties` +func ZeKernelGetProperties( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pKernelProperties *ZeKernelProperties, // pKernelProperties [in,out] query result for kernel properties. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelGetProperties", uintptr(hKernel), uintptr(unsafe.Pointer(pKernelProperties))) +} + +// ZeKernelGetName Retrieve kernel name from Kernel. +/// +/// @details +/// - The caller can pass nullptr for pName when querying only for size. +/// - The implementation will copy the kernel name into a buffer supplied by +/// the caller. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pSize` +func ZeKernelGetName( + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pSize *uintptr, // pSize [in,out] size of kernel name string, including null terminator, in bytes. + pName *byte, // pName [in,out][optional] char pointer to kernel name. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeKernelGetName", uintptr(hKernel), uintptr(unsafe.Pointer(pSize)), uintptr(unsafe.Pointer(pName))) +} + +// ZeGroupCount (ze_group_count_t) Kernel dispatch group count. +type ZeGroupCount struct { + Groupcountx uint32 // Groupcountx [in] number of thread groups in X dimension + Groupcounty uint32 // Groupcounty [in] number of thread groups in Y dimension + Groupcountz uint32 // Groupcountz [in] number of thread groups in Z dimension + +} + +// ZeCommandListAppendLaunchKernel Launch kernel over one or more work groups. +/// +/// @details +/// - The application must ensure the kernel and events are accessible by +/// the device on which the command list was created. +/// - This may **only** be called for a command list created with command +/// queue group ordinal that supports compute. +/// - The application must ensure the command list, kernel and events were +/// created on the same context. +/// - This function may **not** be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pLaunchFuncArgs` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendLaunchKernel( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pLaunchFuncArgs *ZeGroupCount, // pLaunchFuncArgs [in] thread group launch arguments + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendLaunchKernel", uintptr(hCommandList), uintptr(hKernel), uintptr(unsafe.Pointer(pLaunchFuncArgs)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendLaunchKernelWithParameters Launch kernel over one or more work groups and allow to pass +/// additional parameters. +/// +/// @details +/// - The application must ensure the kernel and events are accessible by +/// the device on which the command list was created. +/// - This may **only** be called for a command list created with command +/// queue group ordinal that supports compute. +/// - The application must ensure the command list, kernel and events were +/// created on the same context. +/// - This function may **not** be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// - This function allows to pass additional parameters in the form of +/// `${x}_base_desc_t` +/// - This function can replace ::zeCommandListAppendLaunchCooperativeKernel +/// with additional parameter +/// `${x}_command_list_append_launch_kernel_param_cooperative_desc_t` +/// - This function supports both immediate and regular command lists. +/// +/// @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_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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pGroupCounts` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + when passed additional parameters are invalid or incompatible with the device or command list +func ZeCommandListAppendLaunchKernelWithParameters( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pGroupCounts *ZeGroupCount, // pGroupCounts [in] thread group launch arguments + pNext unsafe.Pointer, // pNext [in][optional] additional parameters passed to the function + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendLaunchKernelWithParameters", uintptr(hCommandList), uintptr(hKernel), uintptr(unsafe.Pointer(pGroupCounts)), uintptr(unsafe.Pointer(pNext)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeGroupSize (ze_group_size_t) Kernel dispatch group sizes. +type ZeGroupSize struct { + Groupsizex uint32 // Groupsizex [in] size of thread group in X dimension + Groupsizey uint32 // Groupsizey [in] size of thread group in Y dimension + Groupsizez uint32 // Groupsizez [in] size of thread group in Z dimension + +} + +// ZeCommandListAppendLaunchKernelWithArguments Launch kernel over one or more work groups with specifying work group +/// size and all kernel arguments and allow to pass additional extensions. +/// +/// @details +/// - The application must ensure the kernel and events are accessible by +/// the device on which the command list was created. +/// - This may **only** be called for a command list created with command +/// queue group ordinal that supports compute. +/// - The application must ensure the command list, kernel and events were +/// created on the same context. +/// - This function may **not** be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// - This function supports both immediate and regular command lists. +/// - This function changes kernel state as if separate +/// ${x}KernelSetGroupSize and ${x}KernelSetArgumentValue functions were +/// called. +/// - This function allows to pass additional extensions in the form of +/// `${x}_base_desc_t` +/// +/// @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_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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + when passed additional extensions are invalid or incompatible with the device or command list +/// - ::ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION - "as per ${x}KernelSetGroupSize" +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT - "as per ${x}KernelSetArgumentValue" +func ZeCommandListAppendLaunchKernelWithArguments( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + groupCounts *ZeGroupCount, // groupCounts [in] thread group counts (gozel hack: converted to a hidden pointer from a struct value) + groupSizes *ZeGroupSize, // groupSizes [in] thread group sizes (gozel hack: converted to a hidden pointer from a struct value) + pArguments *unsafe.Pointer, // pArguments [in]pointer to an array of pointers + pNext unsafe.Pointer, // pNext [in][optional] additional extensions passed to the function + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendLaunchKernelWithArguments", uintptr(hCommandList), uintptr(hKernel), uintptr(unsafe.Pointer(groupCounts)), uintptr(unsafe.Pointer(groupSizes)), uintptr(unsafe.Pointer(pArguments)), uintptr(unsafe.Pointer(pNext)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendLaunchCooperativeKernel Launch kernel cooperatively over one or more work groups. +/// +/// @details +/// - The application must ensure the kernel and events are accessible by +/// the device on which the command list was created. +/// - This may **only** be called for a command list created with command +/// queue group ordinal that supports compute. +/// - This may only be used for a command list that are submitted to command +/// queue with cooperative flag set. +/// - The application must ensure the command list, kernel and events were +/// created on the same context. +/// - This function may **not** be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// - Use ::zeKernelSuggestMaxCooperativeGroupCount to recommend max group +/// count for device for cooperative functions that device supports. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pLaunchFuncArgs` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendLaunchCooperativeKernel( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pLaunchFuncArgs *ZeGroupCount, // pLaunchFuncArgs [in] thread group launch arguments + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendLaunchCooperativeKernel", uintptr(hCommandList), uintptr(hKernel), uintptr(unsafe.Pointer(pLaunchFuncArgs)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendLaunchKernelIndirect Launch kernel over one or more work groups using indirect arguments. +/// +/// @details +/// - The application must ensure the kernel and events are accessible by +/// the device on which the command list was created. +/// - The application must ensure the launch arguments are visible to the +/// device on which the command list was created. +/// - The implementation must not access the contents of the launch +/// arguments as they are free to be modified by either the Host or device +/// up until execution. +/// - This may **only** be called for a command list created with command +/// queue group ordinal that supports compute. +/// - The application must ensure the command list, kernel and events were +/// created, and the memory was allocated, on the same context. +/// - This function may **not** be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// + `nullptr == hKernel` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pLaunchArgumentsBuffer` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendLaunchKernelIndirect( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + hKernel ZeKernelHandle, // hKernel [in] handle of the kernel object + pLaunchArgumentsBuffer *ZeGroupCount, // pLaunchArgumentsBuffer [in] pointer to device buffer that will contain thread group launch arguments + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendLaunchKernelIndirect", uintptr(hCommandList), uintptr(hKernel), uintptr(unsafe.Pointer(pLaunchArgumentsBuffer)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + +// ZeCommandListAppendLaunchMultipleKernelsIndirect Launch multiple kernels over one or more work groups using an array of +/// indirect arguments. +/// +/// @details +/// - The application must ensure the kernel and events are accessible by +/// the device on which the command list was created. +/// - The application must ensure the array of launch arguments and count +/// buffer are visible to the device on which the command list was +/// created. +/// - The implementation must not access the contents of the array of launch +/// arguments or count buffer as they are free to be modified by either +/// the Host or device up until execution. +/// - This may **only** be called for a command list created with command +/// queue group ordinal that supports compute. +/// - The application must enusre the command list, kernel and events were +/// created, and the memory was allocated, on the same context. +/// - This function may **not** be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phKernels` +/// + `nullptr == pCountBuffer` +/// + `nullptr == pLaunchArgumentsBuffer` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +func ZeCommandListAppendLaunchMultipleKernelsIndirect( + hCommandList ZeCommandListHandle, // hCommandList [in] handle of the command list + numKernels uint32, // numKernels [in] maximum number of kernels to launch + phKernels *ZeKernelHandle, // phKernels [in][range(0, numKernels)] handles of the kernel objects + pCountBuffer *uint32, // pCountBuffer [in] pointer to device memory location that will contain the actual number of kernels to launch; value must be less than or equal to numKernels + pLaunchArgumentsBuffer *ZeGroupCount, // pLaunchArgumentsBuffer [in][range(0, numKernels)] pointer to device buffer that will contain a contiguous array of thread group launch arguments + hSignalEvent ZeEventHandle, // hSignalEvent [in][optional] handle of the event to signal on completion + numWaitEvents uint32, // numWaitEvents [in][optional] number of events to wait on before launching; must be 0 if `nullptr == phWaitEvents` + phWaitEvents *ZeEventHandle, // phWaitEvents [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeCommandListAppendLaunchMultipleKernelsIndirect", uintptr(hCommandList), uintptr(numKernels), uintptr(unsafe.Pointer(phKernels)), uintptr(unsafe.Pointer(pCountBuffer)), uintptr(unsafe.Pointer(pLaunchArgumentsBuffer)), uintptr(hSignalEvent), uintptr(numWaitEvents), uintptr(unsafe.Pointer(phWaitEvents))) +} + diff --git a/core/program.go b/core/program.go new file mode 100644 index 0000000..0ab9c4c --- /dev/null +++ b/core/program.go @@ -0,0 +1,54 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" +) + +// ZE_MODULE_PROGRAM_EXP_NAME Module Program Extension Name +const ZE_MODULE_PROGRAM_EXP_NAME = "ZE_experimental_module_program" + +// ZeModuleProgramExpVersion (ze_module_program_exp_version_t) Module Program Extension Version(s) +type ZeModuleProgramExpVersion uintptr +const ( + ZE_MODULE_PROGRAM_EXP_VERSION_1_0 ZeModuleProgramExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_MODULE_PROGRAM_EXP_VERSION_1_0 version 1.0 + ZE_MODULE_PROGRAM_EXP_VERSION_CURRENT ZeModuleProgramExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_MODULE_PROGRAM_EXP_VERSION_CURRENT latest known version + ZE_MODULE_PROGRAM_EXP_VERSION_FORCE_UINT32 ZeModuleProgramExpVersion = 0x7fffffff // ZE_MODULE_PROGRAM_EXP_VERSION_FORCE_UINT32 Value marking end of ZE_MODULE_PROGRAM_EXP_VERSION_* ENUMs + +) + +// ZeModuleProgramExpDesc (ze_module_program_exp_desc_t) Module extended descriptor to support multiple input modules. +/// +/// @details +/// - Implementation must support ::ZE_MODULE_PROGRAM_EXP_NAME extension +/// - Modules support import and export linkage for functions and global +/// variables. +/// - pInputModules, pBuildFlags, and pConstants from ::ze_module_desc_t is +/// ignored. +/// - Format in ::ze_module_desc_t needs to be set to +/// ::ZE_MODULE_FORMAT_IL_SPIRV or ::ZE_MODULE_FORMAT_NATIVE. +/// - All modules in the list must be of the same format and match the +/// format specified in ::ze_module_desc_t. +type ZeModuleProgramExpDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Count uint32 // Count [in] Count of input modules + Inputsizes *uintptr // Inputsizes [in][range(0, count)] sizes of each input module in pInputModules. + Pinputmodules **uint8 // Pinputmodules [in][range(0, count)] pointer to an array of binary modules in format specified as part of ::ze_module_desc_t. + Pbuildflags **byte // Pbuildflags [in][optional][range(0, count)] array of strings containing build flags. See pBuildFlags in ::ze_module_desc_t. + Pconstants **ZeModuleConstants // Pconstants [in][optional][range(0, count)] pointer to array of specialization constant strings. Valid only for SPIR-V input. This must be set to nullptr if no specialization constants are provided. + +} + diff --git a/core/raytracing.go b/core/raytracing.go new file mode 100644 index 0000000..93dfbea --- /dev/null +++ b/core/raytracing.go @@ -0,0 +1,74 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" +) + +// ZE_RAYTRACING_EXT_NAME Raytracing Extension Name +const ZE_RAYTRACING_EXT_NAME = "ZE_extension_raytracing" + +// ZeRaytracingExtVersion (ze_raytracing_ext_version_t) Raytracing Extension Version(s) +type ZeRaytracingExtVersion uintptr +const ( + ZE_RAYTRACING_EXT_VERSION_1_0 ZeRaytracingExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_RAYTRACING_EXT_VERSION_1_0 version 1.0 + ZE_RAYTRACING_EXT_VERSION_CURRENT ZeRaytracingExtVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_RAYTRACING_EXT_VERSION_CURRENT latest known version + ZE_RAYTRACING_EXT_VERSION_FORCE_UINT32 ZeRaytracingExtVersion = 0x7fffffff // ZE_RAYTRACING_EXT_VERSION_FORCE_UINT32 Value marking end of ZE_RAYTRACING_EXT_VERSION_* ENUMs + +) + +// ZeDeviceRaytracingExtFlags (ze_device_raytracing_ext_flags_t) Supported raytracing capability flags +type ZeDeviceRaytracingExtFlags uint32 +const ( + ZE_DEVICE_RAYTRACING_EXT_FLAG_RAYQUERY ZeDeviceRaytracingExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_DEVICE_RAYTRACING_EXT_FLAG_RAYQUERY Supports rayquery + ZE_DEVICE_RAYTRACING_EXT_FLAG_FORCE_UINT32 ZeDeviceRaytracingExtFlags = 0x7fffffff // ZE_DEVICE_RAYTRACING_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_DEVICE_RAYTRACING_EXT_FLAG_* ENUMs + +) + +// ZeDeviceRaytracingExtProperties (ze_device_raytracing_ext_properties_t) Raytracing properties queried using ::zeDeviceGetModuleProperties +/// +/// @details +/// - This structure may be returned from ::zeDeviceGetModuleProperties, via +/// the `pNext` member of ::ze_device_module_properties_t. +type ZeDeviceRaytracingExtProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeDeviceRaytracingExtFlags // Flags [out] 0 or a valid combination of ::ze_device_raytracing_ext_flags_t + Maxbvhlevels uint32 // Maxbvhlevels [out] Maximum number of BVH levels supported + +} + +// ZeRaytracingMemAllocExtFlags (ze_raytracing_mem_alloc_ext_flags_t) Supported raytracing memory allocation flags +type ZeRaytracingMemAllocExtFlags uint32 +const ( + ZE_RAYTRACING_MEM_ALLOC_EXT_FLAG_TBD ZeRaytracingMemAllocExtFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RAYTRACING_MEM_ALLOC_EXT_FLAG_TBD reserved for future use + ZE_RAYTRACING_MEM_ALLOC_EXT_FLAG_FORCE_UINT32 ZeRaytracingMemAllocExtFlags = 0x7fffffff // ZE_RAYTRACING_MEM_ALLOC_EXT_FLAG_FORCE_UINT32 Value marking end of ZE_RAYTRACING_MEM_ALLOC_EXT_FLAG_* ENUMs + +) + +// ZeRaytracingMemAllocExtDesc (ze_raytracing_mem_alloc_ext_desc_t) Raytracing memory allocation descriptor +/// +/// @details +/// - This structure must be passed to ::zeMemAllocShared or +/// ::zeMemAllocDevice, via the `pNext` member of +/// ::ze_device_mem_alloc_desc_t, for any memory allocation that is to be +/// accessed by raytracing fixed-function of the device. +type ZeRaytracingMemAllocExtDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeRaytracingMemAllocExtFlags // Flags [in] flags specifying additional allocation controls. must be 0 (default) or a valid combination of ::ze_raytracing_mem_alloc_ext_flag_t; default behavior may use implicit driver-based heuristics. + +} + diff --git a/core/relaxedAllocLimits.go b/core/relaxedAllocLimits.go new file mode 100644 index 0000000..af62862 --- /dev/null +++ b/core/relaxedAllocLimits.go @@ -0,0 +1,57 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" +) + +// ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME Relaxed Allocation Limits Extension Name +const ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME = "ZE_experimental_relaxed_allocation_limits" + +// ZeRelaxedAllocationLimitsExpVersion (ze_relaxed_allocation_limits_exp_version_t) Relaxed Allocation Limits Extension Version(s) +type ZeRelaxedAllocationLimitsExpVersion uintptr +const ( + ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_1_0 ZeRelaxedAllocationLimitsExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_1_0 version 1.0 + ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_CURRENT ZeRelaxedAllocationLimitsExpVersion = /* ZE_MAKE_VERSION( 1, 0 ) */((( 1 << 16 )|( 0 & 0x0000ffff))) // ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_CURRENT latest known version + ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_FORCE_UINT32 ZeRelaxedAllocationLimitsExpVersion = 0x7fffffff // ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_FORCE_UINT32 Value marking end of ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_* ENUMs + +) + +// ZeRelaxedAllocationLimitsExpFlags (ze_relaxed_allocation_limits_exp_flags_t) Supported relaxed memory allocation flags +type ZeRelaxedAllocationLimitsExpFlags uint32 +const ( + ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE ZeRelaxedAllocationLimitsExpFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE Allocation size may exceed the `maxMemAllocSize` member of + + ///< ::ZeDeviceProperties. + + ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_FORCE_UINT32 ZeRelaxedAllocationLimitsExpFlags = 0x7fffffff // ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_FORCE_UINT32 Value marking end of ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_* ENUMs + +) + +// ZeRelaxedAllocationLimitsExpDesc (ze_relaxed_allocation_limits_exp_desc_t) Relaxed limits memory allocation descriptor +/// +/// @details +/// - This structure may be passed to ::zeMemAllocShared or +/// ::zeMemAllocDevice, via the `pNext` member of +/// ::ze_device_mem_alloc_desc_t. +/// - This structure may also be passed to ::zeMemAllocHost, via the `pNext` +/// member of ::ze_host_mem_alloc_desc_t. +type ZeRelaxedAllocationLimitsExpDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZeRelaxedAllocationLimitsExpFlags // Flags [in] flags specifying allocation limits to relax. must be 0 (default) or a valid combination of ::ze_relaxed_allocation_limits_exp_flag_t; + +} + diff --git a/core/residency.go b/core/residency.go new file mode 100644 index 0000000..6894c47 --- /dev/null +++ b/core/residency.go @@ -0,0 +1,166 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeContextMakeMemoryResident Makes memory resident for the device. +/// +/// @details +/// - The application must ensure the memory is resident before being +/// referenced by the device +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + ptr is not recognized by the implementation +func ZeContextMakeMemoryResident( + hContext ZeContextHandle, // hContext [in] handle of context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + ptr unsafe.Pointer, // ptr [in] pointer to memory to make resident + size uintptr, // size [in] size in bytes to make resident +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextMakeMemoryResident", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(ptr)), uintptr(size)) +} + +// ZeContextEvictMemory Allows memory to be evicted from the device. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the memory before it is evicted +/// - The application may free the memory without evicting; the memory is +/// implicitly evicted when freed. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +func ZeContextEvictMemory( + hContext ZeContextHandle, // hContext [in] handle of context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + ptr unsafe.Pointer, // ptr [in] pointer to memory to evict + size uintptr, // size [in] size in bytes to evict +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextEvictMemory", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(ptr)), uintptr(size)) +} + +// ZeContextMakeImageResident Makes image resident for the device. +/// +/// @details +/// - The application must ensure the image is resident before being +/// referenced by the device +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// + `nullptr == hImage` +func ZeContextMakeImageResident( + hContext ZeContextHandle, // hContext [in] handle of context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + hImage ZeImageHandle, // hImage [in] handle of image to make resident +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextMakeImageResident", uintptr(hContext), uintptr(hDevice), uintptr(hImage)) +} + +// ZeContextEvictImage Allows image to be evicted from the device. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the image before it is evicted +/// - The application may destroy the image without evicting; the image is +/// implicitly evicted when destroyed. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// + `nullptr == hImage` +func ZeContextEvictImage( + hContext ZeContextHandle, // hContext [in] handle of context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + hImage ZeImageHandle, // hImage [in] handle of image to make evict +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeContextEvictImage", uintptr(hContext), uintptr(hDevice), uintptr(hImage)) +} + diff --git a/core/sampler.go b/core/sampler.go new file mode 100644 index 0000000..8988f24 --- /dev/null +++ b/core/sampler.go @@ -0,0 +1,131 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeSamplerAddressMode (ze_sampler_address_mode_t) Sampler addressing modes +type ZeSamplerAddressMode uintptr +const ( + ZE_SAMPLER_ADDRESS_MODE_NONE ZeSamplerAddressMode = 0 // ZE_SAMPLER_ADDRESS_MODE_NONE No coordinate modifications for out-of-bounds image access. + ZE_SAMPLER_ADDRESS_MODE_REPEAT ZeSamplerAddressMode = 1 // ZE_SAMPLER_ADDRESS_MODE_REPEAT Out-of-bounds coordinates are wrapped back around. + ZE_SAMPLER_ADDRESS_MODE_CLAMP ZeSamplerAddressMode = 2 // ZE_SAMPLER_ADDRESS_MODE_CLAMP Out-of-bounds coordinates are clamped to edge. + ZE_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER ZeSamplerAddressMode = 3 // ZE_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER Out-of-bounds coordinates are clamped to border color which is (0.0f, + + ///< 0.0f, 0.0f, 0.0f) if image format swizzle contains alpha, otherwise + ///< (0.0f, 0.0f, 0.0f, 1.0f). + + ZE_SAMPLER_ADDRESS_MODE_MIRROR ZeSamplerAddressMode = 4 // ZE_SAMPLER_ADDRESS_MODE_MIRROR Out-of-bounds coordinates are mirrored starting from edge. + ZE_SAMPLER_ADDRESS_MODE_FORCE_UINT32 ZeSamplerAddressMode = 0x7fffffff // ZE_SAMPLER_ADDRESS_MODE_FORCE_UINT32 Value marking end of ZE_SAMPLER_ADDRESS_MODE_* ENUMs + +) + +// ZeSamplerFilterMode (ze_sampler_filter_mode_t) Sampler filtering modes +type ZeSamplerFilterMode uintptr +const ( + ZE_SAMPLER_FILTER_MODE_NEAREST ZeSamplerFilterMode = 0 // ZE_SAMPLER_FILTER_MODE_NEAREST No coordinate modifications for out of bounds image access. + ZE_SAMPLER_FILTER_MODE_LINEAR ZeSamplerFilterMode = 1 // ZE_SAMPLER_FILTER_MODE_LINEAR Out-of-bounds coordinates are wrapped back around. + ZE_SAMPLER_FILTER_MODE_FORCE_UINT32 ZeSamplerFilterMode = 0x7fffffff // ZE_SAMPLER_FILTER_MODE_FORCE_UINT32 Value marking end of ZE_SAMPLER_FILTER_MODE_* ENUMs + +) + +// ZeSamplerDesc (ze_sampler_desc_t) Sampler descriptor +type ZeSamplerDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Addressmode ZeSamplerAddressMode // Addressmode [in] Sampler addressing mode to determine how out-of-bounds coordinates are handled. + Filtermode ZeSamplerFilterMode // Filtermode [in] Sampler filter mode to determine how samples are filtered. + Isnormalized ZeBool // Isnormalized [in] Are coordinates normalized [0, 1] or not. + +} + +// ZeSamplerCreate Creates sampler on the context. +/// +/// @details +/// - The application must only use the sampler for the device, or its +/// sub-devices, which was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phSampler` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `::ZE_SAMPLER_ADDRESS_MODE_MIRROR < desc->addressMode` +/// + `::ZE_SAMPLER_FILTER_MODE_LINEAR < desc->filterMode` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +func ZeSamplerCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device + desc *ZeSamplerDesc, // desc [in] pointer to sampler descriptor + phSampler *ZeSamplerHandle, // phSampler [out] handle of the sampler +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeSamplerCreate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phSampler))) +} + +// ZeSamplerDestroy Destroys sampler object +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the sampler before it is deleted. +/// - The implementation of this function may immediately free all Host and +/// Device allocations associated with this sampler. +/// - The application must **not** call this function from simultaneous +/// threads with the same sampler handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hSampler` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZeSamplerDestroy( + hSampler ZeSamplerHandle, // hSampler [in][release] handle of the sampler +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeSamplerDestroy", uintptr(hSampler)) +} + diff --git a/core/virtual.go b/core/virtual.go new file mode 100644 index 0000000..0515498 --- /dev/null +++ b/core/virtual.go @@ -0,0 +1,469 @@ +// Code generated by cmd/gen. DO NOT EDIT. + +/* + * + * Copyright (C) 2019-2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + * @file ze_api.h + * @version v1.15-r1.15.31 + * + */ + +package core + +import ( + "unsafe" + + "github.com/fumiama/gozel/internal/zecall" +) + +// ZeMemoryAccessAttribute (ze_memory_access_attribute_t) Virtual memory page access attributes +type ZeMemoryAccessAttribute uintptr +const ( + ZE_MEMORY_ACCESS_ATTRIBUTE_NONE ZeMemoryAccessAttribute = 0 // ZE_MEMORY_ACCESS_ATTRIBUTE_NONE Indicates the memory page is inaccessible. + ZE_MEMORY_ACCESS_ATTRIBUTE_READWRITE ZeMemoryAccessAttribute = 1 // ZE_MEMORY_ACCESS_ATTRIBUTE_READWRITE Indicates the memory page supports read write access. + ZE_MEMORY_ACCESS_ATTRIBUTE_READONLY ZeMemoryAccessAttribute = 2 // ZE_MEMORY_ACCESS_ATTRIBUTE_READONLY Indicates the memory page supports read-only access. + ZE_MEMORY_ACCESS_ATTRIBUTE_FORCE_UINT32 ZeMemoryAccessAttribute = 0x7fffffff // ZE_MEMORY_ACCESS_ATTRIBUTE_FORCE_UINT32 Value marking end of ZE_MEMORY_ACCESS_ATTRIBUTE_* ENUMs + +) + +// ZeVirtualMemReserve Reserves pages in virtual address space. +/// +/// @details +/// - The application must only use the memory allocation on the context for +/// which it was created. +/// - The starting address and size must be page aligned. See +/// ::zeVirtualMemQueryPageSize. +/// - If pStart is not null then implementation will attempt to reserve +/// starting from that address. If not available then will find another +/// suitable starting address. +/// - The application may call this function from simultaneous threads. +/// - The access attributes will default to none to indicate reservation is +/// inaccessible. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pptr` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +func ZeVirtualMemReserve( + hContext ZeContextHandle, // hContext [in] handle of the context object + pStart unsafe.Pointer, // pStart [in][optional] pointer to start of region to reserve. If nullptr then implementation will choose a start address. + size uintptr, // size [in] size in bytes to reserve; must be page aligned. + pptr *unsafe.Pointer, // pptr [out] pointer to virtual reservation. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeVirtualMemReserve", uintptr(hContext), uintptr(unsafe.Pointer(pStart)), uintptr(size), uintptr(unsafe.Pointer(pptr))) +} + +// ZeVirtualMemFree Free pages in a reserved virtual address range. +/// +/// @details +/// - Any existing virtual mappings for the range will be unmapped. +/// - Physical allocations objects that were mapped to this range will not +/// be destroyed. These need to be destroyed explicitly. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +func ZeVirtualMemFree( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] pointer to start of region to free. + size uintptr, // size [in] size in bytes to free; must be page aligned. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeVirtualMemFree", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(size)) +} + +// ZeVirtualMemQueryPageSize Queries page size to use for aligning virtual memory reservations and +/// physical memory allocations. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pagesize` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +func ZeVirtualMemQueryPageSize( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object + size uintptr, // size [in] unaligned allocation size in bytes + pagesize *uintptr, // pagesize [out] pointer to page size to use for start address and size alignments. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeVirtualMemQueryPageSize", uintptr(hContext), uintptr(hDevice), uintptr(size), uintptr(unsafe.Pointer(pagesize))) +} + +// ZePhysicalMemFlags (ze_physical_mem_flags_t) Supported physical memory creation flags +type ZePhysicalMemFlags uint32 +const ( + ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_DEVICE ZePhysicalMemFlags = /* ZE_BIT(0) */(( 1 << 0 )) // ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_DEVICE [default] allocate physical device memory. + ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_HOST ZePhysicalMemFlags = /* ZE_BIT(1) */(( 1 << 1 )) // ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_HOST Allocate physical host memory instead. + ZE_PHYSICAL_MEM_FLAG_FORCE_UINT32 ZePhysicalMemFlags = 0x7fffffff // ZE_PHYSICAL_MEM_FLAG_FORCE_UINT32 Value marking end of ZE_PHYSICAL_MEM_FLAG_* ENUMs + +) + +// ZePhysicalMemDesc (ze_physical_mem_desc_t) Physical memory descriptor +type ZePhysicalMemDesc struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Flags ZePhysicalMemFlags // Flags [in] creation flags. must be 0 (default) or a valid combination of ::ze_physical_mem_flag_t; default is to create physical device memory. + Size uintptr // Size [in] size in bytes to reserve; must be page aligned. + +} + +// ZePhysicalMemProperties (ze_physical_mem_properties_t) Physical memory properties queried using ::zePhysicalMemGetProperties +type ZePhysicalMemProperties struct { + Stype ZeStructureType // Stype [in] type of this structure + Pnext unsafe.Pointer // Pnext [in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext). + Id uint64 // Id [out] unique identifier for the physical memory object + Size uint64 // Size [out] size of the physical memory object in bytes + +} + +// ZePhysicalMemGetProperties Retrieves memory properties of the physical memory object. +/// +/// @details +/// - The application must only use the physical memory object on the +/// context for which it was created. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hPhysicalMem` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pMemProperties` +func ZePhysicalMemGetProperties( + hContext ZeContextHandle, // hContext [in] handle of the context object + hPhysicalMem ZePhysicalMemHandle, // hPhysicalMem [in] handle of the physical memory object + pMemProperties *ZePhysicalMemProperties, // pMemProperties [in,out] pointer to physical memory properties structure. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zePhysicalMemGetProperties", uintptr(hContext), uintptr(hPhysicalMem), uintptr(unsafe.Pointer(pMemProperties))) +} + +// ZePhysicalMemCreate Creates a physical memory object for the context. +/// +/// @details +/// - The application must only use the physical memory object on the +/// context for which it was created. +/// - The size must be page aligned. For host memory, the operating system +/// page size should be used. For device memory, see +/// ::zeVirtualMemQueryPageSize. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phPhysicalMemory` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3 < desc->flags` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == desc->size` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +func ZePhysicalMemCreate( + hContext ZeContextHandle, // hContext [in] handle of the context object + hDevice ZeDeviceHandle, // hDevice [in] handle of the device object, can be `nullptr` if creating physical host memory. + desc *ZePhysicalMemDesc, // desc [in] pointer to physical memory descriptor. + phPhysicalMemory *ZePhysicalMemHandle, // phPhysicalMemory [out] pointer to handle of physical memory object created +) (ZeResult, error) { + return zecall.Call[ZeResult]("zePhysicalMemCreate", uintptr(hContext), uintptr(hDevice), uintptr(unsafe.Pointer(desc)), uintptr(unsafe.Pointer(phPhysicalMemory))) +} + +// ZePhysicalMemDestroy Destroys a physical memory object. +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the physical memory object before it is deleted +/// - The application must **not** call this function from simultaneous +/// threads with the same physical memory handle. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hPhysicalMemory` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +func ZePhysicalMemDestroy( + hContext ZeContextHandle, // hContext [in] handle of the context object + hPhysicalMemory ZePhysicalMemHandle, // hPhysicalMemory [in][release] handle of physical memory object to destroy +) (ZeResult, error) { + return zecall.Call[ZeResult]("zePhysicalMemDestroy", uintptr(hContext), uintptr(hPhysicalMemory)) +} + +// ZeVirtualMemMap Maps pages in virtual address space to pages from physical memory +/// object. +/// +/// @details +/// - The virtual address range must have been reserved using +/// ::zeVirtualMemReserve. +/// - The application must only use the mapped memory allocation on the +/// context for which it was created. +/// - The virtual start address and size must be page aligned. See +/// ::zeVirtualMemQueryPageSize. +/// - The application should use, for the starting address and size, the +/// same size alignment used for the physical allocation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hPhysicalMemory` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `::ZE_MEMORY_ACCESS_ATTRIBUTE_READONLY < access` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +func ZeVirtualMemMap( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] pointer to start of virtual address range to map. + size uintptr, // size [in] size in bytes of virtual address range to map; must be page aligned. + hPhysicalMemory ZePhysicalMemHandle, // hPhysicalMemory [in] handle to physical memory object. + offset uintptr, // offset [in] offset into physical memory allocation object; must be page aligned. + access ZeMemoryAccessAttribute, // access [in] specifies page access attributes to apply to the virtual address range. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeVirtualMemMap", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(size), uintptr(hPhysicalMemory), uintptr(offset), uintptr(access)) +} + +// ZeVirtualMemUnmap Unmaps pages in virtual address space from pages from a physical +/// memory object. +/// +/// @details +/// - The page access attributes for virtual address range will revert back +/// to none. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +/// + Address must be page aligned +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// + Size must be page aligned +func ZeVirtualMemUnmap( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] pointer to start of region to unmap. + size uintptr, // size [in] size in bytes to unmap; must be page aligned. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeVirtualMemUnmap", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(size)) +} + +// ZeVirtualMemSetAccessAttribute Set memory access attributes for a virtual address range. +/// +/// @details +/// - This function may be called from simultaneous threads with the same +/// function handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `::ZE_MEMORY_ACCESS_ATTRIBUTE_READONLY < access` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +/// + Address must be page aligned +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// + Size must be page aligned +func ZeVirtualMemSetAccessAttribute( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] pointer to start of reserved virtual address region. + size uintptr, // size [in] size in bytes; must be page aligned. + access ZeMemoryAccessAttribute, // access [in] specifies page access attributes to apply to the virtual address range. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeVirtualMemSetAccessAttribute", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(size), uintptr(access)) +} + +// ZeVirtualMemGetAccessAttribute Get memory access attribute for a virtual address range. +/// +/// @details +/// - If size and outSize are equal then the pages in the specified virtual +/// address range have the same access attributes. +/// - This function may be called from simultaneous threads with the same +/// function handle. +/// - The implementation of this function should be lock-free. +/// +/// @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_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// + `nullptr == access` +/// + `nullptr == outSize` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT +/// + Address must be page aligned +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE +/// + `0 == size` +/// + Size must be page aligned +func ZeVirtualMemGetAccessAttribute( + hContext ZeContextHandle, // hContext [in] handle of the context object + ptr unsafe.Pointer, // ptr [in] pointer to start of virtual address region for query. + size uintptr, // size [in] size in bytes; must be page aligned. + access *ZeMemoryAccessAttribute, // access [out] query result for page access attribute. + outSize *uintptr, // outSize [out] query result for size of virtual address range, starting at ptr, that shares same access attribute. +) (ZeResult, error) { + return zecall.Call[ZeResult]("zeVirtualMemGetAccessAttribute", uintptr(hContext), uintptr(unsafe.Pointer(ptr)), uintptr(size), uintptr(unsafe.Pointer(access)), uintptr(unsafe.Pointer(outSize))) +} + diff --git a/internal/zecall/errors.go b/internal/zecall/errors.go new file mode 100644 index 0000000..8699851 --- /dev/null +++ b/internal/zecall/errors.go @@ -0,0 +1,15 @@ +package zecall + +import ( + "errors" + "runtime" +) + +var ( + // ErrNotImplemented is a stub error. + ErrNotImplemented = errors.New("zecall is not implemtent on" + runtime.GOOS + " " + runtime.GOARCH) + // ErrZeCallNotInit please call Init() first. + ErrZeCallNotInit = errors.New("zecall not init") + // ErrNoSuchProcess please register the process first. + ErrNoSuchProcess = errors.New("no such process") +) diff --git a/internal/zecall/generic.go b/internal/zecall/generic.go new file mode 100644 index 0000000..dfca7b6 --- /dev/null +++ b/internal/zecall/generic.go @@ -0,0 +1,38 @@ +package zecall + +import ( + "errors" + "math" + "reflect" +) + +type ReturnTypes interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | + ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 +} + +// Call invokes a registered proc by name. For generated call only. +// The go:uintptrescapes directive tells the compiler that args may contain +// pointers converted to uintptr, so the GC will keep them alive during the call. +// +//go:uintptrescapes +func Call[T ReturnTypes](name string, args ...uintptr) (r T, err error) { + r1, r2, err := Syscall(name, args...) + if err != nil { + return + } + k := reflect.TypeOf(r).Kind() + switch k { + case reflect.Int, reflect.Int8, reflect.Int16, + reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, + reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + r = (T)(r1) + case reflect.Float32: + r = (T)(math.Float32frombits(uint32(r2))) + case reflect.Float64: + r = (T)(math.Float64frombits(uint64(r2))) + default: + err = errors.New("zecall unsupported kind " + k.String()) + } + return +} diff --git a/internal/zecall/zecall_linux.go b/internal/zecall/zecall_linux.go index 2959b30..9ea1c77 100644 --- a/internal/zecall/zecall_linux.go +++ b/internal/zecall/zecall_linux.go @@ -1,7 +1,6 @@ package zecall import ( - "errors" "syscall" "github.com/ebitengine/purego" @@ -11,13 +10,6 @@ const ( zeLibraryName = "libze_loader.so" ) -var ( - // ErrZeCallNotInit please call Init() first. - ErrZeCallNotInit = errors.New("zecall not init") - // ErrNoSuchProcess please register the process first. - ErrNoSuchProcess = errors.New("no such process") -) - var ( libZeLoader uintptr procMap = map[string]uintptr{} @@ -47,12 +39,12 @@ func Register(name string) error { return nil } -// Call invokes a registered proc by name. For generated call only. +// Syscall invokes a registered proc by name. For generated call only. // The go:uintptrescapes directive tells the compiler that args may contain // pointers converted to uintptr, so the GC will keep them alive during the call. // //go:uintptrescapes -func Call(name string, args ...uintptr) (r1, r2 uintptr, err error) { +func Syscall(name string, args ...uintptr) (r1, r2 uintptr, err error) { fn, ok := procMap[name] if !ok { return 0, 0, ErrNoSuchProcess diff --git a/internal/zecall/zecall_stub.go b/internal/zecall/zecall_stub.go new file mode 100644 index 0000000..b35c91f --- /dev/null +++ b/internal/zecall/zecall_stub.go @@ -0,0 +1,15 @@ +//go:build !linux && !windows + +package zecall + +// Register a process for calling. For generated init only. Not thread-safe. +func Register(string) error { + return ErrNotImplemented +} + +// Syscall invokes a registered proc by name. For generated call only. +// The go:uintptrescapes directive tells the compiler that args may contain +// pointers converted to uintptr, so the GC will keep them alive during the call. +func Syscall(name string, args ...uintptr) (uintptr, uintptr, error) { + return 0, 0, ErrNotImplemented +} diff --git a/internal/zecall/zecall_windows.go b/internal/zecall/zecall_windows.go index a7e6a77..30492c2 100644 --- a/internal/zecall/zecall_windows.go +++ b/internal/zecall/zecall_windows.go @@ -1,7 +1,6 @@ package zecall import ( - "errors" "syscall" ) @@ -9,13 +8,6 @@ const ( zeLibraryName = "ze_loader.dll" ) -var ( - // ErrZeCallNotInit please call Init() first. - ErrZeCallNotInit = errors.New("zecall not init") - // ErrNoSuchProcess please register the process first. - ErrNoSuchProcess = errors.New("no such process") -) - var ( libZeLoader *syscall.DLL procMap = map[string]*syscall.Proc{} @@ -45,12 +37,12 @@ func Register(name string) error { return nil } -// Call invokes a registered proc by name. For generated call only. +// Syscall invokes a registered proc by name. For generated call only. // The go:uintptrescapes directive tells the compiler that args may contain // pointers converted to uintptr, so the GC will keep them alive during the call. // //go:uintptrescapes -func Call(name string, args ...uintptr) (r1, r2 uintptr, err error) { +func Syscall(name string, args ...uintptr) (r1, r2 uintptr, err error) { fn, ok := procMap[name] if !ok { return 0, 0, ErrNoSuchProcess