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.

Parallel Dot Product: main()<br />

}<br />

// copy inputs <strong>to</strong> device<br />

cudaMemcpy( dev_a, a, size, cudaMemcpyHostToDevice );<br />

cudaMemcpy( dev_b, b, size, cudaMemcpyHostToDevice );<br />

// launch dot() kernel<br />

dot>( dev_a, dev_b, dev_c );<br />

// copy device result back <strong>to</strong> host copy of c<br />

cudaMemcpy( c, dev_c, sizeof( int ) , cudaMemcpyDeviceToHost );<br />

free( a ); free( b ); free( c );<br />

cudaFree( dev_a );<br />

cudaFree( dev_b );<br />

cudaFree( dev_c );<br />

return 0;

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

Saved successfully!

Ooh no, something went wrong!