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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

or it can be a character string. const T& symbol) DESCRIPTION Returns in *devPtr the address of symbol symbol on the device. naming a variable that resides in global memory space. asynchronous launches. *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.1.20 cudaGetSymbolAddress NAME cudaGetSymbolAddress . 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. If symbol cannot be found. or if symbol is not declared in global memory space.5. SEE ALSO cudaGetSymbolSize 44 . symbol can either be a variable that resides in global memory space.

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

cudaChannelFormatKindUnsigned. w. cudaChannelFormatKindFloat. and w. y. DESCRIPTION Returns a channel descriptor with format f and number of bits of each component x. enum cudaChannelFormatKind f. SEE ALSO 64 . z. 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. }. z.cudaCreateChannelDesc HL NAME cudaCreateChannelDesc . where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. y. asynchronous launches.High-level texture API SYNOPSIS template < class T > struct cudaChannelFormatDesc cudaCreateChannelDesc <T >().

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

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

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. readMode >& texRef) DESCRIPTION Unbinds the texture bound to texture reference texRef. SEE ALSO 67 .High-level texture API SYNOPSIS template < class T.cudaUnbindTexture HL NAME cudaUnbindTexture . int dim.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaD3D9ResourceGetMappedSize. IDirect3DResource9 **ppResources).1.9. The resources in ppResources may be accessed in CUDA kernels until they are unmapped.6 cudaD3D9MapResources NAME cudaD3D9MapResources . asynchronous launches. Direct3D should not access any resources while they are mapped by CUDA. cudaD3D9ResourceGetMappedPointer. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned. cudaD3D9UnmapResources. cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9ResourceSetMapFlags. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. 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. cudaD3D9GetDirect3DDevice. cudaD3D9RegisterResource.map Direct3D resources for access by CUDA SYNOPSIS cudaError_t cudaD3D9MapResources(unsigned int count. cudaD3D9UnregisterResource. cudaD3D9ResourceGetMappedPitch 85 . DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. cudaD3D9SetDirect3DDevice. If any of ppResources are presently mapped for access by CUDA then cudaErrorUnknown is returned. If an application does so the results are undefined.

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

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

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

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

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

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

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

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

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

10. 95 .returns the last error from a run-time call SYNOPSIS cudaError_t cudaGetLastError( void ) DESCRIPTION Returns the last error that was returned from any of the runtime calls in the same host thread and resets it to cudaSuccess.1 cudaGetLastError NAME cudaGetLastError . 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.

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1 cuCtxAttach NAME cuCtxAttach .2. cuCtxSynchronize 112 . cuCtxDetach. 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.3. asynchronous launches. cuCtxAttach() fails if there is no context current to the thread. SEE ALSO cuCtxCreate. the Flags parameter 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 Note that this function may also return error codes from previous.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxGetDevice. unsigned int Flags). Currently.

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.3. • 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. • CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for results from the GPU. This can increase latency when waiting for the GPU. 113 . 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. CUdevice dev). but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread.2. The two LSBs of the Flags parameter can be used to control how the OS thread which owns the CUDA context at the time of an API call interacts with the OS scheduler when waiting for results from the GPU.create a CUDA context SYNOPSIS CUresult cuCtxCreate(CUcontext* pCtx.2 cuCtxCreate NAME cuCtxCreate . If C > P then CUDA will yield to other OS threads when waiting for the GPU. This can decrease latency when waiting for the GPU. asynchronous launches. The Flags parameter is described below. but can increase the performance of CPU threads performing work in parallel with the GPU. unsigned int Flags. If a context is already current to the thread. DESCRIPTION Creates a new CUDA context and associates it with the calling thread. 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. • CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for results from the GPU.

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

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

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

cuEventElapsedTime 135 . 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 CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous.creates an event SYNOPSIS CUresult cuEventCreate(CUevent* event. flags is required to be 0. asynchronous launches. DESCRIPTION Creates an event. At present. cuEventSynchronize.6. cuEventDestroy. SEE ALSO cuEventRecord. cuEventQuery.1 cuEventCreate NAME cuEventCreate .2.

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

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

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

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

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

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

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

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

3 cuParamSetSize NAME cuParamSetSize . cuParamSeti. SEE ALSO cuFuncSetBlockShape.2. DESCRIPTION Sets through numbytes the total size in bytes needed by the function parameters of function func. cuFuncSetSharedSize. unsigned int numbytes).7. cuParamSetv. asynchronous launches. cuLaunch.sets the parameter-size for the function SYNOPSIS CUresult cuParamSetSize(CUfunction func. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuLaunchGrid 144 . cuParamSetf. 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. DESCRIPTION Makes the CUDA array or linear memory bound to the texture reference texRef available to a device program as a texture. cuFuncSetSharedSize.4 cuParamSetTexRef NAME cuParamSetTexRef . asynchronous launches. SEE ALSO cuFuncSetBlockShape. int texunit. the texture reference must be obtained via cuModuleGetTexRef() and the texunit parameter must be set to CU_PARAM_TR_DEFAULT. In this version of CUDA. cuParamSetSize. cuParamSeti. cuParamSetv. cuLaunch. CUtexref texRef).2. cuParamSetf. cuLaunchGrid 145 .7.adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func.

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

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

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

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

cuLaunch. unsigned int bytes). asynchronous launches. cuParamSeti. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuParamSetv.2. cuParamSetSize. cuLaunchGrid 150 . SEE ALSO cuFuncSetBlockShape. 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. cuParamSetTexRef.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize .7. cuParamSetf.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemcpy3D 169 . cuMemcpyDtoA. cuMemcpyHtoA. cuMemcpyAtoA. cuMemcpyAtoD. cuMemcpyAtoH.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. cuMemcpyDtoH. cuMemcpyDtoD. SEE ALSO cuMemcpyHtoD.

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

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

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

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

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

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

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

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

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

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

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

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

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

