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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. int value.5.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.1.8 cudaMemset NAME cudaMemset . SEE ALSO cudaMemset2D. cudaMemset3D 32 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMalloc3D 51 . cudaMemset2D.SEE ALSO cudaMemset.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer. cudaD3D9GetDirect3DDevice. If pResource is not registered then cudaErrorInvalidHandle is returned. cudaD3D9MapResources. SEE ALSO cudaD3D9GetDevice. cudaD3D9RegisterResource. cudaD3D9ResourceGetMappedSize. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidHandle cudaErrorUnknown 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.5 cudaD3D9UnregisterResource NAME cudaD3D9UnregisterResource .9. cudaD3D9SetDirect3DDevice. cudaD3D9ResourceGetMappedPitch 84 . cudaD3D9ResourceGetSurfaceDimensions.unregister a Direct3D resource SYNOPSIS cudaError_t cudaD3D9UnregisterResource(IDirect3DResource9* pResource). cudaD3D9UnmapResources. asynchronous launches.1.

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

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

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

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

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

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

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

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

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

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

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.10.1 cudaGetLastError NAME cudaGetLastError .1. 95 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorLaunchFailure cudaErrorPriorLaunchFailure cudaErrorLaunchTimeout cudaErrorLaunchOutOfResources cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration cudaErrorInvalidDevice cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture cudaErrorInvalidTextureBinding cudaErrorInvalidChannelDescriptor cudaErrorTextureFetchFailed cudaErrorTextureNotBound cudaErrorSynchronizationError cudaErrorUnknown cudaErrorInvalidResourceHandle cudaErrorNotReady Note that this function may also return error codes from previous asynchronous launches.

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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). cuCtxSynchronize 112 .increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxAttach() fails if there is no context current to the thread.3.1 cuCtxAttach NAME cuCtxAttach . the Flags parameter must be 0. asynchronous launches. cuCtxGetDevice. cuCtxDetach. Currently. SEE ALSO cuCtxCreate.2. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3 cuStreamQuery NAME cuStreamQuery . SEE ALSO cuStreamCreate.determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream).2. or CUDA_ERROR_NOT_READY if not. cuStreamDestroy 132 .5. asynchronous launches. cuStreamSynchronize. DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed. 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 Blocks until the device has completed all operations in the stream.2. asynchronous launches. cuStreamDestroy 133 . 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.4 cuStreamSynchronize NAME cuStreamSynchronize .block until a stream’s tasks are completed SYNOPSIS CUresult cuStreamSynchronize(CUstream stream).5. SEE ALSO cuStreamCreate. cuStreamQuery.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefSetFilterMode.9.2. cuTexRefGetFilterMode. cuTexRefSetAddressMode. cuTexRefSetFlags.gets the array bound to a texture-reference SYNOPSIS CUresult cuTexRefGetArray(CUarray* array. cuTexRefDestroy. cuTexRefSetAddress. SEE ALSO cuTexRefCreate. CUtexref texRef). cuTexRefGetFormat.5 cuTexRefGetArray NAME cuTexRefGetArray . DESCRIPTION Returns in *array the CUDA array bound by the texture reference texRef. cuTexRefSetFormat. cuTexRefGetFlags 188 . 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. cuTexRefSetArray. or returns CUDA_ERROR_INVALID_VAL if the texture reference is not bound to any CUDA array. asynchronous launches. cuTexRefGetAddress.

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

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

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

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

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

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

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

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

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

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

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

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

3 cuGLMapBufferObject NAME cuGLMapBufferObject .2.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. cuGLUnregisterBufferObject 201 . cuGLUnmapBufferObject. asynchronous launches. unsigned int* size. GLuint bufferObj). SEE ALSO cuGLCtxCreate. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping.10. cuGLInit. cuGLRegisterBufferObject.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful