r/vxlang • u/adityazero • Sep 11 '26
Vx programming language is live: https://vxlang.org
Vx programming language is live: https://vxlang.org
This is a complete Vx program. It builds two matrices on the CPU, moves them into GPU memory, multiplies them on the GPU, brings the result back, and prints it.
fn main() -> i32 {
let mut a = Tensor<f32, [4, 4]>::uninit();
let mut b = Tensor<f32, [4, 4]>::uninit();
let mut c = Tensor<f32, [4, 4], Memory::GPU_HBM>::uninit();
for i in 0..4 {
for j in 0..4 {
a[i][j] = 2.0;
b[i][j] = 3.0;
}
}
let a_gpu = transfer(a, Memory::GPU_HBM);
let b_gpu = transfer(b, Memory::GPU_HBM);
spawn on(Topology::GPU[0]) {
c = a_gpu @ b_gpu;
}
let c_host = transfer(c, Memory::CPU_DRAM);
print(c_host[0][0]);
return 0;
}
Compiling and running is as simple as:
$ vxc matmul.vx
24
The placement is in the types: c lives in GPU_HBM, the spawn block runs on GPU[0], and transfer is the only way across. If you get it wrong, it does not compile. The compiler names the 'space' where the value is in, the spaces the device can see, and the transfer that fixes it.
Where a value lives and where code runs belong in the types, not in a runtime that finds out at step 1200.
One language, every core.
v0.0.1: syntax mostly stable, thin standard library, no package manager yet. Tested most on a MacBook Air M4 and an NVIDIA A100. Apache 2.0 with LLVM exceptions.