StreamManagement. EventManagement. TextureReferenceManagement. MemoryManagement. 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. DeviceManagement.2. OpenGlInteroperability. Direct3dInteroperability 183 . ContextManagement. ModuleManagement.

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

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

CUtexref texRef). cuTexRefSetAddress. cuTexRefSetFilterMode. cuTexRefSetArray. cuTexRefGetFormat.9. or returns CUDA_ERROR_INVALID_VA if the texture reference is not bound to any device memory range. cuTexRefGetArray.2. cuTexRefGetFlags 186 . cuTexRefGetFilterMode. 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. asynchronous launches. SEE ALSO cuTexRefCreate. DESCRIPTION Returns in *devPtr the base address bound to the texture reference texRef. cuTexRefDestroy.3 cuTexRefGetAddress NAME cuTexRefGetAddress .gets the address associated with a texture-reference SYNOPSIS CUresult cuTexRefGetAddress(CUdeviceptr* devPtr. cuTexRefSetFormat. cuTexRefSetAddressMode. 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. DESCRIPTION Returns in *mode the addressing mode corresponding to the dimension dim of the texture reference texRef. cuTexRefSetAddress.9. cuTexRefGetFilterMode.gets the addressing mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetAddressMode(CUaddress_mode* mode. asynchronous launches. cuTexRefSetFormat. Currently the only valid values for dim are 0 and 1. int dim).2.4 cuTexRefGetAddressMode NAME cuTexRefGetAddressMode . cuTexRefSetFilterMode. cuTexRefGetArray. CUtexref texRef. cuTexRefGetFormat. cuTexRefSetArray. cuTexRefGetAddress. SEE ALSO cuTexRefCreate. cuTexRefSetAddressMode. cuTexRefDestroy. cuTexRefGetFlags 187 . cuTexRefSetFlags.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. cuD3D9GetDirect3DDevice.1 cuD3D9GetDevice NAME cuD3D9GetDevice .gets the device number for an adapter SYNOPSIS CUresult cuD3D9GetDevice(CUdevice* dev. 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(). If no device on the adapter with name adapterName is CUDA-compatible then the call will fail. cuD3D9UnmapResources. cuD3D9UnregisterResource. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. SEE ALSO cuD3D9CtxCreate. asynchronous launches.11. cuD3D9RegisterResource. cuD3D9MapResources. cuD3D9ResourceSetMapFlags.2. cuD3D9ResourceGetSurfaceDimensions.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful