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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

this function is best used sparingly to allocate staging areas for data exchange between host and device. cudaMallocPitch. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as cudaMemcpy*(). it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). cudaFreeArray. cudaFreeHost 30 . As a result.6 cudaMallocHost NAME cudaMallocHost . 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. since it reduces the amount of memory available to the system for paging. cudaFree. asynchronous launches. cudaMallocArray.1. SEE ALSO cudaMalloc. Allocating excessive amounts of memory with cudaMallocHost() may degrade system performance.5. size_t size ) DESCRIPTION Allocates size bytes of host memory that is page-locked and accessible to the device.allocates page-locked memory on the host SYNOPSIS cudaError_t cudaMallocHost( void** hostPtr.

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

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

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

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

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

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

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

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

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

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

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

size_t count. naming a variable that resides in global or constant memory space. or it can be a character string.copies data from host memory to GPU SYNOPSIS template < class T > cudaError_t cudaMemcpyToSymbol( const T& symbol. cudaMemcpy2D. cudaMemcpy2DFromArray. cudaMemcpyFromSymbol 42 . symbol can either be a variable that resides in global or constant memory space. cudaMemcpy2DToArray. asynchronous launches. const void* src. 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. cudaMemcpyArrayToArray. size_t offset.1. 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.18 cudaMemcpyToSymbol NAME cudaMemcpyToSymbol . The memory areas may not overlap. cudaMemcpyFromArray. cudaMemcpy2DArrayToArray. cudaMemcpyToArray.5.

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

3 cuStreamQuery NAME cuStreamQuery .5. cuStreamSynchronize. or CUDA_ERROR_NOT_READY if not. DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed.2.determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream). cuStreamDestroy 132 . 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. SEE ALSO cuStreamCreate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Sets an integer parameter that will be specified the next time the kernel corresponding to func will be invoked. cuParamSetf.7. cuLaunch. cuParamSetv. unsigned int value). asynchronous launches. cuParamSetTexRef. cuFuncSetSharedSize.2. cuLaunchGrid 147 .6 cuParamSeti NAME cuParamSeti .adds an integer parameter to the function’s argument list SYNOPSIS CUresult cuParamSeti(CUfunction func. offset is a byte offset. int offset. 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. SEE ALSO cuFuncSetBlockShape.

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

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. cuParamSetv.2. int z). cuParamSetf. cuLaunchGrid 149 . asynchronous launches. int x.7. DESCRIPTION Specifies the X. cuParamSeti. int y.8 cuFuncSetBlockShape NAME cuFuncSetBlockShape . SEE ALSO cuFuncSetSharedSize.sets the block-dimensions for the function SYNOPSIS CUresult cuFuncSetBlockShape(CUfunction func. cuLaunch. cuParamSetSize. cuParamSetTexRef.

cuLaunchGrid 150 . SEE ALSO cuFuncSetBlockShape. asynchronous launches. cuParamSetTexRef. cuParamSetf. cuParamSetv.2.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize .sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. 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. cuLaunch.7. cuParamSeti. unsigned int bytes). DESCRIPTION Sets through bytes the amount of shared memory that will be available to each thread block when the kernel given by func is launched.

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

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

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

and threedimensional otherwise. CU_AD_FORMAT_SIGNED_INT8 = 0x08. • Format specifies the format of the elements. CUarray_format is defined as such: typedef enum CUarray_format_enum { CU_AD_FORMAT_UNSIGNED_INT8 = 0x01. CU_AD_FORMAT_SIGNED_INT16 = 0x09. the CUDA array is one-dimensional if height and depth are 0. height and depth of the CUDA array (in elements). } CUDA_ARRAY3D_DESCRIPTOR. unsigned int Height. Here are examples of CUDA array descriptions: 154 . Height and Depth are the width. CU_AD_FORMAT_UNSIGNED_INT32 = 0x03. 2 or 4. CU_AD_FORMAT_UNSIGNED_INT16 = 0x02. unsigned int Flags. The CUDA_ARRAY3D_DESCRIPTOR structure is defined as such: typedef struct { unsigned int Width. • Flags provides for future features. CU_AD_FORMAT_HALF = 0x10. const CUDA_ARRAY3D_DESCRIPTOR* desc).. where: • Width. unsigned int Depth. CU_AD_FORMAT_SIGNED_INT32 = 0x0a.8. it must be set to 0. two-dimensional if depth is 0. For now. unsigned int NumChannels. it may be 1. • NumChannels specifies the number of packed components per CUDA array element. CU_AD_FORMAT_FLOAT = 0x20 } CUarray_format. CUarray_format Format. DESCRIPTION Creates a CUDA array according to the CUDA_ARRAY3D_DESCRIPTOR structure desc and returns a handle to the new CUDA array in *array.2 cuArray3DCreate NAME cuArray3DCreate .2.creates a CUDA array SYNOPSIS CUresult cuArray3DCreate(CUarray* 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_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. desc. asynchronous launches. desc. cuMemFreeHost.Width = 2048.Format = CU_AD_FORMAT_FLOAT.Width = width. cuMemGetAddressRange. SEE ALSO cuMemGetInfo. desc.Depth = depth. desc. cuArrayDestroy 155 .Depth = 0. desc. desc. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc.Width = 64.Height = height. cuMemAllocHost.NumChannels = 4.Height = 0. cuMemAlloc. desc.NumChannels = 1. cuArray3DGetDescriptor. desc.Format = CU_AD_FORMAT_FLOAT. cuMemFree. desc.Depth = 0. desc.NumChannels = 1.Height = 64. • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY3D_DESCRIPTOR desc. cuMemAllocPitch. • Description for a width x height x depth CUDA array of 64-bit. desc. desc.FormatFlags = CU_AD_FORMAT_HALF.• Description for a CUDA array of 2048 floats: CUDA_ARRAY3D_DESCRIPTOR desc. desc. desc. desc.

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

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

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

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

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

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

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

2.8. DESCRIPTION Frees the memory space pointed to by devPtr. which must have been returned by a previous call to cuMemMalloc() or cuMemMallocPitch(). cuArrayCreate. cuMemGetAddressRange. cuMemAllocPitch. cuMemAllocHost. cuArrayDestroy. cuMemset. cuArrayGetDescriptor. SEE ALSO cuMemGetInfo.frees device memory SYNOPSIS CUresult cuMemFree(CUdeviceptr devPtr). cuMemFreeHost.9 cuMemFree NAME cuMemFree . cuMemAlloc. cuMemset2D 163 . 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuD3D9ResourceGetMappedPitch 212 .2. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. cuD3D9GetDirect3DDevice.6 cuD3D9MapResources NAME cuD3D9MapResources . If an application does so the results are undefined. cuD3D9UnmapResources. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9RegisterResource. cuD3D9CtxCreate. SEE ALSO cuD3D9GetDevice. Direct3D should not access any resources while they are mapped by CUDA. cuD3D9ResourceGetSurfaceDimensions. 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. 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. asynchronous launches. cuD3D9ResourceSetMapFlags. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. IDirect3DResource9 **ppResources).11. cuD3D9UnregisterResource.map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. 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

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

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

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

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

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

64-bit atomic operations are only supported on devices of compute capability 1.1 and higher. BitwiseFunctions 222 . 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. SEE ALSO ArithmeticFunctions.2 and higher.

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

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

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

atomic exchange SYNOPSIS int atomicExch(int* address.2 and higher. atomicDec.1 and higher. atomicInc. 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. DESCRIPTION Reads the 32.1. atomicCAS 226 .3 atomicExch NAME atomicExch . int val). unsigned int atomicExch(unsigned int* address.3. atomicMax. atomicSub.or 64-bit word old located at the address address in global memory and stores val back to global memory at the same address. unsigned long long int val). These two operations are performed in one atomic transaction. The function returns old. unsigned int val). unsigned long long int atomicExch(unsigned long long int* address. SEE ALSO atomicAdd. atomicMin.

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful