NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

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

cudaGetDeviceCount

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

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

1.3

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

1.4

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

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

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

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

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

cudaMallocArray

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

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

i

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

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

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

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

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

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

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

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

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

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

1.8

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

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

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

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

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

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

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

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

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

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

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

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

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

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

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

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

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

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

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

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

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

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

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

2.4

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

iii

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

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

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

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

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

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

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

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

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

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

maxThreadsDim[3] is the maximum sizes of each dimension of a block. cudaGetDevice. SEE ALSO cudaGetDeviceCount. cudaSetDevice. or 0 if not. clockRate is the clock frequency in kilohertz. minor are the major and minor revision numbers defining the device’s compute capability. cudaChooseDevice 7 . 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. maxGridSize[3] is the maximum sizes of each dimension of a grid. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevice Note that this function may also return error codes from previous.memPitch is the maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through cudaMallocPitch(). maxThreadsPerBlock is the maximum number of threads per block. deviceOverlap is 1 if the device can concurrently copy memory between host and device while executing a kernel. totalConstMem is the total amount of constant memory available on the device in bytes. major.

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

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

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

asynchronous launches.2.1. SEE ALSO cudaThreadSynchronize 11 .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 . Any subsequent API call reinitializes the runtime. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

46 . size_t depth.22 cudaMalloc3D NAME cudaMalloc3D . or 3D memory objects on the GPU SYNOPSIS struct cudaPitchedPtr { void *ptr. size_t xsize. the logical width and height of the allocation. 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. The pitch returned in the pitch field of the pitchedDevPtr is the width in bytes of the allocation. it is highly recommended that programmers perform allocations using cudaMalloc3D() or cudaMallocPitch(). struct cudaExtent { size_t width. The function may pad the allocation to ensure hardware alignment requirements are met. Due to alignment restrictions in the hardware. size_t height. 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.allocates logical 1D. size_t ysize. For allocations of 2D. 3D objects. }.1. }. this is especially true if the application will be performing memory copies involving 2D or 3D objects (whether linear memory or CUDA arrays). cudaError_t cudaMalloc3D( struct cudaPitchedPtr* pitchDevPtr. size_t pitch. 2D.5. asynchronous launches.

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. This data contains the dimension for the grid and thread blocks. asynchronous launches. dim3 blockDim. cudaConfigureCall() is stack based. cudaSetupArgument 69 .1.1 cudaConfigureCall NAME cudaConfigureCall . SEE ALSO cudaLaunch.7. Each call pushes data on top of an execution stack.configure a device-launch SYNOPSIS cudaError_t cudaConfigureCall(dim3 gridDim. together with any arguments for the call.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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. asynchronous launches. cuDeviceGetName. cuDeviceGetCount. cuDeviceGetProperties. cuDeviceGet.

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

5 cuDeviceGetName NAME cuDeviceGetName . cuDeviceGetProperties. asynchronous launches.returns an identifier string SYNOPSIS CUresult cuDeviceGetName(char* name.2.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. cuDeviceGet. SEE ALSO cuDeviceComputeCapability. cuDeviceGetAttribute. len specifies the maximum length of the string that may be returned. DESCRIPTION Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name. cuDeviceTotalMem 107 . CUdevice dev). int len. cuDeviceGetCount.

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

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

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

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

unsigned int Flags). cuCtxAttach() fails if there is no context current to the thread. cuCtxGetDevice. 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.1 cuCtxAttach NAME cuCtxAttach . cuCtxSynchronize 112 . the Flags parameter must be 0.3.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. SEE ALSO cuCtxCreate.2. cuCtxDetach. DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context. Currently.

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

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

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

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

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

Floating contexts may be destroyed by calling cuCtxDestroy(). The context may then be made current to a different CPU thread by calling cuCtxPushCurrent(). CUDA contexts have a usage count of 1 upon creation.2.6 cuCtxPopCurrent NAME cuCtxPopCurrent . DESCRIPTION Pops the current CUDA context from the CPU thread. cuCtxPopCurrent() passes back the context handle in *pctx. If a context was current to the CPU thread before cuCtxCreate or cuCtxPushCurrent was called.pops the current CUDA context from the current CPU thread SYNOPSIS CUresult cuCtxPopCurrent(CUcontext *pctx). If successful. cuCtxPushCurrent 118 .3. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. this function makes that context current to the CPU thread again. cuCtxAttach. asynchronous launches. cuCtxDestroy. cuCtxDetach. SEE ALSO cuCtxCreate. the usage count may be incremented with cuCtxAttach() and decremented with cuCtxDetach(). The CUDA context must have a usage count of 1.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemset2D 164 .10 cuMemFreeHost NAME cuMemFreeHost . cuArrayDestroy.frees page-locked host memory SYNOPSIS CUresult cuMemFreeHost(void* hostPtr). 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. asynchronous launches. cuMemGetAddressRange. cuMemset. cuMemAlloc. cuMemAllocHost. cuArrayCreate. cuArrayGetDescriptor.2.8. DESCRIPTION Frees the memory space pointed to by hostPtr. cuMemFree. cuMemAllocPitch. SEE ALSO cuMemGetInfo.

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

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

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

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

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

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

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

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

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

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

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

unsigned int dstIndex. unsigned int count).2. cuMemcpyDtoD. SEE ALSO cuMemcpyHtoD. CUdeviceptr srcDevPtr.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. cuMemcpyAtoD. srcDevPtr specifies the base pointer of the source. asynchronous launches. count specifies the number of bytes to copy. cuMemcpyAtoA.18 cuMemcpyDtoA NAME cuMemcpyDtoA . DESCRIPTION Copies from device memory to a 1D CUDA array. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpyAtoH. cuMemcpyDtoH.8. cuMemcpyHtoA. cuMemcpy2D 176 .

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

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

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

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

CUresult cuMemsetD32(CUdeviceptr dstDevPtr. or 32-bit values to the specified value value.23 cuMemset NAME cuMemset . 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. cuMemAlloc.8. cuMemAllocPitch.2. SEE ALSO cuMemGetInfo. unsigned int count ). unsigned int value. CUresult cuMemsetD16(CUdeviceptr dstDevPtr.initializes device memory SYNOPSIS CUresult cuMemsetD8(CUdeviceptr dstDevPtr. asynchronous launches. unsigned int count ). cuArrayGetDescriptor. DESCRIPTION Sets the memory range of count 8-. cuMemset2D 181 . unsigned char value. cuArrayDestroy. cuMemFree. cuMemFreeHost. cuArrayCreate. unsigned int count ). 16-. unsigned short value. cuMemGetAddressRange.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuGLInit.10. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping.3 cuGLMapBufferObject NAME cuGLMapBufferObject . unsigned int* size. asynchronous launches.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr.2. GLuint bufferObj). SEE ALSO cuGLCtxCreate. cuGLRegisterBufferObject. 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. cuGLUnregisterBufferObject 201 . cuGLUnmapBufferObject.

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

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

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

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

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

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

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

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

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

cuD3D9ResourceGetMappedPitch 211 .unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9UnmapResources. cuD3D9ResourceGetSurfaceDimensions. asynchronous launches. SEE ALSO cuD3D9GetDevice.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . cuD3D9CtxCreate. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9ResourceSetMapFlags. cuD3D9GetDirect3DDevice.11.2. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. 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_UNKNOWN Note that this function may also return error codes from previous. cuD3D9RegisterResource.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful