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

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

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

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

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

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

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

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

asynchronous launches. SEE ALSO cudaGetDeviceCount. cudaChooseDevice 4 . cudaGetDeviceProperties. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDevice Note that this function may also return error codes from previous. cudaGetDevice.1.2 cudaSetDevice NAME cudaSetDevice .1.sets device to be used for GPU executions SYNOPSIS cudaError_t cudaSetDevice( int dev ) DESCRIPTION Records dev as the device on which the active host thread executes the device code.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemcpy2DToArray. const void* src. cudaMemcpyToArrayAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. cudaMemcpy2D.1. cudaMemcpyArrayToArray. SEE ALSO cudaMemcpy.5. cudaMemcpyHostToDevice. cudaMemcpyFromArray. cudaMemcpy2DFromArray. const void* src. size_t dstY. 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. asynchronous launches. size_t count. size_t dstX. 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.12 cudaMemcpyToArray NAME cudaMemcpyToArray . cudaMemcpyDeviceToHost. enum cudaMemcpyKind kind) cudaError_t cudaMemcpyToArrayAsync(struct cudaArray* dstArray. or cudaMemcpyDeviceToDevice. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cudaMemcpy2DArrayToArray. size_t dstX. cudaMemcpyToSymbol. dstY). size_t count. size_t dstY. and specifies the direction of the copy.copies data between host and device SYNOPSIS cudaError_t cudaMemcpyToArray(struct cudaArray* dstArray. enum cudaMemcpyKind kind. cudaMemcpyFromSymbol 36 .

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

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

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

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

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

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

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

naming a variable that resides in global memory space. symbol can either be a variable that resides in global memory space. SEE ALSO cudaGetSymbolSize 44 .finds the address associated with a CUDA symbol SYNOPSIS template < class T > cudaError_t cudaGetSymbolAddress(void** devPtr. 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. or if symbol is not declared in global memory space. *devPtr is unchanged and an error is returned. If symbol cannot be found.1.20 cudaGetSymbolAddress NAME cudaGetSymbolAddress . const T& symbol) DESCRIPTION Returns in *devPtr the address of symbol symbol on the device. or it can be a character string. asynchronous launches.5.

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

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

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

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

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

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

cudaMalloc3D 51 .SEE ALSO cudaMemset. cudaMemset2D.

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

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

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

SYNOPSIS
CUresult cuModuleGetTexRef(CUtexref* texRef, CUmodule hmod, const char* texrefname);

DESCRIPTION
Returns in *texref the handle of the texture reference of name texrefname in the module mod. If no texture reference of that name exists, cuModuleGetTexRef() returns CUDA_ERROR_NOT_FOUND. This texture reference handle should not be destroyed, since it will be destroyed when the module is unloaded.

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

SEE ALSO
cuModuleLoad, cuModuleLoadData, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

SYNOPSIS
CUresult cuModuleLoad(CUmodule* mod, const char* filename);

DESCRIPTION
Takes a file name filename and loads the corresponding module mod into the current context. The CUDA driver API does not attempt to lazily allocate the resources needed by a module; if the memory for functions and data (constant and global) needed by the module cannot be allocated, cuModuleLoad() fails. The file should be a cubin file as output by nvcc.

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

SEE ALSO
cuModuleLoadData, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

SYNOPSIS
CUresult cuModuleLoadData(CUmodule* mod, const void* image);

DESCRIPTION
Takes a pointer image and loads the corresponding module mod into the current context. The pointer may be obtained by mapping a cubin file, passing a cubin file as a text string, or incorporating a cubin object into the executable resources and using operation system calls such as WindowsâĂŹ FindResource() to obtain the pointer.

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

SEE ALSO
cuModuleLoad, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

SYNOPSIS
CUresult cuModuleLoadFatBinary(CUmodule* mod, const void* fatBin);

DESCRIPTION
Takes a pointer fatBin and loads the corresponding module mod into the current context. The pointer represents a fat binary object, which is a collection of different cubin files, all representing the same device code but compiled and optimized for different architectures. There is currently no documented API for constructing and using fat binary objects by programmers, and therefore this function is an internal function in this version of CUDA. More information can be found in the nvcc document.

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

SEE ALSO
cuModuleLoad, cuModuleLoadData, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

127

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

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

flags is required to be 0. unsigned int flags). At present. cuStreamSynchronize. 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.1 cuStreamCreate NAME cuStreamCreate . cuStreamDestroy 130 .2.5. SEE ALSO cuStreamQuery. asynchronous launches.create a stream SYNOPSIS CUresult cuStreamCreate(CUstream* stream. DESCRIPTION Creates a stream.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuArrayDestroy. cuMemAllocHost.frees page-locked host memory SYNOPSIS CUresult cuMemFreeHost(void* hostPtr). DESCRIPTION Frees the memory space pointed to by hostPtr. cuMemGetAddressRange. cuMemset. cuMemset2D 164 . cuMemAllocPitch. cuArrayCreate.8.10 cuMemFreeHost NAME cuMemFreeHost . cuMemAlloc. which must have been returned by a previous call to cuMemAllocHost(). cuMemFree. asynchronous launches.2. SEE ALSO cuMemGetInfo. 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). cuMemAllocHost. cuMemFreeHost. SEE ALSO cuMemGetInfo. cuMemset2D 165 . 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. Both parameters basePtr and size are optional. cuArrayCreate.8. DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr. asynchronous launches. cuMemAlloc. cuArrayDestroy. If one of them is null. cuMemAllocPitch. it is ignored. cuMemFree. unsigned int* size.11 cuMemGetAddressRange NAME cuMemGetAddressRange .get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. cuMemset. cuArrayGetDescriptor.

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

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

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

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

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

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

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

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

CUarray srcArray. cuMemcpyAtoA. asynchronous launches. cuMemcpyAtoH. 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. srcArray and srcIndex specify the CUDA array handle and the index (in array elements) of the array element where the copy is to begin. unsigned int srcIndex. cuMemcpyDtoD. 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. SEE ALSO cuMemcpyHtoD.8. cuMemcpyDtoA. DESCRIPTION Copies from a 1D CUDA array to device memory.16 cuMemcpyAtoD NAME cuMemcpyAtoD . unsigned int count).copies memory from Array to Device SYNOPSIS CUresult cuMemcpyAtoD(CUdeviceptr dstDevPtr. cuMemcpyDtoH.2. cuMemcpy2D 174 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuGLUnregisterBufferObject 202 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_ALREADY_MAPPED Note that this function may also return error codes from previous.4 cuGLRegisterBufferObject NAME cuGLRegisterBufferObject . DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA. cuGLInit. cuGLMapBufferObject. cuGLUnmapBufferObject.registers a GL buffer object SYNOPSIS CUresult cuGLRegisterBufferObject(GLuint bufferObj). SEE ALSO cuGLCtxCreate. asynchronous launches.10. While it is registered.2. 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.

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

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

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

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

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

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

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

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

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

cuD3D9UnregisterResource. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. asynchronous launches. cuD3D9UnmapResources.6 cuD3D9MapResources NAME cuD3D9MapResources . cuD3D9CtxCreate. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9RegisterResource. IDirect3DResource9 **ppResources). cuD3D9GetDirect3DDevice. Direct3D should not access any resources while they are mapped by CUDA.map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. SEE ALSO cuD3D9GetDevice.11. This function provides the synchronization guarantee that any Direct3D calls issued before cuD3D9MapResources will complete before any CUDA kernels issued after cuD3D9MapResources begin.2. cuD3D9ResourceGetMappedPitch 212 . 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. 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. 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. cuD3D9ResourceGetSurfaceDimensions.

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

unsigned int atomicMin(unsigned int* address. atomicMax. atomicSub.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. and stores the result back to global memory at the same address.1.atomic minimum SYNOPSIS int atomicMin(int* address.1 and higher. atomicDec. unsigned int val). atomicExch. atomicCAS 227 . NOTES Atomic operations are only supported on devices of compute capability 1. int val). atomicInc.4 atomicMin NAME atomicMin . SEE ALSO atomicAdd. computes the minimum of old and val. The function returns b<old>.

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful