Matlab Use Thread Pool logo

Matlab Use Thread Pool

OrganizationPopular
matlab
matlab-use-thread-pool

Speed up local parfor, parfeval, or spmd by switching to a thread-based parallel pool. Trigger when a user describes slow or disappointing local parallel performance, even if they don't mention threads. Symptoms: parfor on a laptop/workstation is slower than expected or "only slightly faster than for"; parfor scales poorly with the number of workers; ticBytes/tocBytes, the Parallel Pool dashboard, mpiprofile, or system tools show large per-worker data transfer; large broadcast variables or sliced inputs make iterations slow; opening a process pool dominates a short workload; user mentions serialisation or data transfer overhead. Also trigger on any question about whether code or a function works on a thread pool. For non-pool MATLAB performance work (vectorisation, preallocation, profiling), defer to matlab-optimize-performance.

Overview

Publishermatlab
Repositorymatlab-agentic-toolkit
Skill namematlab-use-thread-pool
Stars
1.2K
Forks
138
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by matlab on GitHub. Read the source before you install it.

Installation

Install the Matlab Use Thread Pool AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/parallel-computing/matlab-use-thread-pool
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit.git /tmp/matlab-agentic-toolkit
mkdir -p .claude/skills
cp -r /tmp/matlab-agentic-toolkit/skills-catalog/parallel-computing/matlab-use-thread-pool .claude/skills/matlab-use-thread-pool
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Matlab Use Thread Pool in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Matlab Use Thread Pool on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Matlab Use Thread Pool is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Use a Thread-Based Parallel Pool

Recommend starting a thread pool using parpool("Threads") instead of using the default process-based pool to speed up local parfor / parfeval / spmd code.

When to Use

  • User asks to improve performance of parfor, parfeval, or spmd on a local machine.
  • Code passes large arrays into iterations or broadcasts them across workers; user mentions slow start-up, serialization, or data transfer.
  • User asks "Processes or Threads?" or wants Threads as the default.

When NOT to Use

  • User is running on a cluster -- thread pools are local-only.
  • Code uses parsim or other Simulink parallel features -- those require a process-based pool.
  • Code uses distributed or codistributed arrays.
  • User wants backgroundPool -- that's for running work asynchronously (e.g. keeping an app responsive while a computation runs), not for parallel speed-up. All MATLAB users have 1 worker in the background pool; users with a Parallel Computing Toolbox license have multiple workers.

For general MATLAB performance tuning (vectorisation, preallocation, profiling), see matlab-optimize-performance (if available).

Workflow

  1. Try it on a thread pool. Don't scan the code first -- just run it. Only create a thread pool if the current pool isn't already a thread pool. Avoid unconditionally deleting whichever pool the user has open. The conditional snippet below is a development convenience -- not something to bake into shipped code:

    matlab
    % Development-time helper: ensure a thread pool is active
    pool = gcp("nocreate");
    if isempty(pool) || ~isa(pool, "parallel.ThreadPool")
        delete(pool);
        parpool("Threads");
    end

    The existing parfor / parfeval / spmd block does not need to change. Thread pools are a drop-in replacement, not a refactor.

  2. Read the diagnostic if it errors. Unsupported features fail loudly -- MATLAB tells you what isn't allowed and to use a process-based pool instead. Recommend parpool("Processes"). No silent wrong answers, no guessing.

  3. Offer the persistent option if the user wants to use a thread pool "always" or "every time": suggest setting Threads as the default profile via parallel.defaultProfile("Threads") (R2022b+). Persists across sessions; no startup script needed.

What threads actually save

Be precise. Broadcast variables are zero-copy on threads (the win). Sliced inputs/outputs (X(:,:,i)) still allocate and copy -- threads only skip the serialize/IPC cost, not the slice itself. Don't say "zero-copy" or "shared memory eliminates the cost entirely" without qualifying it.

Convention

Always run it, never guess. This is the single most important rule in this skill.

LLM training data is incomplete and stale. Thread-based workers gained support for many functions across releases, and new support is added regularly. Do not assert a function is unsupported on threads from memory, by analogy to similar functions, or because it's not on the skill's short blocker list. Reasoning about thread support without running is the biggest failure mode for this skill -- it has pushed users to a process pool unnecessarily.

The default action is to run the code on a thread pool and read the diagnostic if it errors. Don't pre-scan the code looking for blockers. Most functions you'd reach for (load, FFT, imgaussfilt, numeric and basic I/O primitives) work on threads.

Only if you genuinely cannot run the code (planning context, code review, user can't execute right now) should you fall back to documentation. Use an appropriate documentation skill (if available) to fetch the function's reference page and read its Extended Capabilities -> Thread-Based Environment section. Even then: an absent or older entry is not proof the function won't run -- some thread support is undocumented. When in doubt, try it.


Copyright 2026 The MathWorks, Inc.


Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Matlab Use Thread Pool AI skill do?

Speed up local parfor, parfeval, or spmd by switching to a thread-based parallel pool. Trigger when a user describes slow or disappointing local parallel performance, even if they don't mention threads. Symptoms: parfor on a laptop/workstation is slower than expected or "only slightly faster than for"; parfor scales poorly with the number of workers; ticBytes/tocBytes, the Parallel Pool dashboard, mpiprofile, or system tools show large per-worker data transfer; large broadcast variables or sliced inputs make iterations slow; opening a process pool dominates a short workload; user mentions s...

Why use Matlab Use Thread Pool on TypingMind?

Because you install it once and use it with any model. Matlab Use Thread Pool is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Matlab Use Thread Pool in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/parallel-computing/matlab-use-thread-pool. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Matlab Use Thread Pool?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Matlab Use Thread Pool?

As many as you like. As long as a model supports skills, you can use Matlab Use Thread Pool with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Matlab Use Thread Pool AI skill free?

It is published on GitHub by matlab. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