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

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

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

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

. . . . . . . . . . . . . . .3 atomicXor . . 235 vii .2. . . . . . . .3. . . . . . . . . . . . . . . . . . .

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

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

0 that are available for execution. cudaSetDevice. cudaChooseDevice 3 .1. SEE ALSO cudaGetDevice. cudaGetDeviceProperties.1 cudaGetDeviceCount NAME cudaGetDeviceCount . Since this device will be able to emulate all hardware features. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. asynchronous launches.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. If there is no such device.1. cudaGetDeviceCount() returns 1 and device 0 only supports device emulation mode. this device will report major and minor compute capability versions of 9999.

1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevice Note that this function may also return error codes from previous. cudaGetDevice. cudaGetDeviceProperties.1. asynchronous launches.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. SEE ALSO cudaGetDeviceCount.2 cudaSetDevice NAME cudaSetDevice . cudaChooseDevice 4 .

RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. SEE ALSO cudaGetDeviceCount.1. asynchronous launches. 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. cudaChooseDevice 5 . cudaSetDevice.1.3 cudaGetDevice NAME cudaGetDevice .

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

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

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

Direct3D Interoperability. OpenGL Interoperability. Stream Management. 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. Error Handling 9 . Thread Management. Memory Management. Execution Management. Event Management.

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

SEE ALSO cudaThreadSynchronize 11 . asynchronous launches.2.1. cudaThreadExit() is implicitly called on host thread exit.2 cudaThreadExit NAME cudaThreadExit . RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. Any subsequent API call reinitializes the runtime.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.

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

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

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

cudaStreamQuery 15 . asynchronous launches.3.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. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. SEE ALSO cudaStreamCreate.3 cudaStreamSynchronize NAME cudaStreamSynchronize .1. cudaStreamDestroy.

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess cudaErrorNotReady cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. cudaEventSynchronize. asynchronous launches. If cudaEventRecord() has not been called on this event. 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. the function returns cudaErrorInvalidValue.4. cudaEventElapsedTime 20 . SEE ALSO cudaEventCreate.3 cudaEventQuery NAME cudaEventQuery . or cudaErrorNotReady if not.1. cudaEventRecord.

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. the function returns cudaErrorInvalidValue.1.4. cudaEventDestroy. cudaEventRecord.4 cudaEventSynchronize NAME cudaEventSynchronize . SEE ALSO cudaEventCreate. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. asynchronous launches. If cudaEventRecord() has not been called on this event. cudaEventQuery.

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

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

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 . Texture Reference Management. Direct3D Interoperability. OpenGL Interoperability.1.5 MemoryManagement RT NAME Memory Management DESCRIPTION This section describes the CUDA runtime application programming interface. Thread Management. Execution Management. Memory Management. Stream Management. Event Management.

allocate memory on the GPU SYNOPSIS cudaError_t cudaMalloc( void** devPtr. cudaMallocArray. asynchronous launches.1 cudaMalloc NAME cudaMalloc . cudaFree. SEE ALSO cudaMallocPitch. 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. size_t count ) DESCRIPTION Allocates count bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory.1. cudaFreeHost 25 . cudaFreeArray. The memory is not cleared. The allocated memory is suitably aligned for any kind of variable. cudaMallocHost.5.

Due to pitch alignment restrictions in the hardware.2 cudaMallocPitch NAME cudaMallocPitch .1. For allocations of 2D arrays. The intended usage of pitch is as a separate parameter of the allocation. Given the row and column of an array element of type T. The pitch returned in *pitch by cudaMallocPitch() is the width in bytes of the allocation. SEE ALSO cudaMalloc. size_t widthInBytes. size_t* pitch. the address is computed as T* pElement = (T*)((char*)BaseAddress + Row * pitch) + Column. cudaFreeHost 26 . it is recommended that programmers consider performing pitch allocations using cudaMallocPitch(). RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. cudaMallocArray. 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. used to compute addresses within the 2D array. 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).allocates memory on the GPU SYNOPSIS cudaError_t cudaMallocPitch( void** devPtr. cudaFree. 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. cudaMallocHost. asynchronous launches. cudaFreeArray.5.

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

cudaMallocHost.5. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous.allocate an array on the GPU SYNOPSIS cudaError_t cudaMallocArray( struct cudaArray** array. size_t width. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. w. cudaMallocPitch. z. cudaFree. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. cudaChannelFormatKindUnsigned. cudaFreeHost 28 . cudaFreeArray. asynchronous launches. enum cudaChannelFormatKind f. const struct cudaChannelFormatDesc* desc. 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. SEE ALSO cudaMalloc.4 cudaMallocArray NAME cudaMallocArray . cudaChannelFormatKindFloat. y.1. }.

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

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

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

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

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

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

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

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

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

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

cudaMemcpyArrayToArray. cudaMemcpy2DFromArrayAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. asynchronous launches. cudaMemcpyToSymbol. where kind is one of cudaMemcpyHostToHost. cudaMemcpyFromSymbol 39 . cudaMemcpyDeviceToHost. cudaMemcpy2D. size_t height. size_t srcX. and specifies the direction of the copy. including any padding added to the end of each row. 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. size_t dpitch. enum cudaMemcpyKind kind) cudaError_t cudaMemcpy2DFromArrayAsync(void* dst.15 cudaMemcpy2DFromArray NAME cudaMemcpy2DFromArray . cudaMemcpyHostToDevice. size_t width. size_t srcY.5. const struct cudaArray* srcArray. size_t height. cudaMemcpy2DArrayToArray. srcY) to the memory area pointed to by dst. cudaMemcpy2D() returns an error if dpitch is greater than the maximum allowed. const struct cudaArray* srcArray. cudaMemcpy2DToArray. or cudaMemcpyDeviceToDevice. dpitch is the width in memory in bytes of the 2D array pointed to by dst. cudaMemcpyFromArray.copies data between host and device SYNOPSIS cudaError_t cudaMemcpy2DFromArray(void* dst. size_t srcX. cudaMemcpyToArray. SEE ALSO cudaMemcpy. enum cudaMemcpyKind kind. size_t srcY. size_t width.1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidPitchValue 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. size_t dpitch.

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

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

18 cudaMemcpyToSymbol NAME cudaMemcpyToSymbol . 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.copies data from host memory to GPU SYNOPSIS template < class T > cudaError_t cudaMemcpyToSymbol( const T& symbol. The memory areas may not overlap. symbol can either be a variable that resides in global or constant memory space. size_t offset. kind can be either cudaMemcpyHostToDevice or cudaMemcpyDeviceToDevice. size_t count. cudaMemcpy2D. naming 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.1. cudaMemcpy2DFromArray. cudaMemcpyFromArray. cudaMemcpyArrayToArray. const void* src. cudaMemcpyToArray. SEE ALSO cudaMemcpy. cudaMemcpy2DArrayToArray. asynchronous launches. cudaMemcpyFromSymbol 42 . cudaMemcpy2DToArray.5. or it can be a character string.

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

or it can be a character string.20 cudaGetSymbolAddress NAME cudaGetSymbolAddress . SEE ALSO cudaGetSymbolSize 44 . asynchronous launches. 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. 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.finds the address associated with a CUDA symbol SYNOPSIS template < class T > cudaError_t cudaGetSymbolAddress(void** devPtr. *devPtr is unchanged and an error is returned.5.1. naming a variable that resides in global memory space. If symbol cannot be found. symbol can either be a variable that resides in global memory space.

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

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

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

0}.5. For instance.allocate an array on the GPU SYNOPSIS struct cudaExtent { size_t width. }. or 3D arrays. 0} . (1. • A 1D array is allocated if the height and depth extent are both zero. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. a degenerate 2D array allows for significantly more linear storage than a 1D array. 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. For 2D arrays valid extents are {(1. }. w.23 cudaMalloc3DArray NAME cudaMalloc3DArray . 2D. cudaChannelFormatKindUnsigned. const struct cudaChannelFormatDesc* desc. 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. • A 3D array is allocate if all three extents are non-zero. asynchronous launches. 0.1. For 1D arrays valid extents are {(1. size_t depth. 48 . For 3D arrays valid extents are {(1. 2048). (1. 2048)}. 32768). size_t height. cudaChannelFormatKindFloat. 2048). • A 2D array is allocated if only the depth extent is zero. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. 8192). cudaMalloc3DArray is able to allocate 1D. z. 65536). cudaError_t cudaMalloc3DArray( struct cudaArray** arrayPtr. (1. enum cudaChannelFormatKind f. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous.

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

1.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 .6.

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

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

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

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

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

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

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

1.6.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 .

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

const void* devPtr. int dim. const struct texture < T. enum cudaTextureReadMode readMode E<gt> static __inline__ __host__ cudaError_t cudaBindTexture( size_t* offset. size_t size = UINT_MAX) DESCRIPTION Binds size bytes of the memory area pointed to by devPtr to texture reference texRef. Any memory previously bound to texRef is unbound. desc describes how the memory is interpreted when fetching values from the texture. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaBindTexture(size_t* offset. const struct cudaChannelFormatDesc& desc. The offset parameter is an optional byte offset as with the low-level cudaBindTexture() function. const struct texture E<lt> T.cudaBindTexture HL NAME cudaBindTexture . dim. dim. SEE ALSO 65 . asynchronous launches. template E<lt> class T. The channel descriptor is inherited from the texture reference type. const void* devPtr. size_t size = UINT_MAX). int dim. readMode >& texRef. readMode E<gt>& texRef. binds size bytes of the memory area pointed to by devPtr to texture reference texRef. 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.High-level texture API SYNOPSIS template < class T.

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

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

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

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

cudaSetupArgument 70 . naming a function that executes on the device. SEE ALSO cudaConfigureCall. 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 .7. entry must be declared as a __global__ function. or it can be a character string. asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous.launches a device function SYNOPSIS template < class T > cudaError_t cudaLaunch(T entry) DESCRIPTION Launches the function entry on the device.1. entry can either be a function that executes on the device.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaD3D9UnregisterResource. DESCRIPTION Returns in *pWidth. SEE ALSO cudaD3D9GetDevice. cudaD3D9MapResources. cudaD3D9ResourceGetMappedPointer. and pDepth are optional. For 2D surfaces. unsigned int Level). The parameters pWidth. and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. size_t* pHeight.1. *pHeight. unsigned int Face. cudaD3D9RegisterResource. cudaD3D9SetDirect3DDevice. pHeight. size_t *pDepth. cudaD3D9ResourceSetMapFlags.9 cudaD3D9ResourceGetSurfaceDimensions NAME cudaD3D9ResourceGetSurfaceDimensions . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle Note that this function may also return error codes from previous. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. cudaD3D9UnmapResources. 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. asynchronous launches. cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetMappedSize.9. 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 value returned in *pDepth will be 0. IDirect3DResource9* pResource. cudaD3D9ResourceGetMappedPitch 89 .

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

cudaD3D9ResourceGetMappedPitch 91 . cudaD3D9ResourceGetSurfaceDimensio cudaD3D9ResourceSetMapFlags.11 cudaD3D9ResourceGetMappedSize NAME cudaD3D9ResourceGetMappedSize . cudaD3D9UnmapResources. asynchronous launches. If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. SEE ALSO cudaD3D9GetDevice. DESCRIPTION Returns in *pSize the size of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. cudaD3D9GetDirect3DDevice.1. If pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. unsigned int Face.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. cudaD3D9MapResources.9. cudaD3D9RegisterResource. If pResource is not mapped for access by CUDA then cudaErrorUnknown is returned. The value set in pSize may change every time that pResource is mapped. cudaD3D9ResourceGetMappedPointer. cudaD3D9UnregisterResource. unsigned int Level). IDirect3DResource9* pResource. cudaD3D9SetDirect3DDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown 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.1.y. If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. unsigned int Face.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. The values set in pPitch and pPitchSlice may change every time that pResource is mapped. unsigned int Level). size_t* pPitchSlice.12 cudaD3D9ResourceGetMappedPitch NAME cudaD3D9ResourceGetMappedPitch . 92 . For a 2D surface the byte offset of the sample of at position x. If pResource is not mapped for access by CUDA then cudaErrorUnknown is returned. The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. 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.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.9.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. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. asynchronous launches. IDirect3DResource9* pResource.

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

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

95 .1.10. 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.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.1 cudaGetLastError NAME cudaGetLastError .

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

If cuInit() has not been called. SEE ALSO 100 . the Flags parameters must be 0.1 cuInit NAME cuInit . any function from the driver API will return CUDA_ERROR_NOT_INITIALIZED. Currently. DESCRIPTION Initializes the driver API and must be called before any other function from the driver API. asynchronous launches.2.1. 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.initialize the CUDA driver API SYNOPSIS CUresult cuInit( unsigned int Flags ).

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

cuDeviceGetProperties.2. SEE ALSO cuDeviceGetAttribute.returns the compute capability of the device SYNOPSIS CUresult cuDeviceComputeCapability(int* major. cuDeviceGet. asynchronous launches. int* minor. cuDeviceTotalMem 102 . cuDeviceGetName. DESCRIPTION Returns in *major and *minor the major and minor revision numbers that define the compute capability of device dev. cuDeviceGetCount. 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.1 cuDeviceComputeCapability NAME cuDeviceComputeCapability .2.

2. cuDeviceGetName. cuDeviceGetCount. int ordinal).2. asynchronous launches.2 cuDeviceGet NAME cuDeviceGet . cuDeviceTotalMem 103 . cuDeviceGetProperties.returns a device-handle SYNOPSIS CUresult cuDeviceGet(CUdevice* dev. cuDeviceGetCount()-1]. DESCRIPTION Returns in *dev a device handle given an ordinal in the range [0. cuDeviceGetAttribute. SEE ALSO cuDeviceComputeCapability. 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.

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

cuDeviceTotalMem 105 . cuDeviceGetCount. cuDeviceGet. cuDeviceGetProperties. SEE ALSO cuDeviceComputeCapability.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. cuDeviceGetName. asynchronous launches.

DESCRIPTION Returns in *count the number of devices with compute capability greater or equal to 1. cuDeviceGetName.4 cuDeviceGetCount NAME cuDeviceGetCount . asynchronous launches.2.0 that are available for execution. cuDeviceGetCount() returns 0.2. cuDeviceGetAttribute. cuDeviceGetProperties. If there is no such device.returns the number of compute-capable devices SYNOPSIS CUresult cuDeviceGetCount(int* count). 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 cuDeviceComputeCapability. cuDeviceGet. cuDeviceTotalMem 106 .

5 cuDeviceGetName NAME cuDeviceGetName . cuDeviceGetCount. cuDeviceTotalMem 107 .returns an identifier string SYNOPSIS CUresult cuDeviceGetName(char* name. len specifies the maximum length of the string that may be returned. cuDeviceGet. int len. cuDeviceGetAttribute. 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. SEE ALSO cuDeviceComputeCapability.2. DESCRIPTION Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name.2. cuDeviceGetProperties. asynchronous launches.

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

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. cuDeviceGet. cuDeviceGetAttribute. cuDeviceGetCount. SEE ALSO cuDeviceComputeCapability. cuDeviceTotalMem 109 . cuDeviceGetName.

7 cuDeviceTotalMem NAME cuDeviceTotalMem . cuDeviceGet.2. cuDeviceGetName. CUdevice dev ).returns the total amount of memory on the device SYNOPSIS CUresult cuDeviceTotalMem( unsigned int* bytes. cuDeviceGetCount.2. cuDeviceGetAttribute. SEE ALSO cuDeviceComputeCapability. DESCRIPTION Returns in *bytes the total amount of memory available on the device dev in bytes. asynchronous launches. cuDeviceGetProperties 110 . 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.

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

Currently.1 cuCtxAttach NAME cuCtxAttach . asynchronous launches.2. 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. unsigned int Flags).increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxGetDevice.3. cuCtxAttach() fails if there is no context current to the thread. cuCtxSynchronize 112 . the Flags parameter must be 0. SEE ALSO cuCtxCreate. 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.

CUdevice dev). it is supplanted by the newly created context and may be restored by a subsequent call to cuCtxPopCurrent().create a CUDA context SYNOPSIS CUresult cuCtxCreate(CUcontext* pCtx. The Flags parameter is described below. This can increase latency when waiting for the GPU.3. DESCRIPTION Creates a new CUDA context and associates it with the calling thread. but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread. asynchronous launches. If a context is already current to the thread. If C > P then CUDA will yield to other OS threads when waiting for the GPU. otherwise CUDA will not yield while waiting for results and actively spin on the processor. This can decrease latency when waiting for the GPU.2 cuCtxCreate NAME cuCtxCreate . • CU_CTX_SCHED_AUTO: The default value if the Flags parameter is zero. • CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for results from the GPU. 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. 113 .2. 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. unsigned int Flags. • CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for results from the GPU. but can increase the performance of CPU threads performing work in parallel with the GPU. 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. 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.

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

cuCtxPopCurrent 115 . cuCtxPushCurrent. Floating contexts (detached from a CPU thread via cuCtxPopCurrent()) may be destroyed by this function. 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.3 cuCtxDestroy NAME cuCtxDestroy .2. cuCtxDetach. asynchronous launches. this function fails. cuCtxAttach.3. or the context is current to any CPU thread other than the current one. SEE ALSO cuCtxCreate.destroy the current context context or a floating CuDA context SYNOPSIS CUresult cuCtxDestroy(CUcontext ctx). DESCRIPTION Destroys the given CUDA context. If the context usage count is not equal to 1.

cuCtxPushCurrent. cuCtxDestroy. and must be current to the calling thread.2.3. 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. cuCtxAttach. DESCRIPTION Decrements the usage count of the context. asynchronous launches. The context must be a handle that was passed back by cuCtxCreate() or cuCtxAttach(). and destroys the context if the usage count goes to 0.decrement a context’s usage-count SYNOPSIS CUresult cuCtxDetach(CUcontext ctx).4 cuCtxDetach NAME cuCtxDetach . SEE ALSO cuCtxCreate. cuCtxPopCurrent 116 .

2. asynchronous launches.5 cuCtxGetDevice NAME cuCtxGetDevice . cuCtxAttach. cuCtxSynchronize 117 . DESCRIPTION Returns in *device the ordinal of the current context’s device.3. SEE ALSO cuCtxCreate.return device-ID for current context SYNOPSIS CUresult cuCtxGetDevice(CUdevice* 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. cuCtxDetach.

3. 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. cuCtxPopCurrent() passes back the context handle in *pctx. SEE ALSO cuCtxCreate. If successful. cuCtxDetach.2. DESCRIPTION Pops the current CUDA context from the CPU thread. the usage count may be incremented with cuCtxAttach() and decremented with cuCtxDetach(). cuCtxAttach. The CUDA context must have a usage count of 1. If a context was current to the CPU thread before cuCtxCreate or cuCtxPushCurrent was called. The context may then be made current to a different CPU thread by calling cuCtxPushCurrent(). this function makes that context current to the CPU thread again. cuCtxDestroy.pops the current CUDA context from the current CPU thread SYNOPSIS CUresult cuCtxPopCurrent(CUcontext *pctx). Floating contexts may be destroyed by calling cuCtxDestroy(). CUDA contexts have a usage count of 1 upon creation. cuCtxPushCurrent 118 .6 cuCtxPopCurrent NAME cuCtxPopCurrent . asynchronous launches.

The specified context becomes the CPU thread’s current context. not attached to any thread. The context must be "floating. Contexts are made to float by calling cuCtxPopCurrent(). so all CUDA functions that operate on the current context are affected.7 cuCtxPushCurrent NAME cuCtxPushCurrent . 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. cuCtxDestroy. The previous current context may be made current again by calling cuCtxDestroy() or cuCtxPopCurrent().attach floating context to CPU thread SYNOPSIS CUresult cuCtxPushCurrent(CUcontext ctx)." i. asynchronous launches.3.2.e. cuCtxAttach. SEE ALSO cuCtxCreate. DESCRIPTION Pushes the given context onto the CPU thread’s stack of current contexts. cuCtxPopCurrent 119 .

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.2. SEE ALSO cuCtxCreate. cuCtxGetDevice 120 .3.block for a context’s tasks to complete SYNOPSIS CUresult cuCtxSynchronize(void).8 cuCtxSynchronize NAME cuCtxSynchronize . asynchronous launches. cuCtxAttach. cuCtxSynchronize() returns an error if one of the preceding tasks failed. cuCtxDetach.

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

const char* funcname).2. DESCRIPTION Returns in *func the handle of the function of name funcname located in module mod.1 cuModuleGetFunction NAME cuModuleGetFunction . If no function of that name exists. cuModuleGetTexRef 122 . CUmodule mod. cuModuleGetFunction() returns CUDA_ERROR_NOT_FOUND. SEE ALSO cuModuleLoad. 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_NOT_FOUND Note that this function may also return error codes from previous. cuModuleGetGlobal.4.returns a function handle SYNOPSIS CUresult cuModuleGetFunction(CUfunction* func. cuModuleLoadFatBinary. cuModuleUnload. cuModuleLoadData.

If no variable of that name exists. const char* globalname). cuModuleLoadData. CUmodule mod.returns a global pointer from a module SYNOPSIS CUresult cuModuleGetGlobal(CUdeviceptr* devPtr. SEE ALSO cuModuleLoad. it is ignored. cuModuleGetFunction. unsigned int* bytes.4. cuModuleGetGlobal() returns CUDA_ERROR_NOT_FOUND.2. If one of them is null.2 cuModuleGetGlobal NAME cuModuleGetGlobal . cuModuleGetTexRef 123 . Both parameters devPtr and bytes are optional. cuModuleUnload. asynchronous launches. DESCRIPTION Returns in *devPtr and *bytes the base pointer and size of the global of name globalname located in module mod. 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.

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

cuModuleGetTexRef 128 . DESCRIPTION Unloads a module mod from the current context. SEE ALSO cuModuleLoad. cuModuleLoadData.2. cuModuleLoadFatBinary. cuModuleGetGlobal.unloads a module SYNOPSIS CUresult cuModuleUnload(CUmodule mod). 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 cuModuleUnload NAME cuModuleUnload .4. cuModuleGetFunction.

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

flags is required to be 0.2.1 cuStreamCreate NAME cuStreamCreate .create a stream SYNOPSIS CUresult cuStreamCreate(CUstream* stream. SEE ALSO cuStreamQuery. At present.5. DESCRIPTION Creates a stream. asynchronous launches. cuStreamSynchronize. unsigned int flags). cuStreamDestroy 130 . 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.

SEE ALSO cuStreamCreate. cuStreamQuery. DESCRIPTION Destroys the stream.2. cuStreamSynchronize 131 . 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.destroys a stream SYNOPSIS CUresult cuStreamDestroy(CUstream stream).2 cuStreamDestroy NAME cuStreamDestroy .5.

DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed.2. or CUDA_ERROR_NOT_READY if not.determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream). cuStreamDestroy 132 . asynchronous launches. 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.3 cuStreamQuery NAME cuStreamQuery .5. cuStreamSynchronize. SEE ALSO cuStreamCreate.

asynchronous launches.4 cuStreamSynchronize NAME cuStreamSynchronize . DESCRIPTION Blocks until the device has completed all operations in the stream. cuStreamDestroy 133 .2. SEE ALSO cuStreamCreate. cuStreamQuery. 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.5.block until a stream’s tasks are completed SYNOPSIS CUresult cuStreamSynchronize(CUstream stream).

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

6. cuEventQuery. SEE ALSO cuEventRecord. cuEventDestroy.1 cuEventCreate NAME cuEventCreate . DESCRIPTION Creates an event. unsigned int flags). cuEventElapsedTime 135 . flags is required to be 0. 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.creates an event SYNOPSIS CUresult cuEventCreate(CUevent* event. asynchronous launches. cuEventSynchronize. At present.2.

6.2 cuEventDestroy NAME cuEventDestroy . cuEventQuery. cuEventElapsedTime 136 . asynchronous launches. cuEventSynchronize.destroys an event SYNOPSIS CUresult cuEventDestroy(CUevent 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. DESCRIPTION Destroys the event.2. SEE ALSO cuEventCreate. cuEventRecord.

2.3 cuEventElapsedTime NAME cuEventElapsedTime . cuEventSynchronize. SEE ALSO cuEventCreate. cuEventQuery. CUevent start. cuEventDestroy 137 . If either event has not been recorded yet. cuEventRecord. DESCRIPTION Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). this function returns CUDA_ERROR_INVALID_VALUE. the result is undefined. If either event has been recorded with a non-zero stream.computes the elapsed time between two events SYNOPSIS CUresult cuEventDestroy(float* time. 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.6. CUevent end). asynchronous launches.

DESCRIPTION Returns CUDA_SUCCESS if the event has actually been recorded.queries an event’s status SYNOPSIS CUresult cuEventQuery(CUevent event). or CUDA_ERROR_NOT_READY if not.6.4 cuEventQuery NAME cuEventQuery . 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. cuEventElapsedTime 138 . asynchronous launches. cuEventRecord. cuEventDestroy. If cuEventRecord() has not been called on this event.2. SEE ALSO cuEventCreate. cuEventSynchronize.

cuEventQuery() and/or cuEventSynchronize() must be used to determine when the event has actually been recorded. asynchronous launches. otherwise. Since this operation is asynchronous.records an event SYNOPSIS CUresult cuEventRecord(CUevent event. DESCRIPTION Records an event. cuEventQuery. this 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_INVALID_VALUE Note that this function may also return error codes from previous. CUstream stream). the event is recorded after all preceding operations in the stream have been completed. SEE ALSO cuEventCreate. cuEventElapsedTime 139 . If stream is non-zero.2.6. cuEventDestroy. it is recorded after all preceding operations in the CUDA context have been completed. cuEventSynchronize. If cuEventRecord() has previously been called and the event has not been recorded yet.5 cuEventRecord NAME cuEventRecord .

SEE ALSO cuEventCreate. cuEventRecord. 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 cuEventSynchronize NAME cuEventSynchronize . asynchronous launches.6. cuEventQuery.waits for an event to complete SYNOPSIS CUresult cuEventSynchronize(CUevent event).2. the function returns CUDA_ERROR_INVALID_VALUE. cuEventElapsedTime 140 . DESCRIPTION Blocks until the event has actually been recorded. cuEventDestroy. If cuEventRecord() has not been called on this event.

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

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. The block contains the number of threads specified by a previous call to cuFuncSetBlockShape(). cuParamSeti. DESCRIPTION Invokes the kernel func on a 1ÃŮ1 grid of blocks. SEE ALSO cuFuncSetBlockShape. asynchronous launches. cuParamSetf.7.2. cuParamSetv.launches a CUDA function SYNOPSIS CUresult cuLaunch(CUfunction func). cuParamSetTexRef.1 cuLaunch NAME cuLaunch . cuParamSetSize. cuFuncSetSharedSize. cuLaunchGrid 142 .

2 cuLaunchGrid NAME cuLaunchGrid . CUstream stream). cuLaunchGridAsync() can optionally be associated to a stream by passing a non-zero stream argument. cuParamSetf.7. asynchronous launches. int grid_width. Each block contains the number of threads specified by a previous call to cuFuncSetBlockShape(). cuParamSeti. int grid_height. int grid_width. cuParamSetv. cuParamSetTexRef.2. cuParamSetSize. 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. SEE ALSO cuFuncSetBlockShape. cuLaunch 143 . int grid_height). cuFuncSetSharedSize. CUresult cuLaunchGridAsync(CUfunction func. DESCRIPTION Invokes the kernel on a grid_width x grid_height grid of blocks.launches a CUDA function SYNOPSIS CUresult cuLaunchGrid(CUfunction func.

7.2. cuFuncSetSharedSize. cuParamSeti. 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. DESCRIPTION Sets through numbytes the total size in bytes needed by the function parameters of function func. cuLaunchGrid 144 .3 cuParamSetSize NAME cuParamSetSize . cuParamSetv. cuLaunch. cuParamSetf. unsigned int numbytes). SEE ALSO cuFuncSetBlockShape. cuParamSetTexRef.sets the parameter-size for the function SYNOPSIS CUresult cuParamSetSize(CUfunction func.

CUtexref texRef). SEE ALSO cuFuncSetBlockShape. cuFuncSetSharedSize. 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.4 cuParamSetTexRef NAME cuParamSetTexRef . cuParamSetf. cuLaunchGrid 145 . cuParamSeti.2. cuParamSetSize. cuLaunch. cuParamSetv. the texture reference must be obtained via cuModuleGetTexRef() and the texunit parameter must be set to CU_PARAM_TR_DEFAULT. DESCRIPTION Makes the CUDA array or linear memory bound to the texture reference texRef available to a device program as a texture.adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func. asynchronous launches. In this version of CUDA.7. int texunit.

DESCRIPTION Sets a floating point parameter that will be specified the next time the kernel corresponding to func will be invoked. offset is a byte offset. cuParamSetSize. float value). cuLaunchGrid 146 . cuParamSeti. asynchronous launches. cuFuncSetSharedSize.2. SEE ALSO cuFuncSetBlockShape.5 cuParamSetf NAME cuParamSetf .7. int offset. cuParamSetTexRef. cuParamSetv. cuLaunch. 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.adds a floating-point parameter to the function’s argument list SYNOPSIS CUresult cuParamSetf(CUfunction func.

SEE ALSO cuFuncSetBlockShape. cuLaunch.6 cuParamSeti NAME cuParamSeti . cuFuncSetSharedSize.adds an integer parameter to the function’s argument list SYNOPSIS CUresult cuParamSeti(CUfunction func.2. unsigned int value). cuParamSetTexRef. int offset. cuParamSetv. cuParamSetf. cuParamSetSize. 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. DESCRIPTION Sets an integer parameter that will be specified the next time the kernel corresponding to func will be invoked. cuLaunchGrid 147 . offset is a byte offset.7.

asynchronous launches. cuParamSeti. cuLaunchGrid 148 . cuParamSetf. cuParamSetSize. void* ptr.7 cuParamSetv NAME cuParamSetv . cuParamSetTexRef. cuLaunch. unsigned int numbytes). int offset. SEE ALSO cuFuncSetBlockShape.adds arbitrary data to the function’s argument list SYNOPSIS CUresult cuParamSetv(CUfunction func. offset is a byte offset. 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.2.7. DESCRIPTION Copies an arbitrary amount of data into the parameter space of the kernel corresponding to func.

7. cuParamSetv. cuParamSetf. 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.8 cuFuncSetBlockShape NAME cuFuncSetBlockShape . int x. int y. int z). cuParamSeti. cuParamSetSize.2. Y and Z dimensions of the thread blocks that are created when the kernel given by func is launched. cuLaunch. cuParamSetTexRef. SEE ALSO cuFuncSetSharedSize. DESCRIPTION Specifies the X.sets the block-dimensions for the function SYNOPSIS CUresult cuFuncSetBlockShape(CUfunction func. asynchronous launches. cuLaunchGrid 149 .

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. 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. cuParamSetf. SEE ALSO cuFuncSetBlockShape. cuParamSetSize. cuParamSeti. cuParamSetv. cuLaunch. unsigned int bytes).9 cuFuncSetSharedSize NAME cuFuncSetSharedSize .2. cuLaunchGrid 150 . asynchronous launches.7. cuParamSetTexRef.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func.

8 MemoryManagement NAME Memory Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. DeviceManagement. EventManagement.2. ExecutionControl. OpenGlInteroperability. 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. MemoryManagement. StreamManagement. Direct3dInteroperability 151 . ModuleManagement. TextureReferenceManagement. ContextManagement.

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

cuMemFreeHost.NumChannels = 2. cuMemGetAddressRange. • Description for a width x height CUDA array of 16-bit elements.Width = width. desc.Height = 64. cuMemFree.Width = width. SEE ALSO cuMemGetInfo.Height = height.Height = height.Width = 64.Height = 1. desc.NumChannels = 1.NumChannels = 4. cuMemAllocPitch.Format = CU_AD_FORMAT_FLOAT. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc. cuMemset2D 153 . desc. • Description for a width x height CUDA array of 64-bit.NumChannels = 1. desc. each of which is two 8-bit unsigned chars: CUDA_ARRAY_DESCRIPTOR arrayDesc. desc.desc. desc.Width = 2048. 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. cuMemAlloc.FormatFlags = CU_AD_FORMAT_UNSIGNED_INTS. cuArrayGetDescriptor. desc. cuMemset.FormatFlags = CU_AD_FORMAT_HALF. asynchronous launches. cuArrayDestroy. • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY_DESCRIPTOR desc. cuMemAllocHost. desc. desc. desc. desc. desc.

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

desc. desc. desc.Height = 64. SEE ALSO cuMemGetInfo. desc.Depth = depth. desc.Width = width. cuMemFree.Height = height. cuArrayDestroy 155 . • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY3D_DESCRIPTOR desc. cuMemGetAddressRange. • Description for a width x height x depth CUDA array of 64-bit. desc. desc.• Description for a CUDA array of 2048 floats: CUDA_ARRAY3D_DESCRIPTOR desc.Format = CU_AD_FORMAT_FLOAT.Width = 2048.FormatFlags = CU_AD_FORMAT_HALF. cuMemFreeHost. cuMemAllocHost. cuMemAllocPitch.NumChannels = 4. desc. desc.NumChannels = 1. desc. desc. cuArray3DGetDescriptor. asynchronous launches.Depth = 0.Depth = 0.Height = 0. cuMemAlloc. desc.Format = CU_AD_FORMAT_FLOAT. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc. desc. desc.NumChannels = 1. 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.Width = 64.

destroys a CUDA array SYNOPSIS CUresult cuArrayDestroy(CUarray array). cuMemFree. cuArrayCreate. SEE ALSO cuMemGetInfo. DESCRIPTION Destroys the CUDA array array. cuMemset. cuMemset2D 156 . cuArrayGetDescriptor. cuMemGetAddressRange. cuMemAllocPitch. cuMemAllocHost. 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. cuMemFreeHost.3 cuArrayDestroy NAME cuArrayDestroy . cuMemAlloc.2.8. asynchronous launches.

