XU XUv0.16.0

#github.com/xulang-org/packages/vulkan_native

import: vulkan_native #github.com/xulang-org/packages/vulkan_native

counts: 9 functions, 19 methods, 4 types, 0 constants, 0 method sets

Pure-Xu dlopen backend for Vulkan 1.1 compute pipelines (Linux / Windows / MoltenVK). Uses SPIR-V 1.0 compute binaries generated directly in pure Xu (spirv.xu) and allows XU_VULKAN_LIBRARY override for custom ICD/loader paths or test harnesses.

github.com/xulang-org/packages · 1.17.2 · Install and use

struct VulkanPipeline

XuAPI
pub struct VulkanPipeline {
    pub shader_mod u64
    pub desc_layout u64
    pub pipe_layout u64
    pub pipeline u64
    pub num_bindings int
    pub push_bytes int
    pub closed bool
}

Purpose

Structure encapsulating shader_mod, desc_layout, pipe_layout, pipeline, num_bindings.

Public fields

shader_mod u64
field (u64)
desc_layout u64
field (u64)
pipe_layout u64
field (u64)
pipeline u64
field (u64)
num_bindings int
field (int)
push_bytes int
field (int)
closed bool
field (bool)

struct VulkanBuffer

XuAPI
pub struct VulkanBuffer {
    pub handle u64
    pub memory u64
    pub byte_len int
    pub mapped c_ptr
    pub dev c_ptr
    pub closed bool
}

Purpose

Structure encapsulating handle, memory, byte_len, mapped, dev.

Public fields

handle u64
field (u64)
memory u64
field (u64)
byte_len int
field (int)
mapped c_ptr
field (c_ptr)
dev c_ptr
field (c_ptr)
closed bool
field (bool)

struct VulkanDevice

XuAPI
pub struct VulkanDevice {
    pub ordinal int
    pub instance c_ptr
    pub phys c_ptr
    pub device c_ptr
    pub queue c_ptr
    pub qfam int
    pub host_mem_type int
    pub desc_pool u64
    pub cmd_pool u64
    pub dev_name string
    pub vendor int
    pub pipe_add []VulkanPipeline
    pub pipe_mul []VulkanPipeline
    pub pipe_scale []VulkanPipeline
    pub pipe_gemm []VulkanPipeline
    pub pipe_gemm_nt []VulkanPipeline
    pub pipe_gemm_tn []VulkanPipeline
    pub closed bool
}

Purpose

Structure encapsulating ordinal, instance, phys, device, queue.

Public fields

ordinal int
field (int)
instance c_ptr
field (c_ptr)
phys c_ptr
field (c_ptr)
device c_ptr
field (c_ptr)
queue c_ptr
field (c_ptr)
qfam int
field (int)
host_mem_type int
field (int)
desc_pool u64
field (u64)
cmd_pool u64
field (u64)
dev_name string
field (string)
vendor int
field (int)
pipe_add []VulkanPipeline
field ([]VulkanPipeline)
pipe_mul []VulkanPipeline
field ([]VulkanPipeline)
pipe_scale []VulkanPipeline
field ([]VulkanPipeline)
pipe_gemm []VulkanPipeline
field ([]VulkanPipeline)
pipe_gemm_nt []VulkanPipeline
field ([]VulkanPipeline)
pipe_gemm_tn []VulkanPipeline
field ([]VulkanPipeline)
closed bool
field (bool)

available

XuAPI
pub fn available() bool

Purpose

Execute available.

Parameters

No arguments are required.

Returns

bool — true or false

device_count

XuAPI
pub fn device_count() int

Purpose

Device count.

Parameters

No arguments are required.

Returns

int — a value of this type

open

XuAPI
pub fn open(ordinal int) VulkanDevice

Purpose

Open resource or establish connection. Throws on failure; handle the error or propagate it to the caller.

Parameters

ordinal int
ordinal (int)

Returns

VulkanDevice — a value of this type

