AI Blocks › Build and ship software
Thread pool speed-up helper
Give it slow local parallel code. Get it switched to a thread pool and timed to prove the gain.
Thread pool speed-up helper is a free AI skill for the job "Build and ship software". Give the instructions to an AI assistant that supports the required files and tools, then review its output.
Free · No account · BSD 2 Clause licence · Made by MathWorks · Level: advanced
Made by MathWorks. See the original on GitHub; we copied it as it is, with its licence.
What it does
MATLAB code that runs in parallel on your own computer often barely beats a plain loop, because data gets copied between worker processes. Switching to a thread pool removes much of that copying, and your existing parfor, parfeval or spmd code needs no rewrite. The skill starts the thread pool, runs your code, and times it against the process pool so you can see the gain. If something is not supported on threads, MATLAB says so and the skill falls back to a process pool. It also explains what threads really save: large shared variables are not copied, while sliced arrays still are. It can set Threads as your default. It does not apply to clusters or Simulink parallel runs.
You give it
- Your MATLAB parallel code
- Whether you run locally or on a cluster
- A rough sense of data sizes (optional)
- MATLAB with Parallel Computing Toolbox
You get
- Code running on a thread pool
- Timing before and after
- A fallback plan if threads are unsupported
- A setting to make Threads your default
Use it when
- Your parfor loop is only slightly faster than a normal for loop.
- Workers spend a lot of time receiving large arrays.
- Opening a process pool takes longer than your short job.
- You want to know if your function can run on a thread pool at all.
How to use it
- Add it to your AI once: download it and add the folder to Claude, ChatGPT or Codex as a skill.
- Ask for the job in your own words. Your AI opens the skill when it fits.
- It works best when your AI can run MATLAB.