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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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().9 cudaMemset2D NAME cudaMemset2D .initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset2D( void* dstPtr. int value.5. size_t pitch.1. cudaMemset3D 33 . SEE ALSO cudaMemset. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous. including any padding added to the end of each row. size_t width. size_t height ) DESCRIPTION Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D. cudaMalloc3D 51 .SEE ALSO cudaMemset.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

template E<lt> class T. enum cudaTextureReadMode readMode E<gt> static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture E<lt> T. Any CUDA array previously bound to texRef is unbound. const struct cudaChannelFormatDesc& desc) DESCRIPTION Binds the CUDA array array to texture reference texRef. binds the CUDA array array to texture reference texRef. dim. int dim. Any CUDA array previously bound to texRef is unbound. const struct cudaArray* cuArray. dim. The channel descriptor is inherited from the CUDA array. 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.High-level texture API SYNOPSIS template < class T. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture < T. int dim. readMode E<gt>& texRef. SEE ALSO cudaCreateChannelDesc_HL 66 . const struct cudaArray* cuArray). readMode >& texRef.cudaBindTextureToArray HL NAME cudaBindTextureToArray . asynchronous launches.

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

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

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

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

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

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

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

the buffer object cannot be used by any OpenGL commands except as a data source for OpenGL drawing commands. 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. cudaGLMapBufferObject.1.OpenGL interoperability SYNOPSIS cudaError_t cudaGLRegisterBufferObject(GLuint bufferObj) DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA. While it is registered. cudaGLUnregisterBufferObject 74 . SEE ALSO cudaGLSetGLDevice. asynchronous launches.8. cudaGLUnmapBufferObject.2 cudaGLRegisterBufferObject NAME cudaGLRegisterBufferObject .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3 cuStreamQuery NAME cuStreamQuery . DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed.determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream). cuStreamSynchronize. 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 cuStreamCreate.5. or CUDA_ERROR_NOT_READY if not. asynchronous launches.2. cuStreamDestroy 132 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Sets through bytes the amount of shared memory that will be available to each thread block when the kernel given by func is launched. asynchronous launches. SEE ALSO cuFuncSetBlockShape. cuLaunch. cuParamSetf. unsigned int bytes). cuLaunchGrid 150 .7. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuParamSetv.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize .2. cuParamSetTexRef. cuParamSeti.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. cuParamSetSize.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. asynchronous launches.2. respectively. dstDevPtr and srcHostPtr specify the base addresses of the destination and source. unsigned int count.8. DESCRIPTION Copies from host memory to device memory.copy memory from Host to Device SYNOPSIS CUresult cuMemcpyHtoD(CUdeviceptr dstDevPtr. cuMemcpy2D 180 . count specifies the number of bytes to copy. CUresult cuMemcpyHtoDAsync(CUdeviceptr dstDevPtr. cuMemcpyHtoA. const void *srcHostPtr. CUstream stream). cuMemcpyAtoH. cuMemcpyAtoA. unsigned int count). cuMemcpyAtoD. cuMemcpyHtoDAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. 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. const void *srcHostPtr. cuMemcpyDtoD.22 cuMemcpyHtoD NAME cuMemcpyHtoD . cuMemcpyDtoA.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2 cuGLInit NAME cuGLInit . It may fail if the needed OpenGL driver facilities are not available. cuGLRegisterBufferObject.2.10. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.initializes GL interoperability SYNOPSIS CUresult cuGLInit(void). cuGLMapBufferObject. cuGLUnregisterBufferObject 200 . DESCRIPTION Initializes OpenGL interoperability. cuGLUnmapBufferObject. asynchronous launches. SEE ALSO cuGLCtxCreate. It must be called before performing any other OpenGL interoperability operations.

2. cuGLUnregisterBufferObject 201 .maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. SEE ALSO cuGLCtxCreate. cuGLUnmapBufferObject. cuGLInit. GLuint bufferObj). 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. unsigned int* size. 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. cuGLRegisterBufferObject.10. asynchronous launches.3 cuGLMapBufferObject NAME cuGLMapBufferObject .

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

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

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

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

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

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

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

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

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

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

cuD3D9UnmapResources. SEE ALSO cuD3D9GetDevice. cuD3D9GetDirect3DDevice. cuD3D9ResourceGetMappedPitch 212 .map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. If any of ppResources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned. 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. 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. cuD3D9RegisterResource. 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 cuD3D9MapResources will complete before any CUDA kernels issued after cuD3D9MapResources begin. cuD3D9UnregisterResource.2.6 cuD3D9MapResources NAME cuD3D9MapResources . DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. cuD3D9CtxCreate. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. If an application does so the results are undefined.11. asynchronous launches. IDirect3DResource9 **ppResources). Direct3D should not access any resources while they are mapped by CUDA. cuD3D9ResourceSetMapFlags.

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

SYNOPSIS
CUresult cuD3D9UnmapResources(unsigned int count, IDirect3DResource9** ppResources);

DESCRIPTION
Unmaps the count Direct3D resources in ppResources. This function provides the synchronization guarantee that any CUDA kernels issued before cuD3D9UnmapResources will complete before any Direct3D calls issued after cuD3D9UnmapResources begin. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned. If any of ppResources are not presently mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned.

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

SEE ALSO

cuD3D9GetDevice, cuD3D9CtxCreate, cuD3D9GetDirect3DDevice, cuD3D9RegisterResource, cuD3D9UnregisterResource, cuD3D9MapResources, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags, cuD3D9ResourceGetMappedP cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetMappedPitch

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

SYNOPSIS
CUresult cuD3D9ResourceSetMapFlags(IDirect3DResource9 *pResource, unsigned int Flags);

DESCRIPTION
Set flags for mapping the Direct3D resource pResource. Changes to flags will take effect the next time pResource is mapped. The Flags argument may be any of the following. • CU_D3D9_MAPRESOURCE_FLAGS_NONE: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA kernels. This is the default value. • CU_D3D9_MAPRESOURCE_FLAGS_READONLY: Specifies that CUDA kernels which access this resource will not write to this resource. • CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD: Specifies that CUDA kernels which access this resource will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. If pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. If pResource is presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.

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

214

SEE ALSO

cuD3D9GetDevice, cuD3D9CtxCreate, cuD3D9GetDirect3DDevice, cuD3D9RegisterResource, cuD3D9UnregisterResource, cuD3D9MapResources, cuD3D9UnmapResources, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceGetMappedPointe cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetMappedPitch

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

SYNOPSIS
CUresult cuD3D9ResourceGetSurfaceDimensions(unsigned int* pWidth, unsigned int* pHeight, unsigned int *pDepth, IDirect3DResource9* pResource, unsigned int Face, unsigned int Level);

DESCRIPTION
Returns in *pWidth, *pHeight, and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. Because anti-aliased surfaces may have multiple samples per pixel it is possible that the dimensions of a resource will be an integer factor larger than the dimensions reported by the Direct3D runtime. The parameters pWidth, pHeight, and pDepth are optional. For 2D surfaces, the value returned in *pDepth will be 0. If pResource is not of type IDirect3DBaseTexture9 or IDirect3DSurface9 or if pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer.

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

SEE ALSO
cuD3D9GetDevice, cuD3D9CtxCreate, cuD3D9GetDirect3DDevice, cuD3D9RegisterResource, cuD3D9UnregisterResource, cuD3D9MapResources, cuD3D9UnmapResources, cuD3D9ResourceSetMapFlags, cuD3D9ResourceGetMappedPointer, cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetMappedPitch

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful