0Pricing
Mojo Academy · Lesson

Parameterizing Tile and Width

Expose tunable knobs as parameters.

Parameterizing Tile and Width is a free Mojo Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Mojo Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Knobs Must Be Parameters

To let autotuning vary a value, it has to be a compile-time parameter, not a plain runtime variable. Parameters can be specialized per candidate.

Tile Size as a Knob

A tile size controls how big a block of work you process at once. Make it a parameter and the tuner can try 16, 32, 64, and more.

fn process[tile: Int]():
    pass

Width as a Knob

SIMD width sets how many numbers you crunch per instruction. Different chips favor different widths, so expose it as a parameter too.

fn run[width: Int]():
    pass

Declaring the Parameters

Put tunable values inside the function's bracket list. Each entry becomes a knob the autotuner is allowed to change.

fn kernel[tile: Int, width: Int]():
    pass

Use Them Inside

Inside the body, treat the parameter like a constant. The compiler bakes its value in for each specialized version it builds.

fn step[tile: Int]() -> Int:
    return tile * 2

Sensible Ranges

Pick candidate values that make hardware sense: powers of two like 8, 16, 32 for width, and cache-friendly blocks for tile size.

Keep Knobs Independent

Each knob should mean one clear thing. Tangled parameters make the search confusing and the results hard to explain.

Validate with Constraints

Use a constraint to reject impossible combinations early, so the tuner never wastes time building candidates that cannot work.

constrained[width > 0]()

Defaults Still Help

Give each parameter a reasonable default. Code stays usable without tuning, and the search starts from a known-good baseline.

fn kernel[tile: Int = 32]():
    pass

More Knobs, Bigger Space

Every extra parameter multiplies the candidates to test. Expose the few knobs that truly matter, not every number you can find.

Now It Is Tunable

With tile and width as parameters, your kernel is ready: the autotuner has clear dials to turn while searching for peak throughput. 🔧

Quick Check

Confirm what makes a value tunable by the autotuner.

Recap

You exposed tile and width as compile-time parameters, added a constraint and defaults, and gave the autotuner clean dials to turn. 🎯

Frequently asked questions

Is the “Parameterizing Tile and Width” lesson free?

Yes — the full text of “Parameterizing Tile and Width” is free to read here on the web, and the Mojo Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Mojo Academy course, upgrade to CoddyKit PRO.

What will I learn in “Parameterizing Tile and Width”?

Expose tunable knobs as parameters. You practise Mojo Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Mojo Academy?

No prior experience is required. Mojo Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Parameterizing Tile and Width” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Mojo Academy lesson?

Yes. Every Mojo Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Autotuning Solves
  2. Parameterizing Tile and Width
  3. Searching the Parameter Space
  4. Locking In the Best Config
← Back to Mojo Academy