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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. SEE ALSO cudaStreamCreate. cudaStreamQuery 15 .3.3 cudaStreamSynchronize NAME cudaStreamSynchronize . cudaStreamDestroy. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous.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.destroys and cleans-up a stream object SYNOPSIS cudaError_t cudaStreamDestroy( cudaStream_t stream ) DESCRIPTION Destroys a stream object.3.1. cudaStreamDestroy 16 . asynchronous launches. SEE ALSO cudaStreamCreate. cudaStreamSychronize.4 cudaStreamDestroy NAME cudaStreamDestroy .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMalloc3D 51 .SEE ALSO cudaMemset. cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

6 cudaD3D9MapResources NAME cudaD3D9MapResources . If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned. If any of ppResources are presently mapped for access by CUDA then cudaErrorUnknown is returned.9. cudaD3D9SetDirect3DDevice. cudaD3D9UnmapResources. Direct3D should not access any resources while they are mapped by CUDA. cudaD3D9ResourceSetMapFlags. cudaD3D9ResourceGetMappedPitch 85 . SEE ALSO cudaD3D9GetDevice.1. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. cudaD3D9ResourceGetSurfaceDimensions.map Direct3D resources for access by CUDA SYNOPSIS cudaError_t cudaD3D9MapResources(unsigned int count. This function provides the synchronization guarantee that any Direct3D calls issued before cudaD3D9MapResources will complete before any CUDA kernels issued after cudaD3D9MapResources begin. cudaD3D9ResourceGetMappedSize. 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. asynchronous launches. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. IDirect3DResource9 **ppResources). cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetMappedPointer. cudaD3D9UnregisterResource. cudaD3D9RegisterResource.

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2. cuCtxDetach. cuCtxAttach() fails if there is no context current to the thread. cuCtxGetDevice. cuCtxSynchronize 112 . SEE ALSO cuCtxCreate.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. Currently.1 cuCtxAttach NAME cuCtxAttach . unsigned int Flags). DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context.3. asynchronous launches. the Flags parameter must be 0. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

CUevent end). this function returns CUDA_ERROR_INVALID_VALUE. SEE ALSO cuEventCreate. cuEventQuery.2. CUevent start. asynchronous launches.6.computes the elapsed time between two events SYNOPSIS CUresult cuEventDestroy(float* time. cuEventRecord.3 cuEventElapsedTime NAME cuEventElapsedTime . If either event has been recorded with a non-zero stream. cuEventSynchronize. cuEventDestroy 137 . 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.5 microseconds). the result is undefined. DESCRIPTION Computes the elapsed time between two events (in milliseconds with a resolution of around 0.

asynchronous launches. DESCRIPTION Returns CUDA_SUCCESS if the event has actually been recorded. the function returns CUDA_ERROR_INVALID_VALUE RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_READY Note that this function may also return error codes from previous.6. cuEventSynchronize.queries an event’s status SYNOPSIS CUresult cuEventQuery(CUevent event). SEE ALSO cuEventCreate. cuEventRecord. If cuEventRecord() has not been called on this event.2. cuEventElapsedTime 138 .4 cuEventQuery NAME cuEventQuery . cuEventDestroy. or CUDA_ERROR_NOT_READY if not.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

get a 1D or 2D CUDA array descriptor SYNOPSIS CUresult cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR* arrayDesc. but need to know the CUDA array parameters for validation or other purposes. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous. cuArrayDestroy 157 . asynchronous launches. cuArray3DCreate.2. SEE ALSO cuArrayCreate. 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. cuArray3DGetDescriptor. It is useful for subroutines that have been passed a CUDA array.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. cuGLUnregisterBufferObject 201 . SEE ALSO cuGLCtxCreate. cuGLInit. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous.3 cuGLMapBufferObject NAME cuGLMapBufferObject . GLuint bufferObj). unsigned int* size.2. cuGLUnmapBufferObject. cuGLRegisterBufferObject.10. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping.

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful