0Pricing
Mojo Academy · Ders

Paralelliği ve Vektörleştirmeyi Birleştirme

İş parçacıklarını SIMD'nin üzerine ekleyin.

Paralelliği ve Vektörleştirmeyi Birleştirme, CoddyKit'te ücretsiz bir Mojo Academy dersidir. Bu, 4 dersinin 3. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Mojo Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Mojo Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Two Kinds of Speed

SIMD packs many values into one core's instruction. Threads spread work across cores. Stacking both gives you the most. ⚡

Outer Layer: Threads

Use parallelize on the outer level so each core owns a chunk of the data. That is the coarse split across cores.

parallelize[do_chunk](workers)

Inner Layer: Vectors

Inside each chunk, use vectorize so one core chews through its slice in SIMD packs. That is the fine split per core.

from algorithm import vectorize

Import Both Helpers

Both tools live in the algorithm module, so you can bring them in together and combine them in one function.

from algorithm import parallelize, vectorize

The Chunk Worker

Each chunk worker computes its start and end, then hands its own slice to vectorize for the SIMD sweep.

fn do_chunk(c: Int):
    var start = c * chunk

Vectorize the Inner Range

Within the worker, call vectorize on just this chunk's length. The SIMD width sets how many lanes run at once.

vectorize[step, width](end - start)

Offset Into the Data

The inner step gets a local index, so add the chunk start to reach the right spot in the full array.

fn step[w: Int](i: Int):
    out.store[width=w](start + i, ...)

Pick the SIMD Width

Match the vector width to your hardware lanes with simdwidthof so each core uses its registers fully.

alias width = simdwidthof[DType.float32]()

Cores Times Lanes

The win multiplies: many cores, each doing many lanes per step. That product is why combined code is so fast.

Keep Chunks Independent

This stacking only works because chunks never touch each other's data. Independence keeps the two layers safe.

Measure the Combined Gain

Benchmark scalar, vector-only, and combined versions. The numbers reveal how much each layer contributes.

Quick Check

You combine threads and SIMD on the same workload.

Recap

You wrap parallelize over chunks and call vectorize inside each, offsetting by the chunk start, so cores times lanes multiply your throughput. 🚀

Sıkça Sorulan Sorular

“Paralelliği ve Vektörleştirmeyi Birleştirme” dersi ücretsiz mi?

Evet — “Paralelliği ve Vektörleştirmeyi Birleştirme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Mojo Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Mojo Academy kursu toplamda 4 dersten oluşur.

“Paralelliği ve Vektörleştirmeyi Birleştirme” dersinde ne öğreneceğim?

İş parçacıklarını SIMD'nin üzerine ekleyin. Mojo Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Mojo Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Mojo Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 3. dersidir.

“Paralelliği ve Vektörleştirmeyi Birleştirme” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Mojo Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Mojo Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. parallelize İşlevi
  2. İşi Parçalara Bölme
  3. Paralelliği ve Vektörleştirmeyi Birleştirme
  4. Veri Yarışlarından Kaçınma
← Mojo Academy Sayfasına Dön