19.11.2014 Views

Introduction to CUDA C/C++

Introduction to CUDA C/C++

Introduction to CUDA C/C++

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.

Data Race!<br />

• The stencil example will not work…<br />

• Suppose thread 15 reads the halo before thread 0 has fetched it…<br />

temp[lindex] = in[gindex];<br />

if (threadIdx.x < RADIUS) {<br />

}<br />

temp[lindex – RADIUS = in[gindex – RADIUS];<br />

temp[lindex + BLOCK_SIZE] = in[gindex + BLOCK_SIZE];<br />

int result = 0;<br />

result += temp[lindex + 1];<br />

S<strong>to</strong>re at temp[18]<br />

Load from temp[19]<br />

Skipped, threadIdx > RADIUS<br />

© NVIDIA Corporation 2011

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

Saved successfully!

Ooh no, something went wrong!