NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

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

cudaGetDeviceCount

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

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

1.3

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

1.4

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

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

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

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

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

cudaMallocArray

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

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

i

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

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

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

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

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

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

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

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

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

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

1.8

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

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

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

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

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

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

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

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

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

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

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

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

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

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

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

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

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

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

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

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

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

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

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

2.4

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

iii

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

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

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

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

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

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

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

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

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

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

maxGridSize[3] is the maximum sizes of each dimension of a grid. SEE ALSO cudaGetDeviceCount. minor are the major and minor revision numbers defining the device’s compute capability. cudaSetDevice.memPitch is the maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through cudaMallocPitch(). cudaGetDevice. cudaChooseDevice 7 . 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. maxThreadsDim[3] is the maximum sizes of each dimension of a block. texture base addresses that are aligned to textureAlignment bytes do not need an offset applied to texture fetches. deviceOverlap is 1 if the device can concurrently copy memory between host and device while executing a kernel. major. asynchronous launches. clockRate is the clock frequency in kilohertz. totalConstMem is the total amount of constant memory available on the device in bytes. multiProcessorCount is the number of multiprocessors on the device. textureAlignment is the alignment requirement. or 0 if not.

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

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

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

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

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

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

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

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

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

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

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

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

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

1. If cudaEventRecord() has not been called on this event.4. asynchronous launches. cudaEventQuery. SEE ALSO cudaEventCreate. cudaEventDestroy. cudaEventRecord. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. cudaEventElapsedTime 21 . 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.4 cudaEventSynchronize NAME cudaEventSynchronize .

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

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

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

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

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

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

4 cudaMallocArray NAME cudaMallocArray . enum cudaChannelFormatKind f. w.5. }. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. SEE ALSO cudaMalloc. asynchronous launches. cudaFreeHost 28 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. const struct cudaChannelFormatDesc* desc. y. size_t height ) DESCRIPTION Allocates a CUDA array according to the cudaChannelFormatDesc structure desc and returns a handle to the new CUDA array in *array. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. cudaChannelFormatKindUnsigned. cudaMallocHost. size_t width. cudaFreeArray. cudaFree. cudaMallocPitch. cudaChannelFormatKindFloat. z.1.allocate an array on the GPU SYNOPSIS cudaError_t cudaMallocArray( struct cudaArray** array.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMalloc3D 51 .SEE ALSO cudaMemset. cudaMemset2D.

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

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

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

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

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

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

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

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

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

cudaGetTextureAlignmentOffset 61 .Low-level texture API SYNOPSIS cudaError_t cudaUnbindTexture( const struct textureReference* texRef). cudaGetTextureReference. cudaGetChannelDesc. 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. asynchronous launches. cudaBindTexture. cudaBindTextureToArray. SEE ALSO cudaCreateChannelDesc.cudaUnbindTexture NAME cudaUnbindTexture .

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

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

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

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

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

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

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

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

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. entry must be declared as a __global__ function. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. cudaSetupArgument 70 . asynchronous launches.1. or it can be a character string.launches a device function SYNOPSIS template < class T > cudaError_t cudaLaunch(T entry) DESCRIPTION Launches the function entry on the device. SEE ALSO cudaConfigureCall.7.2 cudaLaunch NAME cudaLaunch . entry can either be a function that executes on the device.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

6 cuCtxPopCurrent NAME cuCtxPopCurrent . SEE ALSO cuCtxCreate. asynchronous launches. Floating contexts may be destroyed by calling cuCtxDestroy().pops the current CUDA context from the current CPU thread SYNOPSIS CUresult cuCtxPopCurrent(CUcontext *pctx). If successful. cuCtxAttach. cuCtxDestroy. DESCRIPTION Pops the current CUDA context from the CPU thread. cuCtxDetach. the usage count may be incremented with cuCtxAttach() and decremented with cuCtxDetach(). The CUDA context must have a usage count of 1. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. The context may then be made current to a different CPU thread by calling cuCtxPushCurrent(). cuCtxPushCurrent 118 . If a context was current to the CPU thread before cuCtxCreate or cuCtxPushCurrent was called.2. cuCtxPopCurrent() passes back the context handle in *pctx.3. this function makes that context current to the CPU thread again. 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 CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuCtxDestroy.e. not attached to any thread.2. SEE ALSO cuCtxCreate. DESCRIPTION Pushes the given context onto the CPU thread’s stack of current contexts.7 cuCtxPushCurrent NAME cuCtxPushCurrent . The specified context becomes the CPU thread’s current context. The previous current context may be made current again by calling cuCtxDestroy() or cuCtxPopCurrent(). so all CUDA functions that operate on the current context are affected." i. Contexts are made to float by calling cuCtxPopCurrent(). cuCtxAttach. cuCtxDetach. asynchronous launches. cuCtxPopCurrent 119 .attach floating context to CPU thread SYNOPSIS CUresult cuCtxPushCurrent(CUcontext ctx).3. The context must be "floating.

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

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

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

At present. flags is required to be 0. DESCRIPTION Creates an event. SEE ALSO cuEventRecord.1 cuEventCreate NAME cuEventCreate .6. cuEventSynchronize.creates an event SYNOPSIS CUresult cuEventCreate(CUevent* event. 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. unsigned int flags). cuEventDestroy. cuEventQuery.2. cuEventElapsedTime 135 .

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

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

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

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

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

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

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

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

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

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

int offset. cuParamSetv.7.adds a floating-point parameter to the function’s argument list SYNOPSIS CUresult cuParamSetf(CUfunction func. cuParamSetTexRef. cuFuncSetSharedSize. cuParamSeti. cuLaunch. float value). 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. DESCRIPTION Sets a floating point parameter that will be specified the next time the kernel corresponding to func will be invoked. cuParamSetSize. asynchronous launches.5 cuParamSetf NAME cuParamSetf . offset is a byte offset.2. cuLaunchGrid 146 .

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

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

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

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.2. cuLaunch. 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.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . asynchronous launches. cuParamSetf.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func.7. cuLaunchGrid 150 . cuParamSeti. cuParamSetTexRef. cuParamSetSize. SEE ALSO cuFuncSetBlockShape. cuParamSetv. unsigned int bytes).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cuTexRefCreate. cuTexRefGetFormat. cuTexRefGetAddressMode. the second. int dim. CU_TR_ADDRESS_MODE_MIRROR = 2. cuTexRefSetFlags. and so on. asynchronous launches. cuTexRefSetAddress.10 cuTexRefSetAddressMode NAME cuTexRefSetAddressMode . If dim is zero. cuTexRefSetFilterMode. cuTexRefGetArray. cuTexRefSetArray.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. CUaddress_mode is defined as such: typedef enum CUaddress_mode_enum { CU_TR_ADDRESS_MODE_WRAP = 0.9. cuTexRefSetFormat. CUaddress_mode mode). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetAddress.2. cuTexRefDestroy. cuTexRefGetFilterMode. cuTexRefGetFlags 193 . the addressing mode is applied to the first parameter of the functions used to fetch from the texture. CU_TR_ADDRESS_MODE_CLAMP = 1. DESCRIPTION Specifies the addressing mode mode for the given dimension of the texture reference texRef. } CUaddress_mode. if dim is 1.

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

9. 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. cuTexRefSetFormat. cuTexRefSetFlags. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef. cuTexRefGetArray. CUfilter_mode mode). cuTexRefSetArray. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefGetAddressMode. SEE ALSO cuTexRefCreate. cuTexRefGetFilterMode. asynchronous launches.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . cuTexRefGetAddress.2. cuTexRefGetFormat. cuTexRefDestroy. CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0. cuTexRefSetAddressMode. cuTexRefGetFlags 195 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful