NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

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

cudaGetDeviceCount

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

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

1.3

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

1.4

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

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

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

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

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

cudaMallocArray

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

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

i

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

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

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

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

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

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

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

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

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

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

1.8

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

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

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

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

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

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

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

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

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

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

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

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

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

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

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

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

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

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

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

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

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

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

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

2.4

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

iii

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. cudaEventRecord.4. or cudaErrorNotReady if not. cudaEventDestroy.query if an event has been recorded SYNOPSIS cudaError_t cudaEventQuery( cudaEvent_t event ) DESCRIPTION Returns cudaSuccess if the event has actually been recorded.1. SEE ALSO cudaEventCreate. cudaEventElapsedTime 20 . 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. If cudaEventRecord() has not been called on this event.3 cudaEventQuery NAME cudaEventQuery . cudaEventSynchronize.

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. SEE ALSO cudaEventCreate. asynchronous launches.4 cudaEventSynchronize NAME cudaEventSynchronize . cudaEventElapsedTime 21 .1. the function returns cudaErrorInvalidValue.4. cudaEventDestroy. cudaEventRecord. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMalloc3D 51 . cudaMemset2D.SEE ALSO cudaMemset.

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

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

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

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

cudaChannelFormatKindUnsigned. cudaBindTexture. int y. cudaUnbindTexture. 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. and w. cudaBindTextureToArray. cudaChannelFormatKindFloat. w. SEE ALSO cudaGetChannelDesc. cudaGetTextureReference. y. z. cudaGetTextureAlignmentOffset 56 . DESCRIPTION Returns a channel descriptor with format f and number of bits of each component x. int w. asynchronous launches. int z.Low-level texture API SYNOPSIS struct cudaChannelFormatDesc cudaCreateChannelDesc(int x. enum cudaChannelFormatKin f). where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. }. y. enum cudaChannelFormatKind f. z.cudaCreateChannelDesc NAME cudaCreateChannelDesc .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. SEE ALSO cudaGLSetGLDevice.3 cudaGLMapBufferObject NAME cudaGLMapBufferObject . GLuint bufferObj).OpenGL interoperability SYNOPSIS cudaError_t cudaGLMapBufferObject(void** devPtr. cudaGLUnregisterBufferObject 75 . cudaGLRegisterBufferObject. cudaGLUnmapBufferObject.1.8. asynchronous launches.

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

5 cudaD3D9UnregisterResource NAME cudaD3D9UnregisterResource . cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9ResourceGetMappedSize.1. cudaD3D9SetDirect3DDevice. asynchronous launches.9. If pResource is not registered then cudaErrorInvalidHandle is returned. 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. SEE ALSO cudaD3D9GetDevice. cudaD3D9UnmapResources. cudaD3D9RegisterResource. cudaD3D9MapResources. cudaD3D9ResourceGetMappedPitch 84 . DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. cudaD3D9GetDirect3DDevice.

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

1. RETURN VALUE char* pointer to a NULL-terminated string SEE ALSO cudaGetLastError 97 . 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).10.

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

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Returns in *bytes the total amount of memory available on the device dev in bytes.2.2. cuDeviceGetName. cuDeviceGetCount. CUdevice dev ).7 cuDeviceTotalMem NAME cuDeviceTotalMem . cuDeviceGet. SEE ALSO cuDeviceComputeCapability. cuDeviceGetProperties 110 .returns the total amount of memory on the device SYNOPSIS CUresult cuDeviceTotalMem( unsigned int* bytes. cuDeviceGetAttribute. 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_DEVICE Note that this function may also return error codes from previous.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

4 cuArrayGetDescriptor NAME cuArrayGetDescriptor . but need to know the CUDA array parameters for validation or other purposes.2. CUarray array) DESCRIPTION Returns in *arrayDesc a descriptor of the format and dimensions of the 1D or 2D CUDA array array.8.get a 1D or 2D CUDA array descriptor SYNOPSIS CUresult cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR* arrayDesc. cuArray3DCreate. cuArrayDestroy 157 . 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. cuArray3DGetDescriptor. It is useful for subroutines that have been passed a CUDA array. SEE ALSO cuArrayCreate.

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

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

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

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

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

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

If one of them is null. SEE ALSO cuMemGetInfo. cuMemFreeHost.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. cuMemAllocPitch. CUdeviceptr devPtr).11 cuMemGetAddressRange NAME cuMemGetAddressRange . it is ignored. cuMemset2D 165 . cuMemFree. Both parameters basePtr and size are optional. asynchronous launches. cuArrayCreate.8. 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. cuArrayDestroy. DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr. cuArrayGetDescriptor. cuMemAlloc.2. cuMemset. unsigned int* size.

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

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

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

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

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

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

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

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

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

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

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

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

cuMemcpyAtoA.copies memory from Device to Host SYNOPSIS CUresult cuMemcpyDtoH(void* dstHostPtr. dstHostPtr and srcDevPtrspecify the base addresses of the source and destination. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. asynchronous launches. cuMemcpyDtoA. unsigned int count. DESCRIPTION Copies from device to host memory. MemcpyDtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. unsigned int count).20 cuMemcpyDtoH NAME cuMemcpyDtoH . SEE ALSO cuMemcpyHtoD. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. CUdeviceptr srcDevPtr. cuMemcpyDtoD. countspecifies the number of bytes to copy. respectively. cuMemcpyAtoH.2.8. CUresult cuMemcpyDtoHAsync(void* dstHostPtr. cuMemcpyAtoD. cuMemcpy2D 178 . cuMemcpyHtoA. CUstream stream). CUdeviceptr srcDevPtr.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cuTexRefCreate. cuTexRefGetFilterMode. cuTexRefDestroy. cuTexRefSetAddressMode. format and numPackedComponents are exactly analogous to the Format and NumChannels members of the CUDA_ARRAY_DESCRIPTOR structure: They specify the format of each component and the number of components per array element. cuTexRefGetAddressMode. cuTexRefGetFlags 197 . asynchronous launches.9. cuTexRefSetAddress. cuTexRefSetArray.14 cuTexRefSetFormat NAME cuTexRefSetFormat . cuTexRefSetFlags. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetFilterMode.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. CUarray_format format.2. cuTexRefGetAddress. cuTexRefGetArray. cuTexRefGetFormat.

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

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

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

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

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

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

2.10. 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. cuGLInit. cuGLMapBufferObject. DESCRIPTION Unregisters the buffer object of ID bufferObj for access by CUDA.unregister a GL buffer object SYNOPSIS CUresult cuGLUnregisterBufferObject(GLuint bufferObj). cuGLRegisterBufferObject. cuGLUnmapBufferObject 204 .6 cuGLUnregisterBufferObject NAME cuGLUnregisterBufferObject . SEE ALSO cuGLCtxCreate.

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

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

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

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

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

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

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

Direct3D should not access any resources while they are mapped by CUDA. cuD3D9GetDirect3DDevice. This function provides the synchronization guarantee that any Direct3D calls issued before cuD3D9MapResources will complete before any CUDA kernels issued after cuD3D9MapResources begin.11. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned. 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. If any of ppResources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. cuD3D9UnmapResources. asynchronous launches. cuD3D9ResourceGetMappedPitch 212 . cuD3D9CtxCreate.6 cuD3D9MapResources NAME cuD3D9MapResources . SEE ALSO cuD3D9GetDevice. The resources in ppResources may be accessed in CUDA kernels until they are unmapped.2. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. IDirect3DResource9 **ppResources). cuD3D9RegisterResource. cuD3D9ResourceGetSurfaceDimensions. cuD3D9UnregisterResource. If an application does so the results are undefined. cuD3D9ResourceSetMapFlags.

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

For all other types Level must be 0. If Level is invalid then CUDA_ERROR_INVALID_VALUE is returned. 217 . If Face is invalid then CUDA_ERROR_INVALID_V is returned.11. asynchronous launches. unsigned int Level). IDirect3DResource9* pResource. unsigned int Face.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. At present only mipmap level 0 is supported. The value set in pDevPtr may change every time that pResource is mapped.2. DESCRIPTION Returns in *pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. For all other types Face must be 0. 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. 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.10 cuD3D9ResourceGetMappedPointer NAME cuD3D9ResourceGetMappedPointer . If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. If pResource is not mapped then CUDA_ERROR_NOT_MAPPED is returned. If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful