Compute Programming
Parallel Power for Modern Computing
Course CP293
Road Map • Why Compute Matters Today
• Compute Languages/API
• Core Concepts & Rules
• Essential Algorithms
• Performance Considerations
• Practical Examples
• Future of Compute
• Summary & Resources
Recommend Reading
101 WebGPU and WGSL
Programming Projects (Paperback)
WebGPU Data
Visualization
Cookbook (2nd
Edition)
Lots of projects to keep you busy with compute programming
(working and thinking in parallel)
WebGPU
Compute
(Paperback)
Why Learn Compute Programming Today?
• AI/ML revolution demands GPU compute
• Games and simulations are more complex
• Scientific computing needs more power
• WebGPU brings GPU compute to the browser
Did You Know?
Modern GPUs contain thousands of cores
while CPUs typically have 4-32 cores
What exactly is
compute
programming?
What exactly is compute programming?
• Specialized programming for parallel processing
• Utilizes GPU's architecture for general computation
• Different paradigm from traditional CPU programming
• Used in ML, scientific computing, data processing
What makes GPU
compute different
from CPU
programming?
• Massively parallel vs sequential thinking
• Different memory hierarchy
• Specialized languages (WGSL, CUDA)
• Different performance characteristics
What makes GPU compute different from
CPU programming?
JIM, It’s programming, but not as we know it!
GPU
CPU
Switch ‘Mindset’
Hands-On Task
Visit https://webgpulab.xbdev.net and:
• 1. Check your browser's WebGPU support
• 2. Run the demo compute shaders
• 3. Note the performance metrics
WebGPU Fact
WebGPU provides 3x better
performance than WebGL for
compute workloads
What are the key components of WebGPU?
What are the key components of WebGPU?
• Device: Represents the GPU
• Queue: Command submission
• Buffers: Memory storage
• Textures: Image data
• Bind Groups: Resource binding
• Pipelines: Shader configurations
Debugging Challenge
Try this broken compute shader:
1. Identify why it fails
2. Fix the memory access issue
3. Measure the performance impact
Performance Fact
Coalesced memory access can
improve performance by 20x
compared to random access
What are some common compute
programming pitfalls?
What are some common compute
programming pitfalls?
• Race conditions between threads
• Incorrect memory barriers
• Poor workgroup sizing
• Memory access conflicts
• Insufficient parallelism
Optimization Puzzle
Given this matrix multiplication shader:
• 1. Identify the bottleneck
• 2. Implement tiling with shared memory
• 3. Compare performance before/after
Algorithm Fact
Parallel reduction can accelerate
summation operations by 100x on
GPUs
What are essential compute algorithms to
learn?
What are essential compute algorithms to
learn?
• Parallel reduction (sum, min, max)
• Prefix sum/scan
• Matrix operations
• Sorting (bitonic, radix)
• Image processing kernels
• Physics simulations
Implementation Challenge
Implement a parallel histogram:
• 1. Start with naive version
• 2. Add atomic operations
• 3. Optimize with shared memory
Optimization
Fact
Proper workgroup sizing can
improve performance by 5-10x
How do I profile and
optimize compute
shaders?
How do I profile and optimize compute
shaders?
• Use timestamp queries
• Profile different workgroup sizes
• Analyze memory access patterns
• Check for thread divergence
• Compare against theoretical limits
Profiling Task
Profile this shader with:
1. Different workgroup sizes (8, 16, 32, 64)
2. Different memory layouts
3. Create a performance report
Advanced Fact
Wavefront operations can
enable new optimization
techniques in compute shaders
How does compute
programming
integrate with
graphics?
How does compute programming integrate
with graphics?
• Compute can prepare data for rendering
• Post-processing effects
• Procedural content generation
• Physics simulations
• Hybrid rendering techniques
Research Project
Investigate how:
1. Ray tracing uses compute
2. ML upscaling works
3. Particle systems are optimized
Future Fact
WebGPU is expected to
enable browser-based CAD
applications and scientific
visualization
What's next for
compute
programming?
What's next for compute programming?
• Tighter ML integration
• More hardware features exposed
• Better debugging tools
• Cross-platform standardization
• More accessible APIs
Challenge
Build your first compute shader:
• Simple image processor
• Parallel array reducer
• Interactive simulation
• Compute enables massive parallelism
• WebGPU brings GPU compute to the web
• Different mindset from CPU programming
• Performance requires careful optimization
• Essential for modern applications
Summary
Resources Visit
https://xbdev.net
https://webgpulab.xbdev.net
Questions
Recommend Reading
101 WebGPU and WGSL
Programming Projects (Paperback)
WebGPU Data
Visualization
Cookbook (2nd
Edition)
Lots of projects to keep you busy with compute programming
(working and thinking in parallel)
WebGPU
Compute
(Paperback)

Compute Programming - Parallel Power for Modern Computing

  • 1.
    Compute Programming Parallel Powerfor Modern Computing Course CP293
  • 2.
    Road Map •Why Compute Matters Today • Compute Languages/API • Core Concepts & Rules • Essential Algorithms • Performance Considerations • Practical Examples • Future of Compute • Summary & Resources
  • 3.
    Recommend Reading 101 WebGPUand WGSL Programming Projects (Paperback) WebGPU Data Visualization Cookbook (2nd Edition) Lots of projects to keep you busy with compute programming (working and thinking in parallel) WebGPU Compute (Paperback)
  • 4.
    Why Learn ComputeProgramming Today? • AI/ML revolution demands GPU compute • Games and simulations are more complex • Scientific computing needs more power • WebGPU brings GPU compute to the browser
  • 5.
    Did You Know? ModernGPUs contain thousands of cores while CPUs typically have 4-32 cores
  • 6.
  • 7.
    What exactly iscompute programming? • Specialized programming for parallel processing • Utilizes GPU's architecture for general computation • Different paradigm from traditional CPU programming • Used in ML, scientific computing, data processing
  • 8.
    What makes GPU computedifferent from CPU programming?
  • 9.
    • Massively parallelvs sequential thinking • Different memory hierarchy • Specialized languages (WGSL, CUDA) • Different performance characteristics What makes GPU compute different from CPU programming? JIM, It’s programming, but not as we know it! GPU CPU Switch ‘Mindset’
  • 10.
    Hands-On Task Visit https://webgpulab.xbdev.netand: • 1. Check your browser's WebGPU support • 2. Run the demo compute shaders • 3. Note the performance metrics
  • 11.
    WebGPU Fact WebGPU provides3x better performance than WebGL for compute workloads
  • 12.
    What are thekey components of WebGPU?
  • 13.
    What are thekey components of WebGPU? • Device: Represents the GPU • Queue: Command submission • Buffers: Memory storage • Textures: Image data • Bind Groups: Resource binding • Pipelines: Shader configurations
  • 14.
    Debugging Challenge Try thisbroken compute shader: 1. Identify why it fails 2. Fix the memory access issue 3. Measure the performance impact
  • 15.
    Performance Fact Coalesced memoryaccess can improve performance by 20x compared to random access
  • 16.
    What are somecommon compute programming pitfalls?
  • 17.
    What are somecommon compute programming pitfalls? • Race conditions between threads • Incorrect memory barriers • Poor workgroup sizing • Memory access conflicts • Insufficient parallelism
  • 18.
    Optimization Puzzle Given thismatrix multiplication shader: • 1. Identify the bottleneck • 2. Implement tiling with shared memory • 3. Compare performance before/after
  • 19.
    Algorithm Fact Parallel reductioncan accelerate summation operations by 100x on GPUs
  • 20.
    What are essentialcompute algorithms to learn?
  • 21.
    What are essentialcompute algorithms to learn? • Parallel reduction (sum, min, max) • Prefix sum/scan • Matrix operations • Sorting (bitonic, radix) • Image processing kernels • Physics simulations
  • 22.
    Implementation Challenge Implement aparallel histogram: • 1. Start with naive version • 2. Add atomic operations • 3. Optimize with shared memory
  • 23.
    Optimization Fact Proper workgroup sizingcan improve performance by 5-10x
  • 24.
    How do Iprofile and optimize compute shaders?
  • 25.
    How do Iprofile and optimize compute shaders? • Use timestamp queries • Profile different workgroup sizes • Analyze memory access patterns • Check for thread divergence • Compare against theoretical limits
  • 26.
    Profiling Task Profile thisshader with: 1. Different workgroup sizes (8, 16, 32, 64) 2. Different memory layouts 3. Create a performance report
  • 27.
    Advanced Fact Wavefront operationscan enable new optimization techniques in compute shaders
  • 28.
  • 29.
    How does computeprogramming integrate with graphics? • Compute can prepare data for rendering • Post-processing effects • Procedural content generation • Physics simulations • Hybrid rendering techniques
  • 30.
    Research Project Investigate how: 1.Ray tracing uses compute 2. ML upscaling works 3. Particle systems are optimized
  • 31.
    Future Fact WebGPU isexpected to enable browser-based CAD applications and scientific visualization
  • 32.
  • 33.
    What's next forcompute programming? • Tighter ML integration • More hardware features exposed • Better debugging tools • Cross-platform standardization • More accessible APIs
  • 34.
    Challenge Build your firstcompute shader: • Simple image processor • Parallel array reducer • Interactive simulation
  • 35.
    • Compute enablesmassive parallelism • WebGPU brings GPU compute to the web • Different mindset from CPU programming • Performance requires careful optimization • Essential for modern applications Summary Resources Visit https://xbdev.net https://webgpulab.xbdev.net
  • 36.
  • 37.
    Recommend Reading 101 WebGPUand WGSL Programming Projects (Paperback) WebGPU Data Visualization Cookbook (2nd Edition) Lots of projects to keep you busy with compute programming (working and thinking in parallel) WebGPU Compute (Paperback)