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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaThreadExit 10 .1.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. asynchronous launches. cudaThreadSynchronize() returns an error if one of the preceding tasks failed. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1. asynchronous launches. kind can be either cudaMemcpyHostToDevice or cudaMemcpyDeviceToDevice. cudaMemcpy2DFromArray. cudaMemcpyToArray. 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. const void* src. size_t offset.5.18 cudaMemcpyToSymbol NAME cudaMemcpyToSymbol .copies data from host memory to GPU SYNOPSIS template < class T > cudaError_t cudaMemcpyToSymbol( const T& symbol. 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. SEE ALSO cudaMemcpy. cudaMemcpyFromArray. cudaMemcpyArrayToArray. symbol can either be a variable that resides in global or constant memory space. or it can be a character string. cudaMemcpy2DArrayToArray. The memory areas may not overlap. size_t count. cudaMemcpyFromSymbol 42 . cudaMemcpy2DToArray. cudaMemcpy2D.

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

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

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 .

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

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

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

size_t size = UINT_MAX). const struct cudaChannelFormatDesc* desc. desc describes how the memory is interpreted when fetching values from the texture. asynchronous launches. SEE ALSO cudaCreateChannelDesc. cudaUnbindTexture. const void* devPtr.cudaBindTexture NAME cudaBindTexture . DESCRIPTION Binds size bytes of the memory area pointed to by devPtr to the texture reference texRef. Since the hardware enforces an alignment requirement on texture base addresses. cudaGetChannelDesc. cudaBindTexture() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory.Low-level texture API SYNOPSIS cudaError_t cudaBindTexture(size_t* offset. 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. cudaGetTextureAlignmentOffset 59 . cudaGetTextureReference. 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. const struct textureReference* texRef. 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. cudaBindTextureToArray.

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaGLMapBufferObject. SEE ALSO cudaGLRegisterBufferObject.8.sets the CUDA device for use with GL Interopability SYNOPSIS cudaError_t cudaGLSetGLDevice(int device). cudaGLUnregisterBufferObject 73 . 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. DESCRIPTION Records dev as the device on which the active host thread executes the device code.1 cudaGLSetGLDevice NAME cudaGLSetGLDevice . cudaGLUnmapBufferObject.1. asynchronous launches.

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

DESCRIPTION
This section describes the CUDA runtime application programming interface. cudaD3D9GetDevice cudaD3D9SetDirect3DDevice cudaD3D9GetDirect3DDevice cudaD3D9RegisterResource cudaD3D9UnregisterResource cudaD3D9MapResources cudaD3D9UnmapResources cudaD3D9ResourceGetSurfaceDimensions cudaD3D9ResourceSetMapFlags cudaD3D9ResourceGetMappedPointer cudaD3D9ResourceGetMappedSize cudaD3D9ResourceGetMappedPitch As of CUDA 2.0 the following functions are deprecated. They should not be used in new development. cudaD3D9Begin cudaD3D9End cudaD3D9RegisterVertexBuffer cudaD3D9MapVertexBuffer cudaD3D9UnmapVertexBuffer cudaD3D9UnregisterVertexBuffer

SEE ALSO
Device Management, Thread Management, Stream Management, Event Management, Execution Management, Memory Management, Texture Reference Management, OpenGL Interoperability, Direct3D Interoperability, Error Handling

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

SYNOPSIS
cudaError_t cudaD3D9GetDevice(int* dev, const char* adapterName);

DESCRIPTION
Returns in *dev the CUDA-compatible device corresponding to the adapter name adapterName obtained from EnumDisplayDevices or IDirect3D9::GetAdapterIdentifier(). If no device on the adapter with name adapterName is CUDA-compatible then the call will fail.

RETURN VALUE
Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorUnknown Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO

cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cudaD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch

79

1.9.2

cudaD3D9SetDirect3DDevice

NAME
cudaD3D9SetDirect3DDevice - sets the Direct3D device to use for interoperability in this thread

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

DESCRIPTION
Records pDxDevice as the Direct3D device to use for Direct3D interoperability on this host thread. In order to use Direct3D interoperability, this call must be made before any other CUDA runtime calls on this thread. Successful context creation on pDxDevice will increase the internal reference count on pDxDevice. This reference count will be decremented upon destruction of this context through cudaThreadExit.

RETURN VALUE
Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorInvalidValue Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO

cudaD3D9GetDevice, cudaD3D9GetDirect3DDevice, cudaD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch

80

1.9.3

cudaD3D9GetDirect3DDevice

NAME
cudaD3D9GetDirect3DDevice - get the Direct3D device against which the current CUDA context was created

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

DESCRIPTION
Returns in *ppDxDevice the Direct3D device against which this CUDA context was created in cudaD3D9SetDirect3DDevice.

RETURN VALUE
Relevant return values: cudaSuccess cudaErrorUnknown Note that this function may also return error codes from previous, asynchronous launches.

SEE ALSO

cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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. 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. SEE ALSO 100 . the Flags parameters must be 0.initialize the CUDA driver API SYNOPSIS CUresult cuInit( unsigned int Flags ). If cuInit() has not been called. asynchronous launches.1.1 cuInit NAME cuInit . Currently.2.

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

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

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

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

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

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

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

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

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

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

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

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

• CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for results from the GPU. The context is created with a usage count of 1 and the caller of cuCtxCreate() must call cuCtxDestroy() or cuCtxDetach() when done using the context. unsigned int Flags. • CU_CTX_SCHED_AUTO: The default value if the Flags parameter is zero. 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. but can increase the performance of CPU threads performing work in parallel with the GPU. The Flags parameter is described below.2 cuCtxCreate NAME cuCtxCreate . 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.create a CUDA context SYNOPSIS CUresult cuCtxCreate(CUcontext* pCtx. DESCRIPTION Creates a new CUDA context and associates it with the calling thread.2. 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. This can increase latency when waiting for the GPU. CUdevice dev). otherwise CUDA will not yield while waiting for results and actively spin on the processor. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_DEVICE CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.3. asynchronous launches. If C > P then CUDA will yield to other OS threads when waiting for the GPU. If a context is already current to the thread. This can decrease latency when waiting for the GPU. but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread. 113 .

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

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

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

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.return device-ID for current context SYNOPSIS CUresult cuCtxGetDevice(CUdevice* device). cuCtxSynchronize 117 .3. asynchronous launches. cuCtxAttach. SEE ALSO cuCtxCreate.2.5 cuCtxGetDevice NAME cuCtxGetDevice . DESCRIPTION Returns in *device the ordinal of the current context’s device. cuCtxDetach.

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

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

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

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

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

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

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

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

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

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

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

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

cuStreamQuery.4 cuStreamSynchronize NAME cuStreamSynchronize . cuStreamDestroy 133 .2. asynchronous launches.5.block until a stream’s tasks are completed SYNOPSIS CUresult cuStreamSynchronize(CUstream stream). 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. SEE ALSO cuStreamCreate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

8. cuMemAllocPitch.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. cuArrayGetDescriptor. cuArrayCreate.12 cuMemGetInfo NAME cuMemGetInfo . unsigned int* total). cuMemAllocHost. DESCRIPTION Returns in *free and *total respectively. cuMemset. cuMemFree. the free and total amount of memory available for allocation by the CUDA context.gets free and total memory SYNOPSIS CUresult cuMemGetInfo(unsigned int* free. asynchronous launches. cuMemset2D 166 . in bytes. cuMemGetAddressRange. cuMemFreeHost. cuArrayDestroy. SEE ALSO cuMemAlloc.

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

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

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

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

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

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

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

16 cuMemcpyAtoD NAME cuMemcpyAtoD . cuMemcpy2D 174 . unsigned int srcIndex. 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.2. count specifies the number of bytes to copy and must be evenly divisible by the array element size. unsigned int count). asynchronous launches. cuMemcpyDtoH. SEE ALSO cuMemcpyHtoD. 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. DESCRIPTION Copies from a 1D CUDA array to device memory. cuMemcpyHtoA.copies memory from Array to Device SYNOPSIS CUresult cuMemcpyAtoD(CUdeviceptr dstDevPtr. cuMemcpyAtoA. dstDevPtr specifies the base pointer of the destination and must be naturally aligned with the CUDA array elements. cuMemcpyDtoA. CUarray srcArray.8.

CUresult cuMemcpyAtoHAsync(void* dstHostPtr. cuMemcpyAtoHAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. cuMemcpyDtoA. dstHostPtr specifies the base pointer of the destination. 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 a 1D CUDA array to host memory. CUstream stream). cuMemcpyDtoH. unsigned int count.17 cuMemcpyAtoH NAME cuMempcyAtoH . count specifies the number of bytes to copy. CUarray srcArray. unsigned int count).copies memory from Array to Host SYNOPSIS CUresult cuMemcpyAtoH(void* dstHostPtr. 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.2. asynchronous launches. unsigned int srcIndex. CUarray srcArray. cuMemcpyDtoD. cuMemcpyHtoA.8. cuMemcpyAtoD. srcArray and srcIndex specify the CUDA array handle and starting index of the source data. cuMemcpy2D 175 . cuMemcpyAtoA. unsigned int srcIndex.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefGetArray. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. asynchronous launches. cuTexRefSetArray. CUarray_format format. cuTexRefGetAddress. cuTexRefDestroy.14 cuTexRefSetFormat NAME cuTexRefSetFormat . SEE ALSO cuTexRefCreate. cuTexRefSetFilterMode. cuTexRefGetAddressMode. cuTexRefSetAddress. cuTexRefSetAddressMode.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. cuTexRefGetFlags 197 .9. cuTexRefGetFilterMode. cuTexRefGetFormat. cuTexRefSetFlags.2. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. 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.

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

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

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

asynchronous launches. cuGLInit.2.10. GLuint bufferObj). cuGLRegisterBufferObject. cuGLUnmapBufferObject.3 cuGLMapBufferObject NAME cuGLMapBufferObject . SEE ALSO cuGLCtxCreate. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. unsigned int* size. cuGLUnregisterBufferObject 201 . 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 202 .registers a GL buffer object SYNOPSIS CUresult cuGLRegisterBufferObject(GLuint bufferObj). This function must be called before CUDA can map the buffer object. cuGLUnmapBufferObject. cuGLMapBufferObject.4 cuGLRegisterBufferObject NAME cuGLRegisterBufferObject . While it is registered. cuGLInit.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_ALREADY_MAPPED Note that this function may also return error codes from previous. asynchronous launches. SEE ALSO cuGLCtxCreate. the buffer object cannot be used by any OpenGL commands except as a data source for OpenGL drawing commands. DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA.10.

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

asynchronous launches. cuGLRegisterBufferObject. cuGLUnmapBufferObject 204 . cuGLMapBufferObject.unregister a GL buffer object SYNOPSIS CUresult cuGLUnregisterBufferObject(GLuint bufferObj). cuGLInit.2.6 cuGLUnregisterBufferObject NAME cuGLUnregisterBufferObject . SEE ALSO cuGLCtxCreate. 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.10.

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful