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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaEventDestroy. the function returns cudaErrorInvalidValue.query if an event has been recorded SYNOPSIS cudaError_t cudaEventQuery( cudaEvent_t event ) DESCRIPTION Returns cudaSuccess if the event has actually been recorded. cudaEventSynchronize.4. asynchronous launches.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. If cudaEventRecord() has not been called on this event. cudaEventElapsedTime 20 .1. or cudaErrorNotReady if not. SEE ALSO cudaEventCreate. cudaEventRecord.

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches.1.8 cudaMemset NAME cudaMemset . int value. 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.initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset( void* devPtr.5. cudaMemset3D 32 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

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

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

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

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

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

asynchronous launches. 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. cudaGetTextureReference. cudaUnbindTexture. const void* devPtr. SEE ALSO cudaCreateChannelDesc. desc describes how the memory is interpreted when fetching values from the texture. cudaBindTextureToArray.cudaBindTexture NAME cudaBindTexture . cudaBindTexture() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. 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.Low-level texture API SYNOPSIS cudaError_t cudaBindTexture(size_t* offset. the offset is guaranteed to be 0 and NULL may be passed as the offset parameter. DESCRIPTION Binds size bytes of the memory area pointed to by devPtr to the texture reference texRef. size_t size = UINT_MAX). const struct cudaChannelFormatDesc* desc. If the device memory pointer was returned from cudaMalloc(). cudaGetChannelDesc. cudaGetTextureAlignmentOffset 59 . Any memory previously bound to texRef is unbound. const struct textureReference* texRef.

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

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

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

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

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

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

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

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

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

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

2 cudaLaunch NAME cudaLaunch . or it can be a character string. cudaLaunch() must be preceded by a call to cudaConfigureCall() since it pops the data that was pushed by cudaConfigureCall() from the execution stack. asynchronous launches. 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. SEE ALSO cudaConfigureCall. naming a function that executes on the device.7. entry can either be a function that executes on the device. cudaSetupArgument 70 .launches a device function SYNOPSIS template < class T > cudaError_t cudaLaunch(T entry) DESCRIPTION Launches the function entry on the device.1.

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

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

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

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

asynchronous launches. cudaGLRegisterBufferObject. SEE ALSO cudaGLSetGLDevice.3 cudaGLMapBufferObject NAME cudaGLMapBufferObject .OpenGL interoperability SYNOPSIS cudaError_t cudaGLMapBufferObject(void** devPtr. GLuint bufferObj).1.8. 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. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMapBufferObjectFailed Note that this function may also return error codes from previous. cudaGLUnmapBufferObject. cudaGLUnregisterBufferObject 75 .

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

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

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

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

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

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

DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9UnmapResources.9. cudaD3D9UnregisterResource. IDirect3DResource9 **ppResources). SEE ALSO cudaD3D9GetDevice. This function provides the synchronization guarantee that any Direct3D calls issued before cudaD3D9MapResources will complete before any CUDA kernels issued after cudaD3D9MapResources begin.6 cudaD3D9MapResources NAME cudaD3D9MapResources . cudaD3D9ResourceGetMappedSize. Direct3D should not access any resources while they are mapped by CUDA.1. asynchronous launches. cudaD3D9ResourceGetMappedPointer. cudaD3D9GetDirect3DDevice.map Direct3D resources for access by CUDA SYNOPSIS cudaError_t cudaD3D9MapResources(unsigned int count. cudaD3D9RegisterResource. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidHandle cudaErrorUnknown 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 cudaErrorInvalidHandle is returned. If any of ppResources are presently mapped for access by CUDA then cudaErrorUnknown is returned. cudaD3D9SetDirect3DDevice. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. If an application does so the results are undefined. cudaD3D9ResourceGetMappedPitch 85 . cudaD3D9ResourceSetMapFlags.

SEE ALSO cudaD3D9GetDevice.9. cudaD3D9MapResources.7 cudaD3D9UnmapResources NAME cudaD3D9UnmapResources . cudaD3D9ResourceGetMappedSize. DESCRIPTION Unmaps the count Direct3D resources in ppResources. asynchronous launches.1. 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. This function provides the synchronization guarantee that any CUDA kernels issued before cudaD3D9UnmapResources will complete before any Direct3D calls issued after cudaD3D9UnmapResources begin. cudaD3D9ResourceGetMappedPitch 86 . cudaD3D9SetDirect3DDevice. If any of ppResources are not presently mapped for access by CUDA then cudaErrorUnknown is returned. cudaD3D9ResourceSetMa cudaD3D9ResourceGetMappedPointer. IDirect3DResource9** ppResources). cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9UnregisterResource. cudaD3D9RegisterResource.unmap Direct3D resources SYNOPSIS cudaError_t cudaD3D9UnmapResources(unsigned int count. cudaD3D9GetDirect3DDevice.

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

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

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

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

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

For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.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). The values set in pPitch and pPitchSlice may change every time that pResource is mapped.y.12 cudaD3D9ResourceGetMappedPitch NAME cudaD3D9ResourceGetMappedPitch . 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. IDirect3DResource9* pResource. 92 . size_t* pPitchSlice. asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous.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. If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. For a 2D surface the byte offset of the sample of at position x. If pResource is not mapped for access by CUDA then cudaErrorUnknown is returned.9.1. y*pitch + (bytes per pixel)*x For a 3D surface the byte offset of the sample of at position x. 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.

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Copies from device memory to device memory.2. cuMemcpyHtoA.19 cuMemcpyDtoD NAME cuMemcpyDtoD .copies memory from Device to Device SYNOPSIS CUresult cuMemcpyDtoD(CUdeviceptr dstDevPtr.8. respectively. unsigned int count). cuMemcpyDtoH. asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpyDtoA. dstDevice and srcDevPtr are the base pointers of the destination and source. cuMemcpy2D 177 . cuMemcpyAtoH. cuMemcpyAtoA. CUdeviceptr srcDevPtr. SEE ALSO cuMemcpyHtoD. cuMemcpyAtoD. 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. asynchronous launches.20 cuMemcpyDtoH NAME cuMemcpyDtoH . CUstream stream). cuMemcpyHtoA. cuMemcpyAtoH. DESCRIPTION Copies from device to host memory.copies memory from Device to Host SYNOPSIS CUresult cuMemcpyDtoH(void* dstHostPtr. CUdeviceptr srcDevPtr. cuMemcpyAtoA. cuMemcpyDtoA.8. cuMemcpyDtoD. cuMemcpy2D 178 . dstHostPtr and srcDevPtrspecify the base addresses of the source and destination. MemcpyDtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. unsigned int count. SEE ALSO cuMemcpyHtoD.2. respectively. countspecifies the number of bytes to copy. CUresult cuMemcpyDtoHAsync(void* dstHostPtr. 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. cuMemcpyAtoD. unsigned int count).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefGetFlags 194 . flags must be set to CU_TRSA_OVERRIDE_FORMAT. cuTexRefSetFormat. Any CUDA array previously bound to texRef is unbound. unsigned int flags). 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.binds an array to a texture-reference SYNOPSIS CUresult cuTexRefSetArray(CUtexref texRef.11 cuTexRefSetArray NAME cuTexRefSetArray . cuTexRefSetAddressMode.9. cuTexRefSetFlags. cuTexRefSetAddress. cuTexRefGetAddress. CUarray array. DESCRIPTION Binds the CUDA array array to the texture reference texRef. asynchronous launches. Any previous address or CUDA array state associated with the texture reference is superseded by this function. cuTexRefGetArray. cuTexRefGetFilterMode. cuTexRefDestroy. cuTexRefGetFormat. cuTexRefGetAddressMode. SEE ALSO cuTexRefCreate. cuTexRefSetFilterMode.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. cuTexRefGetFilterMode.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef.9. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef. cuTexRefDestroy. cuTexRefSetArray.2. cuTexRefGetAddressMode. cuTexRefSetAddressMode. Note that this call has no effect if texRef is bound to linear memory. cuTexRefGetFormat. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. SEE ALSO cuTexRefCreate. cuTexRefSetFlags. cuTexRefGetFlags 195 . cuTexRefSetFormat.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . asynchronous launches. CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0. CUfilter_mode mode). cuTexRefSetAddress. cuTexRefGetAddress. cuTexRefGetArray.

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

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

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

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

cuGLUnregisterBufferObject 201 . 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. cuGLUnmapBufferObject. asynchronous launches. SEE ALSO cuGLCtxCreate.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping. GLuint bufferObj). cuGLInit.2. unsigned int* size.10.3 cuGLMapBufferObject NAME cuGLMapBufferObject . cuGLRegisterBufferObject.

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

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

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

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

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

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

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

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

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

cuD3D9ResourceGetSurfaceDimensions. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9GetDirect3DDevice. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. cuD3D9RegisterResource. cuD3D9MapResources. cuD3D9CtxCreate. asynchronous launches. cuD3D9ResourceGetMappedPitch 211 .5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . cuD3D9ResourceSetMapFlags. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource).11. cuD3D9UnmapResources. 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. cuD3D9RegisterResource.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_ALREADY_MAPPED CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9UnmapResources.6 cuD3D9MapResources NAME cuD3D9MapResources . cuD3D9ResourceSetMapFlags. cuD3D9ResourceGetSurfaceDimensions. If any of ppResources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned. cuD3D9UnregisterResource. Direct3D should not access any resources while they are mapped by CUDA. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9GetDirect3DDevice. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. cuD3D9CtxCreate. 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 an application does so the results are undefined.map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceGetMappedPitch 212 . IDirect3DResource9 **ppResources). asynchronous launches.11.

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

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

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

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

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

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

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

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

atomicMin. unsigned int atomicSub(unsigned int* address. DESCRIPTION Reads the 32-bit word old located at the address address in global memory.val). unsigned int val).atomic subtraction SYNOPSIS int atomicSub(int* address.3. SEE ALSO atomicAdd. atomicMax.1 and higher. computes (old . atomicCAS 225 . int val).2 atomicSub NAME atomicSub . and stores the result back to global memory at the same address. atomicDec. atomicExch. atomicInc.1. 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.

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

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

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

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

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

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

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

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

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

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