Hesaplama Çekirdeğinin Anatomisi
İşi yapan yoğun iç döngü.
Hesaplama Çekirdeğinin Anatomisi, CoddyKit'te ücretsiz bir Mojo Academy dersidir. Bu, 4 dersinin 1. 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.
What Is a Kernel?
A compute kernel is the small, focused routine that does the real numerical work, like adding two arrays element by element.
The Hot Inner Loop
Most of a kernel's time lives in one tight inner loop. Speed up that loop and you speed up the whole program.
for i in range(n):
out[i] = a[i] + b[i]Inputs and Outputs
A clean kernel takes its data buffers as parameters, so the same routine can run on any arrays you pass in.
fn add(a: UnsafePointer[Float32], b: UnsafePointer[Float32], out: UnsafePointer[Float32], n: Int):
passUse fn for Strictness
Kernels are written with fn, not def. The strict, typed style lets Mojo compile tight machine code with no surprises.
fn kernel(n: Int):
passKeep the Body Small
The fastest kernels do one thing. A short, predictable inner body is easy for the compiler to optimize aggressively.
No Surprises Inside
Avoid heavy work like allocation or I/O in the hot loop. Each iteration should be cheap and uniform for peak throughput.
Count the Work
Think in terms of total operations. A kernel over n elements does roughly n units of work, so n drives the cost.
Memory Is the Limit
Many kernels are not compute-bound but memory-bound. They wait on data, so how you move bytes often matters most.
Plan to Vectorize
Design the loop so each step can later process many elements with SIMD. A regular access pattern makes vectorizing easy.
A Tiny Saxpy Kernel
A classic kernel is saxpy: out = scale times a plus b. It is small, regular, and a great baseline to optimize.
for i in range(n):
out[i] = scale * a[i] + b[i]Measure Before You Tune
Start with the simple correct version and time it. That number is your baseline for every optimization that follows.
Quick Check
You are about to optimize a kernel. Where does almost all of its time go?
Recap
A kernel is a small fn whose tight inner loop does the work; keep it uniform, mind memory, and measure a baseline first. 🔧
Sıkça Sorulan Sorular
“Hesaplama Çekirdeğinin Anatomisi” dersi ücretsiz mi?
Evet — “Hesaplama Çekirdeğinin Anatomisi” 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.
“Hesaplama Çekirdeğinin Anatomisi” dersinde ne öğreneceğim?
İşi yapan yoğun iç döngü. 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 1. dersidir.
“Hesaplama Çekirdeğinin Anatomisi” 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
- Hesaplama Çekirdeğinin Anatomisi
- SIMD'yi Döngülerle Birleştirme
- Bellek Trafiğini Azaltma
- Önbellek Yerelliği için Döşeme