NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

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

cudaGetDeviceCount

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

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

1.3

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

1.4

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

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

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

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

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

cudaMallocArray

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

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

i

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

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

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

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

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

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

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

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

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

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

1.8

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

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

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

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

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

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

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

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

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

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

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

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

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

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

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

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

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

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

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

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

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

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

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

2.4

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

iii

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Direct3D Interoperability. OpenGL Interoperability. Texture Reference Management. Error Handling 72 . Memory Management. Stream 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. Execution Management. Event Management.1. Thread Management.

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

2 cudaGLRegisterBufferObject NAME cudaGLRegisterBufferObject . SEE ALSO cudaGLSetGLDevice.1. cudaGLUnregisterBufferObject 74 . While it is registered. cudaGLUnmapBufferObject. asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess cudaErrorNotInitialized Note that this function may also return error codes from previous.OpenGL interoperability SYNOPSIS cudaError_t cudaGLRegisterBufferObject(GLuint bufferObj) DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA. 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.8. cudaGLMapBufferObject.

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. For all other types Face must be 0. cudaD3D9UnregisterResource. SEE ALSO cudaD3D9GetDevice. The value set in pPointer may change every time that pResource is mapped. If pResource is not mapped then cudaErrorUnknown is returned. Only mipmap level 0 is supported for now. cudaD3D9UnmapResources. If Face is invalid then cudaErrorInvalidValue is returned.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. cudaD3D9ResourceGetMappedPitch 90 . If Level is invalid then cudaErrorInvalidValue is returned. For all other types Level must be 0. cudaD3D9GetDirect3DDevice. IDirect3DResource9* pResource. cudaD3D9ResourceGetMappedSize.1. If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. If pResource is not registered then cudaErrorInvalidHandle is returned. asynchronous launches. cudaD3D9MapResources. cudaD3D9RegisterResource. unsigned int Level). cudaD3D9ResourceGetSurfaceDimensio cudaD3D9ResourceSetMapFlags. If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level.10 cudaD3D9ResourceGetMappedPointer NAME cudaD3D9ResourceGetMappedPointer . 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. unsigned int Face.9. cudaD3D9SetDirect3DDevice.

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. cuParamSeti. cuParamSetv. cuLaunchGrid 150 . cuParamSetf. unsigned int bytes). DESCRIPTION Sets through bytes the amount of shared memory that will be available to each thread block when the kernel given by func is launched. cuParamSetTexRef.2.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. SEE ALSO cuFuncSetBlockShape. cuParamSetSize. cuLaunch.7.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemcpyHtoA. count specifies the number of bytes to copy. SEE ALSO cuMemcpyHtoD. cuMemcpyAtoA. respectively. cuMemcpyAtoH. cuMemcpy2D 177 . cuMemcpyDtoH. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. CUdeviceptr srcDevPtr. unsigned int count).8. DESCRIPTION Copies from device memory to device memory.2. cuMemcpyDtoA. dstDevice and srcDevPtr are the base pointers of the destination and source. cuMemcpyAtoD.19 cuMemcpyDtoD NAME cuMemcpyDtoD . asynchronous launches.copies memory from Device to Device SYNOPSIS CUresult cuMemcpyDtoD(CUdeviceptr dstDevPtr.

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

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

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

cuArrayGetDescriptor. SEE ALSO cuMemGetInfo. unsigned short value.initializes device memory SYNOPSIS CUresult cuMemsetD8(CUdeviceptr dstDevPtr. unsigned int count ). CUresult cuMemsetD32(CUdeviceptr dstDevPtr. cuArrayDestroy. unsigned int count ). cuMemFree. 16-. unsigned char value. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemAllocHost. cuMemAlloc.8. cuMemGetAddressRange. cuMemAllocPitch. DESCRIPTION Sets the memory range of count 8-.2. asynchronous launches. unsigned int value. unsigned int count ).23 cuMemset NAME cuMemset . CUresult cuMemsetD16(CUdeviceptr dstDevPtr. cuArrayCreate. or 32-bit values to the specified value value. cuMemset2D 181 . 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. cuMemGetAddressRange.2. cuArrayCreate. DESCRIPTION Sets the 2D memory range of width 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(). cuArrayDestroy.initializes device memory SYNOPSIS CUresult cuMemsetD2D8(CUdeviceptr dstDevPtr. or 32-bit values to the specified value value. unsigned int value. cuMemAlloc. unsigned short value. CUresult cuMemsetD2D32(CUdeviceptr dstDevPtr. asynchronous launches.8. unsigned int width. cuArrayGetDescriptor. unsigned char value. unsigned int dstPitch. cuMemFreeHost. cuMemFree. cuMemset 182 . and dstPitch specifies the number of bytes between each row. 16-. SEE ALSO cuMemGetInfo. unsigned int height ). cuMemAllocHost. unsigned int dstPitch. unsigned int width. unsigned int height ). unsigned int dstPitch. unsigned int height ). CUresult cuMemsetD2D16(CUdeviceptr dstDevPtr.24 cuMemset2D NAME cuMemset2D . unsigned int width. cuMemAllocPitch.

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

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

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

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

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

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

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

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

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

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

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

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

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

9. which suppresses the default behavior of having the texture promote integer data to floating point data in the range [0. cuTexRefSetAddressMode. The valid flags are: • CU_TRSF_READ_AS_INTEGER. unsigned int Flags). 1]. cuTexRefSetFormat. • CU_TRSF_NORMALIZED_COORDINATES. SEE ALSO cuTexRefCreate. cuTexRefSetArray. cuTexRefSetFilterMode. asynchronous launches. cuTexRefGetFormat. DESCRIPTION Specifies optional flags to control the behavior of data returned through the texture reference. 1.2. cuTexRefGetAddress.sets flags for a texture-reference SYNOPSIS CUresult cuTexRefSetFlags(CUtexref texRef. Instead. cuTexRefGetFlags 196 . which suppresses the default behavior of having the texture coordinates range from [0. cuTexRefDestroy. cuTexRefSetAddress. Dim) where Dim is the width or height of the CUDA array. cuTexRefGetFilterMode.0) reference the entire breadth of the array dimension RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetAddressMode.13 cuTexRefSetFlags NAME cuTexRefSetFlags . the texture coordinates [0. cuTexRefGetArray.

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

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

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

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

cuGLUnmapBufferObject. cuGLRegisterBufferObject. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous. 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. cuGLInit. asynchronous launches.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr.3 cuGLMapBufferObject NAME cuGLMapBufferObject . GLuint bufferObj).10. cuGLUnregisterBufferObject 201 . unsigned int* size.2. SEE ALSO cuGLCtxCreate.

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

BitwiseFunctions 222 .3 AtomicFunctions NAME Atomic Functions DESCRIPTION Atomic functions can only be used in device functions.1 and higher. SEE ALSO ArithmeticFunctions.2 and higher. 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.

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful