Thrust Vektörleri ve Dönüşümleri
GPU üzerinde STL tarzı paralellik
Thrust Vektörleri ve Dönüşümleri, CoddyKit'te ücretsiz bir CUDA Academy dersidir. Bu, 4 dersinin 2. 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, CUDA Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. CUDA Academy kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
The STL for Your GPU
Thrust is a high-level library that feels like the C++ STL but runs on the GPU. You write almost no kernel code yourself. 🎉
Two Kinds of Vector
Thrust gives you host_vector for CPU memory and device_vector for GPU memory. They look identical but live in different worlds.
thrust::host_vector<int> h(100);
thrust::device_vector<int> d(100);Copy Across the Boundary
Assigning a host_vector to a device_vector triggers a memory transfer automatically. No cudaMemcpy boilerplate to write by hand.
thrust::device_vector<int> d = h; // host to deviceAllocation Is Automatic
A device_vector allocates and frees GPU memory for you using RAII. When it goes out of scope, the memory is released cleanly.
Fill and Sequence
Helpers like thrust::fill and thrust::sequence initialize a whole device_vector in one parallel call instead of a manual loop.
thrust::sequence(d.begin(), d.end()); // 0,1,2,...Transform Maps Element to Element
thrust::transform applies a function to every element in parallel and writes the result to an output range. This is the classic map pattern.
thrust::transform(d.begin(), d.end(),
out.begin(), op);Functors Are the Operation
The operation you pass is a functor: a struct with an operator() marked __host__ __device__ so it can run on the GPU.
struct Square { __host__ __device__
float operator()(float x){ return x*x; } };Built-In Operators
For common math, Thrust ships functors like thrust::plus and thrust::multiplies, so you skip writing a functor for simple jobs.
thrust::transform(a.begin(), a.end(),
b.begin(), c.begin(), thrust::plus<float>());Two Inputs, One Output
The binary form of transform takes two input ranges and combines them pairwise, perfect for element-wise vector addition.
Get the Raw Pointer
Need to drop into a hand-written kernel? thrust::raw_pointer_cast hands you the underlying device pointer to pass along.
float* p = thrust::raw_pointer_cast(d.data());Less Code, Fewer Bugs
Thrust hides allocation, copies, and launch configs. You trade a little control for readable, safe GPU code that just works.
Quick Check
Recall how Thrust applies an operation to a whole vector.
Recap
You used device_vector for automatic memory, transferred data by assignment, and ran transform with functors. STL-style GPU power. 💪
Sıkça Sorulan Sorular
“Thrust Vektörleri ve Dönüşümleri” dersi ücretsiz mi?
Evet — “Thrust Vektörleri ve Dönüşümleri” 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 CUDA Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. CUDA Academy kursu toplamda 4 dersten oluşur.
“Thrust Vektörleri ve Dönüşümleri” dersinde ne öğreneceğim?
GPU üzerinde STL tarzı paralellik CUDA 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.
CUDA Academy öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te CUDA 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 2. dersidir.
“Thrust Vektörleri ve Dönüşümleri” 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 CUDA Academy dersinde kod yazıp çalıştırabilir miyim?
Evet. Her CUDA 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
- cuBLAS GEMM'i Doğru Kullanma
- Thrust Vektörleri ve Dönüşümleri
- Thrust ile Azaltma, Tarama ve Sıralama
- Derin Öğrenme için cuDNN