0Pricing
Mojo Academy · Lektion

Die passende SIMD-Breite wählen

Passen Sie die Breite an die Lanes Ihrer Hardware an.

Die passende SIMD-Breite wählen ist eine kostenlose Mojo Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Mojo Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Width Decides Throughput

The SIMD width is how many lanes you process per instruction. Picking it well is key to real performance.

Hardware Has Fixed Lanes

Your CPU has vector registers of a fixed size. A good SIMD width matches the lanes that hardware can run at once.

Too Narrow Wastes Power

A width of 1 ignores the CPU's vector units entirely. You leave most of the chip's throughput sitting idle.

var slow = SIMD[DType.float32, 1](2.0)

Too Wide Spills Over

If a width is larger than the hardware supports, Mojo splits it into smaller chunks. That still works but adds overhead.

Let Mojo Tell You

Mojo can report the ideal width for a type on this machine through simdwidthof, so you do not have to guess.

from sys import simdwidthof
alias w = simdwidthof[DType.float32]()

Use It as a Parameter

Because simdwidthof is known at compile time, you can feed it straight into a SIMD type as its width.

alias Vec = SIMD[DType.float32, simdwidthof[DType.float32]()]

Width Depends on DType

Smaller elements fit more lanes in the same register. So float32 usually gets a bigger native width than float64.

Portable by Design

Using simdwidthof means your code adapts to each machine automatically. The same source stays fast and portable.

Multiples of Width Are Easy

Data that comes in clean multiples of your width vectorizes neatly, with no leftover lanes to handle as a remainder.

Mind the Leftovers

When a count is not a multiple of the width, a few tail elements remain. You finish those with a small scalar step.

Start with the Native Width

A safe default is simdwidthof for your DType. Measure later, but the native width is almost always a strong start.

Quick Check

You want a SIMD width that fits this CPU's float32 lanes without hardcoding a guess. What helps?

Recap

Match the SIMD width to the hardware: simdwidthof gives the native lane count per DType, and a scalar tail cleans up leftover elements. 🎯

Häufig gestellte Fragen

Ist die Lektion „Die passende SIMD-Breite wählen“ kostenlos?

Ja — der vollständige Text von „Die passende SIMD-Breite wählen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Mojo Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Die passende SIMD-Breite wählen“?

Passen Sie die Breite an die Lanes Ihrer Hardware an. Du übst Mojo Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Mojo Academy zu starten?

Keine Vorkenntnisse erforderlich. Mojo Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.

Wie lange dauert die Lektion „Die passende SIMD-Breite wählen“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Mojo Academy-Lektion Code schreiben und ausführen?

Ja. Jede Mojo Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Der SIMD-Typ
  2. Elementweise SIMD-Mathematik
  3. Die passende SIMD-Breite wählen
  4. Eine Schleife vektorisieren
← Zurück zu Mojo Academy