(&VulkanDevice) name

XuAPI
pub fn (d &VulkanDevice) name() string

Purpose

Execute name on &VulkanDevice.

Parameters

d &VulkanDevice
The VulkanDevice instance used by this call (borrow).

Returns

string — result string

(&VulkanDevice) vendor_id

XuAPI
pub fn (d &VulkanDevice) vendor_id() int

Purpose

Operation on &VulkanDevice: vendor id.

Parameters

d &VulkanDevice
The VulkanDevice instance used by this call (borrow).

Returns

int — a value of this type

(&VulkanDevice) queue_family

XuAPI
pub fn (d &VulkanDevice) queue_family() int

Purpose

Operation on &VulkanDevice: queue family.

Parameters

d &VulkanDevice
The VulkanDevice instance used by this call (borrow).

Returns

int — a value of this type

($&VulkanDevice) close

XuAPI
pub fn (d $&VulkanDevice) close() int

Purpose

Operation on $&VulkanDevice: close the resource.

Parameters

d $&VulkanDevice
The VulkanDevice instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&VulkanDevice) create_buffer

XuAPI
pub fn (d &VulkanDevice) create_buffer(byte_len int) VulkanBuffer

Purpose

Operation on &VulkanDevice: create buffer. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &VulkanDevice
The VulkanDevice instance used by this call (borrow).
byte_len int
byte_len (int)

Returns

VulkanBuffer — a value of this type

(&VulkanDevice) create_f32_buffer

XuAPI
pub fn (d &VulkanDevice) create_f32_buffer(elements int) VulkanBuffer

Purpose

Operation on &VulkanDevice: create f32 buffer. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &VulkanDevice
The VulkanDevice instance used by this call (borrow).
elements int
elements (int)

Returns

VulkanBuffer — a value of this type

($&VulkanBuffer) write_bytes

XuAPI
pub fn (b $&VulkanBuffer) write_bytes(data &string) int

Purpose

Operation on $&VulkanBuffer: write bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

b $&VulkanBuffer
The VulkanBuffer instance used by this call (exclusive borrow).
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&VulkanBuffer) write_f32_bits

XuAPI
pub fn (b $&VulkanBuffer) write_f32_bits(bits &[]int) int

Purpose

Operation on $&VulkanBuffer: write f32 bits. Throws on failure; handle the error or propagate it to the caller.

Parameters

b $&VulkanBuffer
The VulkanBuffer instance used by this call (exclusive borrow).
bits &[]int
bit count (read-only borrow; caller keeps the original; type &[]int)

Returns

int — a value of this type

(&VulkanBuffer) copy_f32_bits

XuAPI
pub fn (b &VulkanBuffer) copy_f32_bits(out $&[]int) int

Purpose

Operation on &VulkanBuffer: copy f32 bits. Throws on failure; handle the error or propagate it to the caller.

Parameters

b &VulkanBuffer
The VulkanBuffer instance used by this call (borrow).
out $&[]int
out (exclusive borrow; may modify the original; type $&[]int)

Returns

int — a value of this type

(&VulkanBuffer) read_f32_bits

XuAPI
pub fn (b &VulkanBuffer) read_f32_bits() []int

Purpose

Operation on &VulkanBuffer: read f32 bits. Throws on failure; handle the error or propagate it to the caller.

Parameters

b &VulkanBuffer
The VulkanBuffer instance used by this call (borrow).

Returns

[]int — slice result

($&VulkanBuffer) close

XuAPI
pub fn (b $&VulkanBuffer) close() int

Purpose

Operation on $&VulkanBuffer: close the resource.

Parameters

b $&VulkanBuffer
The VulkanBuffer instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&VulkanDevice) create_pipeline

XuAPI
pub fn (d &VulkanDevice) create_pipeline(spirv_words &[]int, num_bindings int, push_bytes int) VulkanPipeline

Purpose

Operation on &VulkanDevice: create pipeline. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &VulkanDevice
The VulkanDevice instance used by this call (borrow).
spirv_words &[]int
spirv_words (read-only borrow; caller keeps the original; type &[]int)
num_bindings int
num_bindings (int)
push_bytes int
push_bytes (int)

Returns

VulkanPipeline — a value of this type

(&VulkanDevice) dispatch

XuAPI
pub fn (d &VulkanDevice) dispatch(p &VulkanPipeline, bufs &[]int, sizes &[]int, push_words &[]int, gx int, gy int, gz int) int

Purpose

Execute dispatch on &VulkanDevice. Throws on failure; handle the error or propagate it to the caller.

Parameters

d &VulkanDevice
The VulkanDevice instance used by this call (borrow).
p &VulkanPipeline
p (read-only borrow; caller keeps the original; type &VulkanPipeline)
bufs &[]int
bufs (read-only borrow; caller keeps the original; type &[]int)
sizes &[]int
sizes (read-only borrow; caller keeps the original; type &[]int)
push_words &[]int
push_words (read-only borrow; caller keeps the original; type &[]int)
gx int
gx (int)
gy int
gy (int)
gz int
gz (int)

Returns

int — a value of this type

($&VulkanDevice) add_f32

XuAPI
pub fn (d $&VulkanDevice) add_f32(dst $&VulkanBuffer, a &VulkanBuffer, b &VulkanBuffer, n int) int

Purpose

Operation on $&VulkanDevice: add f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

d $&VulkanDevice
The VulkanDevice instance used by this call (exclusive borrow).
dst $&VulkanBuffer
destination (exclusive borrow; may modify the original; type $&VulkanBuffer)
a &VulkanBuffer
value (read-only borrow; caller keeps the original; type &VulkanBuffer)
b &VulkanBuffer
b (read-only borrow; caller keeps the original; type &VulkanBuffer)
n int
count, length, or limit (int)

Returns

int — a value of this type

($&VulkanDevice) mul_f32

XuAPI
pub fn (d $&VulkanDevice) mul_f32(dst $&VulkanBuffer, a &VulkanBuffer, b &VulkanBuffer, n int) int

Purpose

Operation on $&VulkanDevice: mul f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

d $&VulkanDevice
The VulkanDevice instance used by this call (exclusive borrow).
dst $&VulkanBuffer
destination (exclusive borrow; may modify the original; type $&VulkanBuffer)
a &VulkanBuffer
value (read-only borrow; caller keeps the original; type &VulkanBuffer)
b &VulkanBuffer
b (read-only borrow; caller keeps the original; type &VulkanBuffer)
n int
count, length, or limit (int)

Returns

int — a value of this type

($&VulkanDevice) scale_f32

XuAPI
pub fn (d $&VulkanDevice) scale_f32(dst $&VulkanBuffer, x &VulkanBuffer, n int, alpha f64) int

Purpose

Operation on $&VulkanDevice: scale f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

d $&VulkanDevice
The VulkanDevice instance used by this call (exclusive borrow).
dst $&VulkanBuffer
destination (exclusive borrow; may modify the original; type $&VulkanBuffer)
x &VulkanBuffer
value (read-only borrow; caller keeps the original; type &VulkanBuffer)
n int
count, length, or limit (int)
alpha f64
alpha (f64)

Returns

int — a value of this type

($&VulkanDevice) gemm_f32

XuAPI
pub fn (d $&VulkanDevice) gemm_f32(dst $&VulkanBuffer, a &VulkanBuffer, b &VulkanBuffer, m int, n int, k int) int

Purpose

Operation on $&VulkanDevice: gemm f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

d $&VulkanDevice
The VulkanDevice instance used by this call (exclusive borrow).
dst $&VulkanBuffer
destination (exclusive borrow; may modify the original; type $&VulkanBuffer)
a &VulkanBuffer
value (read-only borrow; caller keeps the original; type &VulkanBuffer)
b &VulkanBuffer
b (read-only borrow; caller keeps the original; type &VulkanBuffer)
m int
m (int)
n int
count, length, or limit (int)
k int
key or index (int)

Returns

int — a value of this type

($&VulkanDevice) gemm_f32_nt

XuAPI
pub fn (d $&VulkanDevice) gemm_f32_nt(dst $&VulkanBuffer, a &VulkanBuffer, b &VulkanBuffer, m int, n int, k int) int

Purpose

Operation on $&VulkanDevice: gemm f32 nt. Throws on failure; handle the error or propagate it to the caller.

Parameters

d $&VulkanDevice
The VulkanDevice instance used by this call (exclusive borrow).
dst $&VulkanBuffer
destination (exclusive borrow; may modify the original; type $&VulkanBuffer)
a &VulkanBuffer
value (read-only borrow; caller keeps the original; type &VulkanBuffer)
b &VulkanBuffer
b (read-only borrow; caller keeps the original; type &VulkanBuffer)
m int
m (int)
n int
count, length, or limit (int)
k int
key or index (int)

Returns

int — a value of this type

($&VulkanDevice) gemm_f32_tn

XuAPI
pub fn (d $&VulkanDevice) gemm_f32_tn(dst $&VulkanBuffer, a &VulkanBuffer, b &VulkanBuffer, m int, n int, k int) int

Purpose

Operation on $&VulkanDevice: gemm f32 tn. Throws on failure; handle the error or propagate it to the caller.

Parameters

d $&VulkanDevice
The VulkanDevice instance used by this call (exclusive borrow).
dst $&VulkanBuffer
destination (exclusive borrow; may modify the original; type $&VulkanBuffer)
a &VulkanBuffer
value (read-only borrow; caller keeps the original; type &VulkanBuffer)
b &VulkanBuffer
b (read-only borrow; caller keeps the original; type &VulkanBuffer)
m int
m (int)
n int
count, length, or limit (int)
k int
key or index (int)

Returns

int — a value of this type

struct SpirvBuilder

XuAPI
pub struct SpirvBuilder {
    pub cap []int
    pub ep []int
    pub exec []int
    pub dec []int
    pub types []int
    pub funcs []int
    pub next_id int
}

Purpose

Structure encapsulating cap, ep, exec, dec, types.

Public fields

cap []int
field ([]int)
ep []int
field ([]int)
exec []int
field ([]int)
dec []int
field ([]int)
types []int
field ([]int)
funcs []int
field ([]int)
next_id int
field (int)

new_builder

XuAPI
pub fn new_builder() SpirvBuilder

Purpose

Construct builder.

Parameters

No arguments are required.

Returns

SpirvBuilder — a value of this type

validate_spirv

XuAPI
pub fn validate_spirv(words &[]int) bool

Purpose

Validate spirv.

Parameters

words &[]int
words (read-only borrow; caller keeps the original; type &[]int)

Returns

bool — true or false

spv_add_f32

XuAPI
pub fn spv_add_f32() []int

Purpose

Spv add f32.

Parameters

No arguments are required.

Returns

[]int — slice result

spv_mul_f32

XuAPI
pub fn spv_mul_f32() []int

Purpose

Spv mul f32.

Parameters

No arguments are required.

Returns

[]int — slice result

spv_scale_f32

XuAPI
pub fn spv_scale_f32() []int

Purpose

Spv scale f32.

Parameters

No arguments are required.

Returns

[]int — slice result

spv_gemm_f32

XuAPI
pub fn spv_gemm_f32(mode int) []int

Purpose

mode 0: dst[r, c] = sum_p a[r*K + p] * b[p*N + c] mode 1 (NT): dst[r, c] = sum_p a[r*K + p] * b[c*K + p] mode 2 (TN): dst[r, c] = sum_p a[p*M + r] * b[p*N + c]

Parameters

mode int
mode (int)

Returns

[]int — slice result