0Pricing
Mojo Academy · Lezione

Parametrizzare tile e larghezza

Esponga i parametri regolabili.

Parametrizzare tile e larghezza è una lezione Mojo Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Mojo Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Mojo Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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

Domande Frequenti

La lezione «Parametrizzare tile e larghezza» è gratuita?

Sì — il testo completo di «Parametrizzare tile e larghezza» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Mojo Academy, passa a CoddyKit PRO. Il corso Mojo Academy include 4 lezioni in totale.

Cosa imparerò in «Parametrizzare tile e larghezza»?

Esponga i parametri regolabili. Eserciti Mojo Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Mojo Academy?

Non è richiesta alcuna esperienza precedente. Mojo Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.

Quanto tempo richiede la lezione «Parametrizzare tile e larghezza»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Mojo Academy?

Sì. Ogni lezione Mojo Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Che cosa risolve l'autotuning
  2. Parametrizzare tile e larghezza
  3. Esplorare lo spazio dei parametri
  4. Fissare la configurazione migliore
← Torna a Mojo Academy