gcp — Return or inspect the current session execution pool.
gcp reads the pool owned by the current RunMat session; the nocreate option avoids creating one.
Syntax
pool = gcp(option)Inputs
option- Type
StringScalar- Required
- No
- Default
- —
- Description
- Use 'nocreate' to inspect the current pool without creating one.
Returns
pool- Type
Any- Description
- Current session pool, or an empty double matrix for 'nocreate' without a pool.
Errors
RunMat:gcp:InvalidInput- When
- An argument other than 'nocreate' is supplied, or more than one argument is supplied.
- Message
gcp accepts no arguments or the option 'nocreate'
Behavior
gcp() returns the session's current execution pool and creates an automatic pool when none exists. gcp("nocreate") performs inspection only and returns an empty matrix when the session has no active pool.
The returned handle identifies one pool generation. Closing or resizing the pool retires that handle together with futures and distributed values owned by it.
Execution placement
gcp reads session execution state. It does not itself schedule work, launch provider kernels, or move numeric data.
Examples
Inspect without creating a pool
pool = gcp("nocreate")Expected output:
pool = [] when the session has no active poolRead the current pool generation
created = parpool(2);
current = gcp("nocreate")Expected output:
current identifies createdUsing gcp with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how gcp changes the result.
Run a small gcp example, explain the result, then change one input and compare the output.
FAQ
Does gcp() create a pool?⌄
Yes when no pool exists. Use gcp("nocreate") for inspection without creation.
What does nocreate return without a pool?⌄
It returns an empty matrix.
Is the pool global to every RunMat process?⌄
No. It is owned by the current RunMat session and its execution service.
Can a stale pool handle become current again?⌄
No. Closing or resizing creates a generation boundary; retired handles remain invalid.
Related Parallel functions
codistributed · codistributed.build · codistributor · codistributor1d · codistributor2dbc · distributed · fetchNext · fetchOutputs · gcat · 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
Source you can read
Every RunMat function's source is public. Read exactly how gcp is executed, line by line, in Rust.
- View the source for gcp 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.