NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

Contents
1 RuntimeApiReference 1.1 DeviceManagement RT 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

cudaGetDeviceCount

cudaSetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDeviceProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaChooseDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ThreadManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 1.2.2 cudaThreadSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaThreadExit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.3

StreamManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 1.3.2 1.3.3 1.3.4 cudaStreamCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.4

EventManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 cudaEventCreate cudaEventRecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventElapsedTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

cudaMalloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMallocArray

cudaFreeArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFreeHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMemset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMemset2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

i

1.5.10 cudaMemcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.11 cudaMemcpy2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34 35 36 37 38 39 40 41 42 43 44 45 46 48 50 52 54 55 63 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

1.5.12 cudaMemcpyToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.13 cudaMemcpy2DToArray 1.5.14 cudaMemcpyFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.15 cudaMemcpy2DFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.16 cudaMemcpyArrayToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.17 cudaMemcpy2DArrayToArray 1.5.18 cudaMemcpyToSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.19 cudaMemcpyFromSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.20 cudaGetSymbolAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.21 cudaGetSymbolSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.22 cudaMalloc3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.23 cudaMalloc3DArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.24 cudaMemset3D 1.5.25 cudaMemcpy3D 1.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

TextureReferenceManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6.1 1.6.2 LowLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HighLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

cudaConfigureCall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaLaunch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaSetupArgument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.8

OpenGlInteroperability RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 cudaGLSetGLDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLRegisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLMapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLUnmapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLUnregisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

cudaD3D9SetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9GetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9RegisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

84 85 86 87 89 90 91 92 94 95 97 98 99

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9UnmapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceSetMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceGetSurfaceDimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

. . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.12 cudaD3D9ResourceGetMappedPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10 ErrorHandling RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.1 cudaGetLastError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.2 cudaGetErrorString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 DriverApiReference 2.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 2.2

cuInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

cuDeviceGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 cuDeviceGetAttribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 cuDeviceGetCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 cuDeviceGetName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 cuDeviceGetProperties cuDeviceTotalMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

cuCtxAttach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 cuCtxCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 cuCtxDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

cuCtxDetach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 cuCtxGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 cuCtxPopCurrent cuCtxPushCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

cuCtxSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

2.4

ModuleManagement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 2.4.1 cuModuleGetFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

iii

.7 2. . . . . . . . . . . . . . . .3 2. . . . . . . 152 cuArray3DCreate cuArrayDestroy . . . 142 cuLaunchGrid cuParamSetSize . . . . . . . . . . . . . . . . . . . .7. . . . . . . . . . . .7. . . . . . . . . . . . . . . . . 157 cuArray3DGetDescriptor . . .7. . . . . . . . . . . . . 139 cuEventSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 2. . . . . . . .1 2. . . . . . . . . . . . . . . . . . . . . . . . 125 cuModuleLoadData . . . . . . . . . . . .5 2. . . . . . . . .6. . . .6 cuEventCreate . .4. . . . . . . .7. . .7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 cuArrayGetDescriptor . . 126 cuModuleLoadFatBinary . . . . . . . . . . 133 cuStreamSynchronize 2. . . . . .7. . . . . . . 158 iv . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . .2 2. . . . . . . . . . . . . . .8. . . 151 cuArrayCreate . . . . . . . . . . . . .2 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 . . . . . . . . . 138 cuEventRecord . . . . . . . . . . . . . . .3 2. . . . . . . . . . 143 . . . . . . . . . . . . . . . . .4 2. . . . . . . . . . . . . . . . . . . . . . . . . .9 cuLaunch . . . . . .5. . . . . . . . . .5 . . . 154 . . 150 2. .3 2. . . 124 cuModuleLoad . 132 . . . . . .6. .7. . 127 cuModuleUnload . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . 149 cuFuncSetSharedSize . .6 2. . . . . 131 . . . . . . . . . . . . . . . . . . . . . . . 135 cuEventDestroy . . . . . . . . . . . . . .8. . . 144 . . . . . . . . . . . . . . . .4. . . . . .5 cuModuleGetGlobal . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . 123 cuModuleGetTexRef . . . . . . . . . .5 2. . . . . . . . . . . . . . . . . . . . . . . . .7. . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 EventManagement . . . . . . . . . . . . . . . . .5 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 2.8 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 2. . . . . . . . . .6 2.2. . . . . . . . . . . . . . . . .8. . . . . . . .4 cuStreamCreate cuStreamDestroy cuStreamQuery . . . . . . . . . . 140 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 2. 134 2. . . . 146 cuParamSeti . . . . . . . . . . . . . . . . . . . 145 cuParamSetTexRef cuParamSetf . . . . . . . . . . . 137 cuEventElapsedTime cuEventQuery . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . .5. . . . . . .1 2.7 ExecutionControl 2. . . . . . . . . . . . . . . . . . . . . 136 . . . . . 148 cuFuncSetBlockShape . . . . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 2. . . . . . . . . . . . . . . . . . . .8. . . . . . . . . . . . . 147 cuParamSetv .8. .1 2. . . . . . . . . .6. .2 2. . . . . . . . . . . . . . . . . . . . . . . . . 128 StreamManagement . . . . . . . . . . . . 129 2. . . . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 2. . .7. . . . . . . . . . . . . . . . . . . . . . . . . . . .8 MemoryManagement 2. . . . . . . . . . . 141 2. . . . . . . . . . . .4. . . . .2 2. . . . . . . . . . . . . . . . . . . . . . . . . .3 2. . . . . . .4. . .

. . . . . . . . . . . . .8. 189 cuTexRefGetFilterMode cuTexRefGetFlags . . . .9. . . . . . . . . . . 190 cuTexRefGetFormat . . . . . . . . . . . . . . . . . . . . . . . . . . .13 cuMemcpy2D 2. . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . .8. . . . . . . . 159 . . . . . . . . . . . . . . .8. . . . . . . . . . . .2 2. . . . .9. . . 178 2. . . . . .9 TextureReferenceManagement 2. . . . . . . . . .15 cuMemcpyAtoA . . . . . 191 cuTexRefSetAddress . . . .9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 2. . . . . . . . . . . . .6 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 . . . . .8. . . . . . 187 cuTexRefGetAddress cuTexRefGetAddressMode cuTexRefGetArray . . . . . 166 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 cuTexRefSetFormat . . . . . . . . . . . . . . . . . . . . . . . .8. . . 188 . . . . . . . . . . . . . . . . . . . . . . 179 2. . .23 cuMemset . . . . . . . . . . . . . . . . . . . . .18 cuMemcpyDtoA . . . . . . . . . . . . . . . . . . . . . . . . . . . .9. . . . .10 cuMemFreeHost . . . . . . . . . . . .8.14 cuMemcpy3D . . . . . . . . . . . . . . . . . . . 170 2. . . . . . . . . . . . .9. . . . . . . . . . . . . . . . . . . .9. 165 2. . . .8 2. . . .8. 174 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 2. . . . . . . .7 2. . . . . . . . . . . . . . . . .3 2. 180 2. . . . .13 cuTexRefSetFlags . . . . . . . . . 163 2. . . . . . . . . . . . . . . . . .10 cuTexRefSetAddressMode 2. . . . . . . . . .9. . . . . . . . .20 cuMemcpyDtoH . . . . . . . .9. . . . . .8. . . . . . . . . . . .7 2. . . . . . . . .8. . . . . . . . . . . . 175 2. . . . . . . .9. . . . . . . . . . . . . . 177 2. . . . . 161 cuMemAllocHost cuMemAllocPitch cuMemFree . . . . . . . . . . . . . . . . . . . 184 .17 cuMemcpyAtoH .9. . . . . . . . 195 2. . . . . .9. . . . . . . . . .8. . . . . . . . . . . . . . . . . . . . 183 . . . . . . . . . . . . .8 2. . .8. . . . . . . . . . .8. . . . 181 2. . . . . .8. . . . . . . . . . . . . 197 v . . . . . . . 185 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8.22 cuMemcpyHtoD . . . . . . . . . . . . . . . . . 176 2. . . . . . . . . .8. .24 cuMemset2D . . . . . . . . . . . . . . . . . . . . . . . . . .11 cuMemGetAddressRange . . 194 2. . . . . . . . . . . . . . . . . . . .8. .19 cuMemcpyDtoD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 . . . . 160 . . . . . . . . . . . . . . . . . . . .21 cuMemcpyHtoA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 2. . . . . . . . . . . . . . . . . . . . 164 2. . . . . . . . . . . . . . . . . . . . . . . . . . . 196 2. . . . . . . . . . . . . . . . . . . . . . . .12 cuMemGetInfo . . . . . . . . . . . . . . . . . .12 cuTexRefSetFilterMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8. .9. . . . . . . . . .9 cuMemAlloc . . . . . 173 2. . . . . . . . .8. . . . . . . . . .9. . . . 182 2. . . . . . . . . . . . .8. . .9 cuTexRefCreate cuTexRefDestroy . . . .16 cuMemcpyAtoD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 2. . . . . . . . . . . . .4 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9. . . . . . . . . . . . . . . . . . . . . . . 167 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 cuTexRefSetArray . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . .1 3. . . . . . . . . . . . . . . . . .4 3. . . . 206 2. . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11. . . . . . . . .10. . . . . .10. . . . . . 198 2. . . . . . . . . . . . . . . . .11.2 3. . .11 Direct3dInteroperability . . . . . . . . . .3 3. . . . . 226 . .10 OpenGlInteroperability . . . . . . . . . . .11. . . .1 cuD3D9GetDevice . . . . . . 219 2. . . . . . . . . .7 3. . . . . . . . . . . . . . . . . . . . .1 222 ArithmeticFunctions . . . . . . . . . 217 2. . . . . . . . 231 3. . . . . . . . . . . . . .10. . . . . . . . . . . .11. . . . . . . . . . . . . . . .12 cuD3D9ResourceGetMappedPitch . . . . . . . . . . . .2. . . . . . . . . . . . . . 205 2. . . . . . .11. . . . . . . . . . . . . . 225 . . . . . . . . . . . . 209 2. . . . . . 207 2. . .9 cuD3D9ResourceGetSurfaceDimensions . . . . . .1. . . . . . 220 3 AtomicFunctions 3. . . . . . . . . . .2 atomicAnd . . . . . .11. . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . .11. . . . . . .7 cuD3D9UnmapResources . . . . . . . . . . . . . . . . . . . . . . . . . 224 atomicSub atomicExch atomicMin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10. . . . . . . . . . . . . . . . 204 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . 201 . . . . . . . . . . 211 2. . . . . 234 vi . . . .11. . . . . . . . . . . . . . . . . . . . . . . . . . . .10. . . . . . . . . .10. . . . . . . . . . . . . . . .2 BitwiseFunctions . . . . . . . . . 202 2. . . . . . . . . . . . . . . . .2 cuGLInit . . . . . 228 atomicInc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 cuGLMapBufferObject . . . . . . .6 cuGLUnregisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . .2 cuD3D9CtxCreate .10 cuD3D9ResourceGetMappedPointer . .8 atomicAdd . . . .8 cuD3D9ResourceSetMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . .6 cuD3D9MapResources . . . .1. . . . . . . . . . . . . . . . . . . . 214 2.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 cuD3D9UnregisterResource . . . . . . . . . . . 229 atomicDec . . . . . . . . . . . .3 cuD3D9GetDirect3DDevice . . . . . . . . . . . . . . . 227 atomicMax . . . . . . . . . . . . . . . . . . . . . . .11. . . . . . . . . . . . . . . .1. . . . . 230 atomicCAS . . . . . . . . .1. . . . . . . . . . . . . . . . . .1. . 212 2. . . . . . . . .4 cuD3D9RegisterResource . . . . . . . . . . . . . . . . . . . . . . . 203 2. . . 213 2. . . . . . . . . . . . . . . . . . . . . . . . .5 cuGLUnmapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 atomicOr . . 208 2. . . . . . . 223 3. . . . . . . . . . . . . . . . . . . . . .1 3. . . . 200 2. . . . .11. . . . . .11. .11. . . . . . . . . . . . 199 2. . . . . . . . . . . . . 216 2. . 232 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 cuGLRegisterBufferObject 2. . . . . . . . .1 cuGLCtxCreate . . . . . . . .5 3. . . . . . . . . . . .6 3. . . . . . . .11 cuD3D9ResourceGetMappedSize . . . . . . . . . . . .

. . . . .2.3. . . . . . . . . . . . . . . 235 vii . . . . . . . . . . . . . . . . . . . .3 atomicXor . . . .

Error Handling 1 . OpenGL Interoperability. Thread Management. Stream Management.1 RuntimeApiReference NAME Runtime API Reference DESCRIPTION There are two levels for the runtime API. The high-level API (cuda_runtime. These wrappers can be used from C++ code and can be compiled with any C++ compiler. SEE ALSO Device Management. It wraps some of the low level API routines. textures. Memory Management. and device functions. Texture Reference Management. using overloading. Execution Management. Direct3D Interoperability. references and default arguments. The low-level API (cuda_runtime_api. These wrappers require the use of nvcc because they depend on code being generated by the compiler. For example.h) is a C++-style interface built on top of the low-level API.h) is a C-style interface that does not require compiling with nvcc. the execution configuration syntax to invoke kernels is only available in source code compiled with nvcc. Event Management. The high-level API also has some CUDA-specific wrappers that wrap low-level routines that deal with symbols.

Memory Management. Execution Management. Thread Management. cudaGetDeviceCount cudaSetDevice cudaGetDevice cudaGetDeviceProperties cudaChooseDevice SEE ALSO Device Management. Error Handling 2 . OpenGL Interoperability. Event Management.1. Texture Reference Management.1 DeviceManagement RT NAME Device Management DESCRIPTION This section describes the CUDA runtime application programming interface. Stream Management. Direct3D Interoperability.

Since this device will be able to emulate all hardware features. cudaGetDeviceProperties. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. SEE ALSO cudaGetDevice. cudaChooseDevice 3 .1.0 that are available for execution. asynchronous launches.1. If there is no such device. cudaGetDeviceCount() returns 1 and device 0 only supports device emulation mode.returns the number of compute-capable devices SYNOPSIS cudaError_t cudaGetDeviceCount( int* count ) DESCRIPTION Returns in *count the number of devices with compute capability greater or equal to 1. this device will report major and minor compute capability versions of 9999.1 cudaGetDeviceCount NAME cudaGetDeviceCount . cudaSetDevice.

2 cudaSetDevice NAME cudaSetDevice .1.sets device to be used for GPU executions SYNOPSIS cudaError_t cudaSetDevice( int dev ) DESCRIPTION Records dev as the device on which the active host thread executes the device code.1. cudaChooseDevice 4 . asynchronous launches. SEE ALSO cudaGetDeviceCount. cudaGetDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevice Note that this function may also return error codes from previous. cudaGetDeviceProperties.

returns which device is currently being used SYNOPSIS cudaError_t cudaGetDevice( int* dev ) DESCRIPTION Returns in *dev the device on which the active host thread executes the device code. asynchronous launches.1. cudaGetDeviceProperties.3 cudaGetDevice NAME cudaGetDevice . SEE ALSO cudaGetDeviceCount.1. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. cudaChooseDevice 5 . cudaSetDevice.

sharedMemPerBlock is the maximum amount of shared memory available to a thread block in bytes. int minor. warpSize is the warp size in threads.1. int warpSize. int dev ) DESCRIPTION Returns in *prop the properties of device dev. this amount is shared by all thread blocks simultaneously resident on a multiprocessor. size_t totalGlobalMem. this number is shared by all thread blocks simultaneously resident on a multiprocessor. totalGlobalMem is the total amount of global memory available on the device in bytes. size_t sharedMemPerBlock. int maxThreadsPerBlock. int regsPerBlock. int major. int clockRate. size_t memPitch. int maxGridSize[3]. 6 .returns information on the compute-device SYNOPSIS cudaError_t cudaGetDeviceProperties( struct cudaDeviceProp* prop. regsPerBlock is the maximum number of 32-bit registers available to a thread block. size_t totalConstMem. } where: name is an ASCII string identifying the device. The cudaDeviceProp structure is defined as: struct cudaDeviceProp { char name[256]. int maxThreadsDim[3].1. int deviceOverlap.4 cudaGetDeviceProperties NAME cudaGetDeviceProperties . size_t textureAlignment. int multiProcessorCount.

multiProcessorCount is the number of multiprocessors on the device. maxThreadsPerBlock is the maximum number of threads per block. maxThreadsDim[3] is the maximum sizes of each dimension of a block. maxGridSize[3] is the maximum sizes of each dimension of a grid. or 0 if not. cudaGetDevice. minor are the major and minor revision numbers defining the device’s compute capability. totalConstMem is the total amount of constant memory available on the device in bytes. clockRate is the clock frequency in kilohertz. major. SEE ALSO cudaGetDeviceCount. deviceOverlap is 1 if the device can concurrently copy memory between host and device while executing a kernel.memPitch is the maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through cudaMallocPitch(). texture base addresses that are aligned to textureAlignment bytes do not need an offset applied to texture fetches. asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevice Note that this function may also return error codes from previous. textureAlignment is the alignment requirement. cudaChooseDevice 7 . cudaSetDevice.

5 cudaChooseDevice NAME cudaChooseDevice .select compute-device which best matches criteria SYNOPSIS cudaError_t cudaChooseDevice( int* dev. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue Note that this function may also return error codes from previous. const struct cudaDeviceProp* prop ) DESCRIPTION Returns in *dev the device which properties best match *prop.1. SEE ALSO cudaGetDeviceCount. cudaGetDevice.1. cudaGetDeviceProperties 8 . cudaSetDevice. asynchronous launches.

Texture Reference Management. cudaThreadSynchronize cudaThreadExit SEE ALSO Device Management.2 ThreadManagement RT NAME Thread Management DESCRIPTION This section describes the CUDA runtime application programming interface.1. Event Management. Error Handling 9 . Memory Management. Direct3D Interoperability. Stream Management. Execution Management. Thread Management. OpenGL Interoperability.

asynchronous launches.wait for compute-device to finish SYNOPSIS cudaError_t cudaThreadSynchronize(void) DESCRIPTION Blocks until the device has completed all preceding requested tasks. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.2. cudaThreadSynchronize() returns an error if one of the preceding tasks failed.1 cudaThreadSynchronize NAME cudaThreadSynchronize . SEE ALSO cudaThreadExit 10 .1.

2.1. asynchronous launches.exit and clean-up from CUDA launches SYNOPSIS cudaError_t cudaThreadExit(void) DESCRIPTION Explicitly cleans up all runtime-related resources associated with the calling host thread. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.2 cudaThreadExit NAME cudaThreadExit . Any subsequent API call reinitializes the runtime. SEE ALSO cudaThreadSynchronize 11 . cudaThreadExit() is implicitly called on host thread exit.

Execution Management.1.3 StreamManagement RT NAME Stream Management DESCRIPTION This section describes the CUDA runtime application programming interface. Error Handling 12 . cudaStreamCreate cudaStreamQuery cudaStreamSynchronize cudaStreamDestroy SEE ALSO Device Management. Thread Management. Stream Management. Event Management. Memory Management. Direct3D Interoperability. Texture Reference Management. OpenGL Interoperability.

3. asynchronous launches. cudaStreamDestroy 13 .1.1 cudaStreamCreate NAME cudaStreamCreate .create an async stream SYNOPSIS cudaError_t cudaStreamCreate( cudaStream_t* stream ) DESCRIPTION Creates a stream. cudaStreamSynchronize. SEE ALSO cudaStreamQuery. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue Note that this function may also return error codes from previous.

cudaStreamSynchronize 14 .3. asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess cudaErrorNotReady cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous.1.2 cudaStreamQuery NAME cudaStreamQuery . or cudaErrorNotReady if not. SEE ALSO cudaStreamCreate.queries a stream for completion-status SYNOPSIS cudaError_t cudaStreamQuery(cudaStream_t stream) DESCRIPTION Returns cudaSuccess if all operations in the stream have completed. cudaStreamDestroy.

asynchronous launches.waits for stream tasks to complete SYNOPSIS cudaError_t cudaStreamSynchronize( cudaStream_t stream ) DESCRIPTION Blocks until the device has completed all operations in the stream. cudaStreamDestroy.3 cudaStreamSynchronize NAME cudaStreamSynchronize . cudaStreamQuery 15 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous.3. SEE ALSO cudaStreamCreate.1.

cudaStreamDestroy 16 .destroys and cleans-up a stream object SYNOPSIS cudaError_t cudaStreamDestroy( cudaStream_t stream ) DESCRIPTION Destroys a stream object. asynchronous launches.4 cudaStreamDestroy NAME cudaStreamDestroy . SEE ALSO cudaStreamCreate. cudaStreamSychronize.1.3. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous.

Thread Management. Memory Management. OpenGL Interoperability. Event Management. Direct3D Interoperability. Error Handling 17 . Execution Management.4 EventManagement RT NAME Event Management DESCRIPTION This section describes the CUDA runtime application programming interface.1. Texture Reference Management. Stream Management. cudaEventCreate cudaEventRecord cudaEventQuery cudaEventSynchronize cudaEventDestroy cudaEventElapsedTime SEE ALSO Device Management.

cudaEventDestroy. cudaEventQuery. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorMemoryAllocation Note that this function may also return error codes from previous.creates an event-object SYNOPSIS cudaError_t cudaEventCreate( cudaEvent_t* event ) DESCRIPTION Creates an event object. SEE ALSO cudaEventRecord.1 cudaEventCreate NAME cudaEventCreate .1.4. cudaEventSynchronzie. asynchronous launches. cudaEventElapsedTime 18 .

it is recorded after all preceding operations in the CUDA context have been completed. the event is recorded after all preceding operations in the stream have been completed. cudaEventElapsedTime 19 . otherwise.1.2 cudaEventRecord NAME cudaEventRecord . this function returns cudaErrorInvalidValue. cudaEventDestroy.records an event SYNOPSIS cudaError_t cudaEventRecord( cudaEvent_t event. If cudaEventRecord() has previously been called and the event has not been recorded yet. If stream is non-zero. cudaEventQuery. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous.4. CUstream stream ) DESCRIPTION Records an event. cudaEventQuery() and/or cudaEventSynchronize() must be used to determine when the event has actually been recorded. Since this operation is asynchronous. asynchronous launches. cudaEventSynchronize. SEE ALSO cudaEventCreate.

SEE ALSO cudaEventCreate. If cudaEventRecord() has not been called on this event.3 cudaEventQuery NAME cudaEventQuery .1. cudaEventRecord.4. RETURN VALUE Relevant return values: cudaSuccess cudaErrorNotReady cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. the function returns cudaErrorInvalidValue. cudaEventElapsedTime 20 . or cudaErrorNotReady if not. cudaEventSynchronize. asynchronous launches. cudaEventDestroy.query if an event has been recorded SYNOPSIS cudaError_t cudaEventQuery( cudaEvent_t event ) DESCRIPTION Returns cudaSuccess if the event has actually been recorded.

4. cudaEventRecord. cudaEventQuery. If cudaEventRecord() has not been called on this event.4 cudaEventSynchronize NAME cudaEventSynchronize . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. asynchronous launches. SEE ALSO cudaEventCreate. cudaEventDestroy. cudaEventElapsedTime 21 .wait for an event to be recorded SYNOPSIS cudaError_t cudaEventSynchronize( cudaEvent_t event ) DESCRIPTION Blocks until the event has actually been recorded.1. the function returns cudaErrorInvalidValue.

cudaEventSynchronize.1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue Note that this function may also return error codes from previous.5 cudaEventDestroy NAME cudaEventDestroy . cudaEventQuery.4. cudaEventElapsedTime 22 . asynchronous launches. cudaEventRecord. SEE ALSO cudaEventCreate.destroys an event-object SYNOPSIS cudaError_t cudaEventDestroy( cudaEvent_t event ) DESCRIPTION Destroys the event-object.

cudaEvent_t end ). this function returns cudaErrorInvalidValue.1.6 cudaEventElapsedTime NAME cudaEventElapsedTime . DESCRIPTION Computes the elapsed time between two events (in milliseconds with a resolution of around 0. asynchronous launches. cudaEventSynchronize.4. If either event has not been recorded yet. If either event has been recorded with a non-zero stream. the result is undefined. cudaEventQuery. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. cudaEventRecord 23 . SEE ALSO cudaEventCreate. cudaEvent_t start.5 microseconds). cudaEventDestroy.computes the elapsed time between events SYNOPSIS cudaError_t cudaEventElapsedTime( float* time.

Texture Reference Management. cudaMalloc cudaMallocPitch cudaFree cudaMallocArray cudaFreeArray cudaMallocHost cudaFreeHost cudaMemset cudaMemset2D cudaMemcpy cudaMemcpy2D cudaMemcpyToArray cudaMemcpy2DToArray cudaMemcpyFromArray cudaMemcpy2DFromArray cudaMemcpyArrayToArray cudaMemcpy2DArrayToArray cudaMemcpyToSymbol cudaMemcpyFromSymbol cudaGetSymbolAddress cudaGetSymbolSize SEE ALSO Device Management. Error Handling 24 . Stream Management. Thread Management.5 MemoryManagement RT NAME Memory Management DESCRIPTION This section describes the CUDA runtime application programming interface. Direct3D Interoperability. Event Management. Execution Management. OpenGL Interoperability.1. Memory Management.

cudaMallocArray. cudaMallocHost. SEE ALSO cudaMallocPitch. cudaFreeArray. cudaFreeHost 25 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. cudaMalloc() returns cudaErrorMemoryAllocation in case of failure. cudaFree. The allocated memory is suitably aligned for any kind of variable.allocate memory on the GPU SYNOPSIS cudaError_t cudaMalloc( void** devPtr.5. size_t count ) DESCRIPTION Allocates count bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The memory is not cleared.1 cudaMalloc NAME cudaMalloc .1. asynchronous launches.

cudaFreeArray. cudaMallocHost. size_t height ) DESCRIPTION Allocates at least widthInBytes*height bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. asynchronous launches. cudaFreeHost 26 . used to compute addresses within the 2D array.allocates memory on the GPU SYNOPSIS cudaError_t cudaMallocPitch( void** devPtr.1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. Given the row and column of an array element of type T. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The intended usage of pitch is as a separate parameter of the allocation. For allocations of 2D arrays. cudaFree. SEE ALSO cudaMalloc. the address is computed as T* pElement = (T*)((char*)BaseAddress + Row * pitch) + Column.5.2 cudaMallocPitch NAME cudaMallocPitch . cudaMallocArray. size_t widthInBytes. this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or CUDA arrays). size_t* pitch. Due to pitch alignment restrictions in the hardware. The pitch returned in *pitch by cudaMallocPitch() is the width in bytes of the allocation. it is recommended that programmers consider performing pitch allocations using cudaMallocPitch().

