NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

Contents
1 RuntimeApiReference 1.1 DeviceManagement RT 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

cudaGetDeviceCount

cudaSetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDeviceProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaChooseDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ThreadManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 1.2.2 cudaThreadSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaThreadExit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.3

StreamManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 1.3.2 1.3.3 1.3.4 cudaStreamCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.4

EventManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 cudaEventCreate cudaEventRecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventElapsedTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

cudaMalloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMallocArray

cudaFreeArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFreeHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMemset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMemset2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

i

1.5.10 cudaMemcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.11 cudaMemcpy2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34 35 36 37 38 39 40 41 42 43 44 45 46 48 50 52 54 55 63 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

1.5.12 cudaMemcpyToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.13 cudaMemcpy2DToArray 1.5.14 cudaMemcpyFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.15 cudaMemcpy2DFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.16 cudaMemcpyArrayToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.17 cudaMemcpy2DArrayToArray 1.5.18 cudaMemcpyToSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.19 cudaMemcpyFromSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.20 cudaGetSymbolAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.21 cudaGetSymbolSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.22 cudaMalloc3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.23 cudaMalloc3DArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.24 cudaMemset3D 1.5.25 cudaMemcpy3D 1.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

TextureReferenceManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6.1 1.6.2 LowLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HighLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

cudaConfigureCall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaLaunch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaSetupArgument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.8

OpenGlInteroperability RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 cudaGLSetGLDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLRegisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLMapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLUnmapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLUnregisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

cudaD3D9SetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9GetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9RegisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

84 85 86 87 89 90 91 92 94 95 97 98 99

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9UnmapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceSetMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceGetSurfaceDimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

. . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.12 cudaD3D9ResourceGetMappedPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10 ErrorHandling RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.1 cudaGetLastError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.2 cudaGetErrorString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 DriverApiReference 2.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 2.2

cuInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

cuDeviceGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 cuDeviceGetAttribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 cuDeviceGetCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 cuDeviceGetName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 cuDeviceGetProperties cuDeviceTotalMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

cuCtxAttach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 cuCtxCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 cuCtxDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

cuCtxDetach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 cuCtxGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 cuCtxPopCurrent cuCtxPushCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

cuCtxSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

2.4

ModuleManagement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 2.4.1 cuModuleGetFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

iii

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMallocArray. cudaFree. no operation is performed.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.5. SEE ALSO cudaMalloc.1.5 cudaFreeArray NAME cudaFreeArray . cudaFreeHost 29 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError Note that this function may also return error codes from previous. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D. cudaMalloc3D 51 .SEE ALSO cudaMemset.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

OpenGL interoperability SYNOPSIS cudaError_t cudaGLUnregisterBufferObject(GLuint bufferObj). cudaGLRegisterBufferObject. cudaGLMapBufferObject. SEE ALSO cudaGLSetGLDevice.1.8.5 cudaGLUnregisterBufferObject NAME cudaGLUnregisterBufferObject . 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. asynchronous launches. cudaGLUnmapBufferObject 77 .

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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. is a non-stand-alone IDirect3DSurface9) or is already registered then cudaErrorInvalidHandle is returned. cudaD3D9ResourceGetMappedSize. cudaD3D9SetDirect3DDevice. asynchronous launches. If pResource cannot be registered then cudaErrorUnknown is returned. cudaD3D9UnmapResources. SEE ALSO cudaD3D9GetDevice.• Surfaces of depth or stencil formats cannot be shared. cudaD3D9ResourceGetMappedPitch 83 . cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetSurfaceDimensions. If pResource is of incorrect type (e. cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer.g. cudaD3D9UnregisterResource. cudaD3D9MapResources.

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

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

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

9.1. If pResource is presently mapped for access by CUDA then cudaErrorUnknown is returned. • cudaD3D9MapFlagsNone: Specifies no hints about how this resource will be used. If pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned.8 cudaD3D9ResourceSetMapFlags NAME cudaD3D9ResourceSetMapFlags . 87 . 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. It is therefore assumed that this resource will be read from and written to by CUDA kernels. unsigned int Flags). • cudaD3D9MapFlagsReadOnly: Specifies that CUDA kernels which access this resource will not write to this resource. DESCRIPTION Set flags for mapping the Direct3D resource pResource. asynchronous launches. • 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. so none of the data previously stored in the resource will be preserved. This is the default value.set usage flags for mapping a Direct3D resource SYNOPSIS cudaError_t cudaD3D9ResourceSetMapFlags(IDirect3DResource9 *pResource.

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.return device-ID for current context SYNOPSIS CUresult cuCtxGetDevice(CUdevice* device).3. cuCtxAttach. SEE ALSO cuCtxCreate.5 cuCtxGetDevice NAME cuCtxGetDevice .2. asynchronous launches. cuCtxDetach.

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

cuStreamDestroy 133 . cuStreamQuery.2.4 cuStreamSynchronize NAME cuStreamSynchronize . SEE ALSO cuStreamCreate.5. asynchronous launches. DESCRIPTION Blocks until the device has completed all operations in the stream.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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemGetAddressRange.3 cuArrayDestroy NAME cuArrayDestroy . cuArrayGetDescriptor. cuMemAllocPitch. asynchronous launches. cuMemAllocHost. cuArrayCreate. SEE ALSO cuMemGetInfo. cuMemset.destroys a CUDA array SYNOPSIS CUresult cuArrayDestroy(CUarray array). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_ARRAY_IS_MAPPED Note that this function may also return error codes from previous. cuMemFreeHost.8. cuMemset2D 156 . cuMemFree. cuMemAlloc.2. DESCRIPTION Destroys the CUDA array array.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Other texture reference functions are used to specify the format and interpretation (addressing. the application must call cuTexRefSetArray() or cuTexRefSetAddress() to associate the reference with allocated memory. cuTexRefSetAddress. DESCRIPTION Creates a texture reference and returns its handle in *texRef.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetFormat. To associate the texture reference with a texture ordinal for a given function. cuTexRefGetFilterMode. cuTexRefGetArray. asynchronous launches.1 cuTexRefCreate NAME cuTexRefCreate . cuTexRefSetFilterMode.9. Once created. cuTexRefGetFlags 184 . cuTexRefGetAddressMode. SEE ALSO cuTexRefDestroy. etc. cuTexRefGetFormat. the application should call cuParamSetTexRef().) to be used when the memory is read through this texture reference.creates a texture-reference SYNOPSIS CUresult cuTexRefCreate(CUtexref* texRef). cuTexRefSetFlags. filtering. cuTexRefSetAddressMode. cuTexRefSetArray. cuTexRefGetAddress.

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

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

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

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

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

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

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

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

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

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

SEE ALSO cuTexRefCreate. cuTexRefGetFormat.2. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef. cuTexRefSetFormat.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode .9. cuTexRefSetAddress. cuTexRefGetAddressMode. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. Note that this call has no effect if texRef is bound to linear memory. cuTexRefSetFlags. cuTexRefDestroy. cuTexRefSetAddressMode. cuTexRefGetArray. asynchronous launches. cuTexRefGetAddress. cuTexRefSetArray. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefGetFilterMode. CUfilter_mode mode). CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0. cuTexRefGetFlags 195 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

is a non-stand-alone IDirect3DSurface9) or is already registered then CUDA_ERROR_INVALID_HANDLE is returned. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceGetSurfaceDimensions. cuD3D9UnregisterResource. If pResource is of incorrect type (e. cuD3D9MapResources. cuD3D9UnmapResources. If pResource cannot be registered then CUDA_ERROR_UNKNOWN is returned. cuD3D9ResourceGetMappedPitch 210 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9GetDirect3DDevice. asynchronous launches. If Direct3D interoperability is not initialized on this context then CUDA_ERROR_INVALID_CONTEXT is returned.g. cuD3D9CtxCreate.• Surfaces of depth or stencil formats cannot be shared. cuD3D9ResourceSetMapFlags.

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

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

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

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

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

SEE ALSO cuD3D9GetDevice. cuD3D9CtxCreate. cuD3D9MapResources. cuD3D9UnmapResources. 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. cuD3D9UnregisterResource. unsigned int Face. cuD3D9ResourceSetMapFlags. asynchronous launches.11. The value set in pSize may change every time that pResource is mapped. cuD3D9ResourceGetSurfaceDimensions.2. IDirect3DResource9* pResource. cuD3D9GetDirect3DDevice.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 has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9ResourceGetMappedPitch 219 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_MAPPED Note that this function may also return error codes from previous. unsigned int Level). If pResource is not mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned. DESCRIPTION Returns in *pSize the size of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer. cuD3D9ResourceGetMappedPointer.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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