为什么要使用CUDA驱动程序API而不是CUDA Runtime API? [英] Why should I use the CUDA Driver API instead of CUDA Runtime API?

查看:731
本文介绍了为什么要使用CUDA驱动程序API而不是CUDA Runtime API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么要使用CUDA驱动程序API,在这种情况下,我不能使用CUDA Runtime API(比Driver API更方便)?

Why should I use the CUDA Driver API, and in which cases I can't use CUDA Runtime API (which is more convenient than Driver API)?

推荐答案

运行时API比驱动程序API更高级的抽象,它通常更容易使用(性能差距应该是最小的)。驱动程序API是基于句柄的,并提供更高程度的控制。相反,运行时API更容易使用(例如,您可以使用 kernel<<<>>> 启动语法)。

The runtime API is an higher level of abstraction over the driver API and it's usually easier to use (the performance gap should be minimal). The driver API is a handle-based one and provides a higher degree of control. The runtime API, on the contrary, is easier to use (e.g. you can use the kernel<<<>>> launch syntax).

更高的控制度意味着使用驱动程序API,你必须以更详细的方式处理模块初始化和内存管理,但是允许你做更多的东西,例如禁用内核代码的驱动程序JIT优化:

That "higher degree of control" means that with the driver API you have to deal with module initialization and memory management in a more verbose way, but that allows you to do more stuff, e.g. disable the driver JIT optimizations for the kernel code:


CU_JIT_OPTIMIZATION_LEVEL - 应用于生成代码的优化级别(0 - 4)是默认和最高级别的优化。
选项类型:unsigned int

CU_JIT_OPTIMIZATION_LEVEL - Level of optimizations to apply to generated code (0 - 4), with 4 being the default and highest level of optimizations. Option type: unsigned int

http://developer.download.nvidia.com/compute/cuda/4_1/rel/toolkit/docs/online/group__CUDA__TYPES_gfaa9995214a4f3341f48c5830cea0d8a.html < a>

From http://developer.download.nvidia.com/compute/cuda/4_1/rel/toolkit/docs/online/group__CUDA__TYPES_gfaa9995214a4f3341f48c5830cea0d8a.html

目前不可能通过运行时API的代码。更精细的控制程度意味着你可能会破坏或更慢,如果你不知道他们是什么,不要使用它。

This isn't currently possible via code with the runtime API. Finer degree of control means that you might render things broken or slower, don't use it if you don't know what they are.

你通常应该使用您的应用程序中的运行时API或驱动程序API(尽管使用较新的CUDA版本,但运行时API代码可以与驱动程序API代码并行共存) http://docs.nvidia.com/cuda/pdf/CUDA_C_Programming_Guide.pdf

You should usually only use either the runtime API or the driver API in your application although, with newer CUDA versions, runtime API code can peacefully coexist with driver API code (http://docs.nvidia.com/cuda/pdf/CUDA_C_Programming_Guide.pdf)


应用程序可以将运行时API代码与驱动程序API代码混合。

An application can mix runtime API code with driver API code.

这篇关于为什么要使用CUDA驱动程序API而不是CUDA Runtime API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