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

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

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

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

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

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

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

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

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

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

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

1. SEE ALSO cudaGetDeviceCount.select compute-device which best matches criteria SYNOPSIS cudaError_t cudaChooseDevice( int* dev. cudaSetDevice.5 cudaChooseDevice NAME cudaChooseDevice . asynchronous launches. cudaGetDevice. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

or it can be a character string. const T& symbol) DESCRIPTION Returns in *devPtr the address of symbol symbol on the device. SEE ALSO cudaGetSymbolSize 44 . naming a variable that resides in global memory space. symbol can either be a variable that resides in global memory space.1. cudaGetSymbolAddress() returns cudaErrorInvalidSymbol in case of failure RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidSymbol cudaErrorAddressOfConstant Note that this function may also return error codes from previous.20 cudaGetSymbolAddress NAME cudaGetSymbolAddress . If symbol cannot be found.5. *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. asynchronous launches. or if symbol is not declared in global memory space.

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

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

int w. cudaUnbindTexture. cudaBindTextureToArray. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. cudaChannelFormatKindFloat. w. asynchronous launches. enum cudaChannelFormatKin f). z. z. cudaGetTextureReference. cudaChannelFormatKindUnsigned. int y. int z. cudaBindTexture. SEE ALSO cudaGetChannelDesc. }. cudaGetTextureAlignmentOffset 56 . enum cudaChannelFormatKind f. and w. y.Low-level texture API SYNOPSIS struct cudaChannelFormatDesc cudaCreateChannelDesc(int x. 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.cudaCreateChannelDesc NAME cudaCreateChannelDesc . DESCRIPTION Returns a channel descriptor with format f and number of bits of each component x. y.

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

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

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

cudaGetTextureAlignmentOffset 60 . const struct cudaArray* array. SEE ALSO cudaCreateChannelDesc. 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. cudaGetTextureReference.cudaBindTextureToArray NAME cudaBindTextureToArray . asynchronous launches. const struct cudaChannelFormatDesc* desc). cudaBindTexture.Low-level texture API SYNOPSIS cudaError_t cudaBindTextureToArray( const struct textureReference* texRef. DESCRIPTION Binds the CUDA array array to the texture reference texRef. cudaUnbindTexture. desc describes how the memory is interpreted when fetching values from the texture. cudaGetChannelDesc.

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

cudaGetTextureReference. cudaGetChannelDesc. DESCRIPTION Returns in *offset the offset that was returned when texture reference texRef was bound. cudaBindTextureToArray.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. asynchronous launches. const struct textureReference* texRef). SEE ALSO cudaCreateChannelDesc. cudaUnbindTexture 62 . cudaBindTexture.cudaGetTextureAlignmentOffset NAME cudaGetTextureAlignmentOffset .

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

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

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

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

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

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

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

asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. entry must be declared as a __global__ function.1.7. 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. or it can be a character string. cudaSetupArgument 70 . SEE ALSO cudaConfigureCall.2 cudaLaunch NAME cudaLaunch . 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cuCtxCreate. cuCtxAttach() fails if there is no context current to the thread. cuCtxGetDevice.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. DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context. cuCtxSynchronize 112 .1 cuCtxAttach NAME cuCtxAttach .3. Currently. the Flags parameter must be 0. cuCtxDetach. unsigned int Flags). asynchronous launches.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.2. asynchronous launches. SEE ALSO cuArrayCreate. It is useful for subroutines that have been passed a CUDA array. cuArray3DGetDescriptor. cuArrayDestroy 157 . 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. cuArray3DCreate.4 cuArrayGetDescriptor NAME cuArrayGetDescriptor .8.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefSetAddress.14 cuTexRefSetFormat NAME cuTexRefSetFormat . cuTexRefGetAddress. cuTexRefGetAddressMode. cuTexRefSetAddressMode. cuTexRefGetFilterMode. cuTexRefSetFilterMode.9. cuTexRefSetFlags. cuTexRefGetArray. format and numPackedComponents are exactly analogous to the Format and NumChannels members of the CUDA_ARRAY_DESCRIPTOR structure: They specify the format of each component and the number of components per array element. CUarray_format format. SEE ALSO cuTexRefCreate. cuTexRefGetFlags 197 . int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef.2. 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. cuTexRefDestroy. cuTexRefGetFormat. asynchronous launches.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef.

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

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

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

SEE ALSO cuGLCtxCreate. asynchronous launches. cuGLUnmapBufferObject.2. cuGLUnregisterBufferObject 201 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous. cuGLInit. cuGLRegisterBufferObject.3 cuGLMapBufferObject NAME cuGLMapBufferObject . unsigned int* size.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. GLuint bufferObj).10. 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.

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

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

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

cuD3D9GetDevice cuD3D9CtxCreate cuD3D9GetDirect3DDevice cuD3D9RegisterResource cuD3D9UnregisterResource cuD3D9MapResources cuD3D9UnmapResources cuD3D9ResourceGetSurfaceDimensions cuD3D9ResourceSetMapFlags cuD3D9ResourceGetMappedPointer cuD3D9ResourceGetMappedSize cuD3D9ResourceGetMappedPitch As of CUDA 2. TextureReferenceManagement.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. MemoryManagement. DeviceManagement. EventManagement. ContextManagement. They should not be used in new development. cuD3D9Begin cuD3D9End cuD3D9MapVertexBuffer cuD3D9RegisterVertexBuffer cuD3D9UnmapVertexBuffer cuD3D9UnregisterVertexBuffer SEE ALSO Initialization. OpenGLInteroperability. ExecutionControl. ModuleManagement.2. Direct3dInteroperability 205 . StreamManagement.

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

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

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

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

cuD3D9ResourceSetMapFlags. If Direct3D interoperability is not initialized on this context then CUDA_ERROR_INVALID_CONTEXT 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_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9CtxCreate. cuD3D9ResourceGetMappedPitch 210 . If pResource cannot be registered then CUDA_ERROR_UNKNOWN is returned. If pResource is of incorrect type (e. SEE ALSO cuD3D9GetDevice. asynchronous launches. cuD3D9GetDirect3DDevice. cuD3D9MapResources.g. cuD3D9ResourceGetSurfaceDimensions.• Surfaces of depth or stencil formats cannot be shared. cuD3D9UnmapResources. cuD3D9UnregisterResource. is a non-stand-alone IDirect3DSurface9) or is already registered then CUDA_ERROR_INVALID_HANDLE 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_UNKNOWN Note that this function may also return error codes from previous.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . cuD3D9UnmapResources. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. asynchronous launches.2. cuD3D9GetDirect3DDevice. cuD3D9MapResources. cuD3D9RegisterResource. cuD3D9CtxCreate. cuD3D9ResourceSetMapFlags.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource).11. cuD3D9ResourceGetSurfaceDimensions. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9ResourceGetMappedPitch 211 . If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned.

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

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

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

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

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

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

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

SEE ALSO ArithmeticFunctions. NOTES 32-bit atomic operations are only supported on devices of compute capability 1.1 and higher.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. BitwiseFunctions 222 .

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

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

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

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

SEE ALSO atomicAdd. computes the minimum of old and val. atomicMax. unsigned int atomicMin(unsigned int* address. atomicExch. These three operations are performed in one atomic transaction.4 atomicMin NAME atomicMin . atomicSub. NOTES Atomic operations are only supported on devices of compute capability 1.3.1 and higher.1.atomic minimum SYNOPSIS int atomicMin(int* address. 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. atomicDec. atomicCAS 227 . int val). The function returns b<old>. atomicInc. unsigned int val).

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful