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

getCurrentWorker — Return the worker assigned to the current invocation.

getCurrentWorker returns a read-only worker identity inside scheduled work and [] when no worker is active.

Syntax

worker = getCurrentWorker()

Returns

context
Type
Any
Description
Current parallel execution object, or an empty matrix when none is active.
NameTypeDescription
contextAnyCurrent parallel execution object, or an empty matrix when none is active.

Errors

RunMat:parallel:TooManyInputs
When
An input argument is supplied.
Message
current-execution introspection does not accept input arguments
RunMat:parallel:RuntimeContextUnavailable
When
No active runtime context is installed for the call.
Message
no active runtime context
IdentifierWhenMessage
RunMat:parallel:TooManyInputsAn input argument is supplied.current-execution introspection does not accept input arguments
RunMat:parallel:RuntimeContextUnavailableNo active runtime context is installed for the call.no active runtime context

Behavior

Current-execution functions project typed scheduler identity into read-only objects. Task objects expose ID, AttemptID, PoolID, WorkerID, and State; worker objects expose ID, PoolID, and Backend; job objects expose ID.

An ordinary driver call has no task, worker, or durable-job assignment and returns []. A worker task has task and worker assignments. A job object is present only when the execution belongs to a submitted durable job.

Execution identity is dynamically scoped. Nested work sees its own assignment, and leaving that scope restores the previous one without leaking worker identity into the driver.

Execution placement

These functions read the active runtime context. They do not schedule work or contact the pool; the returned IDs and backend name describe the assignment already admitted by the execution service.

Examples

Detect ordinary driver execution

worker = getCurrentWorker()

Expected output:

worker = []

Inspect worker identity inside parfor

pool = parpool(2);
seen = false(1, 4);
parfor (index = 1:4, 2)
  worker = getCurrentWorker();
  seen(index) = ~isempty(worker) && worker.ID == worker.ID;
end

Expected output:

seen = [true true true true]

Using getCurrentWorker with coding agents

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

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

FAQ

Why does the function return an empty matrix?⌄

The current invocation has no assignment of that kind, as in ordinary driver execution.

Are the returned objects mutable scheduler records?⌄

No. They are read-only projections of the active typed execution assignment.

Does reading the context contact a worker or cluster?⌄

No. It reads identity already installed in the current runtime scope.

Can nested execution leak its identity?⌄

No. Assignment scopes restore the prior identity when they exit.

Related Parallel functions

codistributed · codistributed.build · codistributor · codistributor1d · codistributor2dbc · distributed · fetchNext · fetchOutputs · gcat · gcp · getCodistributor · getCurrentJob · getCurrentTask · 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 getCurrentWorker is executed, line by line, in Rust.

  • View the source for getCurrentWorker 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
  • Returns
  • Errors
  • Behavior
  • Execution placement
  • Examples
  • Detect ordinary driver execution
  • Inspect worker identity inside parfor
  • Using getCurrentWorker with coding agents
  • FAQ
  • Related Parallel functions
  • Related guides
  • Source you can read
  • About RunMat