如何标记一个函数从主机和设备可调用? [英] How to mark a function callable from host and device?
本文介绍了如何标记一个函数从主机和设备可调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有很多常用函数,如 swap
, min
, max $
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?
推荐答案
您可以从主机和设备上调用它们在函数声明之前使用 __ host __
__ device __
,如:
You use __host__
__device__
before the function declaration, like:
__host__ __device__ int min(int A, int B) {return (A<B)?A:B;}
这在C程序指南此处。
这篇关于如何标记一个函数从主机和设备可调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文