Run math fast on any GPU

RunMat runs array code on NVIDIA, AMD, Intel and Apple GPUs through Metal, DirectX 12, Vulkan and WebGPU, with no GPU code to write. By default it runs each piece of work on the CPU or GPU, whichever would be faster.

Download RunMat

RunMat in the web browser runs on your own GPU through WebGPU.

GPU kernels
1
Temporary arrays
None
ONE GPU KERNELEIGHT GPU KERNELSx-x4*xtanhexpsin.^2.*+y
CPU495 ms
GPU125 ms
4.0× faster on the GPU100 million elements · Apple M5 Max · 2026-10-14

RunMat fuses operations to cut GPU time and memory traffic

Run one by one, each operation writes a temporary array and the next reads it back, so the GPU spends most of its time moving data through memory instead of computing. RunMat combines them into one GPU kernel that reads the input once and writes the result once.

How fusion works

RunMat fuses these types of expressions

y = exp(-x) .* sin(4*x) + tanh(x).^2;
Why this type
Elementwise math is in nearly every script, from signal envelopes and activation functions to physics formulas. Run separately, the eight operations in this line make eight passes over memory and seven temporary arrays, while the fused kernel reads x once and writes y once.
What it covers
Arithmetic and elementwise functions such as exp, sin, tanh and .^ over arrays of the same shape, within one statement or across consecutive statements, up to a statement that has to run on its own, such as an indexed assignment.

Runs on the GPU or the CPU, whichever is faster

Large arrays run on the GPU. Small ones stay on the CPU, where copying them to the GPU would take longer than the work itself. RunMat picks for each piece of work, so you get the speed of both.

  • Choices are based on calibration runs on your machine
  • runmat accel-info shows each decision and the reason for it
  • gpuArray and gather set where a value lives, and one project setting turns automatic placement off

Placement settingsBenchmark method

Time by array size
CPUGPU
GPU fasterCPU faster0.1 ms1 ms10 ms100 ms1000 ms10K100K1M10M100Melements

Hover a size to compare.

Median of 5 runs · single precision · Apple M5 Max · 2026-10-14

Data stays on the GPU between statements

Once data is on the GPU, it stays there. Later statements use it in place, and RunMat copies a result back only when the CPU needs it: to print it, save it or pass it to code that runs on the CPU.

CodeCPUGPU
  1. x = rand(1e7, 1, "single");

    copied to the GPU

  2. y = exp(-x) .* sin(4*x);

    stays on the GPU

  3. z = y + tanh(x).^2;

    stays on the GPU

  4. s = sum(z)

    one number copied back

Two copies in total: the input onto the GPU, and the one-number result back.

Any vendor, any OS

RunMat reaches the GPU through the graphics API each platform already has, so there is no vendor toolkit to install.

Precision

GPUs differ in the number types they support. RunMat checks what each GPU offers and keeps every result at the precision your code asks for.

To run double code on a GPU without double precision, allow single precision with RUNMAT_ALLOW_PRECISION_DOWNCAST=1. RunMat warns when it converts.

SystemThroughGPUs
macOSMetalApple silicon; AMD and Intel on Intel Macs
WindowsDirectX 12NVIDIA, AMD, Intel
LinuxVulkanNVIDIA, AMD, Intel
BrowserWebGPUAny GPU the browser exposes
TypeOn the GPU
singleRuns on every GPU
doubleRuns on GPUs with native double precision. Elsewhere, including Apple GPUs and browsers, it runs on the CPU at full precision
integersint8 to int64 and uint8 to uint64 run on every GPU with exact results. Each operation runs as its own kernel

Use gpuArray and gather as you would in MATLAB

Code runs on the GPU without gpuArray. When you want to decide, gpuArray, gather and gpuDevice give you that control, and existing code that uses them runs as written.

  • gpuArray and gather move data on and off the GPU explicitly
  • gpuDevice reports the active GPU
  • "like" prototypes create arrays on the same device and with the same precision as another
automatic.m
x = rand(1e7, 1, "single");
y = exp(-x) .* sin(4*x);
s = sum(y)
explicit.m
x = gpuArray(rand(1e7, 1, "single"));
y = exp(-x) .* sin(4*x);
s = gather(sum(y))

FAQ

01Do I need CUDA or a vendor toolkit?

No. RunMat drives the GPU through the operating system's graphics API: Metal on macOS, DirectX 12 on Windows and Vulkan on Linux. NVIDIA GPUs run through those too, with the standard driver.

02Does it work on a laptop's built-in GPU?

Yes. Integrated GPUs from Apple, Intel and AMD are supported. They have less memory and bandwidth than discrete cards, and RunMat's placement takes that into account.

03What happens on a machine without a GPU?

The same code runs on the CPU. Nothing needs to change, and results are the same.

04Can I choose between GPUs?

Each RunMat session runs on one GPU. On a machine with both a discrete and an integrated GPU, set wgpu_power_preference to high-performance or low-power in the project configuration to pick one. Parallel workers on that machine share it: one worker holds the GPU at a time, so two workers never compete for its memory. To run on several GPUs at once, send the work to a RunMat cluster, where each server's GPU runs one worker's share of the job.

Run on a cluster

Run it on your GPU

Download RunMat
← Back to the runtime