If devPtr is 0. an error is returned. no operation is performed.frees memory on the GPU SYNOPSIS cudaError_t cudaFree(void* devPtr) DESCRIPTION Frees the memory space pointed to by devPtr.5. SEE ALSO cudaMalloc. cudaFreeHost 27 . which must have been returned by a previous call to cudaMalloc() or cudaMallocPitch().3 cudaFree NAME cudaFree . Otherwise. cudaFree() returns cudaErrorInvalidDevicePointer in case of failure. or if cudaFree(devPtr) has already been called before. asynchronous launches.1. cudaFreeArray. cudaMallocArray. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevicePointer cudaErrorInitializationError Note that this function may also return error codes from previous. cudaMallocPitch. cudaMallocHost.

y. cudaMallocPitch. cudaChannelFormatKindFloat. size_t width. SEE ALSO cudaMalloc. cudaChannelFormatKindUnsigned.5. cudaMallocHost.allocate an array on the GPU SYNOPSIS cudaError_t cudaMallocArray( struct cudaArray** array. cudaFree. size_t height ) DESCRIPTION Allocates a CUDA array according to the cudaChannelFormatDesc structure desc and returns a handle to the new CUDA array in *array. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. z. }. cudaFreeHost 28 .4 cudaMallocArray NAME cudaMallocArray . asynchronous launches.1. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. w. enum cudaChannelFormatKind f. const struct cudaChannelFormatDesc* desc. cudaFreeArray.

1. cudaMallocPitch. cudaFreeHost 29 . SEE ALSO cudaMalloc. asynchronous launches. no operation is performed.5. cudaMallocArray.frees an array on the GPU SYNOPSIS cudaError_t cudaFreeArray( struct cudaArray* array ) DESCRIPTION Frees the CUDA array array. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError Note that this function may also return error codes from previous. If array is 0.5 cudaFreeArray NAME cudaFreeArray . cudaFree. cudaMallocHost.

6 cudaMallocHost NAME cudaMallocHost . size_t size ) DESCRIPTION Allocates size bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as cudaMemcpy*(). it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). asynchronous launches.1. cudaFree. since it reduces the amount of memory available to the system for paging.allocates page-locked memory on the host SYNOPSIS cudaError_t cudaMallocHost( void** hostPtr. As a result. cudaFreeArray. cudaFreeHost 30 . Since the memory can be accessed directly by the device. cudaMallocArray. this function is best used sparingly to allocate staging areas for data exchange between host and device. SEE ALSO cudaMalloc.5. Allocating excessive amounts of memory with cudaMallocHost() may degrade system performance. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. cudaMallocPitch.

which must have been returned by a previous call to cudaMallocHost(). cudaMallocArray. SEE ALSO cudaMalloc.5. cudaMallocPitch.1.frees page-locked memory SYNOPSIS cudaError_t cudaFreeHost( void* hostPtr ) DESCRIPTION Frees the memory space pointed to by hostPtr. cudaMallocHost 31 .7 cudaFreeHost NAME cudaFreeHost . cudaFreeArray. asynchronous launches. cudaFree. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError Note that this function may also return error codes from previous.

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous.5.initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset( void* devPtr.8 cudaMemset NAME cudaMemset . int value. cudaMemset3D 32 . asynchronous launches.1. size_t count ) DESCRIPTION Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value. SEE ALSO cudaMemset2D.

including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by cudaMallocPitch(). size_t width. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous. cudaMemset3D 33 . size_t pitch. asynchronous launches.initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset2D( void* dstPtr. SEE ALSO cudaMemset.1. int value.5.9 cudaMemset2D NAME cudaMemset2D . size_t height ) DESCRIPTION Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. pitch is the width in memory in bytes of the 2D array pointed to by dstPtr.

where kind is one of cudaMemcpyHostToHost. cudaMemcpyToArray. cudaMemcpyArrayToArray. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. const void* src. enum cudaMemcpyKind kind ) cudaError_t cudaMemcpyAsync( void* dst. cudaMemcpy2DFromArray. const void* src.5. asynchronous launches. size_t count. cudaStream_t stream ) DESCRIPTION Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst. cudaMemcpyToSymbol. cudaMemcpy2DArrayToArray. The memory areas may not overlap.copies data between GPU and host SYNOPSIS cudaError_t cudaMemcpy( void* dst. cudaMemcpyDeviceToHost. cudaMemcpyHostToDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. and specifies the direction of the copy. Calling cudaMemcpy() with dst and src pointers that do not match the direction of the copy results in an undefined behavior.1. cudaMemcpyFromArray. enum cudaMemcpyKind kind. SEE ALSO cudaMemcpy2D. cudaMemcpyFromSymbol 34 . cudaMemcpy2DToArray. size_t count. or cudaMemcpyDeviceToDevice.10 cudaMemcpy NAME cudaMemcpy . cudaMemcpyAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument.

cudaStream_t stream ) DESCRIPTION Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area pointed to by dst. cudaMemcpy2DAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. enum cudaMemcpyKind kind. size_t spitch. cudaMemcpy2D() returns an error if dpitch or spitch is greater than the maximum allowed. const void* src. cudaMemcpy2DFromArray. including any padding added to the end of each row. cudaMemcpyArrayToArray. cudaMemcpy2DArrayToArray. The memory areas may not overlap.copies data between host and device SYNOPSIS cudaError_t cudaMemcpy2D( void* dst. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. SEE ALSO cudaMemcpy. cudaMemcpyFromSymbol 35 . enum cudaMemcpyKind kind ) cudaError_t cudaMemcpy2DAsync( void* dst. cudaMemcpyHostToDevice. size_t height. Calling cudaMemcpy2D() with dst and src pointers that do not match the direction of the copy results in an undefined behavior. and specifies the direction of the copy. size_t width. size_t dpitch. where kind is one of cudaMemcpyHostToHost.11 cudaMemcpy2D NAME cudaMemcpy2D . asynchronous launches.5.1. size_t width. size_t height. dpitch and spitch are the widths in memory in bytes of the 2D arrays pointed to by dst and src. cudaMemcpyToSymbol. cudaMemcpy2DToArray. cudaMemcpyToArray. cudaMemcpyFromArray. const void* src. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidPitchValue cudaErrorInvalidDevicePointer cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. size_t dpitch. cudaMemcpyDeviceToHost. or cudaMemcpyDeviceToDevice. size_t spitch.

cudaMemcpyHostToDevice. cudaMemcpyToArrayAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. size_t count.5. enum cudaMemcpyKind kind. size_t dstX. or cudaMemcpyDeviceToDevice. cudaMemcpy2DToArray. cudaMemcpy2DArrayToArray.12 cudaMemcpyToArray NAME cudaMemcpyToArray . cudaMemcpy2D. cudaMemcpyDeviceToHost. asynchronous launches. and specifies the direction of the copy. where kind is one of cudaMemcpyHostToHost. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cudaMemcpyToSymbol. size_t dstY.1. dstY). enum cudaMemcpyKind kind) cudaError_t cudaMemcpyToArrayAsync(struct cudaArray* dstArray. cudaMemcpyFromSymbol 36 . cudaMemcpyArrayToArray. SEE ALSO cudaMemcpy. const void* src. size_t dstX.copies data between host and device SYNOPSIS cudaError_t cudaMemcpyToArray(struct cudaArray* dstArray. cudaStream_t stream) DESCRIPTION Copies count bytes from the memory area pointed to by src to the CUDA array dstArray starting at the upper left corner (dstX. size_t dstY. cudaMemcpy2DFromArray. cudaMemcpyFromArray. size_t count. const void* src.

cudaError_t cudaMemcpy2DToArrayAsync(struct cudaArray* dstArray. dstY). size_t dstY. size_t width. const void* src. cudaMemcpy2DFromArray. size_t width. enum cudaMemcpyKind kind. cudaMemcpyToArray. size_t height. cudaMemcpyFromArray. size_t dstX. spitch is the width in memory in bytes of the 2D array pointed to by src. size_t spitch. cudaMemcpy2DToArrayAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. cudaMemcpy2D. cudaMemcpyFromSymbol 37 . or cudaMemcpyDeviceToDevice. SEE ALSO cudaMemcpy. asynchronous launches. cudaMemcpyDeviceToHost. DESCRIPTION Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the CUDA array dstArray starting at the upper left corner (dstX. size_t spitch. cudaStream_t stream). RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidPitchValue cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. and specifies the direction of the copy.copies data between host and device SYNOPSIS cudaError_t cudaMemcpy2DToArray(struct cudaArray* dstArray.13 cudaMemcpy2DToArray NAME cudaMemcpy2DToArray . cudaMemcpyToSymbol. enum cudaMemcpyKind kind). where kind is one of cudaMemcpyHostToHost. cudaMemcpy2DArrayToArray. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. size_t dstX.5. size_t height. including any padding added to the end of each row. size_t dstY. const void* src. cudaMemcpyHostToDevice. cudaMemcpy2D() returns an error if spitch is greater than the maximum allowed. cudaMemcpyArrayToArray.1.

size_t srcX. and specifies the direction of the copy. size_t srcY.14 cudaMemcpyFromArray NAME cudaMemcpyFromArray . cudaMemcpyHostToDevice. size_t count. enum cudaMemcpyKind kind) cudaError_t cudaMemcpyFromArrayAsync(void* dst. cudaMemcpyFromArrayAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. asynchronous launches. cudaMemcpyToArray. cudaMemcpy2DFromArray. cudaMemcpyDeviceToHost. where kind is one of cudaMemcpyHostToHost. const struct cudaArray* srcArray. or cudaMemcpyDeviceToDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input.1. const struct cudaArray* srcArray.5. cudaMemcpyToSymbol.copies data between host and device SYNOPSIS cudaError_t cudaMemcpyFromArray(void* dst. cudaMemcpyFromSymbol 38 . SEE ALSO cudaMemcpy. size_t srcY. cudaMemcpy2DToArray. cudaMemcpy2D. size_t count. srcY) to the memory area pointed to by dst. cudaStream_t stream) DESCRIPTION Copies count bytes from the CUDA array srcArray starting at the upper left corner (srcX. size_t srcX. cudaMemcpyArrayToArray. enum cudaMemcpyKind kind. cudaMemcpy2DArrayToArray.

cudaMemcpy2D() returns an error if dpitch is greater than the maximum allowed. size_t height.5. cudaMemcpyFromArray. size_t width. size_t width.copies data between host and device SYNOPSIS cudaError_t cudaMemcpy2DFromArray(void* dst. where kind is one of cudaMemcpyHostToHost. cudaMemcpyToSymbol. size_t srcY. size_t srcY. cudaMemcpy2DToArray.1.15 cudaMemcpy2DFromArray NAME cudaMemcpy2DFromArray . asynchronous launches. cudaMemcpyHostToDevice. size_t dpitch. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidPitchValue cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. and specifies the direction of the copy. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cudaMemcpyFromSymbol 39 . cudaMemcpyToArray. cudaMemcpy2D. or cudaMemcpyDeviceToDevice. including any padding added to the end of each row. size_t srcX. cudaMemcpyArrayToArray. enum cudaMemcpyKind kind) cudaError_t cudaMemcpy2DFromArrayAsync(void* dst. SEE ALSO cudaMemcpy. cudaMemcpy2DArrayToArray. size_t dpitch. size_t height. const struct cudaArray* srcArray. cudaMemcpy2DFromArrayAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. srcY) to the memory area pointed to by dst. cudaStream_t stream) DESCRIPTION Copies a matrix (height rows of width bytes each) from the CUDA array srcArray starting at the upper left corner (srcX. const struct cudaArray* srcArray. dpitch is the width in memory in bytes of the 2D array pointed to by dst. cudaMemcpyDeviceToHost. enum cudaMemcpyKind kind. size_t srcX.

cudaMemcpyToArray.copies data between host and device SYNOPSIS cudaError_t cudaMemcpyArrayToArray(struct cudaArray* dstArray. srcY) to the CUDA array dstArray starting at the upper left corner (dstX. cudaMemcpy2D. cudaMemcpy2DFromArray. dstY). size_t dstY.1.16 cudaMemcpyArrayToArray NAME cudaMemcpyArrayToArray . cudaMemcpyFromArray. or cudaMemcpyDeviceToDevice. size_t dstX.5. enum cudaMemcpyKind kind) DESCRIPTION Copies count bytes from the CUDA array srcArray starting at the upper left corner (srcX. size_t srcY. SEE ALSO cudaMemcpy. cudaMemcpyDeviceToHost. cudaMemcpyFromSymbol 40 . and specifies the direction of the copy. asynchronous launches. where kind is one of cudaMemcpyHostToHost. size_t count. cudaMemcpyHostToDevice. size_t srcX. cudaMemcpyToSymbol. const struct cudaArray* srcArray. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. cudaMemcpy2DArrayToArray. cudaMemcpy2DToArray.

and specifies the direction of the copy. enum cudaMemcpyKind kind) DESCRIPTION Copies a matrix (height rows of width bytes each) from the CUDA array srcArray starting at the upper left corner (srcX. or cudaMemcpyDeviceToDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. cudaMemcpyDeviceToHost. cudaMemcpyFromArray.5. dstY).copies data between host and device SYNOPSIS cudaError_t cudaMemcpy2DArrayToArray(struct cudaArray* dstArray. SEE ALSO cudaMemcpy. where kind is one of cudaMemcpyHostToHost. cudaMemcpyToSymbol.17 cudaMemcpy2DArrayToArray NAME cudaMemcpy2DArrayToArray . size_t height. size_t srcX. const struct cudaArray* srcArray. srcY) to the CUDA array dstArray starting at the upper left corner (dstX. size_t width.1. cudaMemcpy2D. cudaMemcpy2DToArray. cudaMemcpyToArray. cudaMemcpyArrayToArray. size_t srcY. size_t dstY. cudaMemcpyFromSymbol 41 . cudaMemcpy2DFromArray. asynchronous launches. size_t dstX. cudaMemcpyHostToDevice.

enum cudaMemcpyKind kind) DESCRIPTION Copies count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol. size_t offset. const void* src. asynchronous launches. cudaMemcpyFromArray. symbol can either be a variable that resides in global or constant memory space. cudaMemcpy2DToArray. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidSymbol cudaErrorInvalidDevicePointer cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. cudaMemcpyFromSymbol 42 .5. cudaMemcpy2DArrayToArray.18 cudaMemcpyToSymbol NAME cudaMemcpyToSymbol .copies data from host memory to GPU SYNOPSIS template < class T > cudaError_t cudaMemcpyToSymbol( const T& symbol. SEE ALSO cudaMemcpy. cudaMemcpy2D. or it can be a character string.1. naming a variable that resides in global or constant memory space. The memory areas may not overlap. cudaMemcpyToArray. cudaMemcpy2DFromArray. size_t count. cudaMemcpyArrayToArray. kind can be either cudaMemcpyHostToDevice or cudaMemcpyDeviceToDevice.

19 cudaMemcpyFromSymbol NAME cudaMemcpyFromSymbol . naming a variable that resides in global or constant memory space. cudaMemcpy2DToArray. size_t count. cudaMemcpyFromArray. or it can be a character string.1. cudaMemcpy2DArrayToArray. cudaMemcpyArrayToArray. SEE ALSO cudaMemcpy. cudaMemcpy2DFromArray. enum cudaMemcpyKind kind) DESCRIPTION Copies count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the memory area pointed to by dst. cudaMemcpy2D. size_t offset. kind can be either cudaMemcpyDeviceToHost or cudaMemcpyDeviceToDevice.copies data from GPU to host memory SYNOPSIS template < class T > cudaError_t cudaMemcpyFromSymbol( void *dst. asynchronous launches. The memory areas may not overlap. const T& symbol.5. symbol can either be a variable that resides in global or constant memory space. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidSymbol cudaErrorInvalidDevicePointer cudaErrorInvalidMemcpyDirection Note that this function may also return error codes from previous. cudaMemcpyToArray. cudaMemcpyToSymbol 43 .

20 cudaGetSymbolAddress NAME cudaGetSymbolAddress . SEE ALSO cudaGetSymbolSize 44 .finds the address associated with a CUDA symbol SYNOPSIS template < class T > cudaError_t cudaGetSymbolAddress(void** devPtr. If symbol cannot be found.1. cudaGetSymbolAddress() returns cudaErrorInvalidSymbol in case of failure RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidSymbol cudaErrorAddressOfConstant Note that this function may also return error codes from previous. *devPtr is unchanged and an error is returned.5. asynchronous launches. or it can be a character string. or if symbol is not declared in global memory space. const T& symbol) DESCRIPTION Returns in *devPtr the address of symbol symbol on the device. symbol can either be a variable that resides in global memory space. naming a variable that resides in global memory space.

SEE ALSO cudaGetSymbolAddress 45 .1. If symbol cannot be found. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidSymbol Note that this function may also return error codes from previous. cudaGetSymbolSize() returns cudaErrorInvalidSymbol in case of failure. symbol can either be a variable that resides in global or constant memory space.21 cudaGetSymbolSize NAME cudaGetSymbolSize . or if symbol is not declared in global or constant memory space.5. naming a variable that resides in global or constant memory space. const T& symbol) DESCRIPTION Returns in *size the size of symbol symbol. asynchronous launches.finds the size of the object associated with a CUDA symbol SYNOPSIS template < class T > cudaError_t cudaGetSymbolSize(size_t* size. *size is unchanged and an error is returned. or it can be a character string.

struct cudaExtent extent ) DESCRIPTION Allocates at least width*height*depth bytes of linear memory on the device and returns a pitchedDevPtr in which ptr is a pointer to the allocated memory. asynchronous launches. this is especially true if the application will be performing memory copies involving 2D or 3D objects (whether linear memory or CUDA arrays).1.22 cudaMalloc3D NAME cudaMalloc3D . size_t height. The function may pad the allocation to ensure hardware alignment requirements are met. 3D objects. Due to alignment restrictions in the hardware. cudaError_t cudaMalloc3D( struct cudaPitchedPtr* pitchDevPtr.allocates logical 1D. }. size_t depth. 46 . it is highly recommended that programmers perform allocations using cudaMalloc3D() or cudaMallocPitch(). The pitch returned in the pitch field of the pitchedDevPtr is the width in bytes of the allocation. size_t pitch. 2D. which are equivalent to the width and height extent parameters provided by the programmer during allocation. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. }. For allocations of 2D. size_t xsize. struct cudaExtent { size_t width. the logical width and height of the allocation. or 3D memory objects on the GPU SYNOPSIS struct cudaPitchedPtr { void *ptr. The returned cudaPitchedPtr contains additional fields xsize and ysize.5. size_t ysize.

SEE ALSO cudaMallocPitch. cudaFree. cudaMemset3D. cudaMemcpy3D. cudaFreeHost 47 . cudaMallocArray. cudaFreeArray. cudaMallocHost. cudaMalloc3DArray.

• A 3D array is allocate if all three extents are non-zero. asynchronous launches. (1. For instance. y. }. struct cudaExtent extent ) DESCRIPTION Allocates a CUDA array according to the cudaChannelFormatDesc structure desc and returns a handle to the new CUDA array in *arrayPtr. • A 2D array is allocated if only the depth extent is zero. (1. cudaMalloc3DArray is able to allocate 1D. For 1D arrays valid extents are {(1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. size_t height. }.5. z. a degenerate 2D array allows for significantly more linear storage than a 1D array. or 3D arrays. (1. For 2D arrays valid extents are {(1. 2048)}. Note: That because of the differing extent limits it may be advantageous to use a degenerate array (with unused dimensions set to one) of higher dimensionality. cudaChannelFormatKindUnsigned. enum cudaChannelFormatKind f. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. 65536). For 3D arrays valid extents are {(1. 32768). cudaError_t cudaMalloc3DArray( struct cudaArray** arrayPtr. cudaChannelFormatKindFloat. 2D. 2048).23 cudaMalloc3DArray NAME cudaMalloc3DArray .1. w. size_t depth. 0. • A 1D array is allocated if the height and depth extent are both zero. 0}. 8192).allocate an array on the GPU SYNOPSIS struct cudaExtent { size_t width. 2048). 48 . const struct cudaChannelFormatDesc* desc. 0} .

cudaMallocHost.SEE ALSO cudaMalloc3D. cudaMallocPitch. cudaFree. cudaFreeArray. cudaFreeHost 49 . cudaMalloc.

Extents with width greater than or equal to the xsize of dstPitchPtr may perform significantly faster than extents narrower than the xsize. cudaError_t cudaMemset3D( struct cudaPitchedPtr dstPitchPtr.24 cudaMemset3D NAME cudaMemset3D . and a depth in slices. The xsize field specifies the logical width of each row in bytes.initializes or sets GPU memory to a value SYNOPSIS struct cudaPitchedPtr { void *ptr. struct cudaExtent extent ) DESCRIPTION Initializes each element of a 3D array to the specified value value. including any padding added to the end of each row. This function performs fastest when the dstPitchPtr has been allocated by cudaMalloc3D(). size_t pitch. size_t height. }. a height in rows.5. size_t ysize. Secondarily. struct cudaExtent { size_t width. The extents of the initialized region are specified as a width in bytes. size_t depth. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous. asynchronous launches. }. The object to initialize is defined by dstPitchPtr. extents with height equal to the ysize of dstPitchPtr will perform faster than when the hieght is shorter than the ysize. size_t xsize.1. int value. The pitch field of dstPitchPtr is the width in memory in bytes of the 3D array pointed to by dstPitchPtr. 50 . while the ysize field specifies the height of each 2D slice in rows.

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

positions must be in the range [0. The extent field defines the dimensions of the transferred area in elements. enum cudaMemcpyKind kind. cudaError_t cudaMemcpy3D( const struct cudaMemcpy3DParms *p ) cudaError_t cudaMemcpy3DAsync( const struct cudaMemcpy3DParms *p. destination. device memory. The kind field defines the direction of the copy. y. }. 52 . The element for a host or device pointer is assumed to be unsigned char. The source. and kind of copy performed is specified by the cudaMemcpy3DParms struct which should be initialized to zero before use: cudaMemcpy3DParms myParms = {0}. struct cudaMemcpy3DParms { struct cudaArray *srcArray. struct cudaPitchedPtr srcPtr. struct cudaPos dstPos.25 cudaMemcpy3D NAME cudaMemcpy3D . The srcPos and dstPos fields are optional offsets into the source and destination objects and are defined in units of each object’s elements. The source and destination objects may be in either host memory. extent. 2048) for any dimension.1. struct cudaPos srcPos. }.5. It must be one of cudaMemcpyHostToHost. cudaStream_t stream ) DESCRIPTION cudaMemcpy3D() copies data betwen two 3D objects.copies data between between 3D objects SYNOPSIS struct cudaExtent { size_t width. If a CUDA array is participating in the copy the extent is defined in terms of that array’s elements. height. depth. or cudaMemcpyDeviceToDevice. The struct passed to cudaMemcpy3D() must specify one of srcArray or srcPtr and one of dstArray or dstPtr. struct cudaArray *dstArray. Passing more than one non-zero source or destination will cause cudaMemcpy3D() to return an error. If no CUDA array is participating in the copy then the extents are defined in elements of unsigned char. struct cudaPos { size_t x. For CUDA arrays. cudaMemcpyDeviceToHost. cudaMemcpyHostToDevice. or a CUDA array. }. struct cudaPitchedPtr dstPtr. struct cudaExtent extent. z.

The pitch of a cudaPitchedPtr allocated with cudaMalloc3D() will always be valid. RETURN VALUE cudaSuccess SEE ALSO cudaMalloc3D. cudaMemset3D. cudaMemcpy3D() returns an error if the pitch of srcPtr or dstPtr is greater than the maximum allowed.If the source and destination are both arrays cudaMemcpy3D() will return an error if they do not have the same element size. cudaMemcpyArrayToArray. cudaMemcpy2DArrayToArray. cudaMemcpy3DAsync() is an asynchronous copy operation and can optionally be associated to a stream by passing a non-zero stream argument. cudaMemcpy2DFromArray. cudaMemcpyToArray. It will return an error if a pointer to memory not allocated with cudaMallocHost() is passed as input. The source and destination object may not overlap. cudaMemcpyToSymbol. cudaMalloc3DArray. If overlapping source and destination objects are specified undefined behavior will result. cudaMemcpyFromArray. If either the source or destination is a host object it must be allocated in page-locked memory returned from cudaMallocHost(). cudaMemcpy2DToArray. cudaMemcpyFromSymbol 53 . cudaMemcpy.

OpenGL Interoperability. Texture Reference Management. Memory Management.1. Thread Management. Event Management. Error Handling 54 . Execution Management. Stream Management.6 TextureReferenceManagement RT NAME Texture Reference Management DESCRIPTION This section describes the CUDA runtime application programming interface. Direct3D Interoperability. Low-Level API High-Level API SEE ALSO Device Management.

1.6.1 LowLevelApi NAME Low-Level Texture API DESCRIPTION This section describes the low-level CUDA run-time application programming interface for textures cudaCreateChannelDesc cudaGetChannelDesc cudaGetTextureReference cudaBindTexture cudaBindTextureToArray cudaUnbindTexture cudaGetTextureAlignmentOffset SEE ALSO High-Level API 55 .

cudaChannelFormatKindUnsigned.Low-level texture API SYNOPSIS struct cudaChannelFormatDesc cudaCreateChannelDesc(int x. y. SEE ALSO cudaGetChannelDesc. asynchronous launches. z. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. and w. cudaGetTextureAlignmentOffset 56 .cudaCreateChannelDesc NAME cudaCreateChannelDesc . w. int z. }. cudaGetTextureReference. cudaBindTextureToArray. DESCRIPTION Returns a channel descriptor with format f and number of bits of each component x. enum cudaChannelFormatKin f). z. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. enum cudaChannelFormatKind f. int y. cudaChannelFormatKindFloat. int w. y. cudaBindTexture. cudaUnbindTexture.

cudaBindTexture. DESCRIPTION Returns in *desc the channel descriptor of the CUDA array array. SEE ALSO cudaCreateChannelDesc. const struct cudaArray* array). cudaGetTextureReference. asynchronous launches. cudaUnbindTexture. cudaBindTextureToArray. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue Note that this function may also return error codes from previous. cudaGetTextureAlignmentOffset 57 .Low-level texture API SYNOPSIS cudaError_t cudaGetChannelDesc(struct cudaChannelFormatDesc* desc.cudaGetChannelDesc NAME cudaGetChannelDesc .

asynchronous launches. cudaUnbindTexture.Low-level texture API SYNOPSIS cudaError_t cudaGetTextureReference( struct textureReference** texRef. cudaBindTextureToArray. cudaBindTexture. const char* symbol) DESCRIPTION Returns in *texRef the structure associated to the texture reference defined by symbol symbol. SEE ALSO cudaCreateChannelDesc.cudaGetTextureReference NAME cudaGetTextureReference . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidTexture Note that this function may also return error codes from previous. cudaGetChannelDesc. cudaGetTextureAlignmentOffset 58 .

cudaGetTextureReference. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture Note that this function may also return error codes from previous. const struct cudaChannelFormatDesc* desc. DESCRIPTION Binds size bytes of the memory area pointed to by devPtr to the texture reference texRef. the offset is guaranteed to be 0 and NULL may be passed as the offset parameter. asynchronous launches. Since the hardware enforces an alignment requirement on texture base addresses.cudaBindTexture NAME cudaBindTexture . Any memory previously bound to texRef is unbound. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function. cudaBindTexture() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. SEE ALSO cudaCreateChannelDesc. size_t size = UINT_MAX). const struct textureReference* texRef. cudaBindTextureToArray. const void* devPtr. desc describes how the memory is interpreted when fetching values from the texture. cudaUnbindTexture. cudaGetChannelDesc.Low-level texture API SYNOPSIS cudaError_t cudaBindTexture(size_t* offset. cudaGetTextureAlignmentOffset 59 . If the device memory pointer was returned from cudaMalloc().

cudaGetTextureAlignmentOffset 60 . cudaGetTextureReference. desc describes how the memory is interpreted when fetching values from the texture.cudaBindTextureToArray NAME cudaBindTextureToArray . cudaBindTexture. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture Note that this function may also return error codes from previous. cudaGetChannelDesc. SEE ALSO cudaCreateChannelDesc. const struct cudaChannelFormatDesc* desc). asynchronous launches. const struct cudaArray* array.Low-level texture API SYNOPSIS cudaError_t cudaBindTextureToArray( const struct textureReference* texRef. Any CUDA array previously bound to texRef is unbound. DESCRIPTION Binds the CUDA array array to the texture reference texRef. cudaUnbindTexture.

cudaBindTexture. SEE ALSO cudaCreateChannelDesc. asynchronous launches. cudaGetTextureAlignmentOffset 61 . cudaGetTextureReference. cudaGetChannelDesc.Low-level texture API SYNOPSIS cudaError_t cudaUnbindTexture( const struct textureReference* texRef). DESCRIPTION Unbinds the texture bound to texture reference texRef. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.cudaUnbindTexture NAME cudaUnbindTexture . cudaBindTextureToArray.

cudaUnbindTexture 62 . cudaBindTextureToArray. SEE ALSO cudaCreateChannelDesc.cudaGetTextureAlignmentOffset NAME cudaGetTextureAlignmentOffset . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidTexture cudaErrorInvalidTextureBinding Note that this function may also return error codes from previous. const struct textureReference* texRef).Low-level texture API SYNOPSIS cudaError_t cudaGetTextureAlignmentOffset(size_t* offset. cudaGetTextureReference. DESCRIPTION Returns in *offset the offset that was returned when texture reference texRef was bound. cudaGetChannelDesc. asynchronous launches. cudaBindTexture.

2 HighLevelApi NAME High-Level Texture API DESCRIPTION This section describes the high-level CUDA run-time application programming interface for textures cudaCreateChannelDesc cudaBindTexture cudaBindTextureToArray cudaUnbindTexture SEE ALSO Low-Level API 63 .6.1.

}. DESCRIPTION Returns a channel descriptor with format f and number of bits of each component x. asynchronous launches. y. z. SEE ALSO 64 .cudaCreateChannelDesc HL NAME cudaCreateChannelDesc . w. cudaChannelFormatKindFloat. enum cudaChannelFormatKind f. y. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. and w. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned.High-level texture API SYNOPSIS template < class T > struct cudaChannelFormatDesc cudaCreateChannelDesc <T >(). cudaChannelFormatKindUnsigned. z.

const struct texture < T. desc describes how the memory is interpreted when fetching values from the texture. int dim. Any memory previously bound to texRef is unbound. size_t size = UINT_MAX). template E<lt> class T. The offset parameter is an optional byte offset as with the low-level cudaBindTexture() function. asynchronous launches. enum cudaTextureReadMode readMode E<gt> static __inline__ __host__ cudaError_t cudaBindTexture( size_t* offset. The channel descriptor is inherited from the texture reference type. const void* devPtr. dim. const struct texture E<lt> T. The offset parameter is an optional byte offset as with the lowlevel cudaBindTexture() function described RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture Note that this function may also return error codes from previous. readMode E<gt>& texRef. int dim.cudaBindTexture HL NAME cudaBindTexture . const void* devPtr. size_t size = UINT_MAX) DESCRIPTION Binds size bytes of the memory area pointed to by devPtr to texture reference texRef. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaBindTexture(size_t* offset.High-level texture API SYNOPSIS template < class T. readMode >& texRef. const struct cudaChannelFormatDesc& desc. dim. binds size bytes of the memory area pointed to by devPtr to texture reference texRef. SEE ALSO 65 .

High-level texture API SYNOPSIS template < class T. dim. binds the CUDA array array to texture reference texRef. desc describes how the memory is interpreted when fetching values from the texture. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture < T. SEE ALSO cudaCreateChannelDesc_HL 66 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture Note that this function may also return error codes from previous. int dim. readMode E<gt>& texRef. readMode >& texRef. const struct cudaChannelFormatDesc& desc) DESCRIPTION Binds the CUDA array array to texture reference texRef.cudaBindTextureToArray HL NAME cudaBindTextureToArray . dim. Any CUDA array previously bound to texRef is unbound. enum cudaTextureReadMode readMode E<gt> static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture E<lt> T. asynchronous launches. Any CUDA array previously bound to texRef is unbound. template E<lt> class T. The channel descriptor is inherited from the CUDA array. const struct cudaArray* cuArray. int dim. const struct cudaArray* cuArray).

