CUDA Unified Memory统一内存使用注意
来源:互联网 发布:js遍历数组里的对象 编辑:程序博客网 时间:2024/05/21 09:30
这主要有两个问题:需要为主机和设备(GPU)分别定义指针和分布malloc内存,然后在使用前后需要在CPU和GPU进行显式的拷贝,代码冗长,维护难度较大。
Unified Memory大大简化了CUDA程序的编写,使用Unified Memory的CUDA编程方式如下:
可见,一方面,只需要定义一个指针即可在主机和设备端通用;另一方面,去掉了显式的内存拷贝,大大缩短了代码数量和编写、维护难度。
在CUDA编程使用Unified Memory的时候有几个注意点:
Unified Memory has three basic requirements:
1, a GPU with SM architecture 3.0 or higher (Kepler class or newer)
2, a 64-bit host application and operating system, except on Android
3, Linux or Windows
这个限制也会对用户的应用场合进行一些限制,一方面是只能是程序只能在Kepler及以后的显卡才能运行,另一方面必须工作在64位的系统上。考虑到Kepler的显卡已经普及了三四年了,大部分gtx6xx系列的显卡已经就是Kepler架构,现在64位系统也已经非常普遍,这些限制应该还可以接受。
附:
1,cuda的release比debug快的多
2,使用流和cudaMemcpyAsync
的性能比使用unified memory的性能要高,我的一个程序中前者比后者高10%。(An important point is that a carefully tuned CUDA program that uses streams and cudaMemcpyAsync
to efficiently overlap execution with data transfers may very well perform better than a CUDA program that only uses Unified Memory. Understandably so: the CUDA runtime never has as much information as the programmer does about where data is needed and when! CUDA programmers still have access to explicit device memory allocation and asynchronous memory copies to optimize data management and CPU-GPU concurrency. )
参考:
https://en.wikipedia.org/wiki/CUDA
http://stackoverflow.com/questions/23600403/cudamallocmanaged-returns-operation-not-supported
https://devblogs.nvidia.com/parallelforall/unified-memory-in-cuda-6/
转载来自:http://blog.csdn.net/u013701860/article/details/51140762
- CUDA Unified Memory统一内存使用注意
- CUDA Unified Memory统一内存使用注意
- cuda Unified Memory
- CUDA总结:Unified Memory
- CUDA Unified Memory
- CUDA内存类型memory
- CUDA内存类型memory
- CUDA内存类型memory
- CUDA内存类型memory
- 测试cuda的unified memory和cudaMemcpy的if判断
- CUDA 6.0 统一内存寻址
- CUDA shared memory使用
- CUDA: 使用shared memory
- Spark 1.6 内存管理模型( Unified Memory Management)分析
- Spark 1.6 内存管理模型( Unified Memory Management)分析
- Spark 1.6 内存管理模型( Unified Memory Management)分析
- Unified Memory与unified memory managed详解
- 测试cuda的unified memory和cudaMemcpy的加减乘除及空间申请时间对比
- 学习Spring Cloud第八课(通过代码自定义配置Ribbon)
- java开发系统内核:第一个控制台命令
- LeetCode 75. Sort Colors (三路快排)
- Week1-2Human Language Versus Other 'Languages'
- 用C#来学习唐诗三百首和全唐诗
- CUDA Unified Memory统一内存使用注意
- 一对多实体类配置文件
- Maven pom.xml文件异常
- 如何快速转载CSDN中的博客
- Golang安装
- zset
- 操作系统的实现——引导
- 安装virtualenv和virtualenvwrapper
- Android-UI:一个手机页面信息