cuArrayDestroy 157 .8. SEE ALSO cuArrayCreate.2. CUarray array) DESCRIPTION Returns in *arrayDesc a descriptor of the format and dimensions of the 1D or 2D CUDA array array. but need to know the CUDA array parameters for validation or other purposes.4 cuArrayGetDescriptor NAME cuArrayGetDescriptor . 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. cuArray3DCreate.get a 1D or 2D CUDA array descriptor SYNOPSIS CUresult cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR* arrayDesc. cuArray3DGetDescriptor. It is useful for subroutines that have been passed a CUDA array.

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 Note that this function may also return error codes from previous.8. cuArrayDestroy 158 . DESCRIPTION Returns in *arrayDesc a descriptor containing information on the format and dimensions of the CUDA array array. cuArrayGetDescriptor. CUarray array). but need to know the CUDA array parameters for validation or other purposes. SEE ALSO cuArrayCreate.5 cuArray3DGetDescriptor NAME cuArray3DGetDescriptor . asynchronous launches. It is useful for subroutines that have been passed a CUDA array. cuArray3DCreate.get a 3D CUDA array descriptor SYNOPSIS CUresult cuArray3DGetDescriptor(CUDA_ARRAY3D_DESC *arrayDesc.

allocates device memory SYNOPSIS CUresult cuMemAlloc(CUdeviceptr* devPtr. DESCRIPTION Allocates count bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. cuArrayGetDescriptor. The allocated memory is suitably aligned for any kind of variable. cuArrayCreate. SEE ALSO cuMemGetInfo. unsigned int count). asynchronous launches. cuMemAlloc() returns CUDA_ERROR_INVALID_VALUE.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. cuArrayDestroy. If count is 0. cuMemset. cuMemAllocHost.8. cuMemFree. The memory is not cleared.6 cuMemAlloc NAME cuMemAlloc . cuMemGetAddressRange. cuMemFreeHost. cuMemset2D 159 . cuMemAllocPitch.

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

8 or 16 (since coalesced memory transactions are not possible on other data sizes). 161 .8 cuMemAllocPitch NAME cuMemAllocPitch . used to compute addresses within the 2D array. DESCRIPTION Allocates at least widthInBytes*height bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. unsigned int elementSizeBytes). 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. unsigned int widthInBytes. Given the row and column of an array element of type T. 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). The pitch returned by cuMemAllocPitch() is guaranteed to work with cuMemcpy2D() under all circumstances. the kernel will run correctly. Due to alignment restrictions in the hardware. but possibly at reduced speed. elementSizeBytes may be 4. The pitch returned in *pitch by cuMemAllocPitch() is the width in bytes of the allocation. unsigned int* pitch. 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.allocates device memory SYNOPSIS CUresult cuMemAllocPitch(CUdeviceptr* devPtr. For allocations of 2D arrays.2. The intended usage of pitch is as a separate parameter of the allocation. elementSizeBytes specifies the size of the largest reads and writes that will be performed on the memory range. If elementSizeBytes is smaller than the actual read/write size of a kernel. asynchronous launches. the address is computed as T* pElement = (T*)((char*)BaseAddress + Row * Pitch) + Column.8. unsigned int height. it is recommended that programmers consider performing pitch allocations using cuMemAllocPitch().

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

cuMemFreeHost. DESCRIPTION Frees the memory space pointed to by devPtr. cuMemset. 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.9 cuMemFree NAME cuMemFree . cuMemset2D 163 .frees device memory SYNOPSIS CUresult cuMemFree(CUdeviceptr devPtr). cuArrayCreate.2. cuMemGetAddressRange. asynchronous launches. cuMemAllocPitch.8. cuMemAllocHost. cuArrayDestroy. cuMemAlloc. which must have been returned by a previous call to cuMemMalloc() or cuMemMallocPitch(). cuArrayGetDescriptor.

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.10 cuMemFreeHost NAME cuMemFreeHost . cuMemFree.frees page-locked host memory SYNOPSIS CUresult cuMemFreeHost(void* hostPtr). cuMemAllocPitch. cuArrayCreate. cuArrayGetDescriptor. which must have been returned by a previous call to cuMemAllocHost(). SEE ALSO cuMemGetInfo.2. DESCRIPTION Frees the memory space pointed to by hostPtr. cuArrayDestroy. cuMemset. cuMemAlloc. cuMemGetAddressRange. asynchronous launches.8. cuMemset2D 164 .

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. If one of them is null. cuMemset2D 165 . cuMemset. SEE ALSO cuMemGetInfo. it is ignored.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. cuMemFreeHost. cuMemAllocPitch. cuMemAllocHost. Both parameters basePtr and size are optional. cuArrayCreate.2. cuArrayGetDescriptor. cuArrayDestroy. DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr. cuMemAlloc. asynchronous launches. CUdeviceptr devPtr).8.11 cuMemGetAddressRange NAME cuMemGetAddressRange . unsigned int* size. cuMemFree.

12 cuMemGetInfo NAME cuMemGetInfo . unsigned int* total). cuMemset2D 166 . DESCRIPTION Returns in *free and *total respectively. SEE ALSO cuMemAlloc. cuMemset. cuMemFreeHost. cuMemGetAddressRange. in bytes. cuMemAllocHost. cuArrayGetDescriptor. asynchronous launches. cuMemFree.gets free and total memory SYNOPSIS CUresult cuMemGetInfo(unsigned int* free. cuArrayDestroy. the free and total amount of memory available for allocation by the CUDA context.2.8. cuArrayCreate. 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. cuMemAllocPitch.

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

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

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

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

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

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

Width-1] for the CUDA array. unsigned int count). but the elements must be the same size. cuMemcpy2D 173 . cuMemcpyAtoH. 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 srcIndex. dstArray and srcArray specify the handles of the destination and source CUDA arrays for the copy. DESCRIPTION Copies from one 1D CUDA array to another. cuMemcpyDtoD. CUarray srcArray. These values are in the range [0.15 cuMemcpyAtoA NAME cuMemcpyAtoA . cuMemcpyAtoD.2. cuMemcpyHtoA.copies memory from Array to Array SYNOPSIS CUresult cuMemcpyAtoA(CUarray dstArray. dstIndex and srcIndex specify the destination and source indices into the CUDA array. count is the number of bytes to be copied. SEE ALSO cuMemcpyHtoD. unsigned int dstIndex. The size of the elements in the CUDA arrays need not be the same format. asynchronous launches. cuMemcpyDtoH. respectively. cuMemcpyDtoA.8. they are not byte offsets.

cuMemcpyHtoA. cuMemcpyDtoD. srcArray and srcIndex specify the CUDA array handle and the index (in array elements) of the array element where the copy is to begin. cuMemcpyDtoH. count specifies the number of bytes to copy and must be evenly divisible by the array element size.8. SEE ALSO cuMemcpyHtoD. dstDevPtr specifies the base pointer of the destination and must be naturally aligned with the CUDA array elements. asynchronous launches.16 cuMemcpyAtoD NAME cuMemcpyAtoD .copies memory from Array to Device SYNOPSIS CUresult cuMemcpyAtoD(CUdeviceptr dstDevPtr. cuMemcpyAtoH. cuMemcpy2D 174 . CUarray srcArray. cuMemcpyAtoA.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. cuMemcpyDtoA. unsigned int srcIndex. DESCRIPTION Copies from a 1D CUDA array to device memory. unsigned int count).

17 cuMemcpyAtoH NAME cuMempcyAtoH . unsigned int srcIndex. cuMemcpyDtoD. count specifies the number of bytes to copy.copies memory from Array to Host SYNOPSIS CUresult cuMemcpyAtoH(void* dstHostPtr. dstHostPtr specifies the base pointer of the destination.8. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cuMemcpyAtoHAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. cuMemcpyAtoA. cuMemcpyHtoA. unsigned int srcIndex. CUarray srcArray. cuMemcpyDtoH. unsigned int count). CUarray srcArray. CUstream stream). CUresult cuMemcpyAtoHAsync(void* dstHostPtr. cuMemcpyAtoD. asynchronous launches.2. cuMemcpy2D 175 . srcArray and srcIndex specify the CUDA array handle and starting index of the source data. unsigned int count. DESCRIPTION Copies from a 1D CUDA array to host memory. cuMemcpyDtoA. SEE ALSO cuMemcpyHtoD. 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.

srcDevPtr specifies the base pointer of the source. count specifies the number of bytes to copy. dstArray and dstIndex specify the CUDA array handle and starting index of the destination data. cuMemcpyAtoD. cuMemcpyHtoA. cuMemcpyDtoH.18 cuMemcpyDtoA NAME cuMemcpyDtoA .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. cuMemcpyDtoD. DESCRIPTION Copies from device memory to a 1D CUDA array.8. asynchronous launches. cuMemcpyAtoH. unsigned int dstIndex. cuMemcpyAtoA. SEE ALSO cuMemcpyHtoD. CUdeviceptr srcDevPtr.copies memory from Device to Array SYNOPSIS CUresult cuMemcpyDtoA(CUarray dstArray. unsigned int count). cuMemcpy2D 176 .

DESCRIPTION Copies from device memory to device memory. count specifies the number of bytes to copy.2.19 cuMemcpyDtoD NAME cuMemcpyDtoD . SEE ALSO cuMemcpyHtoD. CUdeviceptr srcDevPtr. cuMemcpyDtoA. cuMemcpy2D 177 . asynchronous launches.copies memory from Device to Device SYNOPSIS CUresult cuMemcpyDtoD(CUdeviceptr dstDevPtr. cuMemcpyAtoH. respectively. cuMemcpyHtoA. 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. cuMemcpyAtoA. dstDevice and srcDevPtr are the base pointers of the destination and source.8. unsigned int count). cuMemcpyDtoH.

8. respectively. unsigned int count.20 cuMemcpyDtoH NAME cuMemcpyDtoH . It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. countspecifies the number of bytes to copy. cuMemcpyHtoA. DESCRIPTION Copies from device to host memory. cuMemcpyAtoH. CUresult cuMemcpyDtoHAsync(void* dstHostPtr. asynchronous launches. CUdeviceptr srcDevPtr. CUdeviceptr srcDevPtr. cuMemcpyAtoA. cuMemcpyDtoD. CUstream stream). unsigned int count). cuMemcpy2D 178 . 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. SEE ALSO cuMemcpyHtoD. dstHostPtr and srcDevPtrspecify the base addresses of the source and destination. cuMemcpyAtoD.2. MemcpyDtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument.copies memory from Device to Host SYNOPSIS CUresult cuMemcpyDtoH(void* dstHostPtr.

cuMemcpyAtoA.2.8. count specifies the number of bytes to copy.21 cuMemcpyHtoA NAME cuMemcpyHtoA . cuMemcpyDtoD. SEE ALSO cuMemcpyHtoD. 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 dstIndex. unsigned int dstIndex. unsigned int count). dstArray and dstIndex specify the CUDA array handle and starting index of the destination data. cuMemcpyDtoA. CUstream stream). cuMemcpyDtoH. DESCRIPTION Copies from host memory to a 1D CUDA array. srcHostPtr specify the base addresse of the source. cuMemcpyHtoAAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. cuMemcpyAtoH. unsigned int count. const void *srcHostPtr. asynchronous launches. cuMemcpyAtoD.copies memory from Host to Array SYNOPSIS CUresult cuMemcpyHtoA(CUarray dstArray. CUresult cuMemcpyHtoAAsync(CUarray dstArray. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cuMemcpy2D 179 . const void *srcHostPtr.

const void *srcHostPtr. cuMemcpyDtoA. count specifies the number of bytes to copy. cuMemcpyAtoH. dstDevPtr and srcHostPtr specify the base addresses of the destination and source. CUresult cuMemcpyHtoDAsync(CUdeviceptr dstDevPtr. 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. cuMemcpyDtoD. cuMemcpyAtoD. unsigned int count). CUstream stream). asynchronous launches. unsigned int count. const void *srcHostPtr. cuMemcpy2D 180 . respectively. cuMemcpyAtoA. cuMemcpyHtoDAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input.2.8. DESCRIPTION Copies from host memory to device memory. cuMemcpyHtoA.22 cuMemcpyHtoD NAME cuMemcpyHtoD . SEE ALSO cuMemcpyDtoH.copy memory from Host to Device SYNOPSIS CUresult cuMemcpyHtoD(CUdeviceptr dstDevPtr.

initializes device memory SYNOPSIS CUresult cuMemsetD8(CUdeviceptr dstDevPtr. unsigned char value. cuMemAllocPitch. DESCRIPTION Sets the memory range of count 8-. cuMemAllocHost. CUresult cuMemsetD32(CUdeviceptr dstDevPtr. cuArrayDestroy. or 32-bit values to the specified value value. cuMemAlloc. cuArrayGetDescriptor.2.23 cuMemset NAME cuMemset . cuMemFree. 16-. 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. cuMemset2D 181 . asynchronous launches. cuMemFreeHost. unsigned int count ). CUresult cuMemsetD16(CUdeviceptr dstDevPtr. unsigned int count ). unsigned short value. unsigned int value. cuMemGetAddressRange. unsigned int count ). SEE ALSO cuMemGetInfo.8.

8. asynchronous launches. unsigned int height ). unsigned int width. unsigned int value. cuMemAllocPitch. cuMemFreeHost. cuMemAllocHost.24 cuMemset2D NAME cuMemset2D . 16-. unsigned short value. unsigned int width.initializes device memory SYNOPSIS CUresult cuMemsetD2D8(CUdeviceptr dstDevPtr. or 32-bit values to the specified value value. These functions perform fastest when the pitch is one that has been passed back by cuMemAllocPitch(). CUresult cuMemsetD2D32(CUdeviceptr dstDevPtr. cuMemset 182 . SEE ALSO cuMemGetInfo. unsigned int dstPitch. DESCRIPTION Sets the 2D memory range of width 8-. height specifies the number of rows to set. cuMemFree. cuMemAlloc. 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 width. CUresult cuMemsetD2D16(CUdeviceptr dstDevPtr. unsigned char value. unsigned int dstPitch. cuArrayGetDescriptor.2. cuArrayCreate. cuArrayDestroy. unsigned int height ). unsigned int dstPitch. unsigned int height ). and dstPitch specifies the number of bytes between each row.

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

1 cuTexRefCreate NAME cuTexRefCreate . cuTexRefSetArray.) to be used when the memory is read through this texture reference. etc. cuTexRefSetAddressMode. cuTexRefGetFormat. asynchronous launches. cuTexRefGetFilterMode.2. cuTexRefSetAddress. Other texture reference functions are used to specify the format and interpretation (addressing. cuTexRefSetFormat. cuTexRefGetArray. cuTexRefGetFlags 184 . DESCRIPTION Creates a texture reference and returns its handle in *texRef.9.creates a texture-reference SYNOPSIS CUresult cuTexRefCreate(CUtexref* texRef). cuTexRefGetAddressMode. cuTexRefSetFilterMode. the application should call cuParamSetTexRef(). To associate the texture reference with a texture ordinal for a given function. SEE ALSO cuTexRefDestroy. cuTexRefSetFlags. Once created. 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. the application must call cuTexRefSetArray() or cuTexRefSetAddress() to associate the reference with allocated memory. cuTexRefGetAddress. filtering.

DESCRIPTION Destroys the texture reference. cuTexRefSetArray.9.2. SEE ALSO cuTexRefCreate. cuTexRefGetFormat. asynchronous launches. cuTexRefSetFilterMode. cuTexRefGetAddressMode. cuTexRefGetArray.2 cuTexRefDestroy NAME cuTexRefDestroy . cuTexRefSetFlags. cuTexRefGetFlags 185 . cuTexRefGetFilterMode. cuTexRefSetFormat.destroys a texture-reference SYNOPSIS CUresult cuTexRefDestroy(CUtexref texRef). cuTexRefSetAddressMode. cuTexRefSetAddress. 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.

cuTexRefSetAddressMode.gets the address associated with a texture-reference SYNOPSIS CUresult cuTexRefGetAddress(CUdeviceptr* devPtr. cuTexRefSetAddress. 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. or returns CUDA_ERROR_INVALID_VA if the texture reference is not bound to any device memory range. CUtexref texRef). cuTexRefSetArray. cuTexRefGetFilterMode. SEE ALSO cuTexRefCreate. cuTexRefGetFormat. DESCRIPTION Returns in *devPtr the base address bound to the texture reference texRef. cuTexRefSetFormat. cuTexRefGetFlags 186 .9. cuTexRefGetAddressMode. cuTexRefSetFilterMode. cuTexRefSetFlags.3 cuTexRefGetAddress NAME cuTexRefGetAddress . cuTexRefDestroy. cuTexRefGetArray.2.

CUtexref texRef. cuTexRefGetFormat. cuTexRefSetFilterMode. cuTexRefSetArray. Currently the only valid values for dim are 0 and 1.4 cuTexRefGetAddressMode NAME cuTexRefGetAddressMode . cuTexRefGetArray. cuTexRefSetFormat. cuTexRefGetFilterMode. cuTexRefSetFlags. int dim). cuTexRefGetFlags 187 . cuTexRefGetAddress. cuTexRefDestroy. cuTexRefSetAddress. cuTexRefSetAddressMode. SEE ALSO cuTexRefCreate.gets the addressing mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetAddressMode(CUaddress_mode* mode.9. DESCRIPTION Returns in *mode the addressing mode corresponding to the dimension dim of the texture reference 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.2.

cuTexRefSetFilterMode. cuTexRefGetAddress. cuTexRefGetFilterMode. cuTexRefGetFlags 188 . cuTexRefSetFormat. cuTexRefGetFormat.9. or returns CUDA_ERROR_INVALID_VAL if the texture reference is not bound to any CUDA array.5 cuTexRefGetArray NAME cuTexRefGetArray . asynchronous launches.gets the array bound to a texture-reference SYNOPSIS CUresult cuTexRefGetArray(CUarray* array. cuTexRefSetFlags. SEE ALSO cuTexRefCreate. CUtexref texRef). cuTexRefSetAddress.2. DESCRIPTION Returns in *array the CUDA array bound by the texture reference texRef. cuTexRefSetAddressMode. cuTexRefSetArray. cuTexRefGetAddressMode. cuTexRefDestroy. 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.

6 cuTexRefGetFilterMode NAME cuTexRefGetFilterMode . cuTexRefGetFlags 189 . cuTexRefGetAddress. cuTexRefGetAddressMode. 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.gets the filter-mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetFilterMode(CUfilter_mode* mode.2. cuTexRefSetFlags. DESCRIPTION Returns in *mode the filtering mode of the texture reference texRef. cuTexRefGetFormat. cuTexRefSetAddress. cuTexRefDestroy. asynchronous launches. cuTexRefGetArray.9. cuTexRefSetFormat. CUtexref texRef). cuTexRefSetFilterMode. cuTexRefSetArray. SEE ALSO cuTexRefCreate.

cuTexRefSetAddressMode. cuTexRefDestroy. cuTexRefGetArray.7 cuTexRefGetFlags NAME cuTexRefGetFlags . cuTexRefSetFilterMode.9. cuTexRefGetAddress. CUtexref texRef).2. cuTexRefSetFormat. cuTexRefGetFormat 190 .gets the flags used by a texture-reference SYNOPSIS CUresult cuTexRefGetFlags(unsigned int* flags. cuTexRefGetAddressMode. cuTexRefSetAddress. DESCRIPTION Returns in *flags the flags of the texture reference texRef. SEE ALSO cuTexRefCreate. cuTexRefGetFilterMode. cuTexRefSetFlags. asynchronous launches. cuTexRefSetArray. 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. cuTexRefSetFlags. cuTexRefGetAddressMode.9. CUtexref texRef). cuTexRefSetFormat.2. cuTexRefGetAddress. DESCRIPTION Returns in *format and *numPackedComponents the format and number of components of the CUDA array bound to the texture reference texRef. cuTexRefGetFilterMode. int* numPackedComponents. cuTexRefSetArray. cuTexRefSetFilterMode. cuTexRefDestroy. cuTexRefGetFlags 191 . cuTexRefGetArray. SEE ALSO cuTexRefCreate.8 cuTexRefGetFormat NAME cuTexRefGetFormat . cuTexRefSetAddress. 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. If format or numPackedComponents is null. asynchronous launches. it will be ignored.gets the format used by a texture-reference SYNOPSIS CUresult cuTexRefGetFormat(CUarray_format* format.

cuTexRefSetAddress() passes back a byte offset in *byteOffset that must be applied to texture fetches in order to read from the desired memory. CUtexref texRef. Since the hardware enforces an alignment requirement on texture base addresses. SEE ALSO cuTexRefCreate. cuTexRefGetFormat. If the device memory pointer was returned from cuMemAlloc(). asynchronous launches. cuTexRefGetFlags 192 . cuTexRefGetAddress. cuTexRefGetFilterMode. cuTexRefGetAddressMode. 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.9 cuTexRefSetAddress NAME cuTexRefSetAddress . CUdeviceptr devPtr. Any previous address or CUDA array state associated with the texture reference is superseded by this function. cuTexRefSetFlags. DESCRIPTION Binds a linear address range to the texture reference texRef. cuTexRefSetAddressMode. Any memory previously bound to texRef is unbound. cuTexRefSetFilterMode. cuTexRefGetArray. cuTexRefSetFormat. cuTexRefSetArray.binds an address as a texture-reference SYNOPSIS CUresult cuTexRefSetAddress(unsigned int* byteOffset. cuTexRefDestroy. int bytes). 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.2. the offset is guaranteed to be 0 and NULL may be passed as the ByteOffset parameter.

DESCRIPTION Specifies the addressing mode mode for the given dimension of the texture reference texRef. cuTexRefGetAddressMode. CU_TR_ADDRESS_MODE_CLAMP = 1. SEE ALSO cuTexRefCreate. cuTexRefSetFlags. cuTexRefDestroy.2. cuTexRefGetFilterMode.set the addressing mode for a texture-reference SYNOPSIS CUresult cuTexRefSetAddressMode(CUtexref texRef. If dim is zero. cuTexRefGetArray. CUaddress_mode is defined as such: typedef enum CUaddress_mode_enum { CU_TR_ADDRESS_MODE_WRAP = 0. cuTexRefSetArray. cuTexRefSetFilterMode. cuTexRefSetAddress. the second. Note that this call has no effect if texRef is bound to linear memory. the addressing mode is applied to the first parameter of the functions used to fetch from the texture. 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. if dim is 1. CUaddress_mode mode). int dim. CU_TR_ADDRESS_MODE_MIRROR = 2. asynchronous launches. and so on. cuTexRefGetAddress. cuTexRefGetFormat. cuTexRefGetFlags 193 .10 cuTexRefSetAddressMode NAME cuTexRefSetAddressMode . } CUaddress_mode. cuTexRefSetFormat.

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. Any CUDA array previously bound to texRef is unbound. cuTexRefGetArray. cuTexRefGetFlags 194 . cuTexRefDestroy. cuTexRefSetAddressMode. cuTexRefSetAddress. flags must be set to CU_TRSA_OVERRIDE_FORMAT. cuTexRefGetFormat. cuTexRefGetAddress. cuTexRefSetFilterMode. unsigned int flags). CUarray array.binds an array to a texture-reference SYNOPSIS CUresult cuTexRefSetArray(CUtexref texRef. asynchronous launches. cuTexRefGetFilterMode. DESCRIPTION Binds the CUDA array array to the texture reference texRef.9. cuTexRefSetFormat. cuTexRefSetFlags. SEE ALSO cuTexRefCreate. cuTexRefGetAddressMode. Any previous address or CUDA array state associated with the texture reference is superseded by this function.11 cuTexRefSetArray NAME cuTexRefSetArray .

Note that this call has no effect if texRef is bound to linear memory.2. cuTexRefGetAddressMode.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . cuTexRefSetArray. cuTexRefGetAddress. SEE ALSO cuTexRefCreate. 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. CUfilter_mode mode). CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefGetFormat. cuTexRefGetFilterMode.9. cuTexRefDestroy. cuTexRefSetAddress. CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef. cuTexRefSetFlags. cuTexRefGetArray. cuTexRefGetFlags 195 . cuTexRefSetFormat. asynchronous launches.

cuTexRefGetFlags 196 . cuTexRefGetAddress. DESCRIPTION Specifies optional flags to control the behavior of data returned through the texture reference.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. cuTexRefGetFilterMode.13 cuTexRefSetFlags NAME cuTexRefSetFlags . cuTexRefDestroy. the texture coordinates [0. unsigned int Flags). The valid flags are: • CU_TRSF_READ_AS_INTEGER. 1]. cuTexRefSetArray. • CU_TRSF_NORMALIZED_COORDINATES. SEE ALSO cuTexRefCreate. cuTexRefGetArray.sets flags for a texture-reference SYNOPSIS CUresult cuTexRefSetFlags(CUtexref texRef. 1. cuTexRefSetFormat. cuTexRefSetAddressMode. which suppresses the default behavior of having the texture coordinates range from [0. cuTexRefSetFilterMode.2. cuTexRefGetAddressMode. cuTexRefSetAddress. Dim) where Dim is the width or height of the CUDA array. asynchronous launches. cuTexRefGetFormat. which suppresses the default behavior of having the texture promote integer data to floating point data in the range [0. Instead.9.

int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. cuTexRefSetArray. cuTexRefGetFlags 197 .2. asynchronous launches. cuTexRefSetAddress. CUarray_format format.14 cuTexRefSetFormat NAME cuTexRefSetFormat .sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. cuTexRefSetAddressMode.9. 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. cuTexRefSetFlags. cuTexRefSetFilterMode. cuTexRefGetFormat. cuTexRefGetFilterMode. SEE ALSO cuTexRefCreate. cuTexRefGetAddress. cuTexRefDestroy. 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. cuTexRefGetAddressMode.

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

It may fail if the needed OpenGL driver facilities are not available. unsigned int Flags. cuGLUnmapBufferObject. initializes OpenGL interoperability. asynchronous launches. cuGLInit cuGLRegisterBufferObject. cuGLMapBufferObject.10.2. It must be called before performing any other OpenGL interoperability operations. and associates the CUDA context with the calling thread. For usage of the Flags parameter. CUdevice device). see cuCtxCreate.create a CUDA context for interoperability with OpenGL SYNOPSIS CUresult cuGLCtxCreate(CUcontext *pCtx. cuGLUnregisterBufferObject 199 .1 cuGLCtxCreate NAME cuGLCtxCreate . DESCRIPTION Creates a new CUDA context. 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. SEE ALSO cuCtxCreate.

2 cuGLInit NAME cuGLInit .2. It may fail if the needed OpenGL driver facilities are not available. cuGLUnmapBufferObject. DESCRIPTION Initializes OpenGL interoperability.initializes GL interoperability SYNOPSIS CUresult cuGLInit(void). cuGLMapBufferObject.10. asynchronous launches. 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. cuGLUnregisterBufferObject 200 . cuGLRegisterBufferObject. SEE ALSO cuGLCtxCreate. It must be called before performing any other OpenGL interoperability operations.

2. asynchronous launches. GLuint bufferObj). 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. cuGLRegisterBufferObject.10.3 cuGLMapBufferObject NAME cuGLMapBufferObject . unsigned int* size. 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. cuGLUnmapBufferObject. cuGLUnregisterBufferObject 201 .maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. cuGLInit. SEE ALSO cuGLCtxCreate.

4 cuGLRegisterBufferObject NAME cuGLRegisterBufferObject . cuGLUnregisterBufferObject 202 .2. 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. asynchronous launches. SEE ALSO cuGLCtxCreate. DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA. cuGLMapBufferObject. While it is registered. This function must be called before CUDA can map the buffer object. cuGLInit.registers a GL buffer object SYNOPSIS CUresult cuGLRegisterBufferObject(GLuint bufferObj). cuGLUnmapBufferObject. the buffer object cannot be used by any OpenGL commands except as a data source for OpenGL drawing commands.10.

asynchronous launches. cuGLInit.10.5 cuGLUnmapBufferObject NAME cuGLUnmapBufferObject . SEE ALSO cuGLCtxCreate. DESCRIPTION Unmaps the buffer object of ID bufferObj for access by CUDA. cuGLMapBufferObject.2. cuGLUnregisterBufferObject 203 .unmaps a GL buffer object SYNOPSIS CUresult cuGLUnmapBufferObject(GLuint bufferObj). cuGLRegisterBufferObject. 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.

cuGLRegisterBufferObject. cuGLInit.10. asynchronous launches. cuGLUnmapBufferObject 204 .2. SEE ALSO cuGLCtxCreate. cuGLMapBufferObject.unregister a GL buffer object SYNOPSIS CUresult cuGLUnregisterBufferObject(GLuint bufferObj).6 cuGLUnregisterBufferObject NAME cuGLUnregisterBufferObject . 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 Unregisters the buffer object of ID bufferObj for access by CUDA.

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

cuD3D9UnregisterResource. cuD3D9ResourceSetMapFlags. DESCRIPTION Returns in *dev the CUDA-compatible device corresponding to the adapter name adapterName obtained from EnumDisplayDevices or IDirect3D9::GetAdapterIdentifier(). cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. asynchronous launches. If no device on the adapter with name adapterName is CUDA-compatible then the call will fail.gets the device number for an adapter SYNOPSIS CUresult cuD3D9GetDevice(CUdevice* dev. SEE ALSO cuD3D9CtxCreate. 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. cuD3D9UnmapResources. cuD3D9ResourceGetSurfaceDimensions.1 cuD3D9GetDevice NAME cuD3D9GetDevice . cuD3D9MapResources.11. cuD3D9ResourceGetMappedPitch 206 . cuD3D9GetDirect3DDevice. cuD3D9RegisterResource.2. const char* adapterName).

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

DESCRIPTION Returns in *ppDxDevice the Direct3D device against which this CUDA context was created in cuD3D9CtxCreate. cuD3D9ResourceSetMapFlags. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize.get the Direct3D device against which the current CUDA context was created SYNOPSIS CUresult cuD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice). cuD3D9CtxCreate.3 cuD3D9GetDirect3DDevice NAME cuD3D9GetDirect3DDevice . cuD3D9ResourceGetSurfaceDimensions. cuD3D9UnregisterResource. cuD3D9MapResources.11. cuD3D9UnmapResources. cuD3D9RegisterResource. asynchronous launches. 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. cuD3D9ResourceGetMappedPitch 208 .2.

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

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.g. If pResource is of incorrect type (e. cuD3D9UnregisterResource. cuD3D9GetDirect3DDevice. cuD3D9UnmapResources. asynchronous launches. If pResource cannot be registered then CUDA_ERROR_UNKNOWN is returned. cuD3D9ResourceGetSurfaceDimensions. cuD3D9ResourceGetMappedPitch 210 . cuD3D9MapResources. SEE ALSO cuD3D9GetDevice.• Surfaces of depth or stencil formats cannot be shared. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9CtxCreate. If Direct3D interoperability is not initialized on this context then CUDA_ERROR_INVALID_CONTEXT is returned. is a non-stand-alone IDirect3DSurface9) or is already registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9ResourceSetMapFlags.

cuD3D9CtxCreate.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . cuD3D9RegisterResource. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9MapResources. cuD3D9UnmapResources. cuD3D9ResourceSetMapFlags. cuD3D9GetDirect3DDevice. cuD3D9ResourceGetMappedPitch 211 . cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. SEE ALSO cuD3D9GetDevice.2.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again.11. cuD3D9ResourceGetSurfaceDimensions. 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. asynchronous launches.

IDirect3DResource9 **ppResources). 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.map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceGetSurfaceDimensions. This function provides the synchronization guarantee that any Direct3D calls issued before cuD3D9MapResources will complete before any CUDA kernels issued after cuD3D9MapResources begin. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA.2. cuD3D9RegisterResource. cuD3D9UnregisterResource. cuD3D9UnmapResources.11. Direct3D should not access any resources while they are mapped by CUDA. 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. The resources in ppResources may be accessed in CUDA kernels until they are unmapped.6 cuD3D9MapResources NAME cuD3D9MapResources . asynchronous launches. cuD3D9GetDirect3DDevice. cuD3D9ResourceSetMapFlags. If any of ppResources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned. cuD3D9CtxCreate. cuD3D9ResourceGetMappedPitch 212 . If an application does so the results are undefined. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize.

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 Level is invalid then CUDA_ERROR_INVALID_VALUE is returned. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. For all other types Level must be 0. unsigned int Level). DESCRIPTION Returns in *pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level. For all other types Face must be 0. IDirect3DResource9* pResource. 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 was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVA is returned. If pResource is not mapped then CUDA_ERROR_NOT_MAPPED is returned. unsigned int Face.2.11. The value set in pDevPtr 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 CUresult cuD3D9ResourceGetMappedPointer(CUdeviceptr* pDevPtr.10 cuD3D9ResourceGetMappedPointer NAME cuD3D9ResourceGetMappedPointer . At present only mipmap level 0 is supported. 217 . If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. If Face is invalid then CUDA_ERROR_INVALID_V is returned. asynchronous launches.

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

The value set in pSize may change every time that pResource is mapped. asynchronous launches. If pResource is not mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned. For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer. cuD3D9ResourceGetSurfaceDimensions.2. cuD3D9ResourceSetMapFlags. cuD3D9CtxCreate. cuD3D9ResourceGetMappedPointer. cuD3D9GetDirect3DDevice. 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. DESCRIPTION Returns in *pSize the size of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. If pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9UnmapResources. cuD3D9RegisterResource. cuD3D9MapResources. IDirect3DResource9* pResource.11.11 cuD3D9ResourceGetMappedSize NAME cuD3D9ResourceGetMappedSize . If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9UnregisterResource. unsigned int Face. cuD3D9ResourceGetMappedPitch 219 . SEE ALSO cuD3D9GetDevice.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 Level).

2. 220 .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. unsigned int Level). 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.12 cuD3D9ResourceGetMappedPitch NAME cuD3D9ResourceGetMappedPitch . The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows. If pResource is not mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned. For a 2D surface the byte offset of the sample of at position x.11.get the pitch of a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS CUresult cuD3D9ResourceGetMappedPitch(unsigned int* pPitch. For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer. asynchronous launches. unsigned int Face. IDirect3DResource pResource. 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.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. unsigned int* pPitchSlice. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVALID_HANDLE is returned. The values set in pPitch and pPitchSlice may change every time that pResource is mapped. y*pitch + (bytes per pixel)*x For a 3D surface the byte offset of the sample of at position x.

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

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

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

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

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

3 atomicExch NAME atomicExch . atomicDec.1. unsigned long long int val). These two operations are performed in one atomic transaction. unsigned int val). atomicCAS 226 .3. atomicSub. atomicInc. The function returns old.1 and higher.2 and higher. int val). DESCRIPTION Reads the 32. atomicMin. unsigned int atomicExch(unsigned int* address. SEE ALSO atomicAdd. unsigned long long int atomicExch(unsigned long long 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. 64-bit atomic operations are only supported on devices of compute capability 1.atomic exchange SYNOPSIS int atomicExch(int* address. atomicMax. NOTES 32-bit atomic operations are only supported on devices of compute capability 1.

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful