Details

Professional CUDA C Programming


Professional CUDA C Programming


1. Aufl.

von: John Cheng, Max Grossman, Ty McKercher

38,99 €

Verlag: Wiley
Format: PDF
Veröffentl.: 28.08.2014
ISBN/EAN: 9781118739273
Sprache: englisch
Anzahl Seiten: 528

DRM-geschütztes eBook, Sie benötigen z.B. Adobe Digital Editions und eine Adobe ID zum Lesen.

Beschreibungen

<p><b>Break into the powerful world of parallel GPU programming </b><b>with this down-to-earth, practical guide</b></p> <p>Designed for professionals across multiple industrial sectors, <i>Professional CUDA C Programming  </i>presents CUDA -- a parallel computing platform and programming model designed to ease the development of GPU programming -- fundamentals in an easy-to-follow format, and teaches readers how to think in parallel and implement parallel algorithms on GPUs. Each chapter covers a specific topic, and includes workable examples that demonstrate the development process, allowing readers to explore both the "hard" and "soft" aspects of GPU programming.</p> <p>Computing architectures are experiencing a fundamental shift toward scalable parallel computing motivated by application requirements in industry and science. This book demonstrates the challenges of efficiently utilizing compute resources at peak performance, presents modern techniques for tackling these challenges, while increasing accessibility for professionals who are not necessarily parallel programming experts. The CUDA programming model and tools empower developers to write high-performance applications on a scalable, parallel computing platform: the GPU. However, CUDA itself can be difficult to learn without extensive programming experience. Recognized CUDA authorities John Cheng, Max Grossman, and Ty McKercher guide readers through essential GPU programming skills and best practices in <i>Professional CUDA C Programming</i>, including:</p> <ul> <li>CUDA Programming Model</li> <li>GPU Execution Model</li> <li>GPU Memory model</li> <li>Streams, Event and Concurrency</li> <li>Multi-GPU Programming</li> <li>CUDA Domain-Specific Libraries</li> <li>Profiling and Performance Tuning</li> </ul> <p>The book makes complex CUDA concepts easy to understand for anyone with knowledge of basic software development with exercises designed to be both readable and high-performance. For the professional seeking entrance to parallel computing and the high-performance computing community, <i>Professional CUDA C Programming</i> is an invaluable resource, with the most current information available on the market.</p>
<p>Foreword xvii</p> <p>Preface xix</p> <p>Introduction xxi</p> <p><b>Chapter 1: Heterogeneous Parallel Computing with CUDA 1</b></p> <p>Parallel Computing 2</p> <p>Sequential and Parallel Programming 3</p> <p>Parallelism 4</p> <p>Computer Architecture 6</p> <p>Heterogeneous Computing 8</p> <p>Heterogeneous Architecture 9</p> <p>Paradigm of Heterogeneous Computing 12</p> <p>CUDA: A Platform for Heterogeneous Computing 14</p> <p>Hello World from GPU 17</p> <p>Is CUDA C Programming Difficult? 20</p> <p>Summary 21</p> <p><b>Chapter 2: CUDA Programming Model 23</b></p> <p>Introducing the CUDA Programming Model 23</p> <p>CUDA Programming Structure 25</p> <p>Managing Memory 26</p> <p>Organizing Threads 30</p> <p>Launching a CUDA Kernel 36</p> <p>Writing Your Kernel 37</p> <p>Verifying Your Kernel 39</p> <p>Handling Errors 40</p> <p>Compiling and Executing 40</p> <p>Timing Your Kernel 43</p> <p>Timing with CPU Timer 44</p> <p>Timing with nvprof 47</p> <p>Organizing Parallel Threads 49</p> <p>Indexing Matrices with Blocks and Threads 49</p> <p>Summing Matrices with a 2D Grid and 2D Blocks 53</p> <p>Summing Matrices with a 1D Grid and 1D Blocks 57</p> <p>Summing Matrices with a 2D Grid and 1D Blocks 58</p> <p>Managing Devices 60</p> <p>Using the Runtime API to Query GPU Information 61</p> <p>Determining the Best GPU 63</p> <p>Using nvidia-smi to Query GPU Information 63</p> <p>Setting Devices at Runtime 64</p> <p>Summary 65</p> <p><b>Chapter 3: CUDA Execution Model 67</b></p> <p>Introducing the CUDA Execution Model 67</p> <p>GPU Architecture Overview 68</p> <p>The Fermi Architecture 71</p> <p>The Kepler Architecture 73</p> <p>Profile-Driven Optimization 78</p> <p>Understanding the Nature of Warp Execution 80</p> <p>Warps and Thread Blocks 80</p> <p>Warp Divergence 82</p> <p>Resource Partitioning 87</p> <p>Latency Hiding 90</p> <p>Occupancy 93</p> <p>Synchronization 97</p> <p>Scalability 98</p> <p>Exposing Parallelism 98</p> <p>Checking Active Warps with nvprof 100</p> <p>Checking Memory Operations with nvprof 100</p> <p>Exposing More Parallelism 101</p> <p>Avoiding Branch Divergence 104</p> <p>The Parallel Reduction Problem 104</p> <p>Divergence in Parallel Reduction 106</p> <p>Improving Divergence in Parallel Reduction 110</p> <p>Reducing with Interleaved Pairs 112</p> <p>Unrolling Loops 114</p> <p>Reducing with Unrolling 115</p> <p>Reducing with Unrolled Warps 117</p> <p>Reducing with Complete Unrolling 119</p> <p>Reducing with Template Functions 120</p> <p>Dynamic Parallelism 122</p> <p>Nested Execution 123</p> <p>Nested Hello World on the GPU 124</p> <p>Nested Reduction 128</p> <p>Summary 132</p> <p><b>Chapter 4: Global Memory 135</b></p> <p>Introducing the CUDA Memory Model 136</p> <p>Benefits of a Memory Hierarchy 136</p> <p>CUDA Memory Model 137</p> <p>Memory Management 145</p> <p>Memory Allocation and Deallocation 146</p> <p>Memory Transfer 146</p> <p>Pinned Memory 148</p> <p>Zero-Copy Memory 150</p> <p>Unified Virtual Addressing 156</p> <p>Unified Memory 157</p> <p>Memory Access Patterns 158</p> <p>Aligned and Coalesced Access 158</p> <p>Global Memory Reads 160</p> <p>Global Memory Writes 169</p> <p>Array of Structures versus Structure of Arrays 171</p> <p>Performance Tuning 176</p> <p>What Bandwidth Can a Kernel Achieve? 179</p> <p>Memory Bandwidth 179</p> <p>Matrix Transpose Problem 180</p> <p>Matrix Addition with Unified Memory 195</p> <p>Summary 199</p> <p><b>Chapter 5: Shared Memory and Constant Memory 203</b></p> <p>Introducing CUDA Shared Memory 204</p> <p>Shared Memory 204</p> <p>Shared Memory Allocation 206</p> <p>Shared Memory Banks and Access Mode 206</p> <p>Configuring the Amount of Shared Memory 212</p> <p>Synchronization 214</p> <p>Checking the Data Layout of Shared Memory 216</p> <p>Square Shared Memory 217</p> <p>Rectangular Shared Memory 225</p> <p>Reducing Global Memory Access 232</p> <p>Parallel Reduction with Shared Memory 232</p> <p>Parallel Reduction with Unrolling 236</p> <p>Parallel Reduction with Dynamic Shared Memory 238</p> <p>Effective Bandwidth 239</p> <p>Coalescing Global Memory Accesses 239</p> <p>Baseline Transpose Kernel 240</p> <p>Matrix Transpose with Shared Memory 241</p> <p>Matrix Transpose with Padded Shared Memory 245</p> <p>Matrix Transpose with Unrolling 246</p> <p>Exposing More Parallelism 249</p> <p>Constant Memory 250</p> <p>Implementing a 1D Stencil with Constant Memory 250</p> <p>Comparing with the Read-Only Cache 253</p> <p>The Warp Shuffle Instruction 255</p> <p>Variants of the Warp Shuffle Instruction 256</p> <p>Sharing Data within a Warp 258</p> <p>Parallel Reduction Using the Warp Shuffle Instruction 262</p> <p>Summary 264</p> <p><b>Chapter 6: Streams and Concurrency 267</b></p> <p>Introducing Streams and Events 268</p> <p>CUDA Streams 269</p> <p>Stream Scheduling 271</p> <p>Stream Priorities 273</p> <p>CUDA Events 273</p> <p>Stream Synchronization 275</p> <p>Concurrent Kernel Execution 279</p> <p>Concurrent Kernels in Non-NULL Streams 279</p> <p>False Dependencies on Fermi GPUs 281</p> <p>Dispatching Operations with OpenMP 283</p> <p>Adjusting Stream Behavior Using Environment Variables 284</p> <p>Concurrency-Limiting GPU Resources 286</p> <p>Blocking Behavior of the Default Stream 287</p> <p>Creating Inter-Stream Dependencies 288</p> <p>Overlapping Kernel Execution and Data Transfer 289</p> <p>Overlap Using Depth-First Scheduling 289</p> <p>Overlap Using Breadth-First Scheduling 293</p> <p>Overlapping GPU and CPU Execution 294</p> <p>Stream Callbacks 295</p> <p>Summary 297</p> <p><b>Chapter 7: Tuning Instruction-Level Primitives 299</b></p> <p>Introducing CUDA Instructions 300</p> <p>Floating-Point Instructions 301</p> <p>Intrinsic and Standard Functions 303</p> <p>Atomic Instructions 304</p> <p>Optimizing Instructions for Your Application 306</p> <p>Single-Precision vs. Double-Precision 306</p> <p>Standard vs. Intrinsic Functions 309</p> <p>Understanding Atomic Instructions 315</p> <p>Bringing It All Together 322</p> <p>Summary 324</p> <p><b>Chapter 8: GPU-Accelerated CUDA Libraries and OpenACC 327</b></p> <p>Introducing the CUDA Libraries 328</p> <p>Supported Domains for CUDA Libraries 329</p> <p>A Common Library Workflow 330</p> <p>The CUSPARSE Library 332</p> <p>cuSPARSE Data Storage Formats 333</p> <p>Formatting Conversion with cuSPARSE 337</p> <p>Demonstrating cuSPARSE 338</p> <p>Important Topics in cuSPARSE Development 340</p> <p>cuSPARSE Summary 341</p> <p>The cuBLAS Library 341</p> <p>Managing cuBLAS Data 342</p> <p>Demonstrating cuBLAS 343</p> <p>Important Topics in cuBLAS Development 345</p> <p>cuBLAS Summary 346</p> <p>The cuFFT Library 346</p> <p>Using the cuFFT API 347</p> <p>Demonstrating cuFFT 348</p> <p>cuFFT Summary 349</p> <p>The cuRAND Library 349</p> <p>Choosing Pseudo- or Quasi- Random Numbers 349</p> <p>Overview of the cuRAND Library 350</p> <p>Demonstrating cuRAND 354</p> <p>Important Topics in cuRAND Development 357</p> <p>CUDA Library Features Introduced in CUDA 6 358</p> <p>Drop-In CUDA Libraries 358</p> <p>Multi-GPU Libraries 359</p> <p>A Survey of CUDA Library Performance 361</p> <p>cuSPARSE versus MKL 361</p> <p>cuBLAS versus MKL BLAS 362</p> <p>cuFFT versus FFTW versus MKL 363</p> <p>CUDA Library Performance Summary 364</p> <p>Using OpenACC 365</p> <p>Using OpenACC Compute Directives 367</p> <p>Using OpenACC Data Directives 375</p> <p>The OpenACC Runtime API 380</p> <p>Combining OpenACC and the CUDA Libraries 382</p> <p>Summary of OpenACC 384</p> <p>Summary 384</p> <p><b>Chapter 9: Multi-GPU Programming 387</b></p> <p>Moving to Multiple GPUs 388</p> <p>Executing on Multiple GPUs 389</p> <p>Peer-to-Peer Communication 391</p> <p>Synchronizing across Multi-GPUs 392</p> <p>Subdividing Computation across Multiple GPUs 393</p> <p>Allocating Memory on Multiple Devices 393</p> <p>Distributing Work from a Single Host Thread 394</p> <p>Compiling and Executing 395</p> <p>Peer-to-Peer Communication on Multiple GPUs 396</p> <p>Enabling Peer-to-Peer Access 396</p> <p>Peer-to-Peer Memory Copy 396</p> <p>Peer-to-Peer Memory Access with Unified Virtual Addressing 398</p> <p>Finite Difference on Multi-GPU 400</p> <p>Stencil Calculation for 2D Wave Equation 400</p> <p>Typical Patterns for Multi-GPU Programs 401</p> <p>2D Stencil Computation with Multiple GPUs 403</p> <p>Overlapping Computation and Communication 405</p> <p>Compiling and Executing 406</p> <p>Scaling Applications across GPU Clusters 409</p> <p>CPU-to-CPU Data Transfer 410</p> <p>GPU-to-GPU Data Transfer Using Traditional MPI 413</p> <p>GPU-to-GPU Data Transfer with CUDA-aware MPI 416</p> <p>Intra-Node GPU-to-GPU Data Transfer with CUDA-Aware MPI 417</p> <p>Adjusting Message Chunk Size 418</p> <p>GPU to GPU Data Transfer with GPUDirect RDMA 419</p> <p>Summary 422</p> <p><b>Chapter 10: Implementation Considerations 425</b></p> <p>The CUDA C Development Process 426</p> <p>APOD Development Cycle 426</p> <p>Optimization Opportunities 429</p> <p>CUDA Code Compilation 432</p> <p>CUDA Error Handling 437</p> <p>Profile-Driven Optimization 438</p> <p>Finding Optimization Opportunities Using nvprof 439</p> <p>Guiding Optimization Using nvvp 443</p> <p>NVIDIA Tools Extension 446</p> <p>CUDA Debugging 448</p> <p>Kernel Debugging 448</p> <p>Memory Debugging 456</p> <p>Debugging Summary 462</p> <p>A Case Study in Porting C Programs to CUDA C 462</p> <p>Assessing crypt 463</p> <p>Parallelizing crypt 464</p> <p>Optimizing crypt 465</p> <p>Deploying Crypt 472</p> <p>Summary of Porting crypt 475</p> <p>Summary 476</p> <p>Appendix: Suggested Readings 477</p> <p>Index 481</p>
<p><b>John Cheng, P<small>H</small>D,</b> is a Research Scientist at BGP International in Houston. He has developed seismic imaging products with GPU technology and many high-performance parallel production applications on heterogeneous computing-platforms. <p><b>Max Grossman</b> is an expert in GPU computing with experience applying CUDA to problems in medical imaging, machine learning, geophysics, and more. <p><b>Ty McKercher</b> has been helping customers adopt GPU acceleration technologies while he has been employed at NVIDIA since 2008.
<p><b>Break into the powerful world of parallel computing</b> <p>Focused on the essential aspects of CUDA, <i>Professional CUDA C Programming</i> offers down-to-earth coverage of parallel computing. Packed with examples and exercises that help you see code, real-world applications, and try out new skills, this resource makes the complex concepts of parallel computing accessible and easy to understand. Each chapter is organized around one central topic, and includes workable examples that demonstrate the development process, allowing you to measure significant performance gains while exploring all aspects of GPU programming. <p><i>Professional CUDA C Programming:</i> <ul> <li> Focuses on GPU programming skills and best practices that deliver outstanding performance</li> <li> Shows you how to think in parallel</li> <li> Turns complex subjects into easy-to-understand concepts</li> <li> Makes information accessible across multiple industrial sectors</li> <li> Features helpful examples and exercises in each chapter</li> <li> Covers the essentials for those who are not experts in C programming</li> </ul> <p><b>wrox.com</b> <p><b>Programmer Forums</b> <p>Join our Programmer to Programmer forums to ask and answer programming questions about this book, join discussions on the hottest topics in the industry, and connect with fellow programmers from around the world. <p><b>Code Downloads</b> <p>Take advantage of free code samples from this book, as well as code samples from hundreds of other books, all ready to use. <p><b>Read More</b> <p>Find articles, e-books, sample chapters, and tables of contents for hundreds of books, and more reference resources on programming topics that matter to you.

Diese Produkte könnten Sie auch interessieren:

Symbian OS Explained
Symbian OS Explained
von: Jo Stichbury
PDF ebook
32,99 €
Symbian OS Internals
Symbian OS Internals
von: Jane Sales
PDF ebook
56,99 €
Parallel Combinatorial Optimization
Parallel Combinatorial Optimization
von: El-Ghazali Talbi
PDF ebook
120,99 €