0Pricing
Mojo Academy · Lekcja

Parametryzowanie kafelka i szerokości

Udostępnij regulowane parametry.

Parametryzowanie kafelka i szerokości to bezpłatna lekcja Mojo Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Mojo Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Mojo Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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

Często zadawane pytania

Czy lekcja „Parametryzowanie kafelka i szerokości” jest bezpłatna?

Tak — pełny tekst „Parametryzowanie kafelka i szerokości” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Mojo Academy, przejdź na CoddyKit PRO. Kurs Mojo Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „Parametryzowanie kafelka i szerokości”?

Udostępnij regulowane parametry. Ćwiczysz Mojo Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Mojo Academy?

Nie wymagamy żadnego doświadczenia. Mojo Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „Parametryzowanie kafelka i szerokości”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Mojo Academy?

Tak. Każda lekcja Mojo Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Co rozwiązuje autotuning
  2. Parametryzowanie kafelka i szerokości
  3. Przeszukiwanie przestrzeni parametrów
  4. Utrwalanie najlepszej konfiguracji
← Powrót do Mojo Academy