CudaReferenceManual_2.0 | Integer (Computer Science) | Pointer (Computer Programming)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The memory is not cleared. cudaFree. cudaFreeArray. cudaMalloc() returns cudaErrorMemoryAllocation in case of failure. cudaMallocHost. The allocated memory is suitably aligned for any kind of variable.allocate memory on the GPU SYNOPSIS cudaError_t cudaMalloc( void** devPtr. cudaMallocArray. cudaFreeHost 25 .1. asynchronous launches.1 cudaMalloc NAME cudaMalloc .5. 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. SEE ALSO cudaMallocPitch.

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

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

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous. int value.5.1. asynchronous launches. 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. SEE ALSO cudaMemset2D.8 cudaMemset NAME cudaMemset . cudaMemset3D 32 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

1.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 .10.2 cudaGetErrorString NAME cudaGetErrorString . DESCRIPTION Returns a message string from an error code.

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. cuDeviceGetCount. cuDeviceGet. cuDeviceGetAttribute. SEE ALSO cuDeviceComputeCapability. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

it is ignored. If one of them is null. If no variable of that name exists.returns a global pointer from a module SYNOPSIS CUresult cuModuleGetGlobal(CUdeviceptr* devPtr. cuModuleGetGlobal() returns CUDA_ERROR_NOT_FOUND. unsigned int* bytes.2 cuModuleGetGlobal NAME cuModuleGetGlobal . SEE ALSO cuModuleLoad. DESCRIPTION Returns in *devPtr and *bytes the base pointer and size of the global of name globalname located in module mod. CUmodule mod. const char* globalname).4.2. cuModuleGetFunction. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_NOT_FOUND Note that this function may also return error codes from previous. cuModuleLoadData. cuModuleGetTexRef 123 . cuModuleUnload. asynchronous launches. cuModuleLoadFatBinary. Both parameters devPtr and bytes are optional.

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

desc. desc.NumChannels = 1. • Description for a width x height x depth CUDA array of 64-bit. cuMemAllocHost. desc.Depth = 0. desc. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc.Format = CU_AD_FORMAT_FLOAT.Height = 0.• Description for a CUDA array of 2048 floats: CUDA_ARRAY3D_DESCRIPTOR desc.Width = width.Width = 64. cuMemFree. SEE ALSO cuMemGetInfo. 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.Width = 2048. cuMemGetAddressRange.Depth = 0. desc. desc. desc. cuArrayDestroy 155 .Depth = depth. desc. desc. cuMemAllocPitch. • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY3D_DESCRIPTOR desc.NumChannels = 1. desc.NumChannels = 4.Format = CU_AD_FORMAT_FLOAT.Height = 64.FormatFlags = CU_AD_FORMAT_HALF. desc. cuMemAlloc. desc. desc. asynchronous launches. desc. cuMemFreeHost.Height = height. cuArray3DGetDescriptor. desc.

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

It is useful for subroutines that have been passed a CUDA array. but need to know the CUDA array parameters for validation or other purposes. CUarray array) DESCRIPTION Returns in *arrayDesc a descriptor of the format and dimensions of the 1D or 2D CUDA array array.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_HANDLE Note that this function may also return error codes from previous. SEE ALSO cuArrayCreate.4 cuArrayGetDescriptor NAME cuArrayGetDescriptor . asynchronous launches. cuArray3DCreate. cuArray3DGetDescriptor.get a 1D or 2D CUDA array descriptor SYNOPSIS CUresult cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR* arrayDesc. cuArrayDestroy 157 .8.

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

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

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

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

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

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

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

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

asynchronous launches. in bytes. cuMemset2D 166 .8. cuArrayGetDescriptor. cuMemFree. cuMemAllocHost. 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. cuMemset.2.12 cuMemGetInfo NAME cuMemGetInfo . cuArrayDestroy. cuMemAllocPitch.gets free and total memory SYNOPSIS CUresult cuMemGetInfo(unsigned int* free. DESCRIPTION Returns in *free and *total respectively. unsigned int* total). SEE ALSO cuMemAlloc. cuMemGetAddressRange. cuArrayCreate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. CUtexref texRef. cuTexRefDestroy. cuTexRefSetAddress. cuTexRefGetArray. Currently the only valid values for dim are 0 and 1.4 cuTexRefGetAddressMode NAME cuTexRefGetAddressMode . cuTexRefGetFlags 187 . DESCRIPTION Returns in *mode the addressing mode corresponding to the dimension dim of the texture reference texRef.2. cuTexRefGetFilterMode. asynchronous launches. cuTexRefGetAddress.9. cuTexRefSetFlags. SEE ALSO cuTexRefCreate. cuTexRefSetArray.gets the addressing mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetAddressMode(CUaddress_mode* mode. cuTexRefSetFormat. cuTexRefSetAddressMode. cuTexRefGetFormat. int dim). cuTexRefSetFilterMode.

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

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

gets the flags used by a texture-reference SYNOPSIS CUresult cuTexRefGetFlags(unsigned int* flags. cuTexRefGetAddress.2. cuTexRefGetAddressMode. cuTexRefGetFormat 190 .7 cuTexRefGetFlags NAME cuTexRefGetFlags . cuTexRefGetArray. cuTexRefSetAddress. cuTexRefGetFilterMode. asynchronous launches. cuTexRefSetArray. CUtexref texRef). cuTexRefSetAddressMode. cuTexRefSetFlags. cuTexRefSetFilterMode. SEE ALSO cuTexRefCreate. cuTexRefSetFormat. 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. cuTexRefDestroy.9.

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

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

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

cuTexRefGetFilterMode. Any CUDA array previously bound to texRef is unbound. cuTexRefSetFormat. Any previous address or CUDA array state associated with the texture reference is superseded by this function. cuTexRefSetFilterMode. cuTexRefGetAddressMode. cuTexRefSetAddressMode. cuTexRefDestroy. cuTexRefGetArray. cuTexRefSetAddress. SEE ALSO cuTexRefCreate.9. asynchronous launches. cuTexRefSetFlags. cuTexRefGetAddress. flags must be set to CU_TRSA_OVERRIDE_FORMAT.2. unsigned int flags). DESCRIPTION Binds the CUDA array array to the texture reference texRef.binds an array to a texture-reference SYNOPSIS CUresult cuTexRefSetArray(CUtexref texRef.11 cuTexRefSetArray NAME 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. CUarray array. cuTexRefGetFlags 194 . cuTexRefGetFormat.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful