RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • codistributed
    • codistributed.build
    • codistributor
    • codistributor1d
    • codistributor2dbc
    • distributed
    • fetchNext
    • fetchOutputs
    • gcat
    • gcp
    • getCodistributor
    • getCurrentJob
    • getCurrentTask
    • getCurrentWorker
    • getLocalPart
    • globalIndices
    • gop
    • gplus
    • iscodistributed
    • isComplete
    • labBarrier
    • labBroadcast
    • labindex
    • labProbe
    • labReceive
    • labSend
    • labSendReceive
    • numlabs
    • parfeval
    • parfevalOnAll
    • parpool
    • redistribute
    • spmdBarrier
    • spmdBroadcast
    • spmdCat
    • spmdIndex
    • spmdPlus
    • spmdProbe
    • spmdReceive
    • spmdReduce
    • spmdSend
    • spmdSendReceive
    • spmdSize

codistributed.build — Build a codistributed array from worker-local partitions.

codistributed.build cooperatively resolves and validates one local contribution from every worker in an SPMD gang.

Syntax

D = codistributed.build(local_part, codistributor, validation)

Inputs

local_part
Type
Any
Required
Yes
Default
—
Description
Partition contributed by the current worker.
codistributor
Type
Any
Required
No
Default
—
Description
Optional codistributor describing the global array.
validation
Type
StringScalar
Required
No
Default
—
Description
Optional noCommunication validation policy.
NameTypeRequiredDefaultDescription
local_partAnyYes—Partition contributed by the current worker.
codistributorAnyNo—Optional codistributor describing the global array.
validationStringScalarNo—Optional noCommunication validation policy.

Returns

result
Type
Any
Description
Result produced by the parallel operation.
NameTypeDescription
resultAnyResult produced by the parallel operation.

Errors

RunMat:parallel:LoweringRequired
When
The operation is invoked without an active compiler-owned SPMD or distributed execution context.
Message
parallel operation requires executor-aware lowering
IdentifierWhenMessage
RunMat:parallel:LoweringRequiredThe operation is invoked without an active compiler-owned SPMD or distributed execution context.parallel operation requires executor-aware lowering

Behavior

A distributed value stores partition payloads in the execution service. The language value is a typed handle containing its global shape, value class, distribution scheme, owning pool, and generation. Exact integer classes, shapes, and supported complex or sparse representations are retained across partition and materialization boundaries.

Driver construction partitions one complete input. Cooperative construction inside spmd can replicate one value, select a designated worker's value, or build from every worker's local contribution. The default build form validates class, rank, shape, layout, and codistributor agreement across the gang; "noCommunication" skips cross-worker validation only when the caller already guarantees consistency.

Distributed values belong to one pool generation. Closing or resizing that pool retires local-part access, materialization, redistribution, and distributed builtin placement for the stale handle.

Execution placement

Construction, redistribution, and materialization may cross the driver-worker boundary. getLocalPart reads only the selected worker partition, globalIndices computes ownership from the authoritative layout, and getCodistributor projects the resolved description without reading payloads.

Example

Build from one local partition per worker

pool = parpool(2);
spmd
  local = uint64([2 * spmdIndex() - 1, 2 * spmdIndex()]);
  codist = codistributor1d(uint32(2), uint64([2 2]), uint64([1 4]));
  value = codistributed.build(local, codist);
end
result = gather(value)

Expected output:

result = uint64([1 2 3 4])

Using codistributed.build with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how codistributed.build changes the result.

Run a small codistributed.build example, explain the result, then change one input and compare the output.

FAQ

Does the language value contain every partition?⌄

No. It is a typed, generation-fenced handle; the execution service owns partition payloads.

Are integer classes preserved?⌄

Yes. Supported values retain their exact class, shape, and payload through partition, redistribution, local access, and gather.

What happens after the pool is closed or resized?⌄

The old generation is retired and distributed operations reject its stale handles.

Does inspection gather the full value?⌄

No. Codistributor and index inspection use handle metadata; local-part access reads only the selected partition.

Where can I omit a lab argument?⌄

Inside spmd, the active rank selects the local partition. Driver code supplies an explicit lab where the form requires one.

Related Parallel functions

codistributed · codistributor · codistributor1d · codistributor2dbc · distributed · fetchNext · fetchOutputs · gcat · gcp · getCodistributor · getCurrentJob · getCurrentTask · getCurrentWorker · getLocalPart · globalIndices · gop · gplus · iscodistributed · isComplete · labBarrier · labBroadcast · labindex · labProbe · labReceive · labSend · labSendReceive · numlabs · parfeval · parfevalOnAll · parpool · redistribute · spmdBarrier · spmdBroadcast · spmdCat · spmdIndex · spmdPlus · spmdProbe · spmdReceive · spmdReduce · spmdSend · spmdSendReceive · spmdSize

Related guides

  • Parallel execution

Source you can read

Every RunMat function's source is public. Read exactly how codistributed.build is executed, line by line, in Rust.

  • View the source for codistributed.build in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Behavior
  • Execution placement
  • Example
  • Build from one local partition per worker
  • Using codistributed.build with coding agents
  • FAQ
  • Related Parallel functions
  • Related guides
  • Source you can read
  • About RunMat