nvcc - 获取 OpenACC 空闲(或总)设备内存
问题描述
我有一个 GPU 代码,它在每次迭代时决定是否可以将迭代卸载到加速器。OpenACC 成为最好的工具:
void module(struct my_aos *aos, int n_aos){
int criteria = /* check either that n_aos is large enough and that aos[:n_aos] will fit the GPU */
#pragma acc data copy(aos[0:n_aos]) if(criteria)
#pragma acc parallel loop if(criteria)
for(int i = 0; i < n_aos; i++){
/* work on my_aos*/
}
}
我如何提前决定是否aos[0:n_aos]
适合 GPU 内存?有openacc_get_free_device_memory()
某种功能吗?
否则,如果出现内存不足故障,我如何启动设备复制并返回仅 CPU 运行?
解决方案
请参阅 OpenACC 标准的“3.2.6 acc get property”部分。特别是“acc_property_free_memory”属性。
https://www.openacc.org/sites/default/files/inline-images/Specification/OpenACC-3.1-final.pdf
推荐阅读
- php - Laravel 8 路由子域
- angular - Webpack 5 Module Federation 微前端和 Nx monorepos 是互斥的吗?
- javascript - ThreeJS 世界到本地坐标
- sql - How can I use assignment operations in the having clause?
- google-apps-script - Getting Sheet to Modify It with Apps Script
- python - 出现错误 => ModuleNotFoundError: No module named 'django' 当我尝试将我的 django 应用程序部署到 heroku
- javascript - JavaScript map 函数是否比简单的 for 循环更有效?
- javascript - Firebase如何在嵌套对象中找到(equalTo)?
- ubuntu - 无法确定代理 ARP (PPTP VPN) 的以太网地址
- python - 为什么我的 roguelike 的 y 轴框架不起作用?