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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaFreeArray.frees page-locked memory SYNOPSIS cudaError_t cudaFreeHost( void* hostPtr ) DESCRIPTION Frees the memory space pointed to by hostPtr. cudaMallocPitch. cudaMallocHost 31 .7 cudaFreeHost NAME cudaFreeHost . 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(). cudaFree. asynchronous launches. SEE ALSO cudaMalloc.1.5. cudaMallocArray.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

but can increase the performance of CPU threads performing work in parallel with the GPU. 113 . but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread. The Flags parameter is described below. CUdevice dev).3. otherwise CUDA will not yield while waiting for results and actively spin on the processor. • 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.2 cuCtxCreate NAME cuCtxCreate . it is supplanted by the newly created context and may be restored by a subsequent call to cuCtxPopCurrent(). DESCRIPTION Creates a new CUDA context and associates it with the calling thread. The two LSBs of the Flags parameter can be used to control how the OS thread which owns the CUDA context at the time of an API call interacts with the OS scheduler when waiting for results from the GPU. If C > P then CUDA will yield to other OS threads when waiting for the GPU. This can increase latency when waiting for the GPU. 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.2. asynchronous launches. 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.create a CUDA context SYNOPSIS CUresult cuCtxCreate(CUcontext* pCtx. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_DEVICE CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. • CU_CTX_SCHED_AUTO: The default value if the Flags parameter is zero. unsigned int Flags. If a context is already current to the thread. This can decrease latency when waiting for the GPU.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemAllocPitch. asynchronous launches. cuMemAllocHost. cuMemset2D 159 . cuMemGetAddressRange. The allocated memory is suitably aligned for any kind of variable. unsigned int count). cuMemFreeHost. cuArrayDestroy.8. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. The memory is not cleared.allocates device memory SYNOPSIS CUresult cuMemAlloc(CUdeviceptr* devPtr. cuArrayCreate. SEE ALSO cuMemGetInfo. If count is 0. cuArrayGetDescriptor.2.6 cuMemAlloc NAME cuMemAlloc . 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. cuMemset. cuMemFree.

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

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

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

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

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

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

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

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

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

cuMemcpy3D 169 . cuMemcpyAtoH. asynchronous launches. cuMemcpyHtoA. 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. cuMemcpyDtoD. cuMemcpyDtoH. cuMemcpyAtoA. cuMemcpyDtoA. cuMemcpyAtoD.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful