Skip to main content
ClaudeWave
Skill618 estrellas del repoactualizado 8d ago

matlab-use-thread-pool

This skill guides users to replace MATLAB's default process-based parallel pool with a thread-based pool using `parpool("Threads")` to accelerate local `parfor`, `parfeval`, and `spmd` operations. Use it when users need faster parallel execution on a single machine, especially when broadcasting large arrays causes serialization overhead or slow startup, but avoid recommending it for cluster computing, Simulink's `parsim`, or distributed arrays.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit /tmp/matlab-use-thread-pool && cp -r /tmp/matlab-use-thread-pool/skills-catalog/parallel-computing/matlab-use-thread-pool ~/.claude/skills/matlab-use-thread-pool
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# 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.

----
matlab-train-networkSkill

>

matlab-driving-data-importerSkill

Import recorded driving sensor data (GPS, camera, lidar, actor tracks, lanes) into scenariobuilder.* objects (GPSData, CameraData, LidarData, ActorTrackData, Trajectory, laneData) and run preprocessing — synchronize, offset correction, crop, normalizeTimestamps, convertTimestamps. Also: compute actor tracks from lidar when no annotations exist, attach camera/lidar mounting + intrinsics, export to MAT/workspace/timetable/script. Use for raw driving dataset files (KITTI, nuScenes, Waymo, Pandaset, ROS/ROS2 bags, .mat, .csv, .mp4) or driving/vehicle/sensor logs that need wrapping. drivingLogAnalyzer (DLA) is OPT-IN ONLY — invoke only on explicit user request ('DLA', 'open in DLA', 'inspect/explore/analyze the recording') or reported sensor problem (sync drift, timestamp mismatch, overlay misalignment). NEVER auto-launch DLA after wrapping (Rule 0). For 'build scenario / export to RoadRunner / drivingScenario / OpenSCENARIO / Unreal / simulate', hand off to matlab-scenario-builder.

matlab-scenario-builderSkill

Generate driving scenes, scenarios, road surfaces, and 3D content from already-wrapped scenariobuilder.* sensor data (GPS, camera, lidar, actor tracks) using Scenario Builder for Automated Driving Toolbox. Use to BUILD, EXPORT, or AUGMENT a virtual scenario/scene/map: ego or actor trajectories, trajectory smoothing, OpenCRG road-surface extraction, 3D asset generation, static-object placement, point-cloud georeferencing + elevation, lane-based ego localization, sensor-fusion tracking, scenario-event extraction (cut-ins, hard brakes, near-misses, ADAS disengagements), or export to RoadRunner, drivingScenario, OpenDRIVE, OpenCRG, OpenSCENARIO, or Unreal Engine. Also: log-to-scenario, scenario harvesting, accident/near-miss reconstruction, SOTIF (ISO 21448) and ISO 26262 scenario coverage, USGS-aerial-lidar scene augmentation, traffic-sign placement from camera+lidar logs. NOT for raw-data import or multi-sensor sync/crop/offset/timestamp normalization — route those to matlab-driving-data-importer.

roadrunner-asset-mappingSkill

>

roadrunner-convert-lanelet2-to-rrhdSkill

>

roadrunner-import-sceneSkill

>

roadrunner-rrhd-authoringSkill

>

matlab-build-simbiology-modelSkill

Build, modify, and diagram SimBiology models — API reference, helper functions, and layout patterns. Use when constructing or editing models programmatically or visually.