C语言中的Cuda纹理内存分配 [英] Cuda texture Memory Allocation in C

查看:233
本文介绍了C语言中的Cuda纹理内存分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分配cuda纹理内存????有人可以帮我举个例子吗?

How to allocate cuda texture memory????can anyone help me with an example

推荐答案

您可以使用纹理语法对其进行定义:
You define it with the texture syntax:
texture<Type, Dim, ReadMode> Name


其中:
Type 是数据类型(float,int,...)
Dim 是尺寸1D,2D,3D的数量,仅表示为1、2或3的数量
ReadMode 是允许的访问. cudaReadModeNormalizedFloat(在[0-1]范围内的浮点值,在其中转换int)或cudaReadModeElementType(您存储在内存中的实际值).请参考《 Cuda编程指南》 [ ^ ]进一步的解释.
名称是您的变量名称

因此,假设我们要一个2D整数数组(存储为整数),我们将有


Where:
Type is the data type (float, int, ...)
Dim is the number of dimensions 1D, 2D, 3D, represented as just the number 1, 2 or 3
ReadMode is the access allowed. Either cudaReadModeNormalizedFloat (a float value in the range [0-1], where ints are converted) or cudaReadModeElementType (The actual value you store in the memory). Reffer to section 4.3.4 of the Cuda Programming Guide[^] for a further explanation.
Name is your variable name

So, say we want a 2D array of integers (to be stored as integers), we would have

texture<int, 2, cudaReadModeElementType> MyIntGrid;


这篇关于C语言中的Cuda纹理内存分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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