CUDA Programming The GPU Universe
💡
Exercise 1

What is CUDA? 10 XP Easy

Ctrl+Enter Run Ctrl+S Save

Welcome to The Parallel Universe Chronicles! ⚡ You are about to become a commander of thousands of tiny, blazing-fast soldiers called GPU threads.

💡 Imagine this: You need to paint a giant wall. You could do it alone (that's a CPU — one strong worker). Or you could hire 10,000 tiny painters, each painting one small section at the same time (that's a GPU!). The GPU finishes in seconds what takes the CPU hours.

CUDA stands for Compute Unified Device Architecture. It's a platform and programming model created by NVIDIA in 2007 that lets you write programs that run on the GPU.

  • 🎮 GPU = Graphics Processing Unit — originally made for games
  • CUDA = The language/framework to program NVIDIA GPUs
  • 🤖 Why it matters — ChatGPT, Stable Diffusion, Tesla Autopilot all run on CUDA
  • 🚀 Speed — A modern GPU has 10,000+ cores vs 16-32 CPU cores
  • 🏆 Who uses it — Google, Meta, Tesla, NVIDIA, every AI company

CUDA programs are written in C/C++ with special CUDA extensions. The code you write runs on TWO devices: the Host (your CPU) and the Device (your GPU). They work together like a general (CPU) commanding an army (GPU).

// A CUDA program lives in two worlds: // HOST CODE (runs on CPU) int main() { // 1. Prepare data on CPU // 2. Send data to GPU // 3. Tell GPU what to do (launch kernel) // 4. Get results back from GPU return 0; } // DEVICE CODE (runs on GPU — called a "kernel") __global__ void myKernel() { // This runs on THOUSANDS of threads simultaneously! }

🌍 Real-world CUDA applications:

  • 🧠 AI & Deep Learning — Training neural networks (PyTorch, TensorFlow use CUDA under the hood)
  • 🎬 Video rendering — Pixar & Disney render movies using GPU farms
  • 🔬 Scientific simulation — Protein folding, climate modeling, physics simulations
  • 💊 Drug discovery — Simulating drug molecule behavior
  • 🔐 Cryptography — Bitcoin mining, encryption cracking

🎯 Your journey begins now. By the end of this course, you'll understand how the world's most powerful computing systems work — and you'll be able to build them yourself!

📋 Instructions
Let's make sure your CUDA environment is set up and you understand the basics! Write a program that prints an intro to CUDA: ``` Welcome to CUDA Programming! GPU has: 10496 CUDA cores CPU has: 16 cores Speedup possible: 656x ``` (Use any numbers you like — the key is to print 4 lines with those labels.)
This is just C code — use printf() to print each line. Example: printf("Welcome to CUDA Programming!\n"); The \n creates a new line.
⚠️ Try solving it yourself first — you'll learn more!
#include <stdio.h>

int main() {
    printf("Welcome to CUDA Programming!\n");
    printf("GPU has: 10496 CUDA cores\n");
    printf("CPU has: 16 cores\n");
    printf("Speedup possible: 656x\n");
    return 0;
}
main.py
Hi! I'm Rex 👋
Output
Ready. Press ▶ Run or Ctrl+Enter.