15.08.2012 Views

Introduction to CUDA C

Introduction to CUDA C

Introduction to CUDA 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.

A More Complex Example: main()<br />

int main( void ) {<br />

int a, b, c; // host copies of a, b, c<br />

int *dev_a, *dev_b, *dev_c; // device copies of a, b, c<br />

int size = sizeof( int ); // we need space for an integer<br />

// allocate device copies of a, b, c<br />

cudaMalloc( (void**)&dev_a, size );<br />

cudaMalloc( (void**)&dev_b, size );<br />

cudaMalloc( (void**)&dev_c, size );<br />

a = 2;<br />

b = 7;

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

Saved successfully!

Ooh no, something went wrong!