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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset3D 33 . size_t height ) DESCRIPTION Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. asynchronous launches.initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset2D( void* dstPtr.9 cudaMemset2D NAME cudaMemset2D . 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.5. size_t width.1. SEE ALSO cudaMemset. pitch is the width in memory in bytes of the 2D array pointed to by dstPtr. This function performs fastest when the pitch is one that has been passed back by cudaMallocPitch(). size_t pitch.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

readMode E<gt>& texRef. enum cudaTextureReadMode readMode E<gt> static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture E<lt> T. int dim. const struct cudaArray* cuArray). The channel descriptor is inherited from the CUDA array. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture < T. int dim. Any CUDA array previously bound to texRef is unbound. SEE ALSO cudaCreateChannelDesc_HL 66 . dim. readMode >& texRef. const struct cudaChannelFormatDesc& desc) DESCRIPTION Binds the CUDA array array to texture reference texRef. Any CUDA array previously bound to texRef is unbound. 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.cudaBindTextureToArray HL NAME cudaBindTextureToArray . template E<lt> class T. dim.High-level texture API SYNOPSIS template < class T. desc describes how the memory is interpreted when fetching values from the texture. asynchronous launches. const struct cudaArray* cuArray.

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

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

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

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

size_t *pDepth. cudaD3D9MapResources. cudaD3D9UnmapResources. cudaD3D9RegisterResource. 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. pHeight. the value returned in *pDepth will be 0. The parameters pWidth. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. size_t* pHeight. *pHeight. If pResource is not of type IDirect3DBaseTexture9 or IDirect3DSurface9 or if pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. For 2D surfaces. cudaD3D9SetDirect3DDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle Note that this function may also return error codes from previous. cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetMappedPitch 89 . IDirect3DResource9* pResource. cudaD3D9ResourceSetMapFlags. DESCRIPTION Returns in *pWidth. asynchronous launches. unsigned int Face. cudaD3D9ResourceGetMappedSize. and pDepth are optional.get the dimensions of a registered surface SYNOPSIS cudaError_t cudaD3D9ResourceGetSurfaceDimensions(size_t* pWidth. and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. SEE ALSO cudaD3D9GetDevice. cudaD3D9ResourceGetMappedPointer. unsigned int Level).1.9 cudaD3D9ResourceGetSurfaceDimensions NAME cudaD3D9ResourceGetSurfaceDimensions . cudaD3D9UnregisterResource.9.

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

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

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.12 cudaD3D9ResourceGetMappedPitch NAME cudaD3D9ResourceGetMappedPitch . 92 . For a 2D surface the byte offset of the sample of at position x. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. IDirect3DResource9* pResource. size_t* pPitchSlice. 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. unsigned int Face.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. If pResource is not mapped for access by CUDA then cudaErrorUnknown is returned.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.y. asynchronous launches. The values set in pPitch and pPitchSlice may change every time that pResource is mapped.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. unsigned int Level). If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.1.

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

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

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. 95 . 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.1.1 cudaGetLastError NAME cudaGetLastError .10.

cudaError 96 .SEE ALSO cudaGetErrorString.

10.returns the message string from an error SYNOPSIS const char* cudaGetErrorString(cudaError_t error).1.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 .

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

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

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

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

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

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

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

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

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

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

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

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

cuDeviceGetName. SEE ALSO cuDeviceComputeCapability.2.7 cuDeviceTotalMem NAME cuDeviceTotalMem .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_DEVICE Note that this function may also return error codes from previous. cuDeviceGetAttribute. DESCRIPTION Returns in *bytes the total amount of memory available on the device dev in bytes. asynchronous launches.returns the total amount of memory on the device SYNOPSIS CUresult cuDeviceTotalMem( unsigned int* bytes. cuDeviceGetCount. CUdevice dev ). cuDeviceGetProperties 110 . cuDeviceGet.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

launches a CUDA function SYNOPSIS CUresult cuLaunch(CUfunction func). cuParamSetv. asynchronous launches.1 cuLaunch NAME cuLaunch . cuLaunchGrid 142 . cuParamSetTexRef. cuParamSetf. 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. cuParamSetSize. cuFuncSetSharedSize. 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.7.2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

dstArray and dstIndex specify the CUDA array handle and starting index of the destination data. asynchronous launches.2. count specifies the number of bytes to copy. unsigned int count. DESCRIPTION Copies from host memory to a 1D CUDA array.copies memory from Host to Array SYNOPSIS CUresult cuMemcpyHtoA(CUarray dstArray. cuMemcpyAtoH. const void *srcHostPtr. unsigned int dstIndex. cuMemcpyDtoD.21 cuMemcpyHtoA NAME 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. cuMemcpyDtoH.8. srcHostPtr specify the base addresse of the source. cuMemcpyDtoA. SEE ALSO cuMemcpyHtoD. cuMemcpyAtoA. cuMemcpyHtoAAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. unsigned int dstIndex. 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. unsigned int count). CUstream stream).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . cuTexRefGetAddressMode. cuTexRefSetFormat.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. 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. cuTexRefSetFlags. Note that this call has no effect if texRef is bound to linear memory. cuTexRefGetFormat. SEE ALSO cuTexRefCreate.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef. cuTexRefGetFlags 195 . cuTexRefSetAddressMode. cuTexRefGetAddress. CUfilter_mode mode). cuTexRefSetAddress. asynchronous launches.9. cuTexRefSetArray. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefDestroy. cuTexRefGetArray. cuTexRefGetFilterMode.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

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

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

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

atomicSub.5 atomicMax NAME atomicMax . and stores the result back to global memory at the same address. atomicExch. atomicDec. computes the maximum of old and val.atomic maximum SYNOPSIS int atomicMax(int* address. SEE ALSO atomicAdd. The function returns old. 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.1 and higher.1. atomicMin. atomicCAS 228 . atomicInc. unsigned int val).3. These three operations are performed in one atomic transaction. unsigned int atomicMax(unsigned int* address. int val).

These three operations are performed in one atomic transaction.1 and higher. atomicMax. NOTES Atomic operations are only supported on devices of compute capability 1. atomicDec. The function returns old. atomicCAS 229 . atomicExch.atomic increment SYNOPSIS unsigned int atomicInc(unsigned int* address. atomicMin. SEE ALSO atomicAdd.6 atomicInc NAME atomicInc . atomicSub.1. unsigned int val). 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.3. computes ((old >= val) ? 0 : (old+1)).

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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