如何替换已弃用的 tex2D(texture<T, 2, cudaReadModeElementType>, float, float) [with T=float]? [英] How to replace the deprecated tex2D(texture&lt;T, 2, cudaReadModeElementType&gt;, float, float) [with T=float]?

查看:14
本文介绍了如何替换已弃用的 tex2D(texture<T, 2, cudaReadModeElementType>, float, float) [with T=float]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个 cuda 11.3 程序中,我正在使用

In a cuda 11.3 program, I'm using

tex2D(texture<T, 2, cudaReadModeElementType>, float, float)

在 texture_fetch_functions.h(198) 中声明已弃用.用什么代替它?以及如何使用它?

which was declared deprecated in texture_fetch_functions.h(198). What replaces it ? and how do I use it ?

警告:函数 "tex2D(texture<T, 2, cudaReadModeElementType>,float, float) [with T=float]"2>C:Program FilesNVIDIA GPU 计算ToolkitCUDAv11.3include exture_fetch_functions.h(198):这里是宣布弃用

warning : function "tex2D(texture<T, 2, cudaReadModeElementType>, float, float) [with T=float]" 2>C:Program FilesNVIDIA GPU Computing ToolkitCUDAv11.3include exture_fetch_functions.h(198): here was declared deprecated

推荐答案

纹理 历来有两种使用模型:纹理引用和 纹理对象.纹理参考是原始的".CUDA 和纹理对象提供的机制是在 Kepler 一代 GPU 中引入的.

Textures have historically come in 2 usage models: texture references and texture objects. Texture references were the "original" mechanism supplied with CUDA and texture objects were introduced with the Kepler generation of GPUs.

在 CUDA 11.3 中不推荐使用纹理参考.几乎所有可以对纹理引用执行的操作都可以通过纹理对象完成,只需进行一些重构即可.

Texture reference usage is being deprecated in CUDA 11.3. Nearly anything you can do with texture references can be done with texture objects, with some refactoring.

您指出的替换 API 已记录在案 这里.cuda 标签上有很多问题,讨论纹理参考使用和纹理对象使用,这个 介绍性博客介绍了重构以使用纹理对象的好处.

The replacement API for the one you indicate is documented here. There are many questions here on the cuda tag discussing both texture reference usage and texture object usage, and this introductory blog covers the benefits of refactoring to use texture objects.

这里是一个完整的工作示例对纹理对象使用 tex2D().

Here is a complete worked example of using tex2D() for texture objects.

这篇关于如何替换已弃用的 tex2D(texture<T, 2, cudaReadModeElementType>, float, float) [with T=float]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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