Leanpub Header

Skip to main content

CUDA Programming from Scratch

From First Principles to Production-Grade GPU Applications

This book is 100% completeLast updated on 2026-07-13

Learn CUDA programming from the ground up by understanding how GPUs really execute code. This book shows you how to write efficient kernels, optimize performance, and build high-performance applications for AI, scientific computing, image processing, and other demanding workloads on modern NVIDIA GPUs, including Blackwell.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
About

About

About the Book

This book takes you from absolute beginner to advanced practitioner in CUDA programming. You will learn how GPUs execute code, how to design kernels that exploit parallelism at every level of the hardware hierarchy, and how to profile, debug, and optimize production applications. By the end, you will be able to write high-performance GPU code spanning AI training pipelines, scientific simulations, image processing, and high-performance computing using modern CUDA through the Blackwell architecture.

Bundle

Bundles that include this book

Author

About the Author

Steve T. Publications

Steve T. Publications is a specialized book publishing company dedicated to delivering high-quality technical resources for IT professionals, students, educators, and technology enthusiasts. Our mission is to make complex technology concepts accessible through well-structured, practical, and industry-relevant publications.

We focus on publishing books across a wide range of information technology disciplines, including software development, cloud computing, cybersecurity, artificial intelligence, data science, networking, DevOps, databases, and enterprise technologies. Every publication is designed to bridge the gap between theory and real-world application, helping readers build the skills needed to succeed in today's rapidly evolving digital landscape.

At Steve T. Publications, we collaborate with experienced industry experts, educators, and technology professionals to produce accurate, up-to-date, and engaging content. We are committed to maintaining the highest editorial standards while empowering learners and professionals with trusted technical knowledge.

Whether you're beginning your IT journey, preparing for professional certifications, or advancing your expertise in emerging technologies, Steve T. Publications is your trusted source for authoritative and practical technical books.

Contents

Table of Contents

CUDA Programming from Scratch

  1. From First Principles to Production-Grade GPU Applications

Introduction: Why GPU Computing Matters Today

Chapter 1: The GPU Revolution — Architecture and History

  1. From Graphics to General-Purpose Computing
  2. GPU vs CPU: Divergent Design Philosophies
  3. The CUDA Platform Ecosystem
  4. GPU Architecture Roadmap: Fermi through Blackwell

Chapter 2: The CUDA Programming Model — Threads, Blocks, and Warps

  1. SIMT Execution: Single Instruction, Multiple Threads
  2. Thread Hierarchy: Threads, Warps, Blocks, Grids, and Clusters
  3. Kernel Launch Syntax and Configuration
  4. The Grid-Stride Loop Pattern
  5. Occupancy: Theory, Calculation, and the Occupancy API

Chapter 3: Memory Models — The GPU Memory Hierarchy

  1. Registers and Local Memory
  2. Global Memory and Coalesced Access
  3. Shared Memory: Scope, Latency, and Bank Conflicts
  4. Constant and Texture Memory
  5. L1/L2 Cache Architecture
  6. Memory Alignment and Vectorized Access

Chapter 4: Writing and Optimizing Kernels

  1. Your First CUDA Kernels: Vector Addition, Matrix Multiply
  2. Tiling and Shared Memory Optimization
  3. Avoiding Bank Conflicts: Padding and Swizzling
  4. Warp-Specialized Kernels and Producer-Consumer Patterns
  5. Common Pitfalls: Divergence, Race Conditions, Out-of-Bounds

Chapter 5: Synchronization — From Warps to Grids

  1. Warp-Level Synchronization (Implicit and Explicit)
  2. Block-Level Barriers (syncthreads)
  3. Cooperative Groups: Thread Block Tiles, Cluster Groups, Grid Groups
  4. Scoped Atomics and Thread Scopes
  5. Asynchronous Barriers and cuda::barrier (Hopper+)

Chapter 6: Warp-Level and Intrinsics Programming

  1. Warp Shuffle Primitives: __shfl_sync, __shfl_down_sync, __shfl_up_sync, __shfl_xor_sync
  2. Vote and Mask Operations: __ballot_sync, __any_sync, __all_sync, __activemask
  3. Warp-Level Reductions and Scans
  4. Inline PTX Assembly for Performance-Critical Code
  5. When to Use Warp Primitives vs. Cooperative Groups

Chapter 7: Asynchronous Execution — Streams, Events, and Overlap

  1. CUDA Streams: Default and User-Created
  2. Events for Synchronization and Timing
  3. Overlapping Data Transfers with Computation
  4. Multi-Stream Pipelining Patterns
  5. CUDA Graphs: Capture, Replay, and Constant-Time Launch

Chapter 8: Unified Memory and Advanced Memory Management

  1. The Problem with Explicit Host-Device Transfers
  2. cudaMallocManaged and Page Migration Engine
  3. Pinned (Page-Locked) Memory
  4. Unified Memory Performance: When It Works, When It Doesn’t

Chapter 9: Tensor Cores and Mixed-Precision Computing

  1. Evolution of Tensor Cores: Volta through Blackwell
  2. Matrix Multiply-Accumulate (MMA) Operations
  3. Data Precision Formats
  4. Writing Tensor Core Kernels with WGMMA
  5. The Transformer Engine and Dynamic Scaling

Chapter 10: Hopper Innovations — TMA, Barriers, and Pipelines

  1. Tensor Memory Accelerator (TMA): Architecture and Programming Model
  2. cuda::memcpy_async and Asynchronous Data Copies
  3. CUDA Pipelines: Producer-Consumer Patterns with Multi-Buffering
  4. Warp-Specialized Kernels for Maximum Utilization
  5. Cluster-Sized Thread Blocks and GPC-Level Scheduling

Chapter 11: CUDA Libraries — Building on NVIDIA’s Foundation

  1. Linear Algebra: cuBLAS, cuSOLVER, cuSPARSE
  2. Signal Processing: cuFFT
  3. Parallel Primitives: CUB and Thrust
  4. Random Numbers: cuRAND
  5. Image and Video: NPP, nvJPEG, nvCodec
  6. When to Use Libraries vs. Custom Kernels

Chapter 12: Dynamic Parallelism and Multi-GPU Programming

  1. Dynamic Parallelism: Child Kernels, Nested Launches
  2. Multi-GPU Architecture: PCIe vs NVLink
  3. Peer-to-Peer Memory Access (GPUDirect P2P)
  4. NCCL: Collective Communication Primitives
  5. Multi-GPU Design Patterns and Scaling Considerations

Chapter 13: Profiling, Debugging, and Performance Engineering

  1. CUDA-GDB and Nsight Debugger
  2. Compute Sanitizer: memcheck, racecheck, synccheck, initcheck
  3. Nsight Systems: System-Wide Profiling
  4. Nsight Compute: Kernel-Level Metrics and Analysis
  5. The APOD Framework (Assess, Parallelize, Optimize, Deploy)
  6. Performance Engineering Case Studies

Chapter 14: Real-World Applications — AI, HPC, and Scientific Computing

  1. Convolutional Kernels for Image Processing
  2. Matrix Multiplication at Scale: From Naive to Tensor Core Optimized
  3. Sparse Linear Algebra for Scientific Computing
  4. AI Training and Inference Pipelines
  5. Mini-Project: GPU-Accelerated Particle Simulation

Conclusion: The Future of GPU Computing

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub