29.01.2013 Views

Tutorial CUDA

Tutorial CUDA

Tutorial CUDA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example: Avoiding Non-Coalesced<br />

float3 Memory Accesses<br />

Use shared memory to allow coalescing<br />

© NVIDIA Corporation 2008<br />

Need sizeof(float3)*(threads/block) bytes of SMEM<br />

Each thread reads 3 scalar floats:<br />

Offsets: 0, (threads/block), 2*(threads/block)<br />

These will likely be processed by other threads, so sync<br />

Processing<br />

Each thread retrieves its float3 from SMEM array<br />

Cast the SMEM pointer to (float3*)<br />

Use thread ID as index<br />

Rest of the compute code does not change!

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!