What problem does it solve?
Local parallel MATLAB code often underperforms because the default process-based pool adds serialization and data-transfer overhead per worker. This Skill guides an AI agent to switch to a thread-based parallel pool, which eliminates inter-process communication costs for broadcast data and reduces pool startup time.
Core Features & Use Cases
- Thread Pool Activation: Starts a thread-based pool with parpool("Threads") only when the current pool is not already a thread pool, without disrupting existing parfor, parfeval, or spmd code.
- Diagnostic-Driven Fallback: Runs the code first and reads MATLAB error diagnostics to determine thread support, recommending parpool("Processes") only when MATLAB reports an unsupported feature.
- Persistent Configuration: Sets Threads as the default parallel profile via parallel.defaultProfile("Threads") on R2022b or later for users who want thread pools every session.
- Use Case: A user's parfor loop on a laptop is barely faster than a for loop because large broadcast arrays are serialized to each process worker. The agent switches to a thread pool, where broadcast variables are zero-copy, and the loop speeds up without code changes.
Quick Start
Ask the agent to run my parfor code on a thread-based parallel pool and tell me if anything is unsupported.