cuda 函数空间

空间

__global__

1)Executed on the device,
2)Callable from the host,
3)Callable from the device for devices of compute capability 3.2 以上
2. 必须返回void
3. 异步(asynchronous),调用后控制权返回给host

__device__
1.
1)Executed on the device,
2)Callable from the device only.
4. __global____device__不能同时使用

__host__
1.
1)Executed on the host,
2)Callable from the host only.
2.默认可以不写
3.__global__ and__host__ 不能同时出现
4.__device__ and __host__可以同时出现

配置

kernel_name<<< Dg, Db, Ns, S >>>([kernel arguments]);
通过<<< Dg, Db, Ns, S >>>来配置cuda函数

配置参数描述
Dggrid dim (dim3) Dg.x * Dg.y * Dg.z
Dbblock dim (dim3) Db.x * Db.y * Db.z
Nsnumber of bytes (size_t)
ScudaStream_t,是否加入流

例子:

函数配置
__global__ void Func(float* parameter);
Func<<< Dg, Db, Ns >>>(parameter);

参考:
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#function-declaration-specifiers
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#device-side-kernel-launch

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值