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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMallocPitch. no operation is performed. Otherwise. 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. cudaFreeArray.frees memory on the GPU SYNOPSIS cudaError_t cudaFree(void* devPtr) DESCRIPTION Frees the memory space pointed to by devPtr. If devPtr is 0.1. SEE ALSO cudaMalloc.3 cudaFree NAME cudaFree . asynchronous launches. cudaFree() returns cudaErrorInvalidDevicePointer in case of failure.5. which must have been returned by a previous call to cudaMalloc() or cudaMallocPitch(). cudaMallocArray. an error is returned. cudaFreeHost 27 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

asynchronous launches. cudaUnbindTexture. SEE ALSO cudaCreateChannelDesc. DESCRIPTION Returns in *desc the channel descriptor of the CUDA array array.Low-level texture API SYNOPSIS cudaError_t cudaGetChannelDesc(struct cudaChannelFormatDesc* desc. cudaBindTexture. cudaGetTextureAlignmentOffset 57 . cudaBindTextureToArray. const struct cudaArray* array). cudaGetTextureReference.cudaGetChannelDesc NAME cudaGetChannelDesc . 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 cudaGetTextureReference( struct textureReference** texRef. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidTexture Note that this function may also return error codes from previous. const char* symbol) DESCRIPTION Returns in *texRef the structure associated to the texture reference defined by symbol symbol. cudaGetTextureAlignmentOffset 58 .cudaGetTextureReference NAME cudaGetTextureReference . cudaBindTexture. SEE ALSO cudaCreateChannelDesc. cudaGetChannelDesc. cudaUnbindTexture. asynchronous launches. cudaBindTextureToArray.

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaLaunch. 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. asynchronous launches.7. together with any arguments for the call. cudaSetupArgument 69 .1 cudaConfigureCall NAME cudaConfigureCall .configure a device-launch SYNOPSIS cudaError_t cudaConfigureCall(dim3 gridDim. dim3 blockDim. cudaConfigureCall() is stack based. int tokens = 0) DESCRIPTION Specifies the grid and block dimensions for the device call to be executed similar to the execution configuration syntax. This data contains the dimension for the grid and thread blocks. size_t sharedMem = 0.1.

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous.1. 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. asynchronous launches. entry must be declared as a __global__ function.launches a device function SYNOPSIS template < class T > cudaError_t cudaLaunch(T entry) DESCRIPTION Launches the function entry on the device.2 cudaLaunch NAME cudaLaunch . entry can either be a function that executes on the device. naming a function that executes on the device. or it can be a character string.7. cudaSetupArgument 70 .

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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.1 cudaGetLastError NAME cudaGetLastError . 95 .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.

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

returns a device-handle SYNOPSIS CUresult cuDeviceGet(CUdevice* dev. DESCRIPTION Returns in *dev a device handle given an ordinal in the range [0. cuDeviceGetProperties. cuDeviceGetAttribute. SEE ALSO cuDeviceComputeCapability. cuDeviceGetName. cuDeviceTotalMem 103 .2 cuDeviceGet NAME cuDeviceGet .2. cuDeviceGetCount()-1].2. int ordinal). 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. cuDeviceGetCount.

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

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

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

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

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

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

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

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

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

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

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

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

cuCtxAttach. and must be current to the calling thread. cuCtxPushCurrent. asynchronous launches. The context must be a handle that was passed back by cuCtxCreate() or cuCtxAttach().3. DESCRIPTION Decrements the usage count of the context. cuCtxDestroy. and destroys the context if the usage count goes to 0.4 cuCtxDetach NAME cuCtxDetach .2. cuCtxPopCurrent 116 . SEE ALSO cuCtxCreate.decrement a context’s usage-count SYNOPSIS CUresult cuCtxDetach(CUcontext ctx). 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.

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

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

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

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

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

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

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

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

unloads a module SYNOPSIS CUresult cuModuleUnload(CUmodule mod).4. cuModuleLoadFatBinary. asynchronous launches.2. cuModuleGetGlobal. DESCRIPTION Unloads a module mod from the current context.7 cuModuleUnload NAME cuModuleUnload . cuModuleGetTexRef 128 . SEE ALSO cuModuleLoad. cuModuleLoadData. cuModuleGetFunction. 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 StreamManagement NAME Stream Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. ContextManagement. ExecutionControl. EventManagement. TextureReferenceManagement.2. Direct3dInteroperability 129 . cuStreamCreate cuStreamDestroy cuStreamQuery cuStreamSynchronize SEE ALSO Initialization. ModuleManagement. MemoryManagement. DeviceManagement. OpenGlInteroperability. StreamManagement.

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

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

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

5. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous. asynchronous launches.2. cuStreamQuery. cuStreamDestroy 133 . SEE ALSO cuStreamCreate.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.4 cuStreamSynchronize NAME cuStreamSynchronize .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

desc. desc. desc. desc.Width = 64. desc. desc. cuArrayDestroy 155 . cuMemFree. cuMemGetAddressRange. cuMemFreeHost.FormatFlags = CU_AD_FORMAT_HALF. desc. desc.NumChannels = 4. desc. cuMemAlloc. SEE ALSO cuMemGetInfo.Depth = 0.NumChannels = 1.Width = 2048.Depth = 0. desc. desc. cuMemAllocHost. • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY3D_DESCRIPTOR desc. cuMemAllocPitch.Format = CU_AD_FORMAT_FLOAT.• Description for a CUDA array of 2048 floats: CUDA_ARRAY3D_DESCRIPTOR desc.Depth = depth.Format = CU_AD_FORMAT_FLOAT. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc. asynchronous launches.Height = 0.NumChannels = 1. desc. desc. desc.Height = height.Width = width.Height = 64. cuArray3DGetDescriptor. 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. • Description for a width x height x depth CUDA array of 64-bit. desc.

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

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

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

cuMemAlloc() returns CUDA_ERROR_INVALID_VALUE.2. asynchronous launches. unsigned int count). SEE ALSO cuMemGetInfo. DESCRIPTION Allocates count bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. cuMemAllocHost. If count is 0.6 cuMemAlloc NAME cuMemAlloc . cuMemFree. The memory is not cleared.allocates device memory SYNOPSIS CUresult cuMemAlloc(CUdeviceptr* devPtr. cuArrayCreate. cuArrayGetDescriptor. cuMemset2D 159 . cuMemGetAddressRange. cuMemset. cuArrayDestroy. 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. cuMemFreeHost. cuMemAllocPitch.8. The allocated memory is suitably aligned for any kind of variable.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3 cuGLMapBufferObject NAME cuGLMapBufferObject . cuGLRegisterBufferObject. SEE ALSO cuGLCtxCreate. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous. asynchronous launches. GLuint bufferObj). unsigned int* size.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. cuGLUnregisterBufferObject 201 . cuGLInit. 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. cuGLUnmapBufferObject.10.2.

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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 int atomicExch(unsigned int* address. unsigned int val). unsigned long long int val).3.1. atomicDec. NOTES 32-bit atomic operations are only supported on devices of compute capability 1. These two operations are performed in one atomic transaction.1 and higher. 64-bit atomic operations are only supported on devices of compute capability 1. atomicMin. The function returns old. atomicMax. DESCRIPTION Reads the 32. unsigned long long int atomicExch(unsigned long long int* address. int val). atomicSub.atomic exchange SYNOPSIS int atomicExch(int* address. SEE ALSO atomicAdd. atomicCAS 226 .3 atomicExch NAME atomicExch .2 and higher. atomicInc.

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful