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

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

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

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

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

the execution configuration syntax to invoke kernels is only available in source code compiled with nvcc. For example. using overloading.h) is a C-style interface that does not require compiling with nvcc. The high-level API also has some CUDA-specific wrappers that wrap low-level routines that deal with symbols. references and default arguments. The high-level API (cuda_runtime. 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. Direct3D Interoperability.h) is a C++-style interface built on top of the low-level API. OpenGL Interoperability. It wraps some of the low level API routines. Memory Management. Texture Reference Management. Stream Management. The low-level API (cuda_runtime_api. Execution Management. and device functions. Error Handling 1 . textures. These wrappers can be used from C++ code and can be compiled with any C++ compiler. Thread Management. Event Management. SEE ALSO Device Management.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset2D( void* dstPtr. 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. 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 . SEE ALSO cudaMemset.5. This function performs fastest when the pitch is one that has been passed back by cudaMallocPitch(). asynchronous launches. size_t pitch. cudaMemset3D 33 . size_t width.1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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). cudaGetChannelDesc. asynchronous launches. cudaBindTexture. cudaUnbindTexture. cudaGetTextureAlignmentOffset 60 .cudaBindTextureToArray NAME cudaBindTextureToArray . SEE ALSO cudaCreateChannelDesc. const struct cudaArray* array. cudaGetTextureReference. Any CUDA array previously bound to texRef is unbound. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture Note that this function may also return error codes from previous. desc describes how the memory is interpreted when fetching values from the texture.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaGLUnmapBufferObject 77 . asynchronous launches.5 cudaGLUnregisterBufferObject NAME cudaGLUnregisterBufferObject . cudaGLRegisterBufferObject.OpenGL interoperability SYNOPSIS cudaError_t cudaGLUnregisterBufferObject(GLuint bufferObj). DESCRIPTION Unregisters the buffer object of ID bufferObj for access by CUDA. cudaGLMapBufferObject.8.1. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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. cuDeviceGetCount() returns 0. asynchronous launches. cuDeviceGetName. cuDeviceGetProperties.returns the number of compute-capable devices SYNOPSIS CUresult cuDeviceGetCount(int* count).2. cuDeviceGetAttribute. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuDeviceGet.0 that are available for execution. SEE ALSO cuDeviceComputeCapability.2. cuDeviceTotalMem 106 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

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

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

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

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

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

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

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

cuEventDestroy. If cuEventRecord() has not been called on this event. asynchronous launches.6.2. the function returns CUDA_ERROR_INVALID_VALUE. 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. DESCRIPTION Blocks until the event has actually been recorded.waits for an event to complete SYNOPSIS CUresult cuEventSynchronize(CUevent event). SEE ALSO cuEventCreate. cuEventElapsedTime 140 . cuEventRecord.6 cuEventSynchronize NAME cuEventSynchronize .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0) reference the entire breadth of the array dimension RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetAddressMode. cuTexRefGetFlags 196 . DESCRIPTION Specifies optional flags to control the behavior of data returned through the texture reference. The valid flags are: • CU_TRSF_READ_AS_INTEGER.sets flags for a texture-reference SYNOPSIS CUresult cuTexRefSetFlags(CUtexref texRef. the texture coordinates [0. SEE ALSO cuTexRefCreate. cuTexRefSetArray. 1. cuTexRefGetFilterMode. • CU_TRSF_NORMALIZED_COORDINATES. cuTexRefGetArray. cuTexRefSetFilterMode. unsigned int Flags). which suppresses the default behavior of having the texture coordinates range from [0. cuTexRefGetFormat. cuTexRefSetFormat. cuTexRefGetAddressMode. cuTexRefSetAddress. 1]. which suppresses the default behavior of having the texture promote integer data to floating point data in the range [0.13 cuTexRefSetFlags NAME cuTexRefSetFlags . Dim) where Dim is the width or height of the CUDA array. asynchronous launches.2.9. Instead. cuTexRefGetAddress. cuTexRefDestroy.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuD3D9ResourceGetMappedPitch 211 .11. cuD3D9GetDirect3DDevice. cuD3D9ResourceGetSurfaceDimensions.2. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9RegisterResource. 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.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . cuD3D9UnmapResources. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceSetMapFlags. asynchronous launches. cuD3D9MapResources.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. cuD3D9CtxCreate.

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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