cudaUnbindTexture HL NAME cudaUnbindTexture . asynchronous launches. dim.High-level texture API SYNOPSIS template < class T. int dim. readMode >& texRef) DESCRIPTION Unbinds the texture bound to texture reference texRef. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaUnbindTexture(const struct texture < T. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. SEE ALSO 67 .

cudaConfigureCall cudaLaunch cudaSetupArgument SEE ALSO Device Management. Memory Management. Direct3D Interoperability. Error Handling 68 . Execution Management. Texture Reference Management. OpenGL Interoperability. Stream Management. Event Management.1.7 ExecutionControl RT NAME Execution Control DESCRIPTION This section describes the CUDA runtime application programming interface. Thread Management.

This data contains the dimension for the grid and thread blocks. together with any arguments for the call. Each call pushes data on top of an execution stack. cudaConfigureCall() is stack based. int tokens = 0) DESCRIPTION Specifies the grid and block dimensions for the device call to be executed similar to the execution configuration syntax. size_t sharedMem = 0. dim3 blockDim. asynchronous launches.7. cudaSetupArgument 69 .configure a device-launch SYNOPSIS cudaError_t cudaConfigureCall(dim3 gridDim.1 cudaConfigureCall NAME cudaConfigureCall . SEE ALSO cudaLaunch. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidConfiguration Note that this function may also return error codes from previous.1.

naming a function that executes on the device. entry can either be a function that executes on the device. SEE ALSO cudaConfigureCall. entry must be declared as a __global__ function. asynchronous launches. cudaLaunch() must be preceded by a call to cudaConfigureCall() since it pops the data that was pushed by cudaConfigureCall() from the execution stack.2 cudaLaunch NAME cudaLaunch .1.7. or it can be a character string.launches a device function SYNOPSIS template < class T > cudaError_t cudaLaunch(T entry) DESCRIPTION Launches the function entry on the device. cudaSetupArgument 70 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous.

size_t offset) template < class T > cudaError_t cudaSetupArgument(T arg. SEE ALSO cudaConfigureCall.7.3 cudaSetupArgument NAME cudaSetupArgument . The arguments are stored in the top of the execution stack.configure a device-launch SYNOPSIS cudaError_t cudaSetupArgument(void* arg. which starts at offset 0. asynchronous launches. size_t offset) DESCRIPTION Pushes count bytes of the argument pointed to by arg at offset bytes from the start of the parameter passing area.1. cudaLaunch 71 . size_t count. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. cudaSetupArgument() must be preceded by a call to cudaConfigureCall().

OpenGL Interoperability. Stream Management. Thread Management. Error Handling 72 . Execution Management. Direct3D Interoperability. Event Management.1. Memory Management. cudaGLSetGLDevice cudaGLRegisterBufferObject cudaGLMapBufferObject cudaGLUnmapBufferObject cudaGLUnregisterBufferObject SEE ALSO Device Management. Texture Reference Management.8 OpenGlInteroperability RT NAME OpenGL Interoperability DESCRIPTION This section describes the CUDA runtime application programming interface.

SEE ALSO cudaGLRegisterBufferObject.1. DESCRIPTION Records dev as the device on which the active host thread executes the device code. cudaGLMapBufferObject. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevice Note that this function may also return error codes from previous.8.1 cudaGLSetGLDevice NAME cudaGLSetGLDevice . Records the thread as using GL Interopability. asynchronous launches. cudaGLUnregisterBufferObject 73 . cudaGLUnmapBufferObject.sets the CUDA device for use with GL Interopability SYNOPSIS cudaError_t cudaGLSetGLDevice(int device).

the buffer object cannot be used by any OpenGL commands except as a data source for OpenGL drawing commands. While it is registered. RETURN VALUE Relevant return values: cudaSuccess cudaErrorNotInitialized Note that this function may also return error codes from previous. cudaGLUnregisterBufferObject 74 .1.OpenGL interoperability SYNOPSIS cudaError_t cudaGLRegisterBufferObject(GLuint bufferObj) DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA. cudaGLUnmapBufferObject. asynchronous launches.2 cudaGLRegisterBufferObject NAME cudaGLRegisterBufferObject . This function must be called before CUDA can map the buffer object.8. cudaGLMapBufferObject. SEE ALSO cudaGLSetGLDevice.

OpenGL interoperability SYNOPSIS cudaError_t cudaGLMapBufferObject(void** devPtr. cudaGLRegisterBufferObject.3 cudaGLMapBufferObject NAME cudaGLMapBufferObject . RETURN VALUE Relevant return values: cudaSuccess cudaErrorMapBufferObjectFailed Note that this function may also return error codes from previous. SEE ALSO cudaGLSetGLDevice. asynchronous launches. GLuint bufferObj). cudaGLUnregisterBufferObject 75 .8.1. cudaGLUnmapBufferObject. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of CUDA and returns in *devPtr the base pointer of the resulting mapping.

OpenGL interoperability SYNOPSIS cudaError_t cudaGLUnmapBufferObject(GLuint bufferObj).8. SEE ALSO cudaGLSetGLDevice. cudaGLMapBufferObject. cudaGLUnregisterBufferObject 76 .1. cudaGLRegisterBufferObject. asynchronous launches.4 cudaGLUnmapBufferObject NAME cudaGLUnmapBufferObject . DESCRIPTION Unmaps the buffer object of ID bufferObj for access by CUDA. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevicePointer cudaErrorUnmapBufferObjectFailed Note that this function may also return error codes from previous.

5 cudaGLUnregisterBufferObject NAME cudaGLUnregisterBufferObject . cudaGLUnmapBufferObject 77 . asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.1. DESCRIPTION Unregisters the buffer object of ID bufferObj for access by CUDA. cudaGLRegisterBufferObject. SEE ALSO cudaGLSetGLDevice.OpenGL interoperability SYNOPSIS cudaError_t cudaGLUnregisterBufferObject(GLuint bufferObj). cudaGLMapBufferObject.8.

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

DESCRIPTION
This section describes the CUDA runtime application programming interface. cudaD3D9GetDevice cudaD3D9SetDirect3DDevice cudaD3D9GetDirect3DDevice cudaD3D9RegisterResource cudaD3D9UnregisterResource cudaD3D9MapResources cudaD3D9UnmapResources cudaD3D9ResourceGetSurfaceDimensions cudaD3D9ResourceSetMapFlags cudaD3D9ResourceGetMappedPointer cudaD3D9ResourceGetMappedSize cudaD3D9ResourceGetMappedPitch As of CUDA 2.0 the following functions are deprecated. They should not be used in new development. cudaD3D9Begin cudaD3D9End cudaD3D9RegisterVertexBuffer cudaD3D9MapVertexBuffer cudaD3D9UnmapVertexBuffer cudaD3D9UnregisterVertexBuffer

SEE ALSO
Device Management, Thread Management, Stream Management, Event Management, Execution Management, Memory Management, Texture Reference Management, OpenGL Interoperability, Direct3D Interoperability, Error Handling

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

SYNOPSIS
cudaError_t cudaD3D9GetDevice(int* dev, const char* adapterName);

DESCRIPTION
Returns in *dev the CUDA-compatible device corresponding to the adapter name adapterName obtained from EnumDisplayDevices or IDirect3D9::GetAdapterIdentifier(). If no device on the adapter with name adapterName is CUDA-compatible then the call will fail.

RETURN VALUE
Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorUnknown Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO

cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cudaD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch

79

1.9.2

cudaD3D9SetDirect3DDevice

NAME
cudaD3D9SetDirect3DDevice - sets the Direct3D device to use for interoperability in this thread

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

DESCRIPTION
Records pDxDevice as the Direct3D device to use for Direct3D interoperability on this host thread. In order to use Direct3D interoperability, this call must be made before any other CUDA runtime calls on this thread. Successful context creation on pDxDevice will increase the internal reference count on pDxDevice. This reference count will be decremented upon destruction of this context through cudaThreadExit.

RETURN VALUE
Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorInvalidValue Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO

cudaD3D9GetDevice, cudaD3D9GetDirect3DDevice, cudaD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch

80

1.9.3

cudaD3D9GetDirect3DDevice

NAME
cudaD3D9GetDirect3DDevice - get the Direct3D device against which the current CUDA context was created

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

DESCRIPTION
Returns in *ppDxDevice the Direct3D device against which this CUDA context was created in cudaD3D9SetDirect3DDevice.

RETURN VALUE
Relevant return values: cudaSuccess cudaErrorUnknown Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO

cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch

81

The type of pResource must be one of the following. • Any resources allocated in D3DPOOL_SYSTEMMEM may not be registered with CUDA. In particular. size. or 4 channels of 8. 82 .1. This reference count will be decremented when this resource is unregistered through cudaD3D9UnregisterResource. • cudaD3D9RegisterFlagsNone: Specifies that CUDA will access this resource through a void*. The following value is allowed. To access individual surfaces associated with a texture. or 32-bit integer or floating-point data cannot be shared. • IDirect3DIndexBuffer9: No notes. and cudaD3D9ResourceGetMappedPitch respectively. • Resources allocated as shared may not be registered with CUDA.4 cudaD3D9RegisterResource NAME cudaD3D9RegisterResource . 2. 16. unsigned int Flags). The following are some limitations.register a Direct3D resource for access by CUDA SYNOPSIS cudaError_t cudaD3D9RegisterResource(IDirect3DResource9* pResource. Also on success. and pitch for each subresource of this resource may be queried through cudaD3D9ResourceGetMappedPointe cudaD3D9ResourceGetMappedSize. This call is potentially high-overhead and should not be called every frame in interactive applications. The Flags argument specifies the mechanism through which CUDA will access the Direct3D resource. DESCRIPTION Registers the Direct3D resource pResource for access by CUDA. • The primary rendertarget may not be registered with CUDA. • IDirect3DVertexBuffer9: No notes. • Textures which are not of a format which is 1.9. • IDirect3DBaseTexture9: When a texture is registered all surfaces associated with the all mipmap levels of all faces of the texture will be accessible to CUDA. Not all Direct3D resources of the above types may be used for interoperability with CUDA. • IDirect3DSurface9: Only stand-alone objects of type IDirect3DSurface9 may be explicitly shared. individual mipmap levels and faces of cube maps may not be registered directly. If this call is successful then the application will be able to map and unmap this resource until it is unregistered through cudaD3D9UnregisterResource. This option is valid for all resource types. The pointer. one must register the base texture object. this call will increase the internal reference count on pResource.

cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9SetDirect3DDevice. If pResource cannot be registered then cudaErrorUnknown is returned. cudaD3D9ResourceGetMappedSize. cudaD3D9GetDirect3DDevice. cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer. If pResource is of incorrect type (e.• Surfaces of depth or stencil formats cannot be shared. is a non-stand-alone IDirect3DSurface9) or is already registered then cudaErrorInvalidHandle is returned. cudaD3D9UnmapResources. cudaD3D9ResourceGetMappedPitch 83 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. asynchronous launches. cudaD3D9MapResources.g. SEE ALSO cudaD3D9GetDevice. If Direct3D interoperability is not initialized on this context then is returned. cudaD3D9UnregisterResource.

asynchronous launches. cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9MapResources. If pResource is not registered then cudaErrorInvalidHandle is returned. cudaD3D9ResourceGetMappedPitch 84 . cudaD3D9RegisterResource. cudaD3D9GetDirect3DDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. cudaD3D9SetDirect3DDevice.5 cudaD3D9UnregisterResource NAME cudaD3D9UnregisterResource . cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. cudaD3D9ResourceGetMappedSize.1. cudaD3D9UnmapResources.9. SEE ALSO cudaD3D9GetDevice.unregister a Direct3D resource SYNOPSIS cudaError_t cudaD3D9UnregisterResource(IDirect3DResource9* pResource).

cudaD3D9SetDirect3DDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous.6 cudaD3D9MapResources NAME cudaD3D9MapResources . IDirect3DResource9 **ppResources). asynchronous launches. cudaD3D9UnmapResources. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned. cudaD3D9ResourceGetMappedPointer. If an application does so the results are undefined. Direct3D should not access any resources while they are mapped by CUDA. cudaD3D9ResourceGetMappedSize. cudaD3D9GetDirect3DDevice.9. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. If any of ppResources are presently mapped for access by CUDA then cudaErrorUnknown is returned. cudaD3D9ResourceGetMappedPitch 85 .map Direct3D resources for access by CUDA SYNOPSIS cudaError_t cudaD3D9MapResources(unsigned int count. cudaD3D9ResourceSetMapFlags.1. cudaD3D9RegisterResource. SEE ALSO cudaD3D9GetDevice. cudaD3D9UnregisterResource. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. This function provides the synchronization guarantee that any Direct3D calls issued before cudaD3D9MapResources will complete before any CUDA kernels issued after cudaD3D9MapResources begin. cudaD3D9ResourceGetSurfaceDimensions.

cudaD3D9GetDirect3DDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. cudaD3D9MapResources. This function provides the synchronization guarantee that any CUDA kernels issued before cudaD3D9UnmapResources will complete before any Direct3D calls issued after cudaD3D9UnmapResources begin. DESCRIPTION Unmaps the count Direct3D resources in ppResources. SEE ALSO cudaD3D9GetDevice. cudaD3D9ResourceGetMappedPitch 86 . cudaD3D9ResourceGetMappedSize. cudaD3D9ResourceGetSurfaceDimensions.7 cudaD3D9UnmapResources NAME cudaD3D9UnmapResources . cudaD3D9RegisterResource. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned. cudaD3D9ResourceSetMa cudaD3D9ResourceGetMappedPointer.1. cudaD3D9UnregisterResource. cudaD3D9SetDirect3DDevice. If any of ppResources are not presently mapped for access by CUDA then cudaErrorUnknown is returned. IDirect3DResource9** ppResources).9.unmap Direct3D resources SYNOPSIS cudaError_t cudaD3D9UnmapResources(unsigned int count. asynchronous launches.

set usage flags for mapping a Direct3D resource SYNOPSIS cudaError_t cudaD3D9ResourceSetMapFlags(IDirect3DResource9 *pResource.9. so none of the data previously stored in the resource will be preserved. • cudaD3D9MapFlagsReadOnly: Specifies that CUDA kernels which access this resource will not write to this resource. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. Changes to flags will take effect the next time pResource is mapped. The Flags argument may be any of the following. If pResource is presently mapped for access by CUDA then cudaErrorUnknown is returned. unsigned int Flags). If pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. DESCRIPTION Set flags for mapping the Direct3D resource pResource.1. This is the default value. It is therefore assumed that this resource will be read from and written to by CUDA kernels.8 cudaD3D9ResourceSetMapFlags NAME cudaD3D9ResourceSetMapFlags . • cudaD3D9MapFlagsWriteDiscard: Specifies that CUDA kernels which access this resource will not read from this resource and will write over the entire contents of the resource. 87 . asynchronous launches. • cudaD3D9MapFlagsNone: Specifies no hints about how this resource will be used.

SEE ALSO cudaD3D9GetDevice. cudaD3D9UnregisterResource. cudaD3D9MapResources. cudaD3D9ResourceGetMappedPitch 88 . cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetSurfaceDimensio cudaD3D9ResourceGetMappedPointer. cudaD3D9SetDirect3DDevice. cudaD3D9UnmapResources. cudaD3D9ResourceGetMappedSize. cudaD3D9RegisterResource.

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle Note that this function may also return error codes from previous. unsigned int Face.9. unsigned int Level). size_t* pHeight. pHeight. and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. *pHeight. cudaD3D9MapResources. asynchronous launches. cudaD3D9SetDirect3DDevice. cudaD3D9UnmapResources. cudaD3D9ResourceGetMappedSize. cudaD3D9ResourceGetMappedPitch 89 . and pDepth are optional. DESCRIPTION Returns in *pWidth. The parameters pWidth. cudaD3D9UnregisterResource. the value returned in *pDepth will be 0. If pResource is not of type IDirect3DBaseTexture9 or IDirect3DSurface9 or if pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned.get the dimensions of a registered surface SYNOPSIS cudaError_t cudaD3D9ResourceGetSurfaceDimensions(size_t* pWidth. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. For 2D surfaces. size_t *pDepth.1. IDirect3DResource9* pResource. cudaD3D9GetDirect3DDevice. SEE ALSO cudaD3D9GetDevice. cudaD3D9ResourceSetMapFlags. cudaD3D9RegisterResource.9 cudaD3D9ResourceGetSurfaceDimensions NAME cudaD3D9ResourceGetSurfaceDimensions . Because anti-aliased surfaces may have multiple samples per pixel it is possible that the dimensions of a resource will be an integer factor larger than the dimensions reported by the Direct3D runtime. cudaD3D9ResourceGetMappedPointer.

SEE ALSO cudaD3D9GetDevice. unsigned int Level). If pResource is not mapped then cudaErrorUnknown is returned. cudaD3D9UnmapResources. IDirect3DResource9* pResource. For all other types Face must be 0. If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. DESCRIPTION Returns in *pPointer the base pointer of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. asynchronous launches.10 cudaD3D9ResourceGetMappedPointer NAME cudaD3D9ResourceGetMappedPointer . cudaD3D9ResourceGetMappedPitch 90 . cudaD3D9UnregisterResource. cudaD3D9ResourceGetSurfaceDimensio cudaD3D9ResourceSetMapFlags.1. If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level. cudaD3D9RegisterResource. unsigned int Face. cudaD3D9GetDirect3DDevice. If Level is invalid then cudaErrorInvalidValue is returned. If pResource is not registered then cudaErrorInvalidHandle is returned. cudaD3D9ResourceGetMappedSize. cudaD3D9SetDirect3DDevice. If Face is invalid then cudaErrorInvalidValue is returned. For all other types Level must be 0. Only mipmap level 0 is supported for now. The value set in pPointer may change every time that pResource is mapped.get a pointer through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS cudaError_t cudaD3D9ResourceGetMappedPointer(void** pPointer.9. If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. cudaD3D9MapResources.

cudaD3D9UnmapResources. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. cudaD3D9UnregisterResource. cudaD3D9SetDirect3DDevice. DESCRIPTION Returns in *pSize the size of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. cudaD3D9MapResources. unsigned int Level). cudaD3D9ResourceGetMappedPointer. If pResource is not mapped for access by CUDA then cudaErrorUnknown is returned. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. cudaD3D9GetDirect3DDevice. cudaD3D9RegisterResource. If pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. unsigned int Face. cudaD3D9ResourceGetMappedPitch 91 . cudaD3D9ResourceGetSurfaceDimensio cudaD3D9ResourceSetMapFlags. SEE ALSO cudaD3D9GetDevice.1. asynchronous launches. The value set in pSize may change every time that pResource is mapped.11 cudaD3D9ResourceGetMappedSize NAME cudaD3D9ResourceGetMappedSize . If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. IDirect3DResource9* pResource.9.get the size of a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS cudaError_t cudaD3D9ResourceGetMappedSize(size_t* pSize.

For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer.1. asynchronous launches.y from the base pointer of the surface is If pResource is not of type IDirect3DBaseTexture9 or one of its sub-types or if pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. If pResource is not mapped for access by CUDA then cudaErrorUnknown is returned.z from the base pointer of the surface is z*slicePitch + y*pitch + (bytes per pixel)*x Both parameters pPitch and pPitchSlice are optional and may be set to NULL. IDirect3DResource9* pResource. y*pitch + (bytes per pixel)*x For a 3D surface the byte offset of the sample of at position x. If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. size_t* pPitchSlice. 92 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous.9. DESCRIPTION Returns in *pPitch and *pPitchSlice the pitch and Z-slice pitch of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level.y. The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.12 cudaD3D9ResourceGetMappedPitch NAME cudaD3D9ResourceGetMappedPitch . For a 2D surface the byte offset of the sample of at position x. The values set in pPitch and pPitchSlice may change every time that pResource is mapped.get the pitch of a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS cudaError_t cudaD3D9ResourceGetMappedPitch(size_t* pPitch. unsigned int Level). unsigned int Face.

cudaD3D9ResourceGetMappedPointer. cudaD3D9SetDirect3DDevice. cudaD3D9ResourceGetMappedSize 93 . cudaD3D9RegisterResource. cudaD3D9UnregisterResource. cudaD3D9GetDirect3DDevice. cudaD3D9MapResources.SEE ALSO cudaD3D9GetDevice. cudaD3D9UnmapResources. cudaD3D9ResourceGetSurfaceDimensio cudaD3D9ResourceSetMapFlags.

10 ErrorHandling RT NAME Error Handling DESCRIPTION This section describes the CUDA runtime application programming interface. Execution Management. Texture Reference Management. Event Management. Error Handling 94 .1. Stream Management. cudaGetLastError cudaGetErrorString SEE ALSO Device Management. Memory Management. OpenGL Interoperability. Direct3D Interoperability. Thread Management.

1 cudaGetLastError NAME cudaGetLastError . 95 .returns the last error from a run-time call SYNOPSIS cudaError_t cudaGetLastError( void ) DESCRIPTION Returns the last error that was returned from any of the runtime calls in the same host thread and resets it to cudaSuccess. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorLaunchFailure cudaErrorPriorLaunchFailure cudaErrorLaunchTimeout cudaErrorLaunchOutOfResources cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration cudaErrorInvalidDevice cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture cudaErrorInvalidTextureBinding cudaErrorInvalidChannelDescriptor cudaErrorTextureFetchFailed cudaErrorTextureNotBound cudaErrorSynchronizationError cudaErrorUnknown cudaErrorInvalidResourceHandle cudaErrorNotReady Note that this function may also return error codes from previous asynchronous launches.10.1.

SEE ALSO cudaGetErrorString. cudaError 96 .

returns the message string from an error SYNOPSIS const char* cudaGetErrorString(cudaError_t error). DESCRIPTION Returns a message string from an error code. RETURN VALUE char* pointer to a NULL-terminated string SEE ALSO cudaGetLastError 97 .2 cudaGetErrorString NAME cudaGetErrorString .10.1.

TextureReferenceManagement.2 DriverApiReference NAME Driver API Reference DESCRIPTION This section describes the low-level CUDA driver application programming interface. StreamManagement. MemoryManagement. OpenGlInteroperability. ModuleManagement. ContextManagement. DeviceManagement. EventManagement. SEE ALSO Initialization. Direct3dInteroperability 98 . ExecutionControl.

ModuleManagement. OpenGlInteroperability.2. EventManagement. Direct3dInteroperability 99 .1 Initialization NAME Driver Initialization DESCRIPTION This section describes the low-level CUDA driver application programming interface. TextureReferenceManagement. MemoryManagement. ExecutionControl. cuInit SEE ALSO Initialization. ContextManagement. DeviceManagement. StreamManagement.

SEE ALSO 100 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NO_DEVICE Note that this function may also return error codes from previous. asynchronous launches. the Flags parameters must be 0.1 cuInit NAME cuInit . DESCRIPTION Initializes the driver API and must be called before any other function from the driver API.2. If cuInit() has not been called. any function from the driver API will return CUDA_ERROR_NOT_INITIALIZED. Currently.initialize the CUDA driver API SYNOPSIS CUresult cuInit( unsigned int Flags ).1.

MemoryManagement. ModuleManagement. Direct3dInteroperability 101 .2. ContextManagement. TextureReferenceManagement.2 DeviceManagement NAME Device Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. EventManagement. cuDeviceComputeCapability cuDeviceGet cuDeviceGetAttribute cuDeviceGetCount cuDeviceGetName cuDeviceGetProperties cuDeviceTotalMem SEE ALSO Initialization. ExecutionControl. OpenGlInteroperability. StreamManagement. DeviceManagement.

cuDeviceGetCount.1 cuDeviceComputeCapability NAME cuDeviceComputeCapability . SEE ALSO cuDeviceGetAttribute. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_DEVICE Note that this function may also return error codes from previous.2. int* minor. CUdevice dev).returns the compute capability of the device SYNOPSIS CUresult cuDeviceComputeCapability(int* major.2. cuDeviceTotalMem 102 . cuDeviceGetName. cuDeviceGetProperties. cuDeviceGet. asynchronous launches. DESCRIPTION Returns in *major and *minor the major and minor revision numbers that define the compute capability of device dev.

cuDeviceGetProperties.returns a device-handle SYNOPSIS CUresult cuDeviceGet(CUdevice* dev. cuDeviceGetCount()-1].2 cuDeviceGet NAME cuDeviceGet . asynchronous launches.2. SEE ALSO cuDeviceComputeCapability.2. cuDeviceGetName. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_DEVICE Note that this function may also return error codes from previous. int ordinal). cuDeviceGetCount. DESCRIPTION Returns in *dev a device handle given an ordinal in the range [0. cuDeviceTotalMem 103 . cuDeviceGetAttribute.

104 . • CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT: alignment requirement. • CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y: maximum y-dimension of a grid. • CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z: maximum z-dimension of a grid. The supported attributes are: • CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK: maximum number of threads per block. • CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT: number of multiprocessors on the device. • CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK: maximum number of 32-bit registers available to a thread block.3 cuDeviceGetAttribute NAME cuDeviceGetAttribute . or 0 if not. CUdevice dev). texture base addresses aligned to textureAlign bytes do not need an offset applied to texture fetches. • CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z: maximum z-dimension of a block. • CU_DEVICE_ATTRIBUTE_WARP_SIZE: warp size in threads. DESCRIPTION Returns in *value the integer value of the attribute attrib on device dev. • CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X: maximum x-dimension of a block.returns information about the device SYNOPSIS CUresult cuDeviceGetAttribute(int* value. • CU_DEVICE_ATTRIBUTE_MAX_PITCH: maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through cuMemAllocPitch(). this number is shared by all thread blocks simultaneously resident on a multiprocessor. CUdevice_attribute attrib. • CU_DEVICE_ATTRIBUTE_CLOCK_RATE: clock frequency in kilohertz. • CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK: maximum amount of shared memory available to a thread block in bytes. this amount is shared by all thread blocks simultaneously resident on a multiprocessor. • CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X: maximum x-dimension of a grid. • CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y: maximum y-dimension of a block.2. • CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY: total amount of constant memory available on the device in bytes. • CU_DEVICE_ATTRIBUTE_GPU_OVERLAP: 1 if the device can concurrently copy memory between host and device while executing a kernel.2.

asynchronous launches.RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_DEVICE Note that this function may also return error codes from previous. cuDeviceTotalMem 105 . SEE ALSO cuDeviceComputeCapability. cuDeviceGetProperties. cuDeviceGetCount. cuDeviceGetName. cuDeviceGet.

If there is no such device. cuDeviceGetCount() returns 0.0 that are available for execution. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.2. cuDeviceGetProperties. cuDeviceGet. cuDeviceTotalMem 106 . cuDeviceGetName. cuDeviceGetAttribute.4 cuDeviceGetCount NAME cuDeviceGetCount . DESCRIPTION Returns in *count the number of devices with compute capability greater or equal to 1.2. SEE ALSO cuDeviceComputeCapability.returns the number of compute-capable devices SYNOPSIS CUresult cuDeviceGetCount(int* count). asynchronous launches.

int len. len specifies the maximum length of the string that may be returned. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_DEVICE Note that this function may also return error codes from previous. cuDeviceGetCount.5 cuDeviceGetName NAME cuDeviceGetName . SEE ALSO cuDeviceComputeCapability. cuDeviceGetProperties.returns an identifier string SYNOPSIS CUresult cuDeviceGetName(char* name. CUdevice dev). cuDeviceGetAttribute. DESCRIPTION Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name.2. cuDeviceTotalMem 107 . asynchronous launches. cuDeviceGet.2.

int sharedMemPerBlock. • maxGridSize[3] is the maximum sizes of each dimension of a grid. int SIMDWidth. int clockRate. where: • maxThreadsPerBlock is the maximum number of threads per block.get device properties SYNOPSIS CUresult cuDeviceGetProperties(CUdevprop* prop. • SIMDWidth is the warp size. texture base addresses that are aligned to textureAlign bytes do not need an offset applied to texture fetches.2. int maxThreadsDim[3]. • sharedMemPerBlock is the total amount of shared memory available per block in bytes. int maxGridSize[3]. • regsPerBlock is the total number of registers available per block. int memPitch. • maxThreadsDim[3] is the maximum sizes of each dimension of a block. int totalConstantMemory. • textureAlign is the alignment requirement. The CUdevprop structure is defined as: typedef struct CUdevprop_st { int maxThreadsPerBlock. • clockRate is the clock frequency in kilohertz. DESCRIPTION Returns in *prop the properties of device dev. int regsPerBlock. int textureAlign } CUdevprop. • memPitch is the maximum pitch allowed by the memory copy functions that involve memory regions allocated through cuMemAllocPitch(). CUdevice dev). 108 .2. • totalConstantMemory is the total amount of constant memory available on the device in bytes.6 cuDeviceGetProperties NAME cuDeviceGetProperties .

SEE ALSO cuDeviceComputeCapability. cuDeviceTotalMem 109 . cuDeviceGetAttribute.RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_DEVICE Note that this function may also return error codes from previous. asynchronous launches. cuDeviceGetName. cuDeviceGetCount. cuDeviceGet.

asynchronous launches. DESCRIPTION Returns in *bytes the total amount of memory available on the device dev in bytes. cuDeviceGetCount.2. cuDeviceGet. SEE ALSO cuDeviceComputeCapability. CUdevice dev ). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_DEVICE Note that this function may also return error codes from previous.7 cuDeviceTotalMem NAME cuDeviceTotalMem .2.returns the total amount of memory on the device SYNOPSIS CUresult cuDeviceTotalMem( unsigned int* bytes. cuDeviceGetName. cuDeviceGetAttribute. cuDeviceGetProperties 110 .

OpenGlInteroperability. DeviceManagement. MemoryManagement. StreamManagement. TextureReferenceManagement. EventManagement. ContextManagement.2. cuCtxAttach cuCtxCreate cuCtxDestroy cuCtxDetach cuCtxGetDevice cuCtxPopCurrent cuCtxPushCurrent cuCtxSynchronize SEE ALSO Initialization.3 ContextManagement NAME Context Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. Direct3dInteroperability 111 . ExecutionControl. ModuleManagement.

Currently.2. SEE ALSO cuCtxCreate. unsigned int Flags). DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxAttach() fails if there is no context current to the thread.3. cuCtxDetach. asynchronous launches. the Flags parameter must be 0. cuCtxSynchronize 112 .1 cuCtxAttach NAME cuCtxAttach . cuCtxGetDevice.

3. If a context is already current to the thread. it is supplanted by the newly created context and may be restored by a subsequent call to cuCtxPopCurrent(). uses a heuristic based on the number of active CUDA contexts in the process C and the number of logical processors in the system P. If C > P then CUDA will yield to other OS threads when waiting for the GPU.2. otherwise CUDA will not yield while waiting for results and actively spin on the processor. • CU_CTX_SCHED_AUTO: The default value if the Flags parameter is zero. but can increase the performance of CPU threads performing work in parallel with the GPU.create a CUDA context SYNOPSIS CUresult cuCtxCreate(CUcontext* pCtx. The context is created with a usage count of 1 and the caller of cuCtxCreate() must call cuCtxDestroy() or cuCtxDetach() when done using the context. asynchronous launches. This can increase latency when waiting for the GPU. but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread. unsigned int Flags. CUdevice dev). DESCRIPTION Creates a new CUDA context and associates it with the calling thread. The two LSBs of the Flags parameter can be used to control how the OS thread which owns the CUDA context at the time of an API call interacts with the OS scheduler when waiting for results from the GPU. The Flags parameter is described below. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_DEVICE CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. 113 .2 cuCtxCreate NAME cuCtxCreate . • CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for results from the GPU. • CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for results from the GPU. This can decrease latency when waiting for the GPU.

cuCtxDestroy. cuCtxPushCurrent.SEE ALSO cuCtxAttach. cuCtxPopCurrent 114 . cuCtxDetach.

cuCtxPushCurrent. Floating contexts (detached from a CPU thread via cuCtxPopCurrent()) may be destroyed by this function. or the context is current to any CPU thread other than the current one. cuCtxAttach. asynchronous launches.2. DESCRIPTION Destroys the given CUDA context. this function fails.3.destroy the current context context or a floating CuDA context SYNOPSIS CUresult cuCtxDestroy(CUcontext ctx). SEE ALSO cuCtxCreate. If the context usage count is not equal to 1. cuCtxPopCurrent 115 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuCtxDetach.3 cuCtxDestroy NAME cuCtxDestroy .

cuCtxPopCurrent 116 . DESCRIPTION Decrements the usage count of the context.2. SEE ALSO cuCtxCreate. The context must be a handle that was passed back by cuCtxCreate() or cuCtxAttach().3. cuCtxPushCurrent. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. asynchronous launches. and must be current to the calling thread.decrement a context’s usage-count SYNOPSIS CUresult cuCtxDetach(CUcontext ctx). cuCtxAttach.4 cuCtxDetach NAME cuCtxDetach . cuCtxDestroy. and destroys the context if the usage count goes to 0.

DESCRIPTION Returns in *device the ordinal of the current context’s device. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.5 cuCtxGetDevice NAME cuCtxGetDevice . cuCtxDetach. cuCtxAttach. asynchronous launches. SEE ALSO cuCtxCreate.3. cuCtxSynchronize 117 .return device-ID for current context SYNOPSIS CUresult cuCtxGetDevice(CUdevice* device).2.

this function makes that context current to the CPU thread again. cuCtxAttach.3.2. asynchronous launches. CUDA contexts have a usage count of 1 upon creation. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. cuCtxDetach.pops the current CUDA context from the current CPU thread SYNOPSIS CUresult cuCtxPopCurrent(CUcontext *pctx). If successful. cuCtxPopCurrent() passes back the context handle in *pctx. If a context was current to the CPU thread before cuCtxCreate or cuCtxPushCurrent was called. cuCtxDestroy. the usage count may be incremented with cuCtxAttach() and decremented with cuCtxDetach(). The CUDA context must have a usage count of 1. Floating contexts may be destroyed by calling cuCtxDestroy(). cuCtxPushCurrent 118 . SEE ALSO cuCtxCreate. The context may then be made current to a different CPU thread by calling cuCtxPushCurrent().6 cuCtxPopCurrent NAME cuCtxPopCurrent . DESCRIPTION Pops the current CUDA context from the CPU thread.

not attached to any thread. The specified context becomes the CPU thread’s current context. SEE ALSO cuCtxCreate." i.e. The previous current context may be made current again by calling cuCtxDestroy() or cuCtxPopCurrent(). cuCtxDetach.3. DESCRIPTION Pushes the given context onto the CPU thread’s stack of current contexts. asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.7 cuCtxPushCurrent NAME cuCtxPushCurrent . cuCtxDestroy. so all CUDA functions that operate on the current context are affected. Contexts are made to float by calling cuCtxPopCurrent(). cuCtxPopCurrent 119 . cuCtxAttach. The context must be "floating.2.attach floating context to CPU thread SYNOPSIS CUresult cuCtxPushCurrent(CUcontext ctx).

cuCtxGetDevice 120 . SEE ALSO cuCtxCreate.block for a context’s tasks to complete SYNOPSIS CUresult cuCtxSynchronize(void). cuCtxDetach. cuCtxSynchronize() returns an error if one of the preceding tasks failed. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. DESCRIPTION Blocks until the device has completed all preceding requested tasks. asynchronous launches.3.2. cuCtxAttach.8 cuCtxSynchronize NAME cuCtxSynchronize .

4 ModuleManagement NAME Module Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. ExecutionControl. MemoryManagement. EventManagement. cuModuleGetFunction cuModuleGetGlobal cuModuleGetTexRef cuModuleLoad cuModuleLoadData cuModuleLoadFatBinary cuModuleUnload SEE ALSO Initialization. Direct3dInteroperability 121 . DeviceManagement. OpenGlInteroperability. ContextManagement. StreamManagement. TextureReferenceManagement. ModuleManagement.2.

returns a function handle SYNOPSIS CUresult cuModuleGetFunction(CUfunction* func. cuModuleGetTexRef 122 .2. cuModuleGetGlobal. DESCRIPTION Returns in *func the handle of the function of name funcname located in module mod. asynchronous launches. CUmodule mod. cuModuleLoadData.4. cuModuleGetFunction() returns CUDA_ERROR_NOT_FOUND. cuModuleUnload.1 cuModuleGetFunction NAME cuModuleGetFunction . SEE ALSO cuModuleLoad. If no function of that name exists. const char* funcname). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NOT_FOUND Note that this function may also return error codes from previous. cuModuleLoadFatBinary.

cuModuleGetTexRef 123 . unsigned int* bytes. cuModuleLoadData. const char* globalname). Both parameters devPtr and bytes are optional.2.2 cuModuleGetGlobal NAME cuModuleGetGlobal . cuModuleUnload. it is ignored.4. If one of them is null. cuModuleGetFunction.returns a global pointer from a module SYNOPSIS CUresult cuModuleGetGlobal(CUdeviceptr* devPtr. asynchronous launches. cuModuleGetGlobal() returns CUDA_ERROR_NOT_FOUND. CUmodule mod. cuModuleLoadFatBinary. DESCRIPTION Returns in *devPtr and *bytes the base pointer and size of the global of name globalname located in module mod. SEE ALSO cuModuleLoad. If no variable of that name exists. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NOT_FOUND Note that this function may also return error codes from previous.

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

SYNOPSIS
CUresult cuModuleGetTexRef(CUtexref* texRef, CUmodule hmod, const char* texrefname);

DESCRIPTION
Returns in *texref the handle of the texture reference of name texrefname in the module mod. If no texture reference of that name exists, cuModuleGetTexRef() returns CUDA_ERROR_NOT_FOUND. This texture reference handle should not be destroyed, since it will be destroyed when the module is unloaded.

RETURN VALUE
Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NOT_FOUND Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO
cuModuleLoad, cuModuleLoadData, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

SYNOPSIS
CUresult cuModuleLoad(CUmodule* mod, const char* filename);

DESCRIPTION
Takes a file name filename and loads the corresponding module mod into the current context. The CUDA driver API does not attempt to lazily allocate the resources needed by a module; if the memory for functions and data (constant and global) needed by the module cannot be allocated, cuModuleLoad() fails. The file should be a cubin file as output by nvcc.

RETURN VALUE
Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NOT_FOUND CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_FILE_NOT_FOUND Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO
cuModuleLoadData, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

SYNOPSIS
CUresult cuModuleLoadData(CUmodule* mod, const void* image);

DESCRIPTION
Takes a pointer image and loads the corresponding module mod into the current context. The pointer may be obtained by mapping a cubin file, passing a cubin file as a text string, or incorporating a cubin object into the executable resources and using operation system calls such as WindowsâĂŹ FindResource() to obtain the pointer.

RETURN VALUE
Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO
cuModuleLoad, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

SYNOPSIS
CUresult cuModuleLoadFatBinary(CUmodule* mod, const void* fatBin);

DESCRIPTION
Takes a pointer fatBin and loads the corresponding module mod into the current context. The pointer represents a fat binary object, which is a collection of different cubin files, all representing the same device code but compiled and optimized for different architectures. There is currently no documented API for constructing and using fat binary objects by programmers, and therefore this function is an internal function in this version of CUDA. More information can be found in the nvcc document.

RETURN VALUE
Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NOT_FOUND CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_NO_BINARY_FOR_GPU Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO
cuModuleLoad, cuModuleLoadData, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

127

4. cuModuleGetTexRef 128 . cuModuleGetFunction. cuModuleLoadFatBinary. cuModuleLoadData.unloads a module SYNOPSIS CUresult cuModuleUnload(CUmodule mod). DESCRIPTION Unloads a module mod from the current context. SEE ALSO cuModuleLoad. cuModuleGetGlobal.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. asynchronous launches.7 cuModuleUnload NAME cuModuleUnload .

DeviceManagement.2. Direct3dInteroperability 129 . TextureReferenceManagement. cuStreamCreate cuStreamDestroy cuStreamQuery cuStreamSynchronize SEE ALSO Initialization. ContextManagement.5 StreamManagement NAME Stream Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. MemoryManagement. ModuleManagement. EventManagement. ExecutionControl. OpenGlInteroperability. StreamManagement.

At present. flags is required to be 0.1 cuStreamCreate NAME cuStreamCreate . cuStreamDestroy 130 .2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous.5.create a stream SYNOPSIS CUresult cuStreamCreate(CUstream* stream. unsigned int flags). asynchronous launches. DESCRIPTION Creates a stream. SEE ALSO cuStreamQuery. cuStreamSynchronize.

cuStreamQuery.destroys a stream SYNOPSIS CUresult cuStreamDestroy(CUstream stream). cuStreamSynchronize 131 .2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous.2 cuStreamDestroy NAME cuStreamDestroy . asynchronous launches.5. DESCRIPTION Destroys the stream. SEE ALSO cuStreamCreate.

5. cuStreamDestroy 132 . DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed. asynchronous launches. SEE ALSO cuStreamCreate.determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream).2.3 cuStreamQuery NAME cuStreamQuery . or CUDA_ERROR_NOT_READY if not. cuStreamSynchronize. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_READY Note that this function may also return error codes from previous.

SEE ALSO cuStreamCreate.5.block until a stream’s tasks are completed SYNOPSIS CUresult cuStreamSynchronize(CUstream stream). DESCRIPTION Blocks until the device has completed all operations in the stream. cuStreamDestroy 133 . asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous. cuStreamQuery.4 cuStreamSynchronize NAME cuStreamSynchronize .2.

2. ModuleManagement. MemoryManagement. Direct3dInteroperability 134 . DeviceManagement. ContextManagement. EventManagement. cuEventCreate cuEventDestroy cuEventElapsedTime cuEventQuery cuEventRecord cuEventSynchronize SEE ALSO Initialization. TextureReferenceManagement. ExecutionControl.6 EventManagement NAME Event Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. StreamManagement. OpenGlInteroperability.

cuEventDestroy. unsigned int flags).1 cuEventCreate NAME cuEventCreate . DESCRIPTION Creates an event. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. cuEventQuery.creates an event SYNOPSIS CUresult cuEventCreate(CUevent* event. flags is required to be 0. cuEventElapsedTime 135 . cuEventSynchronize.2. asynchronous launches. At present. SEE ALSO cuEventRecord.6.

2. SEE ALSO cuEventCreate. asynchronous launches. cuEventElapsedTime 136 . DESCRIPTION Destroys the event. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous.6. cuEventRecord. cuEventSynchronize.destroys an event SYNOPSIS CUresult cuEventDestroy(CUevent event).2 cuEventDestroy NAME cuEventDestroy . cuEventQuery.

SEE ALSO cuEventCreate. If either event has been recorded with a non-zero stream. CUevent start. CUevent end). If either event has not been recorded yet. cuEventSynchronize.2. DESCRIPTION Computes the elapsed time between two events (in milliseconds with a resolution of around 0. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. this function returns CUDA_ERROR_INVALID_VALUE.5 microseconds). asynchronous launches. cuEventQuery. the result is undefined.6. cuEventDestroy 137 .3 cuEventElapsedTime NAME cuEventElapsedTime .computes the elapsed time between two events SYNOPSIS CUresult cuEventDestroy(float* time. cuEventRecord.

asynchronous launches.queries an event’s status SYNOPSIS CUresult cuEventQuery(CUevent event).4 cuEventQuery NAME cuEventQuery . If cuEventRecord() has not been called on this event. SEE ALSO cuEventCreate. DESCRIPTION Returns CUDA_SUCCESS if the event has actually been recorded.2. cuEventElapsedTime 138 . or CUDA_ERROR_NOT_READY if not.6. cuEventDestroy. cuEventSynchronize. the function returns CUDA_ERROR_INVALID_VALUE RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_READY Note that this function may also return error codes from previous. cuEventRecord.

records an event SYNOPSIS CUresult cuEventRecord(CUevent event. cuEventSynchronize. SEE ALSO cuEventCreate. cuEventDestroy. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. CUstream stream). otherwise.2. cuEventElapsedTime 139 . this function returns CUDA_ERROR_INVALID_VALUE. cuEventQuery. DESCRIPTION Records an event. If cuEventRecord() has previously been called and the event has not been recorded yet. cuEventQuery() and/or cuEventSynchronize() must be used to determine when the event has actually been recorded. it is recorded after all preceding operations in the CUDA context have been completed.6. If stream is non-zero.5 cuEventRecord NAME cuEventRecord . asynchronous launches. Since this operation is asynchronous. the event is recorded after all preceding operations in the stream have been completed.

SEE ALSO cuEventCreate. the function returns CUDA_ERROR_INVALID_VALUE. cuEventDestroy. cuEventQuery.6. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous. cuEventRecord.6 cuEventSynchronize NAME cuEventSynchronize . If cuEventRecord() has not been called on this event. cuEventElapsedTime 140 . DESCRIPTION Blocks until the event has actually been recorded.waits for an event to complete SYNOPSIS CUresult cuEventSynchronize(CUevent event).2. asynchronous launches.

EventManagement. MemoryManagement. DeviceManagement. OpenGlInteroperability. ContextManagement.2. ExecutionControl. TextureReferenceManagement.7 ExecutionControl NAME Execution Control DESCRIPTION This section describes the low-level CUDA driver application programming interface. StreamManagement. ModuleManagement. cuLaunch cuLaunchGrid cuParamSetSize cuParamSetTexRef cuParamSetf cuParamSeti cuParamSetv cuFuncSetBlockShape cuFuncSetSharedSize SEE ALSO Initialization. Direct3dInteroperability 141 .

1 cuLaunch NAME cuLaunch . cuParamSetf.7. DESCRIPTION Invokes the kernel func on a 1ÃŮ1 grid of blocks. cuParamSetTexRef. cuFuncSetSharedSize. cuParamSetSize.2. cuLaunchGrid 142 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING Note that this function may also return error codes from previous. cuParamSetv.launches a CUDA function SYNOPSIS CUresult cuLaunch(CUfunction func). asynchronous launches. SEE ALSO cuFuncSetBlockShape. The block contains the number of threads specified by a previous call to cuFuncSetBlockShape(). cuParamSeti.

DESCRIPTION Invokes the kernel on a grid_width x grid_height grid of blocks. cuLaunch 143 . int grid_height). cuParamSetf. cuParamSetTexRef. SEE ALSO cuFuncSetBlockShape. Each block contains the number of threads specified by a previous call to cuFuncSetBlockShape(). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING Note that this function may also return error codes from previous. cuParamSetv. cuParamSetSize. asynchronous launches.2 cuLaunchGrid NAME cuLaunchGrid . int grid_height. cuLaunchGridAsync() can optionally be associated to a stream by passing a non-zero stream argument. CUstream stream). int grid_width.2.launches a CUDA function SYNOPSIS CUresult cuLaunchGrid(CUfunction func. cuParamSeti. cuFuncSetSharedSize. CUresult cuLaunchGridAsync(CUfunction func. int grid_width.7.

sets the parameter-size for the function SYNOPSIS CUresult cuParamSetSize(CUfunction func. cuLaunch.3 cuParamSetSize NAME cuParamSetSize . cuParamSetf. DESCRIPTION Sets through numbytes the total size in bytes needed by the function parameters of function func. cuParamSeti. cuLaunchGrid 144 . SEE ALSO cuFuncSetBlockShape. cuParamSetv.2.7. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuParamSetTexRef. unsigned int numbytes). asynchronous launches. cuFuncSetSharedSize.

adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func. In this version of CUDA.4 cuParamSetTexRef NAME cuParamSetTexRef . the texture reference must be obtained via cuModuleGetTexRef() and the texunit parameter must be set to CU_PARAM_TR_DEFAULT. cuLaunchGrid 145 . cuParamSetv. asynchronous launches. CUtexref texRef). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. SEE ALSO cuFuncSetBlockShape. cuParamSeti. cuParamSetf. int texunit. cuFuncSetSharedSize. DESCRIPTION Makes the CUDA array or linear memory bound to the texture reference texRef available to a device program as a texture.7.2. cuParamSetSize. cuLaunch.

float value). int offset. cuFuncSetSharedSize. asynchronous launches. cuParamSeti. offset is a byte offset.adds a floating-point parameter to the function’s argument list SYNOPSIS CUresult cuParamSetf(CUfunction func. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuParamSetSize. DESCRIPTION Sets a floating point parameter that will be specified the next time the kernel corresponding to func will be invoked. cuLaunchGrid 146 . cuParamSetv.5 cuParamSetf NAME cuParamSetf . cuLaunch. SEE ALSO cuFuncSetBlockShape.2.7. cuParamSetTexRef.

DESCRIPTION Sets an integer parameter that will be specified the next time the kernel corresponding to func will be invoked. asynchronous launches. cuLaunchGrid 147 . cuParamSetv. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuLaunch.2. int offset. cuParamSetf. cuParamSetSize.7. offset is a byte offset. unsigned int value). cuFuncSetSharedSize. cuParamSetTexRef.6 cuParamSeti NAME cuParamSeti .adds an integer parameter to the function’s argument list SYNOPSIS CUresult cuParamSeti(CUfunction func. SEE ALSO cuFuncSetBlockShape.

adds arbitrary data to the function’s argument list SYNOPSIS CUresult cuParamSetv(CUfunction func. int offset. offset is a byte offset. cuParamSeti. asynchronous launches.7. cuParamSetSize. DESCRIPTION Copies an arbitrary amount of data into the parameter space of the kernel corresponding to func. cuParamSetf. cuLaunchGrid 148 . SEE ALSO cuFuncSetBlockShape. cuLaunch. unsigned int numbytes).7 cuParamSetv NAME cuParamSetv . void* ptr. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuFuncSetSharedSize. cuParamSetTexRef.2.

cuParamSeti.sets the block-dimensions for the function SYNOPSIS CUresult cuFuncSetBlockShape(CUfunction func. int z). asynchronous launches. cuLaunchGrid 149 . cuParamSetf. cuParamSetv. cuParamSetTexRef. cuParamSetSize.2.7. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. Y and Z dimensions of the thread blocks that are created when the kernel given by func is launched. SEE ALSO cuFuncSetSharedSize. DESCRIPTION Specifies the X.8 cuFuncSetBlockShape NAME cuFuncSetBlockShape . int x. cuLaunch. int y.

cuParamSetSize. cuParamSetTexRef.7.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . unsigned int bytes). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuParamSetv. cuParamSetf. cuLaunch. cuParamSeti.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. SEE ALSO cuFuncSetBlockShape. asynchronous launches. cuLaunchGrid 150 . DESCRIPTION Sets through bytes the amount of shared memory that will be available to each thread block when the kernel given by func is launched.2.

cuArrayCreate cuArray3DCreate cuArrayDestroy cuArrayGetDescriptor cuArray3DGetDescriptor cuMemAlloc cuMemAllocHost cuMemAllocPitch cuMemFree cuMemFreeHost cuMemGetAddressRange cuMemGetInfo cuMemcpy2D cuMemcpy3D cuMemcpyAtoA cuMemcpyAtoD cuMemcpyAtoH cuMemcpyDtoA cuMemcpyDtoD cuMemcpyDtoH cuMemcpyHtoA cuMemcpyHtoD cuMemset cuMemset2D SEE ALSO Initialization. DeviceManagement. ExecutionControl. ModuleManagement. OpenGlInteroperability. MemoryManagement. Direct3dInteroperability 151 . StreamManagement.2. EventManagement.8 MemoryManagement NAME Memory Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. TextureReferenceManagement. ContextManagement.

CU_AD_FORMAT_SIGNED_INT32 = 0x0a. The CUDA_ARRAY_DESCRIPTOR structure is defined as such: typedef struct { unsigned int Width. • Format specifies the format of the elements. CU_AD_FORMAT_UNSIGNED_INT32 = 0x03. CU_AD_FORMAT_HALF = 0x10. 2 or 4. two-dimensional. CUarray_format is defined as such: typedef enum CUarray_format_enum { CU_AD_FORMAT_UNSIGNED_INT8 = 0x01. CU_AD_FORMAT_SIGNED_INT16 = 0x09.8. the CUDA array is one-dimensional if height is 0. CU_AD_FORMAT_UNSIGNED_INT16 = 0x02. Here are examples of CUDA array descriptions: • Description for a CUDA array of 2048 floats: CUDA_ARRAY_DESCRIPTOR desc.Format = CU_AD_FORMAT_FLOAT.. CU_AD_FORMAT_FLOAT = 0x20 } CUarray_format.1 cuArrayCreate NAME cuArrayCreate . CU_AD_FORMAT_SIGNED_INT8 = 0x08.2. it may be 1. CUarray_format Format. unsigned int Height. otherwise. 152 . const CUDA_ARRAY_DESCRIPTOR* desc). DESCRIPTION Creates a CUDA array according to the CUDA_ARRAY_DESCRIPTOR structure desc and returns a handle to the new CUDA array in *array. } CUDA_ARRAY_DESCRIPTOR. desc. unsigned int NumChannels. where: • Width and Height are the width and height of the CUDA array (in elements). • NumChannels specifies the number of packed components per CUDA array element.creates a 1D or 2D CUDA array SYNOPSIS CUresult cuArrayCreate(CUarray* array.

desc.Width = 64.Width = width.FormatFlags = CU_AD_FORMAT_HALF. desc. each of which is two 8-bit unsigned chars: CUDA_ARRAY_DESCRIPTOR arrayDesc. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc.NumChannels = 1. desc. cuMemFree. desc.FormatFlags = CU_AD_FORMAT_UNSIGNED_INTS. desc.Height = 1. cuMemAllocPitch. desc.Format = CU_AD_FORMAT_FLOAT.Height = height. desc. desc. desc.Width = 2048. • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY_DESCRIPTOR desc. desc. cuArrayGetDescriptor. • Description for a width x height CUDA array of 16-bit elements. cuArrayDestroy.Width = width.NumChannels = 1. cuMemFreeHost. cuMemAlloc.Height = 64.desc.NumChannels = 2. asynchronous launches.NumChannels = 4. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. desc. cuMemset2D 153 .Height = height. • Description for a width x height CUDA array of 64-bit. cuMemset. SEE ALSO cuMemGetInfo. cuMemAllocHost. desc. desc. cuMemGetAddressRange. desc.

creates a CUDA array SYNOPSIS CUresult cuArray3DCreate(CUarray* array. • Flags provides for future features. it must be set to 0. where: • Width. } CUDA_ARRAY3D_DESCRIPTOR. DESCRIPTION Creates a CUDA array according to the CUDA_ARRAY3D_DESCRIPTOR structure desc and returns a handle to the new CUDA array in *array. CU_AD_FORMAT_UNSIGNED_INT32 = 0x03. Here are examples of CUDA array descriptions: 154 .8. 2 or 4. height and depth of the CUDA array (in elements). unsigned int Flags. CU_AD_FORMAT_SIGNED_INT8 = 0x08.2. CU_AD_FORMAT_SIGNED_INT16 = 0x09. • Format specifies the format of the elements. CU_AD_FORMAT_FLOAT = 0x20 } CUarray_format. unsigned int Depth. CU_AD_FORMAT_UNSIGNED_INT16 = 0x02. unsigned int Height. For now. and threedimensional otherwise. the CUDA array is one-dimensional if height and depth are 0. it may be 1. CUarray_format is defined as such: typedef enum CUarray_format_enum { CU_AD_FORMAT_UNSIGNED_INT8 = 0x01. unsigned int NumChannels. CU_AD_FORMAT_SIGNED_INT32 = 0x0a.. The CUDA_ARRAY3D_DESCRIPTOR structure is defined as such: typedef struct { unsigned int Width. • NumChannels specifies the number of packed components per CUDA array element. const CUDA_ARRAY3D_DESCRIPTOR* desc). CUarray_format Format.2 cuArray3DCreate NAME cuArray3DCreate . two-dimensional if depth is 0. CU_AD_FORMAT_HALF = 0x10. Height and Depth are the width.

asynchronous launches. desc.NumChannels = 1. desc.Width = width. cuArrayDestroy 155 . desc. cuMemFreeHost.• Description for a CUDA array of 2048 floats: CUDA_ARRAY3D_DESCRIPTOR desc. cuMemAllocHost. desc. cuMemFree.Format = CU_AD_FORMAT_FLOAT. desc. desc.Height = 64. SEE ALSO cuMemGetInfo. desc. desc. desc. desc. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.NumChannels = 1. cuMemAlloc.Format = CU_AD_FORMAT_FLOAT. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc. desc.Width = 2048.Depth = depth.NumChannels = 4. • Description for a width x height x depth CUDA array of 64-bit. desc.Height = height. desc.Height = 0.Width = 64. cuMemGetAddressRange.Depth = 0. cuArray3DGetDescriptor.Depth = 0. desc.FormatFlags = CU_AD_FORMAT_HALF. cuMemAllocPitch. • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY3D_DESCRIPTOR desc. desc.

cuMemset.2.destroys a CUDA array SYNOPSIS CUresult cuArrayDestroy(CUarray array). cuMemset2D 156 . cuMemFreeHost. DESCRIPTION Destroys the CUDA array array. cuArrayGetDescriptor. cuMemFree. cuMemAllocPitch. asynchronous launches. cuArrayCreate.3 cuArrayDestroy NAME cuArrayDestroy . cuMemAllocHost. cuMemGetAddressRange. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_ARRAY_IS_MAPPED Note that this function may also return error codes from previous. cuMemAlloc. SEE ALSO cuMemGetInfo.8.

CUarray array) DESCRIPTION Returns in *arrayDesc a descriptor of the format and dimensions of the 1D or 2D CUDA array array. It is useful for subroutines that have been passed a CUDA array. asynchronous launches. cuArray3DGetDescriptor. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous. cuArray3DCreate. SEE ALSO cuArrayCreate.8.4 cuArrayGetDescriptor NAME cuArrayGetDescriptor . but need to know the CUDA array parameters for validation or other purposes.2. cuArrayDestroy 157 .get a 1D or 2D CUDA array descriptor SYNOPSIS CUresult cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR* arrayDesc.

8. cuArrayDestroy 158 . SEE ALSO cuArrayCreate. cuArrayGetDescriptor.2. cuArray3DCreate. DESCRIPTION Returns in *arrayDesc a descriptor containing information on the format and dimensions of the CUDA array array. It is useful for subroutines that have been passed a CUDA array.5 cuArray3DGetDescriptor NAME cuArray3DGetDescriptor . asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous. but need to know the CUDA array parameters for validation or other purposes.get a 3D CUDA array descriptor SYNOPSIS CUresult cuArray3DGetDescriptor(CUDA_ARRAY3D_DESC *arrayDesc. CUarray array).

cuArrayCreate. cuMemFree. cuMemGetAddressRange. cuArrayGetDescriptor.8. cuMemset. cuMemFreeHost. cuMemset2D 159 .allocates device memory SYNOPSIS CUresult cuMemAlloc(CUdeviceptr* devPtr. If count is 0. cuMemAllocHost. The allocated memory is suitably aligned for any kind of variable. SEE ALSO cuMemGetInfo. The memory is not cleared.2. cuMemAllocPitch. cuArrayDestroy. unsigned int count).6 cuMemAlloc NAME cuMemAlloc . DESCRIPTION Allocates count bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. cuMemAlloc() returns CUDA_ERROR_INVALID_VALUE. asynchronous launches.

Allocating excessive amounts of memory with cuMemAllocHost() may degrade system performance. DESCRIPTION Allocates count bytes of host memory that is page-locked and accessible to the device.7 cuMemAllocHost NAME cuMemAllocHost . cuMemset2D 160 .8. cuMemFree. unsigned int count). cuMemGetAddressRange. cuArrayCreate. cuMemFreeHost. since it reduces the amount of memory available to the system for paging. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as cuMemcpy(). cuMemset. SEE ALSO cuMemGetInfo. cuArrayGetDescriptor.2. cuArrayDestroy. this function is best used sparingly to allocate staging areas for data exchange between host and device. As a result.allocates page-locked host memory SYNOPSIS CUresult cuMemAllocHost(void** hostPtr. asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. cuMemAlloc. it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). Since the memory can be accessed directly by the device. cuMemAllocPitch.

elementSizeBytes specifies the size of the largest reads and writes that will be performed on the memory range. unsigned int widthInBytes. Due to alignment restrictions in the hardware. The pitch returned in *pitch by cuMemAllocPitch() is the width in bytes of the allocation. asynchronous launches. If elementSizeBytes is smaller than the actual read/write size of a kernel. 161 . 8 or 16 (since coalesced memory transactions are not possible on other data sizes). this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or CUDA arrays).8. elementSizeBytes may be 4. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. but possibly at reduced speed. it is recommended that programmers consider performing pitch allocations using cuMemAllocPitch(). unsigned int* pitch. unsigned int elementSizeBytes). The pitch returned by cuMemAllocPitch() is guaranteed to work with cuMemcpy2D() under all circumstances. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. the kernel will run correctly. the address is computed as T* pElement = (T*)((char*)BaseAddress + Row * Pitch) + Column.2.allocates device memory SYNOPSIS CUresult cuMemAllocPitch(CUdeviceptr* devPtr.8 cuMemAllocPitch NAME cuMemAllocPitch . DESCRIPTION Allocates at least widthInBytes*height bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. For allocations of 2D arrays. Given the row and column of an array element of type T. unsigned int height. used to compute addresses within the 2D array. The intended usage of pitch is as a separate parameter of the allocation.

cuMemset2D 162 .SEE ALSO cuMemGetInfo. cuMemAllocHost. cuArrayDestroy. cuMemGetAddressRange. cuArrayGetDescriptor. cuMemFree. cuMemAlloc. cuMemset. cuArrayCreate. cuMemFreeHost.

cuMemGetAddressRange. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemset2D 163 . cuMemset. asynchronous launches. which must have been returned by a previous call to cuMemMalloc() or cuMemMallocPitch().2.8. cuMemAllocHost. cuMemAlloc.frees device memory SYNOPSIS CUresult cuMemFree(CUdeviceptr devPtr). cuArrayCreate. cuArrayDestroy.9 cuMemFree NAME cuMemFree . SEE ALSO cuMemGetInfo. DESCRIPTION Frees the memory space pointed to by devPtr. cuMemFreeHost. cuArrayGetDescriptor. cuMemAllocPitch.

frees page-locked host memory SYNOPSIS CUresult cuMemFreeHost(void* hostPtr). DESCRIPTION Frees the memory space pointed to by hostPtr. cuMemset. cuArrayDestroy. cuMemAlloc. cuMemAllocHost.8. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuArrayCreate.10 cuMemFreeHost NAME cuMemFreeHost . SEE ALSO cuMemGetInfo. cuMemset2D 164 . asynchronous launches. cuMemFree. which must have been returned by a previous call to cuMemAllocHost(). cuMemGetAddressRange. cuMemAllocPitch.2. cuArrayGetDescriptor.

SEE ALSO cuMemGetInfo. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuArrayDestroy. cuMemFree.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr.2. unsigned int* size. asynchronous launches. cuMemAlloc. it is ignored. cuMemAllocPitch. DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr. cuArrayGetDescriptor. CUdeviceptr devPtr).11 cuMemGetAddressRange NAME cuMemGetAddressRange . cuMemset. cuMemFreeHost. cuMemset2D 165 . cuArrayCreate. Both parameters basePtr and size are optional.8. cuMemAllocHost. If one of them is null.

cuMemGetAddressRange.gets free and total memory SYNOPSIS CUresult cuMemGetInfo(unsigned int* free. DESCRIPTION Returns in *free and *total respectively. asynchronous launches. cuMemset2D 166 . in bytes. cuArrayGetDescriptor. cuMemset. cuMemFreeHost. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemAllocHost.8. SEE ALSO cuMemAlloc.12 cuMemGetInfo NAME cuMemGetInfo . cuArrayDestroy. cuMemAllocPitch. cuArrayCreate. the free and total amount of memory available for allocation by the CUDA context.2. unsigned int* total). cuMemFree.

CUresult cuMemcpy2DAsync(const CUDA_MEMCPY2D* copyParam. respectively. CUdeviceptr srcDevice. srcY. CUmemorytype srcMemoryType. If srcMemoryType is CU_MEMORYTYPE_DEVICE. srcArray is ignored. CUarray srcArray. where: • srcMemoryType and dstMemoryType specify the type of memory of the source and destination. CUmemorytype dstMemoryType. unsigned int dstXInBytes. srcDevice and srcPitch specify the (device) base address of the source data and the bytes per row to apply. unsigned int WidthInBytes. If srcMemoryType is CU_MEMORYTYPE_HOST. void *dstHost. srcHost and srcPitch specify the (host) base address of the source data and the bytes per row to apply. CU_MEMORYTYPE_ARRAY = 0x03 } CUmemorytype. unsigned int srcPitch. CUmemorytype_enum is defined as such: typedef enum CUmemorytype_enum { CU_MEMORYTYPE_HOST = 0x01. CUstream stream). CU_MEMORYTYPE_DEVICE = 0x02.copies memory for 2D arrays SYNOPSIS CUresult cuMemcpy2D(const CUDA_MEMCPY2D* copyParam). CUdeviceptr dstDevice. unsigned int Height. dstY. srcArray is ignored.8.2.13 cuMemcpy2D NAME cuMemcpy2D . CUresult cuMemcpy2DUnaligned(const CUDA_MEMCPY2D* copyParam). 167 . } CUDA_MEMCPY2D. CUarray dstArray. The CUDA_MEMCPY2D structure is defined as such: typedef struct CUDA_MEMCPY2D_st { unsigned int srcXInBytes. unsigned int dstPitch. DESCRIPTION Perform a 2D memory copy according to the parameters specified in copyParam. const void *srcHost.

cuMemcpy2DAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. Any pitches must be greater than or equal to WidthInBytes.If srcMemoryType is CU_MEMORYTYPE_ARRAY. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED 168 . For CUDA arrays. • WidthInBytes and Height specify the width (in bytes) and height of the 2D copy being performed. For device pointers. • dstXInBytes and dstY specify the base address of the destination data for the copy. cuMemcpy2D() returns an error if any pitch is greater than the maximum allowed (CU_DEVICE_ATTRIBUTE_ cuMemAllocPitch() passes back pitches that always work with cuMemcpy2D(). For host pointers. dstHost and dstPitch specify the (host) base address of the destination data and the bytes per row to apply. dstArray is ignored. If dstMemoryType is CU_MEMORYTYPE_HOST. • srcXInBytes and srcY specify the base address of the source data for the copy. dstXInBytes must be evenly divisible by the array element size. srcArray specifies the handle of the source data. dstHost. For CUDA arrays. On intra-device memory copies (device ? device. For host pointers. For device pointers. the base address is void* dstStart = (void*)((char*)dstHost+dstY*dstPitch + dstXInBytes). the starting address is CUdeviceptr Start = srcDevice+srcY*srcPitch+srcXInBytes. the starting address is CUdeviceptr dstStart = dstDevice+dstY*dstPitch+dstXInBytes. cuMemcpy2DUnaligned() does not have this restriction. dstDevice and dstPitch are ignored. If dstMemoryType is CU_MEMORYTYPE_DEVICE. dstDevice and dstPitch specify the (device) base address of the destination data and the bytes per row to apply. srcXInBytes must be evenly divisible by the array element size. If dstMemoryType is CU_MEMORYTYPE_ARRAY. dstArray specifies the handle of the destination data. CUDA array ? CUDA array). srcHost. CUDA array ? device. cuMemcpy2D() may fail for pitches not computed by cuMemAllocPitch(). but may run significantly slower in the cases where cuMemcpy2D() would have returned an error code. dstArray is ignored. srcDevice and srcPitch are ignored. the starting address is void* Start = (void*)((char*)srcHost+srcY*srcPitch + srcXInBytes). It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input.

cuMemcpyHtoA. cuMemcpyDtoH. cuMemcpyDtoD. cuMemcpyAtoH. asynchronous launches. SEE ALSO cuMemcpyHtoD. cuMemcpyAtoD.CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpy3D 169 . cuMemcpyAtoA. cuMemcpyDtoA.

DESCRIPTION Perform a 3D memory copy according to the parameters specified in copyParam. const void *srcHost. void *dstHost. CUarray dstArray.copies memory for 3D arrays SYNOPSIS CUresult cuMemcpy3D(const CUDA_MEMCPY3D* copyParam). may be 0 if Depth==1 unsigned int dstXInBytes. unsigned int dstLOD. dstZ. CUdeviceptr dstDevice. unsigned int Depth. CUdeviceptr srcDevice. respectively. CUstream stream). srcY. unsigned int dstPitch. // ignored when dst is array unsigned int dstHeight. unsigned int srcPitch. unsigned int Height. CUarray srcArray.14 cuMemcpy3D NAME cuMemcpy3D . // ignored when dst is array. unsigned int srcLOD. srcZ.2. The CUDA_MEMCPY3D structure is defined as such: typedef struct CUDA_MEMCPY3D_st { unsigned int srcXInBytes. CUmemorytype_enum is defined as such: typedef enum CUmemorytype_enum { 170 . may be 0 if Depth==1 unsigned int WidthInBytes. } CUDA_MEMCPY3D. // ignored when src is array. dstY. where: • srcMemoryType and dstMemoryType specify the type of memory of the source and destination. CUmemorytype srcMemoryType.8. CUresult CUDAAPI cuMemcpy3D( const CUDA_MEMCPY3D *pCopy ). CUresult cuMemcpy3DAsync(const CUDA_MEMCPY3D* copyParam. CUmemorytype dstMemoryType. // ignored when src is array unsigned int srcHeight.

and the height of each 2D slice of the 3D array. If dstMemoryType is CU_MEMORYTYPE_DEVICE. srcPitch and srcHeight specify the (host) base address of the source data. For device pointers. If srcMemoryType is CU_MEMORYTYPE_ARRAY. If dstMemoryType is CU_MEMORYTYPE_ARRAY. • WidthInBytes. CU_MEMORYTYPE_ARRAY = 0x03 } CUmemorytype. and the height of each 2D slice of the 3D array. For host pointers. For CUDA arrays. the bytes per row. • srcXInBytes. srcDevice. For host pointers. the base address is void* dstStart = (void*)((char*)dstHost+(dstZ*dstHeight+dstY)*dstPitch + dstXInBytes).CU_MEMORYTYPE_HOST = 0x01. CU_MEMORYTYPE_DEVICE = 0x02. the bytes per row. If dstMemoryType is CU_MEMORYTYPE_HOST. height and depth of the 3D copy being performed. dstY and dstZ specify the base address of the destination data for the copy. dstPitch and dstHeight are ignored. dstDevice. Height and Depth specify the width (in bytes). dstArray is ignored. srcXInBytes must be evenly divisible by the array element size. dstArray is ignored. dstHost and dstPitch specify the (host) base address of the destination data. srcDevice. srcArray is ignored. srcPitch and srcHeight specify the (device) base address of the source data. the bytes per row. The srcLOD and dstLOD members of the CUDA_MEMCPY3D structure must be set to 0. srcHost. cuMemcpy3DAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. srcHost. the bytes per row. the starting address is void* Start = (void*)((char*)srcHost+(srcZ*srcHeight+srcY)*srcPitch + srcXInBytes). Any pitches must be greater than or equal to WidthInBytes. • dstXInBytes. If srcMemoryType is CU_MEMORYTYPE_HOST. 171 cuMemcpy3D() returns an error if any pitch is greater than the maximum allowed (CU_DEVICE_ATTRIBUTE_ . and the height of each 2D slice of the 3D array. srcY and srcZ specify the base address of the source data for the copy. srcArray specifies the handle of the source data. dstXInBytes must be evenly divisible by the array element size. the starting address is CUdeviceptr Start = srcDevice+(srcZ*srcHeight+srcY)*srcPitch+srcXInBytes. and the height of each 2D slice of the 3D array. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. the starting address is CUdeviceptr dstStart = dstDevice+(dstZ*dstHeight+dstY)*dstPitch+dstXInBytes. srcPitch and srcHeight are ignored. If srcMemoryType is CU_MEMORYTYPE_DEVICE. dstDevice and dstPitch specify the (device) base address of the destination data. dstHost. For device pointers. dstArray specifies the handle of the destination data. srcArray is ignored. For CUDA arrays.

cuMemcpyAtoD. cuMemcpyAtoH. cuMemcpyAtoA. cuMemcpy2DAsync 172 . cuMemcpy2D. cuMemcpyHtoA. cuMemcpyDtoD. cuMemcpyDtoA.RETURN VALUE CUDA_SUCCESS SEE ALSO cuMemcpyHtoD. cuMemcpyDtoH.

copies memory from Array to Array SYNOPSIS CUresult cuMemcpyAtoA(CUarray dstArray. cuMemcpyHtoA.2. Width-1] for the CUDA array. count is the number of bytes to be copied. unsigned int dstIndex. SEE ALSO cuMemcpyHtoD. they are not byte offsets. unsigned int srcIndex. cuMemcpyAtoH. DESCRIPTION Copies from one 1D CUDA array to another. unsigned int count). cuMemcpyDtoD. cuMemcpyDtoH.8. These values are in the range [0. dstIndex and srcIndex specify the destination and source indices into the CUDA array. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpyAtoD. CUarray srcArray. dstArray and srcArray specify the handles of the destination and source CUDA arrays for the copy. but the elements must be the same size.15 cuMemcpyAtoA NAME cuMemcpyAtoA . cuMemcpyDtoA. The size of the elements in the CUDA arrays need not be the same format. cuMemcpy2D 173 . asynchronous launches. respectively. and count must be evenly divisible by that size.

RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. unsigned int count). unsigned int srcIndex. cuMemcpyAtoA. SEE ALSO cuMemcpyHtoD. cuMemcpyDtoH. cuMemcpyAtoH. cuMemcpyDtoA. cuMemcpy2D 174 . DESCRIPTION Copies from a 1D CUDA array to device memory. asynchronous launches. count specifies the number of bytes to copy and must be evenly divisible by the array element size.copies memory from Array to Device SYNOPSIS CUresult cuMemcpyAtoD(CUdeviceptr dstDevPtr.16 cuMemcpyAtoD NAME cuMemcpyAtoD .8. dstDevPtr specifies the base pointer of the destination and must be naturally aligned with the CUDA array elements.2. srcArray and srcIndex specify the CUDA array handle and the index (in array elements) of the array element where the copy is to begin. cuMemcpyHtoA. CUarray srcArray. cuMemcpyDtoD.

8. cuMemcpyAtoHAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. cuMemcpyDtoD. unsigned int count. srcArray and srcIndex specify the CUDA array handle and starting index of the source data. DESCRIPTION Copies from a 1D CUDA array to host memory.17 cuMemcpyAtoH NAME cuMempcyAtoH . CUarray srcArray. dstHostPtr specifies the base pointer of the destination. SEE ALSO cuMemcpyHtoD.copies memory from Array to Host SYNOPSIS CUresult cuMemcpyAtoH(void* dstHostPtr. asynchronous launches. cuMemcpyDtoA. CUstream stream). unsigned int srcIndex. cuMemcpyAtoD. CUarray srcArray. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpy2D 175 . It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cuMemcpyAtoA. unsigned int srcIndex. cuMemcpyHtoA. CUresult cuMemcpyAtoHAsync(void* dstHostPtr. cuMemcpyDtoH.2. count specifies the number of bytes to copy. unsigned int count).

8. unsigned int count). cuMemcpyHtoA. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. DESCRIPTION Copies from device memory to a 1D CUDA array. SEE ALSO cuMemcpyHtoD. cuMemcpy2D 176 . count specifies the number of bytes to copy. dstArray and dstIndex specify the CUDA array handle and starting index of the destination data. srcDevPtr specifies the base pointer of the source. unsigned int dstIndex. cuMemcpyAtoH.copies memory from Device to Array SYNOPSIS CUresult cuMemcpyDtoA(CUarray dstArray. cuMemcpyAtoD.18 cuMemcpyDtoA NAME cuMemcpyDtoA .2. asynchronous launches. cuMemcpyDtoH. CUdeviceptr srcDevPtr. cuMemcpyDtoD. cuMemcpyAtoA.

unsigned int count).8. asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpyDtoA. DESCRIPTION Copies from device memory to device memory.19 cuMemcpyDtoD NAME cuMemcpyDtoD . cuMemcpy2D 177 . SEE ALSO cuMemcpyHtoD. cuMemcpyHtoA. cuMemcpyDtoH. respectively. cuMemcpyAtoH. cuMemcpyAtoD. count specifies the number of bytes to copy. CUdeviceptr srcDevPtr. dstDevice and srcDevPtr are the base pointers of the destination and source.copies memory from Device to Device SYNOPSIS CUresult cuMemcpyDtoD(CUdeviceptr dstDevPtr. cuMemcpyAtoA.2.

copies memory from Device to Host SYNOPSIS CUresult cuMemcpyDtoH(void* dstHostPtr. SEE ALSO cuMemcpyHtoD.2. cuMemcpyDtoD. dstHostPtr and srcDevPtrspecify the base addresses of the source and destination. CUdeviceptr srcDevPtr. unsigned int count). CUstream stream). cuMemcpyAtoD. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. MemcpyDtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. cuMemcpyDtoA. unsigned int count.8. cuMemcpyAtoH. respectively. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input.20 cuMemcpyDtoH NAME cuMemcpyDtoH . cuMemcpyHtoA. countspecifies the number of bytes to copy. DESCRIPTION Copies from device to host memory. asynchronous launches. cuMemcpyAtoA. CUdeviceptr srcDevPtr. CUresult cuMemcpyDtoHAsync(void* dstHostPtr. cuMemcpy2D 178 .

CUstream stream). count specifies the number of bytes to copy. SEE ALSO cuMemcpyHtoD.21 cuMemcpyHtoA NAME cuMemcpyHtoA . cuMemcpyAtoH. cuMemcpyHtoAAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. dstArray and dstIndex specify the CUDA array handle and starting index of the destination data. cuMemcpyAtoD.8. cuMemcpyDtoH. srcHostPtr specify the base addresse of the source. unsigned int count. asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpyAtoA. CUresult cuMemcpyHtoAAsync(CUarray dstArray. unsigned int dstIndex. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cuMemcpy2D 179 . cuMemcpyDtoA.2. unsigned int count). DESCRIPTION Copies from host memory to a 1D CUDA array.copies memory from Host to Array SYNOPSIS CUresult cuMemcpyHtoA(CUarray dstArray. unsigned int dstIndex. cuMemcpyDtoD. const void *srcHostPtr. const void *srcHostPtr.

unsigned int count. cuMemcpyHtoDAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. const void *srcHostPtr. cuMemcpyDtoA. cuMemcpyDtoD. unsigned int count). asynchronous launches.22 cuMemcpyHtoD NAME cuMemcpyHtoD .8. CUstream stream). dstDevPtr and srcHostPtr specify the base addresses of the destination and source. DESCRIPTION Copies from host memory to device memory. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cuMemcpyAtoA. cuMemcpy2D 180 . cuMemcpyAtoD.copy memory from Host to Device SYNOPSIS CUresult cuMemcpyHtoD(CUdeviceptr dstDevPtr. const void *srcHostPtr. CUresult cuMemcpyHtoDAsync(CUdeviceptr dstDevPtr.2. cuMemcpyAtoH. count specifies the number of bytes to copy. cuMemcpyHtoA. respectively. SEE ALSO cuMemcpyDtoH.

23 cuMemset NAME cuMemset .2. unsigned int count ). cuMemset2D 181 . cuMemAllocPitch. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemGetAddressRange. cuMemFreeHost. unsigned int value. cuMemAllocHost. cuArrayDestroy. SEE ALSO cuMemGetInfo. cuArrayGetDescriptor. CUresult cuMemsetD32(CUdeviceptr dstDevPtr. cuMemFree. unsigned short value. unsigned int count ).initializes device memory SYNOPSIS CUresult cuMemsetD8(CUdeviceptr dstDevPtr. DESCRIPTION Sets the memory range of count 8-. 16-. cuArrayCreate. CUresult cuMemsetD16(CUdeviceptr dstDevPtr.8. or 32-bit values to the specified value value. unsigned char value. unsigned int count ). cuMemAlloc. asynchronous launches.

cuMemAllocPitch. cuMemFree. unsigned short value. unsigned int dstPitch.2. 16-. unsigned int height ). unsigned int dstPitch. unsigned int value. CUresult cuMemsetD2D16(CUdeviceptr dstDevPtr. cuArrayCreate. unsigned int width.initializes device memory SYNOPSIS CUresult cuMemsetD2D8(CUdeviceptr dstDevPtr. cuArrayDestroy.24 cuMemset2D NAME cuMemset2D . DESCRIPTION Sets the 2D memory range of width 8-. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemGetAddressRange. unsigned int height ). These functions perform fastest when the pitch is one that has been passed back by cuMemAllocPitch(). unsigned int width. height specifies the number of rows to set. SEE ALSO cuMemGetInfo. asynchronous launches. unsigned char value. cuMemFreeHost. or 32-bit values to the specified value value. cuArrayGetDescriptor. cuMemAlloc. unsigned int dstPitch. and dstPitch specifies the number of bytes between each row. unsigned int height ). unsigned int width. cuMemset 182 . CUresult cuMemsetD2D32(CUdeviceptr dstDevPtr. cuMemAllocHost.8.

9 TextureReferenceManagement NAME Texture Reference Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. ExecutionControl. ModuleManagement. cuTexRefCreate cuTexRefDestroy cuTexRefGetAddress cuTexRefGetAddressMode cuTexRefGetArray cuTexRefGetFilterMode cuTexRefGetFlags cuTexRefGetFormat cuTexRefSetAddress cuTexRefSetAddressMode cuTexRefSetArray cuTexRefSetFilterMode cuTexRefSetFlags cuTexRefSetFormat SEE ALSO Initialization. ContextManagement. OpenGlInteroperability. EventManagement. MemoryManagement. DeviceManagement. TextureReferenceManagement. Direct3dInteroperability 183 .2. StreamManagement.

cuTexRefGetAddress.1 cuTexRefCreate NAME cuTexRefCreate . DESCRIPTION Creates a texture reference and returns its handle in *texRef. SEE ALSO cuTexRefDestroy. cuTexRefSetAddress. the application should call cuParamSetTexRef(). cuTexRefSetAddressMode. cuTexRefGetFlags 184 .) to be used when the memory is read through this texture reference. To associate the texture reference with a texture ordinal for a given function. cuTexRefSetArray. cuTexRefGetArray. filtering. cuTexRefSetFilterMode. asynchronous launches. cuTexRefGetAddressMode. the application must call cuTexRefSetArray() or cuTexRefSetAddress() to associate the reference with allocated memory. cuTexRefSetFormat. etc. Other texture reference functions are used to specify the format and interpretation (addressing.creates a texture-reference SYNOPSIS CUresult cuTexRefCreate(CUtexref* texRef). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.2. cuTexRefGetFormat. Once created. cuTexRefSetFlags. cuTexRefGetFilterMode.9.

RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetFlags 185 . cuTexRefGetFormat. cuTexRefGetArray. cuTexRefGetAddressMode. cuTexRefSetFormat. cuTexRefGetFilterMode. asynchronous launches. cuTexRefSetAddress. cuTexRefGetAddress.2 cuTexRefDestroy NAME cuTexRefDestroy .destroys a texture-reference SYNOPSIS CUresult cuTexRefDestroy(CUtexref texRef). cuTexRefSetAddressMode.2. SEE ALSO cuTexRefCreate. DESCRIPTION Destroys the texture reference.9. cuTexRefSetFilterMode. cuTexRefSetFlags. cuTexRefSetArray.

or returns CUDA_ERROR_INVALID_VA if the texture reference is not bound to any device memory range. cuTexRefSetFilterMode.9. cuTexRefDestroy. cuTexRefSetAddress.2. cuTexRefSetFlags. cuTexRefGetAddressMode. DESCRIPTION Returns in *devPtr the base address bound to the texture reference texRef.3 cuTexRefGetAddress NAME cuTexRefGetAddress . cuTexRefGetArray. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. SEE ALSO cuTexRefCreate. cuTexRefSetAddressMode. cuTexRefGetFlags 186 . cuTexRefGetFormat. cuTexRefSetFormat. cuTexRefSetArray.gets the address associated with a texture-reference SYNOPSIS CUresult cuTexRefGetAddress(CUdeviceptr* devPtr. cuTexRefGetFilterMode. CUtexref texRef). asynchronous launches.

RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetFlags.9. cuTexRefGetFormat. Currently the only valid values for dim are 0 and 1. asynchronous launches. CUtexref texRef. cuTexRefDestroy. cuTexRefGetFlags 187 .2.4 cuTexRefGetAddressMode NAME cuTexRefGetAddressMode .gets the addressing mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetAddressMode(CUaddress_mode* mode. cuTexRefSetFormat. int dim). cuTexRefSetArray. cuTexRefSetAddressMode. DESCRIPTION Returns in *mode the addressing mode corresponding to the dimension dim of the texture reference texRef. cuTexRefSetAddress. cuTexRefGetAddress. cuTexRefGetArray. cuTexRefGetFilterMode. SEE ALSO cuTexRefCreate. cuTexRefSetFilterMode.

cuTexRefGetFilterMode.gets the array bound to a texture-reference SYNOPSIS CUresult cuTexRefGetArray(CUarray* array. SEE ALSO cuTexRefCreate. cuTexRefGetAddressMode. cuTexRefGetFlags 188 . cuTexRefSetAddressMode. or returns CUDA_ERROR_INVALID_VAL if the texture reference is not bound to any CUDA array. cuTexRefDestroy.9. CUtexref texRef). cuTexRefGetFormat. cuTexRefGetAddress. cuTexRefSetAddress. DESCRIPTION Returns in *array the CUDA array bound by the texture reference texRef.5 cuTexRefGetArray NAME cuTexRefGetArray . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetFormat. cuTexRefSetArray. asynchronous launches.2. cuTexRefSetFlags. cuTexRefSetFilterMode.

RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetFormat. cuTexRefDestroy. DESCRIPTION Returns in *mode the filtering mode of the texture reference texRef.gets the filter-mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetFilterMode(CUfilter_mode* mode.2. asynchronous launches. cuTexRefGetFormat. cuTexRefSetFlags. cuTexRefGetFlags 189 . CUtexref texRef).9. cuTexRefGetAddressMode.6 cuTexRefGetFilterMode NAME cuTexRefGetFilterMode . cuTexRefSetAddressMode. SEE ALSO cuTexRefCreate. cuTexRefGetArray. cuTexRefSetAddress. cuTexRefSetArray. cuTexRefSetFilterMode. cuTexRefGetAddress.

cuTexRefGetAddress. cuTexRefGetArray. cuTexRefGetFilterMode.gets the flags used by a texture-reference SYNOPSIS CUresult cuTexRefGetFlags(unsigned int* flags. cuTexRefGetFormat 190 . cuTexRefSetFormat.2. cuTexRefSetAddressMode. cuTexRefDestroy. cuTexRefSetAddress. cuTexRefSetFlags. SEE ALSO cuTexRefCreate. cuTexRefSetFilterMode.9. cuTexRefSetArray.7 cuTexRefGetFlags NAME cuTexRefGetFlags . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetAddressMode. DESCRIPTION Returns in *flags the flags of the texture reference texRef. asynchronous launches. CUtexref texRef).

CUtexref texRef). cuTexRefGetArray. DESCRIPTION Returns in *format and *numPackedComponents the format and number of components of the CUDA array bound to the texture reference texRef. cuTexRefSetArray. asynchronous launches. cuTexRefGetFlags 191 . cuTexRefSetFormat. cuTexRefDestroy.8 cuTexRefGetFormat NAME cuTexRefGetFormat . cuTexRefSetAddressMode. cuTexRefSetFilterMode. SEE ALSO cuTexRefCreate. it will be ignored.9. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetFilterMode. If format or numPackedComponents is null. cuTexRefGetAddressMode. cuTexRefGetAddress. int* numPackedComponents. cuTexRefSetFlags.gets the format used by a texture-reference SYNOPSIS CUresult cuTexRefGetFormat(CUarray_format* format. cuTexRefSetAddress.2.

cuTexRefGetFilterMode. cuTexRefGetAddress. CUtexref texRef. cuTexRefDestroy. cuTexRefGetFormat. cuTexRefGetFlags 192 . This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function.binds an address as a texture-reference SYNOPSIS CUresult cuTexRefSetAddress(unsigned int* byteOffset. cuTexRefSetFilterMode. Since the hardware enforces an alignment requirement on texture base addresses.2.9. cuTexRefSetFlags. If the device memory pointer was returned from cuMemAlloc(). cuTexRefSetAddressMode. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.9 cuTexRefSetAddress NAME cuTexRefSetAddress . CUdeviceptr devPtr. Any previous address or CUDA array state associated with the texture reference is superseded by this function. cuTexRefSetFormat. cuTexRefGetAddressMode. int bytes). DESCRIPTION Binds a linear address range to the texture reference texRef. Any memory previously bound to texRef is unbound. cuTexRefSetArray. cuTexRefGetArray. asynchronous launches. the offset is guaranteed to be 0 and NULL may be passed as the ByteOffset parameter. cuTexRefSetAddress() passes back a byte offset in *byteOffset that must be applied to texture fetches in order to read from the desired memory. SEE ALSO cuTexRefCreate.

CU_TR_ADDRESS_MODE_MIRROR = 2. cuTexRefDestroy. if dim is 1.2. and so on.10 cuTexRefSetAddressMode NAME cuTexRefSetAddressMode . Note that this call has no effect if texRef is bound to linear memory. CUaddress_mode is defined as such: typedef enum CUaddress_mode_enum { CU_TR_ADDRESS_MODE_WRAP = 0. cuTexRefGetAddress. cuTexRefGetFormat. cuTexRefSetArray. } CUaddress_mode. cuTexRefSetFilterMode.9. cuTexRefGetAddressMode. the second. int dim. cuTexRefSetAddress. cuTexRefGetFlags 193 . cuTexRefSetFlags. CUaddress_mode mode). If dim is zero. DESCRIPTION Specifies the addressing mode mode for the given dimension of the texture reference texRef. cuTexRefGetFilterMode.set the addressing mode for a texture-reference SYNOPSIS CUresult cuTexRefSetAddressMode(CUtexref texRef. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. SEE ALSO cuTexRefCreate. cuTexRefSetFormat. the addressing mode is applied to the first parameter of the functions used to fetch from the texture. CU_TR_ADDRESS_MODE_CLAMP = 1. cuTexRefGetArray. asynchronous launches.

cuTexRefSetFlags. Any previous address or CUDA array state associated with the texture reference is superseded by this function. Any CUDA array previously bound to texRef is unbound.binds an array to a texture-reference SYNOPSIS CUresult cuTexRefSetArray(CUtexref texRef. SEE ALSO cuTexRefCreate. cuTexRefGetFlags 194 . cuTexRefGetAddress. DESCRIPTION Binds the CUDA array array to the texture reference texRef.11 cuTexRefSetArray NAME cuTexRefSetArray . cuTexRefGetAddressMode. cuTexRefSetFormat. CUarray array. cuTexRefDestroy. cuTexRefGetArray. flags must be set to CU_TRSA_OVERRIDE_FORMAT. asynchronous launches. cuTexRefGetFormat. cuTexRefSetFilterMode. unsigned int flags). cuTexRefSetAddress.9.2. cuTexRefSetAddressMode. cuTexRefGetFilterMode. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.

cuTexRefSetAddressMode. cuTexRefSetFormat. cuTexRefGetAddress. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetArray. asynchronous launches. cuTexRefGetAddressMode. SEE ALSO cuTexRefCreate. Note that this call has no effect if texRef is bound to linear memory. cuTexRefGetFilterMode.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef. cuTexRefSetFlags. CUfilter_mode mode). cuTexRefGetFormat.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . cuTexRefDestroy.2. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefGetFlags 195 . cuTexRefGetArray.9. cuTexRefSetAddress. CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0.

Instead. cuTexRefDestroy. which suppresses the default behavior of having the texture promote integer data to floating point data in the range [0.13 cuTexRefSetFlags NAME cuTexRefSetFlags . unsigned int Flags). DESCRIPTION Specifies optional flags to control the behavior of data returned through the texture reference. asynchronous launches. SEE ALSO cuTexRefCreate. cuTexRefSetFormat. cuTexRefGetFilterMode. The valid flags are: • CU_TRSF_READ_AS_INTEGER. cuTexRefSetAddress. Dim) where Dim is the width or height of the CUDA array. 1]. 1.9. cuTexRefGetAddressMode. • CU_TRSF_NORMALIZED_COORDINATES. cuTexRefSetFilterMode. which suppresses the default behavior of having the texture coordinates range from [0. cuTexRefGetFormat.2.sets flags for a texture-reference SYNOPSIS CUresult cuTexRefSetFlags(CUtexref texRef. cuTexRefGetAddress.0) reference the entire breadth of the array dimension RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetFlags 196 . cuTexRefSetAddressMode. the texture coordinates [0. cuTexRefGetArray. cuTexRefSetArray.

9.14 cuTexRefSetFormat NAME cuTexRefSetFormat . asynchronous launches. cuTexRefGetFlags 197 . CUarray_format format. cuTexRefGetAddress. cuTexRefGetArray. cuTexRefSetAddress. cuTexRefSetArray. cuTexRefSetFilterMode.2.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. cuTexRefGetFormat. cuTexRefDestroy. cuTexRefGetFilterMode. SEE ALSO cuTexRefCreate. cuTexRefSetFlags. cuTexRefGetAddressMode. cuTexRefSetAddressMode. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. format and numPackedComponents are exactly analogous to the Format and NumChannels members of the CUDA_ARRAY_DESCRIPTOR structure: They specify the format of each component and the number of components per array element.

ExecutionControl.10 OpenGlInteroperability NAME OpenGL Interoperability DESCRIPTION This section describes the low-level CUDA driver application programming interface.2. StreamManagement. cuGLCtxCreate cuGLInit cuGLMapBufferObject cuGLRegisterBufferObject cuGLUnmapBufferObject cuGLUnregisterBufferObject SEE ALSO Initialization. ContextManagement. OpenGLInteroperability. ModuleManagement. DeviceManagement. MemoryManagement. EventManagement. TextureReferenceManagement. Direct3dInteroperability 198 .

see cuCtxCreate. asynchronous launches. cuGLUnmapBufferObject. cuGLInit cuGLRegisterBufferObject.create a CUDA context for interoperability with OpenGL SYNOPSIS CUresult cuGLCtxCreate(CUcontext *pCtx. It may fail if the needed OpenGL driver facilities are not available. CUdevice device). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous.10. cuGLMapBufferObject. and associates the CUDA context with the calling thread.2. For usage of the Flags parameter.1 cuGLCtxCreate NAME cuGLCtxCreate . It must be called before performing any other OpenGL interoperability operations. initializes OpenGL interoperability. DESCRIPTION Creates a new CUDA context. SEE ALSO cuCtxCreate. cuGLUnregisterBufferObject 199 . unsigned int Flags.

10. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.initializes GL interoperability SYNOPSIS CUresult cuGLInit(void). cuGLUnregisterBufferObject 200 .2 cuGLInit NAME cuGLInit . DESCRIPTION Initializes OpenGL interoperability.2. SEE ALSO cuGLCtxCreate. It may fail if the needed OpenGL driver facilities are not available. asynchronous launches. cuGLMapBufferObject. cuGLUnmapBufferObject. cuGLRegisterBufferObject. It must be called before performing any other OpenGL interoperability operations.

SEE ALSO cuGLCtxCreate.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping.3 cuGLMapBufferObject NAME cuGLMapBufferObject . asynchronous launches. GLuint bufferObj). cuGLUnmapBufferObject. cuGLInit.10. cuGLUnregisterBufferObject 201 . cuGLRegisterBufferObject. unsigned int* size.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous.

RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_ALREADY_MAPPED Note that this function may also return error codes from previous.2. cuGLUnregisterBufferObject 202 . asynchronous launches. While it is registered. DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA. cuGLInit. cuGLMapBufferObject. This function must be called before CUDA can map the buffer object. cuGLUnmapBufferObject.registers a GL buffer object SYNOPSIS CUresult cuGLRegisterBufferObject(GLuint bufferObj). the buffer object cannot be used by any OpenGL commands except as a data source for OpenGL drawing commands.4 cuGLRegisterBufferObject NAME cuGLRegisterBufferObject . SEE ALSO cuGLCtxCreate.10.

cuGLMapBufferObject.2. cuGLUnregisterBufferObject 203 . cuGLInit.unmaps a GL buffer object SYNOPSIS CUresult cuGLUnmapBufferObject(GLuint bufferObj). cuGLRegisterBufferObject.5 cuGLUnmapBufferObject NAME cuGLUnmapBufferObject . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. SEE ALSO cuGLCtxCreate. DESCRIPTION Unmaps the buffer object of ID bufferObj for access by CUDA.10. asynchronous launches.

cuGLRegisterBufferObject.2. asynchronous launches. DESCRIPTION Unregisters the buffer object of ID bufferObj for access by CUDA.10. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.unregister a GL buffer object SYNOPSIS CUresult cuGLUnregisterBufferObject(GLuint bufferObj). cuGLUnmapBufferObject 204 . cuGLInit. cuGLMapBufferObject.6 cuGLUnregisterBufferObject NAME cuGLUnregisterBufferObject . SEE ALSO cuGLCtxCreate.

StreamManagement. OpenGLInteroperability. cuD3D9GetDevice cuD3D9CtxCreate cuD3D9GetDirect3DDevice cuD3D9RegisterResource cuD3D9UnregisterResource cuD3D9MapResources cuD3D9UnmapResources cuD3D9ResourceGetSurfaceDimensions cuD3D9ResourceSetMapFlags cuD3D9ResourceGetMappedPointer cuD3D9ResourceGetMappedSize cuD3D9ResourceGetMappedPitch As of CUDA 2.2.0 the following functions are deprecated. cuD3D9Begin cuD3D9End cuD3D9MapVertexBuffer cuD3D9RegisterVertexBuffer cuD3D9UnmapVertexBuffer cuD3D9UnregisterVertexBuffer SEE ALSO Initialization. TextureReferenceManagement. EventManagement. ContextManagement. ModuleManagement. They should not be used in new development. Direct3dInteroperability 205 . DeviceManagement. ExecutionControl. MemoryManagement.11 Direct3dInteroperability NAME Direct3D Interoperability DESCRIPTION This section describes Direct3D interoperability in the the low-level CUDA driver application programming interface.

If no device on the adapter with name adapterName is CUDA-compatible then the call will fail.2. cuD3D9GetDirect3DDevice. cuD3D9ResourceSetMapFlags.1 cuD3D9GetDevice NAME cuD3D9GetDevice . SEE ALSO cuD3D9CtxCreate. const char* adapterName). cuD3D9ResourceGetMappedPitch 206 . asynchronous launches. cuD3D9UnmapResources.11. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9UnregisterResource. DESCRIPTION Returns in *dev the CUDA-compatible device corresponding to the adapter name adapterName obtained from EnumDisplayDevices or IDirect3D9::GetAdapterIdentifier(). cuD3D9MapResources. cuD3D9ResourceGetSurfaceDimensions. cuD3D9RegisterResource. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_VALUE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.gets the device number for an adapter SYNOPSIS CUresult cuD3D9GetDevice(CUdevice* dev.

2. see cuCtxCreate. DESCRIPTION Creates a new CUDA context. CUdevice* pCuDevice. For usage of the Flags parameter. This reference count will be decremented upon destruction of this context through cuCtxDestroy.11. SEE ALSO cuD3D9GetDevice. cuD3D9GetDirect3DDevice. and associates the created CUDA context with the calling thread. asynchronous launches. IDirect3DDevice9* pDxDevice). cuD3D9UnregisterResource. cuD3D9RegisterResource. The CUcontext created will be returned in *pCtx. On success. If pCuDevice is non-NULL then the CUdevice on which this CUDA context was created will be returned in *pCuDevice. unsigned int Flags. cuD3D9MapResources cuD3D9UnmapResources. cuD3D9ResourceSetMapFlags. cuD3D9ResourceGetMappedPitch 207 . enables interoperability for that context with the Direct3D device pDxDevice. this call will increase the internal reference count on pDxDevice. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. This context will function only until its Direct3D device is destroyed.create a CUDA context for interoperability with Direct3D SYNOPSIS CUresult cuD3D9CtxCreate(CUcontext* pCtx.2 cuD3D9CtxCreate NAME cuD3D9CtxCreate . cuD3D9ResourceGetSurfaceDimensions. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. Direct3D resources from this device may be registered and mapped through the lifetime of this CUDA context.

get the Direct3D device against which the current CUDA context was created SYNOPSIS CUresult cuD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice). cuD3D9UnregisterResource. cuD3D9RegisterResource. cuD3D9ResourceSetMapFlags. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. cuD3D9UnmapResources. DESCRIPTION Returns in *ppDxDevice the Direct3D device against which this CUDA context was created in cuD3D9CtxCreate. cuD3D9ResourceGetSurfaceDimensions. cuD3D9ResourceGetMappedPitch 208 . SEE ALSO cuD3D9GetDevice. cuD3D9MapResources.11. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. asynchronous launches. cuD3D9CtxCreate.3 cuD3D9GetDirect3DDevice NAME cuD3D9GetDirect3DDevice .2.

16. • Any resources allocated in D3DPOOL_SYSTEMMEM may not be registered with CUDA. The pointer. The Flags argument specifies the mechanism through which CUDA will access the Direct3D resource. and cuD3D9ResourceGetMappedPitch respectively.4 cuD3D9RegisterResource NAME cuD3D9RegisterResource . • CU_D3D9_REGISTER_FLAGS_NONE: Specifies that CUDA will access this resource through a CUdeviceptr. • Resources allocated as shared may not be registered with CUDA. This call is potentially high-overhead and should not be called every frame in interactive applications. In particular. • IDirect3DBaseTexture9: When a texture is registered all surfaces associated with the all mipmap levels of all faces of the texture will be accessible to CUDA. one must register the base texture object.2. • IDirect3DIndexBuffer9: No notes. Not all Direct3D resources of the above types may be used for interoperability with CUDA. or 32-bit integer or floating-point data cannot be shared. • Textures which are not of a format which is 1. unsigned int Flags). DESCRIPTION Registers the Direct3D resource pResource for access by CUDA. and pitch for each subresource of this resource may be queried through cuD3D9ResourceGetMappedPointer.11. This option is valid for all resource types. If this call is successful then the application will be able to map and unmap this resource until it is unregistered through cuD3D9UnregisterResource. • The primary rendertarget may not be registered with CUDA. The following value is allowed. This reference count will be decremented when this resource is unregistered through cuD3D9UnregisterResource.register a Direct3D resource for access by CUDA SYNOPSIS CUresult cuD3D9RegisterResource(IDirect3DResource9* pResource. size. • IDirect3DVertexBuffer9: No notes. or 4 channels of 8. 209 . 2. • IDirect3DSurface9: Only stand-alone objects of type IDirect3DSurface9 may be explicitly shared. this call will increase the internal reference count on pResource. cuD3D9ResourceGetMappedSize. The type of pResource must be one of the following. To access individual surfaces associated with a texture. individual mipmap levels and faces of cube maps may not be registered directly. The following are some limitations. Also on success.

cuD3D9ResourceGetMappedPitch 210 . asynchronous launches. cuD3D9UnmapResources. is a non-stand-alone IDirect3DSurface9) or is already registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9GetDirect3DDevice. cuD3D9ResourceSetMapFlags. If Direct3D interoperability is not initialized on this context then CUDA_ERROR_INVALID_CONTEXT is returned. cuD3D9MapResources. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize.• Surfaces of depth or stencil formats cannot be shared. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. SEE ALSO cuD3D9GetDevice. cuD3D9CtxCreate. If pResource cannot be registered then CUDA_ERROR_UNKNOWN is returned.g. cuD3D9ResourceGetSurfaceDimensions. cuD3D9UnregisterResource. If pResource is of incorrect type (e.

SEE ALSO cuD3D9GetDevice. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. cuD3D9ResourceGetMappedPitch 211 . cuD3D9MapResources.11.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . cuD3D9ResourceGetSurfaceDimensions. asynchronous launches.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9GetDirect3DDevice. cuD3D9RegisterResource. cuD3D9UnmapResources. cuD3D9ResourceSetMapFlags. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). cuD3D9CtxCreate.

11. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned. SEE ALSO cuD3D9GetDevice. asynchronous launches. IDirect3DResource9 **ppResources).map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. cuD3D9ResourceGetMappedPitch 212 . If any of ppResources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.2. cuD3D9CtxCreate. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_ALREADY_MAPPED CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9ResourceGetSurfaceDimensions. This function provides the synchronization guarantee that any Direct3D calls issued before cuD3D9MapResources will complete before any CUDA kernels issued after cuD3D9MapResources begin. cuD3D9GetDirect3DDevice. cuD3D9UnmapResources. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize.6 cuD3D9MapResources NAME cuD3D9MapResources . cuD3D9RegisterResource. Direct3D should not access any resources while they are mapped by CUDA. If an application does so the results are undefined. cuD3D9ResourceSetMapFlags. cuD3D9UnregisterResource.

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

SYNOPSIS
CUresult cuD3D9UnmapResources(unsigned int count, IDirect3DResource9** ppResources);

DESCRIPTION
Unmaps the count Direct3D resources in ppResources. This function provides the synchronization guarantee that any CUDA kernels issued before cuD3D9UnmapResources will complete before any Direct3D calls issued after cuD3D9UnmapResources begin. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned. If any of ppResources are not presently mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned.

RETURN VALUE
Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_MAPPED CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO

cuD3D9GetDevice, cuD3D9CtxCreate, cuD3D9GetDirect3DDevice, cuD3D9RegisterResource, cuD3D9UnregisterResource, cuD3D9MapResources, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags, cuD3D9ResourceGetMappedP cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetMappedPitch

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

SYNOPSIS
CUresult cuD3D9ResourceSetMapFlags(IDirect3DResource9 *pResource, unsigned int Flags);

DESCRIPTION
Set flags for mapping the Direct3D resource pResource. Changes to flags will take effect the next time pResource is mapped. The Flags argument may be any of the following. • CU_D3D9_MAPRESOURCE_FLAGS_NONE: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA kernels. This is the default value. • CU_D3D9_MAPRESOURCE_FLAGS_READONLY: Specifies that CUDA kernels which access this resource will not write to this resource. • CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD: Specifies that CUDA kernels which access this resource will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. If pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. If pResource is presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.

RETURN VALUE
Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_ALREADY_MAPPED Note that this function may also return error codes from previous, asynchronous launches.

214

SEE ALSO

cuD3D9GetDevice, cuD3D9CtxCreate, cuD3D9GetDirect3DDevice, cuD3D9RegisterResource, cuD3D9UnregisterResource, cuD3D9MapResources, cuD3D9UnmapResources, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceGetMappedPointe cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetMappedPitch

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

SYNOPSIS
CUresult cuD3D9ResourceGetSurfaceDimensions(unsigned int* pWidth, unsigned int* pHeight, unsigned int *pDepth, IDirect3DResource9* pResource, unsigned int Face, unsigned int Level);

DESCRIPTION
Returns in *pWidth, *pHeight, and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. Because anti-aliased surfaces may have multiple samples per pixel it is possible that the dimensions of a resource will be an integer factor larger than the dimensions reported by the Direct3D runtime. The parameters pWidth, pHeight, and pDepth are optional. For 2D surfaces, the value returned in *pDepth will be 0. If pResource is not of type IDirect3DBaseTexture9 or IDirect3DSurface9 or if pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer.

RETURN VALUE
Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO
cuD3D9GetDevice, cuD3D9CtxCreate, cuD3D9GetDirect3DDevice, cuD3D9RegisterResource, cuD3D9UnregisterResource, cuD3D9MapResources, cuD3D9UnmapResources, cuD3D9ResourceSetMapFlags, cuD3D9ResourceGetMappedPointer, cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetMappedPitch

216

If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. 217 .11. IDirect3DResource9* pResource.10 cuD3D9ResourceGetMappedPointer NAME cuD3D9ResourceGetMappedPointer . If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level. DESCRIPTION Returns in *pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. If Level is invalid then CUDA_ERROR_INVALID_VALUE is returned. For all other types Face must be 0.get a pointer through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS CUresult cuD3D9ResourceGetMappedPointer(CUdeviceptr* pDevPtr. asynchronous launches. unsigned int Face. The value set in pDevPtr may change every time that pResource is mapped. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_MAPPED Note that this function may also return error codes from previous. If pResource is not mapped then CUDA_ERROR_NOT_MAPPED is returned. If Face is invalid then CUDA_ERROR_INVALID_V is returned. unsigned int Level).2. For all other types Level must be 0. If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVA is returned. At present only mipmap level 0 is supported.

cuD3D9RegisterResource. cuD3D9ResourceGetMappedSize. cuD3D9UnmapResources. cuD3D9MapResources. cuD3D9ResourceGetMappedPitch 218 . cuD3D9ResourceSetMapFlags. cuD3D9CtxCreate. cuD3D9ResourceGetSurfaceDimensions. cuD3D9UnregisterResource. cuD3D9GetDirect3DDevice.SEE ALSO cuD3D9GetDevice.

If pResource is not mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned. cuD3D9ResourceGetSurfaceDimensions. cuD3D9RegisterResource. cuD3D9ResourceSetMapFlags. cuD3D9UnregisterResource. cuD3D9ResourceGetMappedPointer. IDirect3DResource9* pResource. cuD3D9UnmapResources. SEE ALSO cuD3D9GetDevice. DESCRIPTION Returns in *pSize the size of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level.2. cuD3D9MapResources. cuD3D9ResourceGetMappedPitch 219 . If pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVALID_HANDLE is returned.get the size of a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS CUresult cuD3D9ResourceGetMappedSize(unsigned int* pSize. unsigned int Face. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_MAPPED Note that this function may also return error codes from previous. asynchronous launches.11.11 cuD3D9ResourceGetMappedSize NAME cuD3D9ResourceGetMappedSize . unsigned int Level). For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer. cuD3D9GetDirect3DDevice. The value set in pSize may change every time that pResource is mapped. cuD3D9CtxCreate.

12 cuD3D9ResourceGetMappedPitch NAME cuD3D9ResourceGetMappedPitch .2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_MAPPED Note that this function may also return error codes from previous. y*pitch + (bytes per pixel)*x For a 3D surface the byte offset of the sample of at position x. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVALID_HANDLE is returned. For a 2D surface the byte offset of the sample of at position x.get the pitch of a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS CUresult cuD3D9ResourceGetMappedPitch(unsigned int* pPitch. unsigned int Face. asynchronous launches. DESCRIPTION Returns in *pPitch and *pPitchSlice the pitch and Z-slice pitch of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level.11. unsigned int* pPitchSlice. 220 . For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer. If pResource is not mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned. The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.z from the base pointer of the surface is z*slicePitch + y*pitch + (bytes per pixel)*x Both parameters pPitch and pPitchSlice are optional and may be set to NULL. IDirect3DResource pResource. The values set in pPitch and pPitchSlice may change every time that pResource is mapped. unsigned int Level).y.y from the base pointer of the surface is If pResource is not of type IDirect3DBaseTexture9 or one of its sub-types or if pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned.

cuD3D9RegisterResource. cuD3D9CtxCreate.SEE ALSO cuD3D9GetDevice. cuD3D9ResourceSetMapFlags. cuD3D9GetDirect3DDevice. cuD3D9MapResources. cuD3D9ResourceGetMappedSize 221 . cuD3D9UnmapResources. cuD3D9ResourceGetSurfaceDimensions. cuD3D9ResourceGetMappedPointer. cuD3D9UnregisterResource.

64-bit atomic operations are only supported on devices of compute capability 1. SEE ALSO ArithmeticFunctions. BitwiseFunctions 222 .2 and higher.3 AtomicFunctions NAME Atomic Functions DESCRIPTION Atomic functions can only be used in device functions.1 and higher. NOTES 32-bit atomic operations are only supported on devices of compute capability 1.

atomicAdd atomicSub atomicExch atomicMin atomicMax atomicInc atomicDec atomicCAS SEE ALSO BitwiseFunctions 223 .3.1 ArithmeticFunctions NAME Arithmetic Functions DESCRIPTION This section describes the atomic arithmetic functions.

unsigned long long int atomicAdd(unsigned long long int* address. atomicInc. These three operations are performed in one atomic transaction.1 and higher.2 and higher. SEE ALSO atomicSub.atomic addition SYNOPSIS int atomicAdd(int* address. computes (old + val). The function returns old. unsigned int atomicAdd(unsigned int* address. 64-bit atomic operations are only supported on devices of compute capability 1. atomicDec. atomicCAS 224 .1 atomicAdd NAME atomicAdd . DESCRIPTION Reads the 32. int val). unsigned int val). unsigned long long int val). NOTES 32-bit atomic operations are only supported on devices of compute capability 1.or 64-bit word old located at the address address in global memory. atomicMax.3. atomicExch. and stores the result back to global memory at the same address.1. atomicMin.

atomicInc. atomicMax. atomicCAS 225 . The function returns old.2 atomicSub NAME atomicSub .1. SEE ALSO atomicAdd. atomicMin. DESCRIPTION Reads the 32-bit word old located at the address address in global memory.3.1 and higher. int val). These three operations are performed in one atomic transaction. unsigned int val). computes (old . atomicDec.val). and stores the result back to global memory at the same address. unsigned int atomicSub(unsigned int* address. atomicExch. NOTES Atomic operations are only supported on devices of compute capability 1.atomic subtraction SYNOPSIS int atomicSub(int* address.

or 64-bit word old located at the address address in global memory and stores val back to global memory at the same address. These two operations are performed in one atomic transaction. unsigned int atomicExch(unsigned int* address. unsigned long long int atomicExch(unsigned long long int* address.2 and higher. The function returns old.3 atomicExch NAME atomicExch .3.1. SEE ALSO atomicAdd. atomicMax. NOTES 32-bit atomic operations are only supported on devices of compute capability 1. unsigned int val). atomicDec. unsigned long long int val). atomicMin. DESCRIPTION Reads the 32. atomicInc. 64-bit atomic operations are only supported on devices of compute capability 1. atomicCAS 226 .1 and higher. atomicSub. int val).atomic exchange SYNOPSIS int atomicExch(int* address.

atomicExch. SEE ALSO atomicAdd. atomicMax. unsigned int val). atomicDec. NOTES Atomic operations are only supported on devices of compute capability 1. The function returns b<old>.4 atomicMin NAME atomicMin . atomicSub.atomic minimum SYNOPSIS int atomicMin(int* address. unsigned int atomicMin(unsigned int* address. computes the minimum of old and val. atomicCAS 227 . int val).3. atomicInc. DESCRIPTION Reads the 32-bit word old located at the address address in global memory. These three operations are performed in one atomic transaction.1 and higher. and stores the result back to global memory at the same address.1.

unsigned int atomicMax(unsigned int* address. These three operations are performed in one atomic transaction. atomicMin. atomicCAS 228 . unsigned int val).5 atomicMax NAME atomicMax .1 and higher. int val).3. and stores the result back to global memory at the same address. NOTES Atomic operations are only supported on devices of compute capability 1. atomicExch.1.atomic maximum SYNOPSIS int atomicMax(int* address. atomicInc. SEE ALSO atomicAdd. atomicSub. DESCRIPTION Reads the 32-bit word old located at the address address in global memory. computes the maximum of old and val. The function returns old. atomicDec.

unsigned int val). NOTES Atomic operations are only supported on devices of compute capability 1. computes ((old >= val) ? 0 : (old+1)). atomicMin. atomicExch. The function returns old.6 atomicInc NAME atomicInc . atomicCAS 229 . atomicSub. atomicMax.3.1 and higher. These three operations are performed in one atomic transaction. DESCRIPTION Reads the 32-bit word old located at the address address in global memory. SEE ALSO atomicAdd.atomic increment SYNOPSIS unsigned int atomicInc(unsigned int* address. and stores the result back to global memory at the same address. atomicDec.1.

DESCRIPTION Reads the 32-bit word old located at the address address in global memory. and stores the result back to global memory at the same address.1 and higher. SEE ALSO atomicAdd.1. atomicInc. atomicMin. NOTES Atomic operations are only supported on devices of compute capability 1. atomicExch.7 atomicDec NAME atomicDec . The function returns old. atomicCAS 230 .atomic decrement SYNOPSIS unsigned int atomicDec(unsigned int* address.3. computes (((old == 0) . atomicMax. These three operations are performed in one atomic transaction. atomicSub. unsigned int val).

computes (old == compare ? val : old).atomic compare-and-swap SYNOPSIS int atomicCAS(int* address. unsigned int compare. The function returns old (Compare And Swap). atomicMin.1. atomicInc. unsigned int atomicCAS(unsigned int* address. These three operations are performed in one atomic transaction. SEE ALSO atomicAdd. NOTES 32-bit atomic operations are only supported on devices of compute capability 1. atomicMax. int compare. int val). unsigned long long int atomicCAS(unsigned long long int* address.8 atomicCAS NAME atomicCAS . atomicDec 231 .1 and higher. unsigned int val). unsigned long long int compare.3. atomicExch. 64-bit atomic operations are only supported on devices of compute capability 1. DESCRIPTION Reads the 32. atomicSub. and stores the result back to global memory at the same address.2 and higher.or 64-bit word old located at the address address in global memory. unsigned long long int val).

3.2

BitwiseFunctions

NAME
Bitwise Functions

DESCRIPTION
This section describes the atomic bitwise functions. atomicAnd atomicOr atomicXor

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

SYNOPSIS
int atomicAnd(int* address, int val); unsigned int atomicAnd(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old & val), and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

SYNOPSIS
int atomicOr(int* address, int val); unsigned int atomicOr(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old , and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

SYNOPSIS
int atomicXor(int* address, int val); unsigned int atomicXor(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old ˆ val), and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicAnd, atomicOr

235

77 cudaLaunch. 216 cuD3D9ResourceSetMapFlags.Index ArithmeticFunctions. 46 cudaMalloc3DArray. 19 cudaEventSynchronize. 20 cudaEventRecord. 116 cuCtxGetDevice. 81 cudaD3D9MapResources. 113 cuCtxDestroy. 26 cudaMemcpy. 235 BitwiseFunctions. 29 cudaFreeHost. 219 cuD3D9ResourceGetSurfaceDimensions. 31 cudaGetChannelDesc. 65 cudaBindTextureToArray. 41 cudaMemcpy2DFromArray. 66 cudaChooseDevice. 21 cudaFree. 39 cudaMemcpy2DToArray. 76 cudaGLUnregisterBufferObject. 227 atomicOr. 157 cuCtxAttach. 117 cuCtxPopCurrent. 233 atomicCAS. 35 cudaMemcpy2DArrayToArray. 75 cudaGLRegisterBufferObject. 120 cuD3D9CtxCreate. 34 cudaMemcpy2D. 3 cudaGetDeviceProperties. 89 cudaD3D9ResourceSetMapFlags. 97 cudaGetLastError. 222 atomicInc. 214 cuD3D9UnmapResources. 213 cuD3D9UnregisterResource. 28 cudaMallocHost. 212 cuD3D9RegisterResource. 45 cudaGetTextureAlignmentOffset. 230 atomicExch. 18 cudaEventDestroy. 5 cudaGetDeviceCount. 30 cudaMallocPitch. 211 cudaBindTexture. 22 cudaEventElapsedTime. 73 cudaGLUnmapBufferObject. 209 cuD3D9ResourceGetMappedPitch. 217 cuD3D9ResourceGetMappedSize. 70 cudaMalloc. 85 cudaD3D9RegisterResource. 69 cudaCreateChannelDesc. 231 atomicDec. 25 cudaMalloc3D. 37 cudaMemcpy3D. 119 cuCtxSynchronize. 156 cuArrayGetDescriptor. 56 cudaCreateChannelDesc HL. 40 cudaMemcpyFromArray. 6 cudaGetErrorString. 82 cudaD3D9ResourceGetMappedPitch. 74 cudaGLSetGLDevice. 225 atomicXor. 112 cuCtxCreate. 48 cudaMallocArray. 223 atomicAdd. 23 cudaEventQuery. 206 cuD3D9GetDirect3DDevice. 38 cudaMemcpyFromSymbol. 91 cudaD3D9ResourceGetSurfaceDimensions. 90 cudaD3D9ResourceGetMappedSize. 80 cudaD3D9UnmapResources. 234 atomicSub. 79 cudaD3D9GetDirect3DDevice. 158 cuArrayCreate. 59 cudaBindTexture HL. 43 236 . 208 cuD3D9MapResources. 152 cuArrayDestroy. 52 cudaMemcpyArrayToArray. 118 cuCtxPushCurrent. 224 atomicAnd. 87 cudaD3D9SetDirect3DDevice. 220 cuD3D9ResourceGetMappedPointer. 57 cudaGetDevice. 64 cudaD3D9GetDevice. 8 cudaConfigureCall. 84 cudaEventCreate. 58 cudaGLMapBufferObject. 86 cudaD3D9UnregisterResource. 228 atomicMin. 111 cuArray3DCreate. 95 cudaGetSymbolAddress. 62 cudaGetTextureReference. 44 cudaGetSymbolSize. 60 cudaBindTextureToArray HL. 92 cudaD3D9ResourceGetMappedPointer. 232 ContextManagement. 27 cudaFreeArray. 207 cuD3D9GetDevice. 229 atomicMax. 115 cuCtxDetach. 226 AtomicFunctions. 154 cuArray3DGetDescriptor.

170 cuMemcpyAtoA. 146 cuParamSeti. 174 cuMemcpyAtoH. 148 cuStreamCreate. 161 cuMemcpy2D. 103 cuDeviceGetAttribute. 181 cuMemset2D. 201 cuGLRegisterBufferObject. 185 cuTexRefGetAddress. 50 cudaSetDevice. 173 cuMemcpyAtoD. 124 cuModuleLoad. 24 237 . 67 cuDeviceComputeCapability. 68 HighLevelApi. 160 cuMemAllocPitch. 32 cudaMemset2D. 202 cuGLUnmapBufferObject. 150 cuGLCtxCreate. 99 LowLevelApi. 204 cuInit. 137 cuEventQuery. 145 cuParamSetv. 132 cuStreamSynchronize. 11 cudaThreadSynchronize. 147 cuParamSetSize. 199 cuGLInit. 71 cudaStreamCreate. 179 cuMemcpyHtoD. 193 cuTexRefSetArray. 176 cuMemcpyDtoD. 188 cuTexRefGetFilterMode. 138 cuEventRecord. 195 cuTexRefSetFlags. 125 cuModuleLoadData. 14 cudaStreamSynchronize.cudaMemcpyToArray. 187 cuTexRefGetArray. 98 ErrorHandling RT. 159 cuMemAllocHost. 133 cuTexRefCreate. 123 cuModuleGetTexRef. 164 cuMemGetAddressRange. 106 cuDeviceGetName. 16 cudaStreamQuery. 128 cuParamSetf. 130 cuStreamDestroy. 200 cuGLMapBufferObject. 197 DeviceManagement. 143 cuMemAlloc. 142 cuLaunchGrid. 108 cuDeviceTotalMem. 33 cudaMemset3D. 107 cuDeviceGetProperties. 131 cuStreamQuery. 63 Initialization. 102 cuDeviceGet. 101 DeviceManagement RT. 192 cuTexRefSetAddressMode. 42 cudaMemset. 15 cudaThreadExit. 135 cuEventDestroy. 134 EventManagement RT. 205 Direct3dInteroperability RT. 127 cuModuleUnload. 2 Direct3dInteroperability. 175 cuMemcpyDtoA. 196 cuTexRefSetFormat. 136 cuEventElapsedTime. 110 cuEventCreate. 36 cudaMemcpyToSymbol. 167 cuMemcpy3D. 13 cudaStreamDestroy. 189 cuTexRefGetFlags. 163 cuMemFreeHost. 182 cuModuleGetFunction. 180 cuMemFree. 122 cuModuleGetGlobal. 165 cuMemGetInfo. 10 cudaUnbindTexture. 149 cuFuncSetSharedSize. 4 cudaSetupArgument. 151 MemoryManagement RT. 144 cuParamSetTexRef. 61 cudaUnbindTexture HL. 140 cuFuncSetBlockShape. 178 cuMemcpyHtoA. 104 cuDeviceGetCount. 203 cuGLUnregisterBufferObject. 184 cuTexRefDestroy. 17 ExecutionControl. 94 EventManagement. 139 cuEventSynchronize. 190 cuTexRefGetFormat. 100 cuLaunch. 166 cuMemset. 191 cuTexRefSetAddress. 186 cuTexRefGetAddressMode. 78 DriverApiReference. 141 ExecutionControl RT. 55 MemoryManagement. 126 cuModuleLoadFatBinary. 177 cuMemcpyDtoH. 194 cuTexRefSetFilterMode.

1 StreamManagement. 9 238 . 12 TextureReferenceManagement. 198 OpenGlInteroperability RT. 72 RuntimeApiReference.ModuleManagement. 183 TextureReferenceManagement RT. 121 OpenGlInteroperability. 54 ThreadManagement RT. 129 StreamManagement RT.

Sign up to vote on this title
UsefulNot useful