greenoldman
greenoldman

Reputation: 21082

How to mark a function callable from host and device?

I have bunch of common functions like swap, min, max etc. How to mark them so I could call them both from the host and from the device?

Upvotes: 1

Views: 375

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 152249

You use __host__ __device__ before the function declaration, like:

__host__ __device__ int min(int A, int B) {return (A<B)?A:B;}

This is documented in the C programming guide here.

Upvotes: 5

Related Questions