CUDA C Programming Guide 在线教程学习笔记 Part 6

? 纹理内存读取函数

  1 /****************************************************************/
  2
  3 // Texture Object API
  4
  5 /****************************************************************/
  6
  7 template<class T>
  8 T tex1Dfetch(cudaTextureObject_t texObj, int x);
  9     // 一维纹理,整数下标。只用于非正规化坐标,挤压模式或边界模式,不能滤波
 10
 11 template<class T>
 12 T tex1D(cudaTextureObject_t texObj, float x);
 13     // 一维纹理,浮点数下标
 14
 15 template<class T>
 16 T tex1DLod(cudaTextureObject_t texObj, float x, float level);
 17     // 一维纹理,基于 level-of-detail(层次细节)算法
 18
 19 template<class T>
 20 T tex1DGrad(cudaTextureObject_t texObj, float x, float dx, float dy);
 21     // 一维纹理,基于 gradients(梯度)算法
 22
 23 template<class T>
 24 T tex2D(cudaTextureObject_t texObj, float x, float y);
 25     // 二维纹理
 26
 27 template<class T>
 28 tex2DLod(cudaTextureObject_t texObj, float x, float y, float level);
 29     // 二维纹理,基于 level-of-detail(层次细节)算法
 30
 31 template<class T>
 32 T tex2DGrad(cudaTextureObject_t texObj, float x, float y,float2 dx, float2 dy);
 33     // 二维纹理,基于 gradients(梯度)算法
 34
 35 template<class T>
 36 T tex3D(cudaTextureObject_t texObj, float x, float y, float z);
 37     // 三维纹理
 38
 39 template<class T>
 40 T tex3DLod(cudaTextureObject_t texObj, float x, float y, float z, float level);
 41     // 三维纹理,基于 level-of-detail(层次细节)算法
 42
 43 template<class T>
 44 T tex3DGrad(cudaTextureObject_t texObj, float x, float y, float z,float4 dx, float4 dy);
 45     // 三维纹理,基于 gradients(梯度)算法
 46
 47 template<class T>
 48 T tex1DLayered(cudaTextureObject_t texObj, float x, int layer);
 49     // 一维分层纹理
 50
 51 template<class T>
 52 T tex1DLayeredLod(cudaTextureObject_t texObj, float x, int layer, float level);
 53     // 一维分层纹理,基于 level-of-detail(层次细节)算法
 54
 55 template<class T>
 56 T tex1DLayeredGrad(cudaTextureObject_t texObj, float x, int layer, float dx, float dy);
 57     // 一维分层纹理,基于 gradients(梯度)算法
 58
 59 template<class T>
 60 T tex2DLayered(cudaTextureObject_t texObj, float x, float y, int layer);
 61     // 二维分层纹理
 62
 63 template<class T>
 64 T tex2DLayeredLod(cudaTextureObject_t texObj, float x, float y, int layer, float level);
 65     // 二维分层纹理,基于 level-of-detail(层次细节)算法
 66
 67 template<class T>
 68 T tex2DLayeredGrad(cudaTextureObject_t texObj, float x, float y, int layer, float2 dx, float2 dy);
 69     // 二维分层纹理,基于 gradients(梯度)算法
 70
 71 template<class T>
 72 T texCubemap(cudaTextureObject_t texObj, float x, float y, float z);
 73     // 立方体贴图纹理
 74
 75 template<class T>
 76 T texCubemapLod(cudaTextureObject_t texObj, float x, float, y, float z, float level);
 77     // 立方体贴图纹理,基于 level-of-detail(层次细节)算法
 78
 79 template<class T>
 80 T texCubemapLayered(cudaTextureObject_t texObj, float x, float y, float z, int layer);
 81     // 立方体分层贴图纹理
 82
 83 template<class T>
 84 T texCubemapLayeredLod(cudaTextureObject_t texObj, float x, float y, float z, int layer, float level);
 85     // 立方分层体贴图纹理,基于 level-of-detail(层次细节)算法
 86
 87 template<class T>
 88 T tex2Dgather(cudaTextureObject_t texObj, float x, float y, int comp = 0);
 89     // ?
 90
 91 /****************************************************************/
 92
 93 // Texture Object API
 94
 95 /****************************************************************/
 96
 97 template<class DataType>
 98 Type tex1Dfetch(texture<DataType, cudaTextureType1D, cudaReadModeElementType> texRef, int x);
 99
100 float tex1Dfetch(texture<unsigned char, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
101 float tex1Dfetch(texture<signed char, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
102 float tex1Dfetch(texture<unsigned short, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
103 float tex1Dfetch(texture<signed short, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
104     // 一维纹理,整数下标。只用于非正规化坐标,挤压模式或边界模式,不能滤波
105
106 // 2元组,4元组也可以使用这种方法,例如:
107 float4 tex1Dfetch(texture<uchar2, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
108 float4 tex1Dfetch(texture<uchar4, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
109
110 // 其他函数名类似 Texture Object API
111 template<class DataType, enum cudaTextureReadMode readMode>
112 Type tex1D(texture<DataType, cudaTextureType1D, readMode> texRef, float x);
113
114 template<class DataType, enum cudaTextureReadMode readMode>
115 Type tex1DLod(texture<DataType, cudaTextureType1D, readMode> texRef, float x, float level);
116
117 template<class DataType, enum cudaTextureReadMode readMode>
118 Type tex1DGrad(texture<DataType, cudaTextureType1D, readMode> texRef, float x, float dx, float dy);
119
120 template<class DataType, enum cudaTextureReadMode readMode>
121 Type tex2D(texture<DataType, cudaTextureType2D, readMode> texRef,float x, float y);
122
123 template<class DataType, enum cudaTextureReadMode readMode>
124 Type tex2DLod(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, float level);
125
126 template<class DataType, enum cudaTextureReadMode readMode>
127 Type tex2DGrad(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, float2 dx, float2 dy);
128
129 template<class DataType, enum cudaTextureReadMode readMode>
130 Type tex3D(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z);
131
132 template<class DataType, enum cudaTextureReadMode readMode>
133 Type tex3DLod(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, float level);
134
135 template<class DataType, enum cudaTextureReadMode readMode>
136 Type tex3DGrad(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, float4 dx, float4 dy);
137
138 template<class DataType, enum cudaTextureReadMode readMode>
139 Type tex1DLayered(texture<DataType, cudaTextureType1DLayered, readMode> texRef, float x, int layer);
140
141 template<class DataType, enum cudaTextureReadMode readMode>
142 Type tex1DLayeredLod(texture<DataType, cudaTextureType1D, readMode> texRef, float x, int layer, float level);
143
144 template<class DataType, enum cudaTextureReadMode readMode>
145 Type tex1DLayeredGrad(texture<DataType, cudaTextureType1D, readMode> texRef, float x, int layer, float dx, float dy);
146
147 template<class DataType, enum cudaTextureReadMode readMode>
148 Type tex2DLayered(texture<DataType, cudaTextureType2DLayered, readMode> texRef, float x, float y, int layer);
149
150 template<class DataType, enum cudaTextureReadMode readMode>
151 Type tex2DLayeredLod(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, int layer, float level);
152
153 template<class DataType, enum cudaTextureReadMode readMode>
154 Type tex2DLayeredGrad(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, int layer, float2 dx, float2 dy);
155
156 template<class DataType, enum cudaTextureReadMode readMode>
157 Type texCubemap(texture<DataType, cudaTextureTypeCubemap, readMode> texRef, float x, float y, float z);
158
159 template<class DataType, enum cudaTextureReadMode readMode>
160 Type texCubemapLod(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, float level);
161
162 template<class DataType, enum cudaTextureReadMode readMode>
163 Type texCubemapLayered(texture<DataType, cudaTextureTypeCubemapLayered, readMode> texRef, float x, float y, float z, int layer);
164
165 template<class DataType, enum cudaTextureReadMode readMode>
166 Type texCubemapLayeredLod(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, int layer, float level);
167
168 template<class DataType, enum cudaTextureReadMode readMode>
169 Type tex2Dgather(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, int comp = 0);

? 表面内存读写函数

  1 /****************************************************************/
  2
  3 // Surface Object API
  4
  5 /****************************************************************/
  6
  7 template<class T>
  8 T surf1Dread(cudaSurfaceObject_t surfObj, int x, boundaryMode = cudaBoundaryModeTrap);
  9     // 一维表面读取
 10
 11 template<class T>
 12 void surf1Dwrite(T data, cudaSurfaceObject_t surfObj, int x, boundaryMode = cudaBoundaryModeTrap);
 13     // 一维表面写入
 14
 15 template<class T>
 16 T surf2Dread(cudaSurfaceObject_t surfObj, int x, int y, boundaryMode = cudaBoundaryModeTrap);
 17     // 二维表面读取
 18 template<class T>
 19 void surf2Dread(T* data, cudaSurfaceObject_t surfObj, int x, int y, boundaryMode = cudaBoundaryModeTrap);
 20     // 二维表面读取
 21
 22 template<class T>
 23 void surf2Dwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, boundaryMode = cudaBoundaryModeTrap);
 24     // 二维表面写入
 25
 26 template<class T>
 27 T surf3Dread(cudaSurfaceObject_t surfObj, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
 28     // 三维表面读取
 29
 30 template<class T>
 31 void surf3Dread(T* data, cudaSurfaceObject_t surfObj, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
 32     // 三维表面读取
 33
 34 template<class T>
 35 void surf3Dwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
 36     // 三维表面写入
 37
 38 template<class T>
 39 T surf1DLayeredread(cudaSurfaceObject_t surfObj, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
 40     // 一维分层表面读取
 41
 42 template<class T>
 43 void surf1DLayeredread(T data, cudaSurfaceObject_t surfObj, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
 44     // 一维分层表面读取
 45
 46 template<class Type>
 47 void surf1DLayeredwrite(T data, cudaSurfaceObject_t surfObj, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
 48     // 一维分层表面写入
 49
 50 template<class T>
 51 T surf2DLayeredread(cudaSurfaceObject_t surfObj, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
 52     // 二维分层表面读取
 53
 54 template<class T>
 55 void surf2DLayeredread(T data, cudaSurfaceObject_t surfObj, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
 56     // 二维分层表面读取
 57 template<class T>
 58 void surf2DLayeredwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
 59     // 二维分层表面写入
 60
 61 template<class T>
 62 T surfCubemapread(cudaSurfaceObject_t surfObj, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
 63     // 立方体贴图表面读取
 64
 65 template<class T>
 66 void surfCubemapread(T data, cudaSurfaceObject_t surfObj, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
 67     // 立方体贴图表面读取
 68
 69 template<class T>
 70 void surfCubemapwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
 71     // 立方体贴图表面写入
 72
 73 template<class T>
 74 T surfCubemapLayeredread(cudaSurfaceObject_t surfObj, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
 75     // 立方体分层贴图表面读取
 76
 77 template<class T>
 78 void surfCubemapLayeredread(T data, cudaSurfaceObject_t surfObj, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
 79     // 立方体分层贴图表面读取
 80
 81 template<class T>
 82 void surfCubemapLayeredwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
 83     // 立方体分层贴图表面写入
 84
 85 /****************************************************************/
 86
 87 // Surface Refernence API
 88
 89 /****************************************************************/
 90
 91 // 函数名类似 Texture Object API
 92 template<class Type>
 93 Type surf1Dread(surface<void, cudaSurfaceType1D> surfRef, int x, boundaryMode = cudaBoundaryModeTrap);
 94
 95 template<class Type>
 96 void surf1Dread(Type data, surface<void, cudaSurfaceType1D> surfRef, int x, boundaryMode = cudaBoundaryModeTrap);
 97
 98 template<class Type>
 99 void surf1Dwrite(Type data, surface<void, cudaSurfaceType1D> surfRef, int x, boundaryMode = cudaBoundaryModeTrap);
100
101 template<class Type>
102 Type surf2Dread(surface<void, cudaSurfaceType2D> surfRef, int x, int y, boundaryMode = cudaBoundaryModeTrap);
103
104 template<class Type>
105 void surf2Dread(Type* data, surface<void, cudaSurfaceType2D> surfRef, int x, int y, boundaryMode = cudaBoundaryModeTrap);
106
107 template<class Type>
108 void surf3Dwrite(Type data, surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
109
110 template<class Type>
111 Type surf3Dread(surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
112
113 template<class Type>
114 void surf3Dread(Type* data, surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
115
116 template<class Type>
117 void surf3Dwrite(Type data, surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
118
119 template<class Type>
120 Type surf1DLayeredread(surface<void, cudaSurfaceType1DLayered> surfRef, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
121
122 template<class Type>
123 void surf1DLayeredread(Type data, surface<void, cudaSurfaceType1DLayered> surfRef, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
124
125 template<class Type>
126 void surf1DLayeredwrite(Type data, surface<void, cudaSurfaceType1DLayered> surfRef, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
127
128 template<class Type>
129 Type surf2DLayeredread(surface<void, cudaSurfaceType2DLayered> surfRef, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
130
131 template<class Type>
132 void surf2DLayeredread(Type data, surface<void, cudaSurfaceType2DLayered> surfRef, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
133
134 template<class Type>
135 void surf2DLayeredwrite(Type data, surface<void, cudaSurfaceType2DLayered> surfRef, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
136
137 template<class Type>
138 Type surfCubemapread(surface<void, cudaSurfaceTypeCubemap> surfRef, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
139
140 template<class Type>
141 void surfCubemapread(Type data, surface<void, cudaSurfaceTypeCubemap> surfRef, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
142
143 template<class Type>
144 void surfCubemapwrite(Type data, surface<void, cudaSurfaceTypeCubemap> surfRef, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
145
146 template<class Type>
147 Type surfCubemapLayeredread(surface<void, cudaSurfaceTypeCubemapLayered> surfRef, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
148
149 template<class Type>
150 void surfCubemapLayeredread(Type data, surface<void, cudaSurfaceTypeCubemapLayered> surfRef, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
151
152 template<class Type>
153 void surfCubemapLayeredwrite(Type data, surface<void, cudaSurfaceTypeCubemapLayered> surfRef, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
时间: 2024-08-26 01:19:18

CUDA C Programming Guide 在线教程学习笔记 Part 6的相关文章

CUDA C Programming Guide 在线教程学习笔记 Part 2

? 纹理内存使用 ● 纹理内存使用有两套 API,称为 Object API 和 Reference API .纹理对象(texture object)在运行时被 Object API 创建,同时指定了纹理单元.纹理引用(Tezture Reference)在编译时被 Reference API 创建,但是在运行时才指定纹理单元,并将纹理引用绑定到纹理单元上面去. ● 不同的纹理引用可能绑定到相同或内存上有重叠的的纹理单元上,纹理单元可能是 CUDA 线性内存或CUDA array 的任意部分.

CUDA C Programming Guide 在线教程学习笔记 Part 5

附录 A,CUDA计算设备 附录 B,C语言扩展 ? 函数的标识符 ● __device__,__global__ 和 __host__ ● 宏 __CUDA_ARCH__ 可用于区分代码的运行位置. 1 __host__ __device__ void fun() 2 { 3 # if __CUDA_ARCH__ >=600 4 // 代码运行于计算能力 6.x 设备 5 #elif __CUDA_ARCH__ >= 500 6 // 代码运行于计算能力 5.x 设备 7 #elif __C

CUDA C Programming Guide 在线教程学习笔记 Part 3

? 表面内存使用 ● 创建 cuda 数组时使用标志 cudaArraySurfaceLoadStore 来创建表面内存,可以用表面对象(surface object)或表面引用(surface reference)来对其进行读写. ● 使用 Surface Object API ■ 涉及的结构定义.接口函数. 1 // vector_types.h 2 struct __device_builtin__ __align__(4) uchar4 3 { 4 unsigned char x, y,

CUDA C Best Practices Guide 在线教程学习笔记 Part 1

0. APOD过程 ● 评估.分析代码运行时间的组成,对瓶颈进行并行化设计.了解需求和约束条件,确定应用程序的加速性能改善的上限. ● 并行化.根据原来的代码,采用一些手段进行并行化,例如使用现有库,或加入一些预处理指令等.同时需要代码重构来暴露它们固有的并行性. ● 优化.并行化完成后,需要通过优化来提高性能.优化可以应用于各个级别,从数据传输到计算到浮点操作序列的微调.分析工具对这一过程非常有用,可以建议开发人员优化工作的下一个策略. ● 部署.将结果与原始期望进行比较.回想一下,初始评估步

廖雪峰Git教程学习笔记

廖雪峰git简单教程学习笔记 教程地址:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b0001.可以这样设计目录,在d:\reposisoty\ 在这个目录下面有很多的仓库.mkdir learngitcd learngit>>git init          #这样就把learngit 初始化成了一个仓库>>git status        #说明当前仓库的状态并

[简明python教程]学习笔记之编写简单备份脚本

[[email protected] 0503]# cat backup_ver3.py #!/usr/bin/python #filename:backup_ver3.py import os import time #source source=['/root/a.sh','/root/b.sh','/root/c.sh'] #source='/root/c.sh' #backup dir target_dir='/tmp/' today=target_dir+time.strftime('

[简明python教程]学习笔记2014-05-05

今天学习了python的输入输出.异常处理和python标准库 1.文件 通过创建一个file类的对象去处理文件,方法有read.readline.write.close等 [[email protected] 0505]# cat using_file.py #!/usr/bin/python #filename:using_file.py poem='''Programing is fun when the work is done use Python! ''' f=file('poem.

Webpack新手入门教程(学习笔记)

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; text-align: center; font: 30.0px Helvetica; color: #000000 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px "PingFang TC Semibold"; color: #000000 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0

SQL语句教程学习笔记之一

转自http://www.1keydata.com/cn/sql/ 无论您是一位 SQL 的新手,或是一位只是需要对 SQL 复习一下的资料仓储业界老将, 您就来对地方了.这个 SQL 教材网站列出常用的 SQL 指令.包含以下几个部分: SQL 指令: SQL 如何被用来储存.读取.以及处理数据库之中的资料. 表格处理: SQL 如何被用来处理数据库中的表格. SQL语法: 这一页列出所有在这个教材中被提到的 SQL 语法. 对于每一个指令,我们将会先列出及解释这个指令的语法,然后我们会用一个