19.11.2014 Views

with CUDA Fortran

with CUDA Fortran

with CUDA Fortran

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.

Calling Thrust from <strong>CUDA</strong> <strong>Fortran</strong><br />

C wrapper for Thrust: csort.cu<br />

#include <br />

#include <br />

#include <br />

extern "C" {<br />

//Sort for integer arrays<br />

void sort_int_wrapper( int *data, int N)<br />

{<br />

}<br />

// Wrap raw pointer <strong>with</strong> a device_ptr<br />

thrust::device_ptr dev_ptr(data);<br />

// Use device_ptr in Thrust sort<br />

// algorithm<br />

thrust::sort(dev_ptr, dev_ptr+N);<br />

//Sort for single precision arrays<br />

void sort_float_wrapper( float *data, int N)<br />

{<br />

}<br />

thrust::device_ptr dev_ptr(data);<br />

thrust::sort(dev_ptr, dev_ptr+N);<br />

//Sort for double precision arrays<br />

void sort_double_wrapper(double *data, int N)<br />

{<br />

}<br />

}<br />

thrust::device_ptr dev_ptr(data);<br />

thrust::sort(dev_ptr, dev_ptr+N);

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

Saved successfully!

Ooh no, something went wrong!