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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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 .

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

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

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

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

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

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

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

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

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

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

int dim.cudaBindTextureToArray HL NAME cudaBindTextureToArray . readMode E<gt>& texRef.High-level texture API SYNOPSIS template < class T. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture < T. Any CUDA array previously bound to texRef is unbound. dim. int dim. const struct cudaArray* cuArray. The channel descriptor is inherited from the CUDA array. template E<lt> class T. const struct cudaChannelFormatDesc& desc) DESCRIPTION Binds the CUDA array array to texture reference texRef. asynchronous launches. enum cudaTextureReadMode readMode E<gt> static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture E<lt> T. 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. binds the CUDA array array to texture reference texRef. Any CUDA array previously bound to texRef is unbound. dim. readMode >& texRef. SEE ALSO cudaCreateChannelDesc_HL 66 .

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

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

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

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

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

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

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

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

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

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. SEE ALSO cudaGLSetGLDevice. cudaGLUnregisterBufferObject 76 .8. cudaGLMapBufferObject. cudaGLRegisterBufferObject. asynchronous launches.OpenGL interoperability SYNOPSIS cudaError_t cudaGLUnmapBufferObject(GLuint bufferObj).4 cudaGLUnmapBufferObject NAME cudaGLUnmapBufferObject .1.

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

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

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

cudaD3D9UnregisterResource. asynchronous launches.g. cudaD3D9MapResources. cudaD3D9ResourceGetSurfaceDimensions. SEE ALSO cudaD3D9GetDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous.• Surfaces of depth or stencil formats cannot be shared. cudaD3D9SetDirect3DDevice. cudaD3D9ResourceGetMappedPitch 83 . 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. cudaD3D9UnmapResources. cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer. If pResource is of incorrect type (e. If pResource cannot be registered then cudaErrorUnknown is returned. cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetMappedSize.

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

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

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

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

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

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

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

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

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

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

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

1. 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. 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.10.

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

SEE ALSO cuDeviceGetAttribute. cuDeviceGetCount.2. DESCRIPTION Returns in *major and *minor the major and minor revision numbers that define the compute capability of device dev. cuDeviceGetName. 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. cuDeviceGet. cuDeviceTotalMem 102 .1 cuDeviceComputeCapability NAME cuDeviceComputeCapability . asynchronous launches.2. int* minor. cuDeviceGetProperties.returns the compute capability of the device SYNOPSIS CUresult cuDeviceComputeCapability(int* major.

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

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

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

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

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

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

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

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

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

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

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

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

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

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.2. cuCtxDestroy.3. asynchronous launches. The context must be a handle that was passed back by cuCtxCreate() or cuCtxAttach(). cuCtxPushCurrent. cuCtxPopCurrent 116 .4 cuCtxDetach NAME cuCtxDetach . and must be current to the calling thread. SEE ALSO cuCtxCreate.decrement a context’s usage-count SYNOPSIS CUresult cuCtxDetach(CUcontext ctx). cuCtxAttach. DESCRIPTION Decrements the usage count of 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.return device-ID for current context SYNOPSIS CUresult cuCtxGetDevice(CUdevice* device). SEE ALSO cuCtxCreate. asynchronous launches.5 cuCtxGetDevice NAME cuCtxGetDevice .2. cuCtxAttach.3. DESCRIPTION Returns in *device the ordinal of the current context’s device. cuCtxSynchronize 117 . cuCtxDetach.

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cuStreamCreate. DESCRIPTION Blocks until the device has completed all operations in the stream. cuStreamDestroy 133 .5.2. cuStreamQuery.4 cuStreamSynchronize NAME cuStreamSynchronize . 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.block until a stream’s tasks are completed SYNOPSIS CUresult cuStreamSynchronize(CUstream stream).

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Sets through numbytes the total size in bytes needed by the function parameters of function func.sets the parameter-size for the function SYNOPSIS CUresult cuParamSetSize(CUfunction func.7. cuParamSetv. SEE ALSO cuFuncSetBlockShape. cuParamSetf. asynchronous launches. cuLaunchGrid 144 .3 cuParamSetSize NAME cuParamSetSize .2. 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. cuParamSeti. unsigned int numbytes). cuParamSetTexRef. cuFuncSetSharedSize.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuGLInit. cuGLRegisterBufferObject. SEE ALSO cuGLCtxCreate. 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_MAP_FAILED Note that this function may also return error codes from previous. cuGLUnmapBufferObject.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr.2. GLuint bufferObj). unsigned int* size. cuGLUnregisterBufferObject 201 .10. 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.3 cuGLMapBufferObject NAME cuGLMapBufferObject .

the buffer object cannot be used by any OpenGL commands except as a data source for OpenGL drawing commands. While it is registered.registers a GL buffer object SYNOPSIS CUresult cuGLRegisterBufferObject(GLuint bufferObj). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_ALREADY_MAPPED Note that this function may also return error codes from previous.4 cuGLRegisterBufferObject NAME cuGLRegisterBufferObject . asynchronous launches.2. SEE ALSO cuGLCtxCreate. cuGLUnregisterBufferObject 202 . DESCRIPTION Registers the buffer object of ID bufferObj for access by CUDA. cuGLUnmapBufferObject. This function must be called before CUDA can map the buffer object.10. cuGLMapBufferObject. cuGLInit.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

DESCRIPTION
This section describes the atomic bitwise functions. atomicAnd atomicOr atomicXor

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

SYNOPSIS
int atomicAnd(int* address, int val); unsigned int atomicAnd(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old & val), and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

SYNOPSIS
int atomicOr(int* address, int val); unsigned int atomicOr(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old , and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

SYNOPSIS
int atomicXor(int* address, int val); unsigned int atomicXor(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old ˆ val), and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful