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

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

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

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.returns the number of compute-capable devices SYNOPSIS cudaError_t cudaGetDeviceCount( int* count ) DESCRIPTION Returns in *count the number of devices with compute capability greater or equal to 1. SEE ALSO cudaGetDevice. Since this device will be able to emulate all hardware features.1. cudaGetDeviceCount() returns 1 and device 0 only supports device emulation mode. If there is no such device. cudaChooseDevice 3 .1 cudaGetDeviceCount NAME cudaGetDeviceCount .1. cudaSetDevice.0 that are available for execution. cudaGetDeviceProperties. asynchronous launches. this device will report major and minor compute capability versions of 9999.

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

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

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

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

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

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

1. SEE ALSO cudaThreadExit 10 .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. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. asynchronous launches. cudaThreadSynchronize() returns an error if one of the preceding tasks failed.2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Due to pitch alignment restrictions in the hardware. cudaFree.allocates memory on the GPU SYNOPSIS cudaError_t cudaMallocPitch( void** devPtr. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The pitch returned in *pitch by cudaMallocPitch() is the width in bytes of the allocation. Given the row and column of an array element of type T. size_t height ) DESCRIPTION Allocates at least widthInBytes*height bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. the address is computed as T* pElement = (T*)((char*)BaseAddress + Row * pitch) + Column. asynchronous launches. cudaMallocHost.2 cudaMallocPitch NAME cudaMallocPitch . For allocations of 2D arrays. The intended usage of pitch is as a separate parameter of the allocation. this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or CUDA arrays). cudaFreeArray.5. size_t widthInBytes.1. it is recommended that programmers consider performing pitch allocations using cudaMallocPitch(). cudaFreeHost 26 . cudaMallocArray. SEE ALSO cudaMalloc. size_t* pitch. used to compute addresses within the 2D array.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. 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.1. which starts at offset 0. size_t count. cudaSetupArgument() must be preceded by a call to cudaConfigureCall().configure a device-launch SYNOPSIS cudaError_t cudaSetupArgument(void* arg.3 cudaSetupArgument NAME cudaSetupArgument . SEE ALSO cudaConfigureCall. cudaLaunch 71 . The arguments are stored in the top of the execution stack.7.

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

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

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

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

DESCRIPTION Unmaps the buffer object of ID bufferObj for access by CUDA. cudaGLUnregisterBufferObject 76 . cudaGLMapBufferObject.4 cudaGLUnmapBufferObject NAME cudaGLUnmapBufferObject . SEE ALSO cudaGLSetGLDevice. asynchronous launches.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. cudaGLRegisterBufferObject.8.1.

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorLaunchFailure cudaErrorPriorLaunchFailure cudaErrorLaunchTimeout cudaErrorLaunchOutOfResources cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration cudaErrorInvalidDevice cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture cudaErrorInvalidTextureBinding cudaErrorInvalidChannelDescriptor cudaErrorTextureFetchFailed cudaErrorTextureNotBound cudaErrorSynchronizationError cudaErrorUnknown cudaErrorInvalidResourceHandle cudaErrorNotReady Note that this function may also return error codes from previous asynchronous launches.1 cudaGetLastError NAME cudaGetLastError . 95 .10.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.

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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 . asynchronous launches.initialize the CUDA driver API SYNOPSIS CUresult cuInit( unsigned int Flags ). If cuInit() has not been called.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NO_DEVICE Note that this function may also return error codes from previous. Currently.1. SEE ALSO 100 . the Flags parameters must be 0.

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

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

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

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

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

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

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

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

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

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

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

2. DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context.1 cuCtxAttach NAME cuCtxAttach .3. the Flags parameter must be 0. Currently. SEE ALSO cuCtxCreate. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuCtxSynchronize 112 . cuCtxAttach() fails if there is no context current to the thread. cuCtxGetDevice.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. unsigned int Flags). cuCtxDetach. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Unloads a module mod from the current context. SEE ALSO cuModuleLoad.7 cuModuleUnload NAME cuModuleUnload . asynchronous launches. cuModuleGetFunction.4. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuModuleLoadData.2. cuModuleLoadFatBinary.unloads a module SYNOPSIS CUresult cuModuleUnload(CUmodule mod). cuModuleGetTexRef 128 . cuModuleGetGlobal.

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

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

destroys a stream SYNOPSIS CUresult cuStreamDestroy(CUstream stream). cuStreamSynchronize 131 . 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.2 cuStreamDestroy NAME cuStreamDestroy .2.5. asynchronous launches. cuStreamQuery. DESCRIPTION Destroys the stream.

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

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

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

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

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

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

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

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

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

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

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

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

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

cuLaunch. SEE ALSO cuFuncSetBlockShape.2. CUtexref texRef). cuLaunchGrid 145 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. DESCRIPTION Makes the CUDA array or linear memory bound to the texture reference texRef available to a device program as a texture. cuParamSetSize. int texunit. In this version of CUDA. cuParamSetf. cuFuncSetSharedSize.adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func. cuParamSetv. the texture reference must be obtained via cuModuleGetTexRef() and the texunit parameter must be set to CU_PARAM_TR_DEFAULT.7.4 cuParamSetTexRef NAME cuParamSetTexRef . asynchronous launches. cuParamSeti.

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

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

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

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

cuParamSeti. cuParamSetv. unsigned int bytes). cuParamSetSize. cuLaunch.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize .2. asynchronous launches.7. DESCRIPTION Sets through bytes the amount of shared memory that will be available to each thread block when the kernel given by func is launched. cuParamSetTexRef.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. cuParamSetf. cuLaunchGrid 150 . 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. SEE ALSO cuFuncSetBlockShape.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefSetAddress. cuTexRefGetFilterMode. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetAddress. cuTexRefSetAddressMode.9.14 cuTexRefSetFormat NAME cuTexRefSetFormat . SEE ALSO cuTexRefCreate. CUarray_format format. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. cuTexRefSetFilterMode. cuTexRefDestroy. cuTexRefGetAddressMode.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. cuTexRefGetFormat.2. cuTexRefGetFlags 197 . cuTexRefSetArray. asynchronous launches. cuTexRefGetArray. cuTexRefSetFlags. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

cuD3D9ResourceGetMappedPitch 211 . cuD3D9RegisterResource.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource .11. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9UnmapResources. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. SEE ALSO cuD3D9GetDevice. cuD3D9CtxCreate.2. cuD3D9GetDirect3DDevice. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9ResourceSetMapFlags. cuD3D9MapResources.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). cuD3D9ResourceGetSurfaceDimensions. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful