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

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

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

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

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

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

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

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

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

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

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

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

5 cudaChooseDevice NAME cudaChooseDevice .1. cudaGetDeviceProperties 8 . SEE ALSO cudaGetDeviceCount.1. asynchronous launches. cudaGetDevice. const struct cudaDeviceProp* prop ) DESCRIPTION Returns in *dev the device which properties best match *prop. cudaSetDevice. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

If a CUDA array is participating in the copy the extent is defined in terms of that array’s elements. positions must be in the range [0. It must be one of cudaMemcpyHostToHost. y. struct cudaPos dstPos. struct cudaArray *dstArray. The source and destination objects may be in either host memory. struct cudaExtent extent. cudaStream_t stream ) DESCRIPTION cudaMemcpy3D() copies data betwen two 3D objects. cudaMemcpyHostToDevice. or cudaMemcpyDeviceToDevice. Passing more than one non-zero source or destination will cause cudaMemcpy3D() to return an error. device memory. The kind field defines the direction of the copy. struct cudaPitchedPtr dstPtr.5. If no CUDA array is participating in the copy then the extents are defined in elements of unsigned char.copies data between between 3D objects SYNOPSIS struct cudaExtent { size_t width. enum cudaMemcpyKind kind.1. cudaError_t cudaMemcpy3D( const struct cudaMemcpy3DParms *p ) cudaError_t cudaMemcpy3DAsync( const struct cudaMemcpy3DParms *p. cudaMemcpyDeviceToHost. or a CUDA array. 2048) for any dimension. For CUDA arrays. The element for a host or device pointer is assumed to be unsigned char. and kind of copy performed is specified by the cudaMemcpy3DParms struct which should be initialized to zero before use: cudaMemcpy3DParms myParms = {0}. The struct passed to cudaMemcpy3D() must specify one of srcArray or srcPtr and one of dstArray or dstPtr. The extent field defines the dimensions of the transferred area in elements. 52 . struct cudaPitchedPtr srcPtr. }. }. struct cudaPos { size_t x. struct cudaPos srcPos. struct cudaMemcpy3DParms { struct cudaArray *srcArray. The source. extent. height. destination. z.25 cudaMemcpy3D NAME cudaMemcpy3D . depth. 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 the source and destination are both arrays cudaMemcpy3D() will return an error if they do not have the same element size. cudaMemcpyFromSymbol 53 . The pitch of a cudaPitchedPtr allocated with cudaMalloc3D() will always be valid. The source and destination object may not overlap. If overlapping source and destination objects are specified undefined behavior will result. cudaMemcpy3D() returns an error if the pitch of srcPtr or dstPtr is greater than the maximum allowed. cudaMemcpyArrayToArray. cudaMemcpy. If either the source or destination is a host object it must be allocated in page-locked memory returned from cudaMallocHost(). cudaMemcpyToArray. cudaMalloc3DArray. It will return an error if a pointer to memory not allocated with cudaMallocHost() is passed as input. cudaMemset3D. cudaMemcpy2DArrayToArray. cudaMemcpyFromArray. cudaMemcpy2DToArray. cudaMemcpy3DAsync() is an asynchronous copy operation and can optionally be associated to a stream by passing a non-zero stream argument. cudaMemcpy2DFromArray. RETURN VALUE cudaSuccess SEE ALSO cudaMalloc3D. cudaMemcpyToSymbol.

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

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

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

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

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

cudaGetTextureReference.Low-level texture API SYNOPSIS cudaError_t cudaBindTexture(size_t* offset. cudaGetTextureAlignmentOffset 59 . cudaGetChannelDesc. const struct cudaChannelFormatDesc* desc. size_t size = UINT_MAX). DESCRIPTION Binds size bytes of the memory area pointed to by devPtr to the texture reference texRef. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function. 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(). SEE ALSO cudaCreateChannelDesc.cudaBindTexture NAME cudaBindTexture . Any memory previously bound to texRef is unbound. desc describes how the memory is interpreted when fetching values from the texture. cudaBindTexture() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. cudaUnbindTexture. the offset is guaranteed to be 0 and NULL may be passed as the offset parameter. asynchronous launches. Since the hardware enforces an alignment requirement on texture base addresses. const struct textureReference* texRef. cudaBindTextureToArray.

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

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

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

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

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

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

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

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

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

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

asynchronous launches.1. 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 .2 cudaLaunch NAME cudaLaunch . or it can be a character string. naming a function that executes on the device. entry must be declared as a __global__ function. SEE ALSO cudaConfigureCall.launches a device function SYNOPSIS template < class T > cudaError_t cudaLaunch(T entry) DESCRIPTION Launches the function entry on the device.7. entry can either be a function that executes on the device. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous.

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

*pHeight. cudaD3D9SetDirect3DDevice.9 cudaD3D9ResourceGetSurfaceDimensions NAME cudaD3D9ResourceGetSurfaceDimensions . size_t* pHeight. and pDepth are optional. unsigned int Face. cudaD3D9ResourceGetMappedPitch 89 . pHeight. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle Note that this function may also return error codes from previous. cudaD3D9ResourceSetMapFlags. SEE ALSO cudaD3D9GetDevice. cudaD3D9UnregisterResource. The parameters pWidth. For 2D surfaces. unsigned int Level). DESCRIPTION Returns in *pWidth. If pResource is not of type IDirect3DBaseTexture9 or IDirect3DSurface9 or if pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. size_t *pDepth.get the dimensions of a registered surface SYNOPSIS cudaError_t cudaD3D9ResourceGetSurfaceDimensions(size_t* pWidth. the value returned in *pDepth will be 0. cudaD3D9UnmapResources. cudaD3D9MapResources. cudaD3D9ResourceGetMappedSize. IDirect3DResource9* pResource. cudaD3D9ResourceGetMappedPointer. cudaD3D9RegisterResource.1.9. and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. asynchronous launches. cudaD3D9GetDirect3DDevice. Because anti-aliased surfaces may have multiple samples per pixel it is possible that the dimensions of a resource will be an integer factor larger than the dimensions reported by the Direct3D runtime.

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

cuDeviceGet.7 cuDeviceTotalMem NAME cuDeviceTotalMem . SEE ALSO cuDeviceComputeCapability. cuDeviceGetProperties 110 .returns the total amount of memory on the device SYNOPSIS CUresult cuDeviceTotalMem( unsigned int* bytes. cuDeviceGetName. cuDeviceGetCount. 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. cuDeviceGetAttribute. asynchronous launches. DESCRIPTION Returns in *bytes the total amount of memory available on the device dev in bytes.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

create a stream SYNOPSIS CUresult cuStreamCreate(CUstream* stream. cuStreamSynchronize. unsigned int flags). cuStreamDestroy 130 .1 cuStreamCreate NAME cuStreamCreate . asynchronous launches. At present. flags is required to be 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_OUT_OF_MEMORY Note that this function may also return error codes from previous.2. DESCRIPTION Creates a stream. SEE ALSO cuStreamQuery.5.

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

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. DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed. cuStreamSynchronize. asynchronous launches. cuStreamDestroy 132 .3 cuStreamQuery NAME cuStreamQuery . or CUDA_ERROR_NOT_READY if not. SEE ALSO cuStreamCreate.determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream).5.2.

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

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

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

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

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

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

cuEventQuery. DESCRIPTION Records an event. CUstream stream). cuEventSynchronize.2. the event is recorded after all preceding operations in the stream have been completed. If stream is non-zero. otherwise. SEE ALSO cuEventCreate. Since this operation is asynchronous.records an event SYNOPSIS CUresult cuEventRecord(CUevent event.5 cuEventRecord NAME cuEventRecord . If cuEventRecord() has previously been called and the event has not been recorded yet. it is recorded after all preceding operations in the CUDA context have been completed. cuEventQuery() and/or cuEventSynchronize() must be used to determine when the event has actually been recorded. cuEventDestroy.6. cuEventElapsedTime 139 . this 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_INVALID_VALUE Note that this function may also return error codes from previous. asynchronous launches.

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

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

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

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

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

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

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

asynchronous launches. int offset. cuParamSetf. cuFuncSetSharedSize. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuLaunch. SEE ALSO cuFuncSetBlockShape.adds an integer parameter to the function’s argument list SYNOPSIS CUresult cuParamSeti(CUfunction func. 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. cuParamSetSize.7. cuParamSetTexRef.6 cuParamSeti NAME cuParamSeti . unsigned int value). cuParamSetv. cuLaunchGrid 147 .2.

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

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

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

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

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

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

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

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

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

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

but need to know the CUDA array parameters for validation or other purposes. cuArray3DCreate.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_INVALID_HANDLE Note that this function may also return error codes from previous.5 cuArray3DGetDescriptor NAME cuArray3DGetDescriptor . SEE ALSO cuArrayCreate. cuArrayDestroy 158 . cuArrayGetDescriptor. It is useful for subroutines that have been passed a CUDA array. DESCRIPTION Returns in *arrayDesc a descriptor containing information on the format and dimensions of the CUDA array array. CUarray array). asynchronous launches.get a 3D CUDA array descriptor SYNOPSIS CUresult cuArray3DGetDescriptor(CUDA_ARRAY3D_DESC *arrayDesc.2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefSetFlags. DESCRIPTION Binds a linear address range to the texture reference texRef.2. SEE ALSO cuTexRefCreate.9. Any memory previously bound to texRef is unbound. cuTexRefGetFormat. If the device memory pointer was returned from cuMemAlloc(). CUtexref texRef. cuTexRefGetFilterMode. CUdeviceptr devPtr. cuTexRefGetAddressMode. cuTexRefGetAddress.binds an address as a texture-reference SYNOPSIS CUresult cuTexRefSetAddress(unsigned int* byteOffset. cuTexRefGetArray. 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. 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. Any previous address or CUDA array state associated with the texture reference is superseded by this function. cuTexRefSetAddressMode. int bytes). cuTexRefSetArray. Since the hardware enforces an alignment requirement on texture base addresses. asynchronous launches. cuTexRefSetAddress() passes back a byte offset in *byteOffset 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 ByteOffset parameter. cuTexRefDestroy.9 cuTexRefSetAddress NAME cuTexRefSetAddress . cuTexRefSetFilterMode. cuTexRefGetFlags 192 .

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

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

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

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

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

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

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

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

unsigned int* size.3 cuGLMapBufferObject NAME cuGLMapBufferObject . SEE ALSO cuGLCtxCreate. cuGLRegisterBufferObject.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. cuGLUnmapBufferObject. cuGLInit.10. cuGLUnregisterBufferObject 201 . asynchronous launches. GLuint bufferObj). 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. 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.2.

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

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

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

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

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

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

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

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

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

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

map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. cuD3D9UnmapResources.6 cuD3D9MapResources NAME cuD3D9MapResources .2. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. asynchronous launches. If an application does so the results are undefined. cuD3D9GetDirect3DDevice. cuD3D9ResourceGetMappedPitch 212 . Direct3D should not access any resources while they are mapped by CUDA. cuD3D9ResourceGetSurfaceDimensions. SEE ALSO cuD3D9GetDevice. cuD3D9UnregisterResource. 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. This function provides the synchronization guarantee that any Direct3D calls issued before cuD3D9MapResources will complete before any CUDA kernels issued after cuD3D9MapResources begin. cuD3D9RegisterResource. If any of ppResources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.11. 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. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9ResourceSetMapFlags. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. cuD3D9CtxCreate. 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 pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level. For all other types Level must be 0. If Face is invalid then CUDA_ERROR_INVALID_V is returned.2. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. If pResource is not mapped then CUDA_ERROR_NOT_MAPPED is returned. IDirect3DResource9* pResource. DESCRIPTION Returns in *pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. The value set in pDevPtr may change every time that pResource is mapped. If Level is invalid then CUDA_ERROR_INVALID_VALUE is returned. For all other types Face must be 0. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVA is returned.get a pointer through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS CUresult cuD3D9ResourceGetMappedPointer(CUdeviceptr* pDevPtr. 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. At present only mipmap level 0 is supported. asynchronous launches. unsigned int Face.10 cuD3D9ResourceGetMappedPointer NAME cuD3D9ResourceGetMappedPointer . 217 . unsigned int Level). If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES.11.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful