CudaReferenceManual_2.0 | Integer (Computer Science) | Pointer (Computer Programming)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaThreadExit 10 . asynchronous launches. 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.1.2.wait for compute-device to finish SYNOPSIS cudaError_t cudaThreadSynchronize(void) DESCRIPTION Blocks until the device has completed all preceding requested tasks.1 cudaThreadSynchronize NAME cudaThreadSynchronize .

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. Any subsequent API call reinitializes the runtime. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.2. asynchronous launches. SEE ALSO cudaThreadSynchronize 11 .2 cudaThreadExit NAME cudaThreadExit .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

it is recommended that programmers consider performing pitch allocations using cudaMallocPitch(). Due to pitch alignment restrictions in the hardware.2 cudaMallocPitch NAME cudaMallocPitch . RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. size_t* pitch. asynchronous launches. 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.5. cudaFreeArray.allocates memory on the GPU SYNOPSIS cudaError_t cudaMallocPitch( void** devPtr. For allocations of 2D arrays. 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. used to compute addresses within the 2D array. this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or CUDA arrays).1. 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. size_t widthInBytes. cudaMallocArray. SEE ALSO cudaMalloc. The intended usage of pitch is as a separate parameter of the allocation. cudaFreeHost 26 . Given the row and column of an array element of type T. cudaFree. cudaMallocHost.

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

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

no operation is performed. SEE ALSO cudaMalloc.5. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError Note that this function may also return error codes from previous. cudaFree. cudaMallocArray. If array is 0. cudaMallocPitch.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 .1. cudaFreeHost 29 . cudaMallocHost.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

If symbol cannot be found.1. SEE ALSO cudaGetSymbolAddress 45 .21 cudaGetSymbolSize NAME cudaGetSymbolSize . *size is unchanged and an error is returned. or it can be a character string. asynchronous launches. naming a variable that resides in global or constant memory space. or if symbol is not declared in global or constant memory space. cudaGetSymbolSize() returns cudaErrorInvalidSymbol in case of failure. symbol can either be a variable that resides in global or constant memory space.5.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. const T& symbol) DESCRIPTION Returns in *size the size of symbol symbol.

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

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

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

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

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

cudaMalloc3D 51 .SEE ALSO cudaMemset. cudaMemset2D.

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

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

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

1.6.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 .

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

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

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. cudaUnbindTexture. const char* symbol) DESCRIPTION Returns in *texRef the structure associated to the texture reference defined by symbol symbol. SEE ALSO cudaCreateChannelDesc. cudaGetTextureAlignmentOffset 58 . cudaBindTexture. cudaBindTextureToArray. cudaGetChannelDesc. asynchronous launches.cudaGetTextureReference NAME cudaGetTextureReference .

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

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

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

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

1.6.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 .

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

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

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

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. dim. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaUnbindTexture(const struct texture < T. readMode >& texRef) DESCRIPTION Unbinds the texture bound to texture reference texRef. asynchronous launches. int dim. SEE ALSO 67 .cudaUnbindTexture HL NAME cudaUnbindTexture .

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

asynchronous launches. 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.configure a device-launch SYNOPSIS cudaError_t cudaConfigureCall(dim3 gridDim.1. size_t sharedMem = 0.1 cudaConfigureCall NAME cudaConfigureCall . 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. together with any arguments for the call. dim3 blockDim. cudaSetupArgument 69 .7. SEE ALSO cudaLaunch.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. otherwise CUDA will not yield while waiting for results and actively spin on the processor. CUdevice dev). 113 .2. • CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for results from the GPU.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. 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. asynchronous launches. This can decrease latency when waiting for the GPU. • CU_CTX_SCHED_AUTO: The default value if the Flags parameter is zero. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_DEVICE CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. • CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for results from the GPU. it is supplanted by the newly created context and may be restored by a subsequent call to cuCtxPopCurrent(). If a context is already current to the thread. but can increase the performance of CPU threads performing work in parallel with the GPU. The context is created with a usage count of 1 and the caller of cuCtxCreate() must call cuCtxDestroy() or cuCtxDetach() when done using the context. The Flags parameter is described below. unsigned int Flags.3. This can increase latency when waiting for the GPU.2 cuCtxCreate NAME cuCtxCreate .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

CUarray array) DESCRIPTION Returns in *arrayDesc a descriptor of the format and dimensions of the 1D or 2D CUDA array array. It is useful for subroutines that have been passed a CUDA array.8. cuArrayDestroy 157 .get a 1D or 2D CUDA array descriptor SYNOPSIS CUresult cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR* arrayDesc. asynchronous launches. but need to know the CUDA array parameters for validation or other purposes.4 cuArrayGetDescriptor NAME cuArrayGetDescriptor . 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.2. SEE ALSO cuArrayCreate. 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_INVALID_HANDLE Note that this function may also return error codes from previous. but need to know the CUDA array parameters for validation or other purposes. It is useful for subroutines that have been passed a CUDA array. cuArray3DCreate. CUarray array). DESCRIPTION Returns in *arrayDesc a descriptor containing information on the format and dimensions of the CUDA array array.2.get a 3D CUDA array descriptor SYNOPSIS CUresult cuArray3DGetDescriptor(CUDA_ARRAY3D_DESC *arrayDesc. cuArrayGetDescriptor. SEE ALSO cuArrayCreate.8.5 cuArray3DGetDescriptor NAME cuArray3DGetDescriptor . cuArrayDestroy 158 . asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefSetAddress. cuTexRefGetFormat. SEE ALSO cuTexRefCreate. asynchronous launches.destroys a texture-reference SYNOPSIS CUresult cuTexRefDestroy(CUtexref texRef). cuTexRefGetFilterMode. DESCRIPTION Destroys the texture reference.2. cuTexRefGetFlags 185 . cuTexRefSetFlags. cuTexRefSetAddressMode. cuTexRefSetFilterMode.9.2 cuTexRefDestroy NAME cuTexRefDestroy . 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. cuTexRefSetArray. cuTexRefGetAddressMode. cuTexRefGetArray. cuTexRefSetFormat.

gets the address associated with a texture-reference SYNOPSIS CUresult cuTexRefGetAddress(CUdeviceptr* devPtr. cuTexRefSetFilterMode. cuTexRefSetAddressMode. cuTexRefGetArray. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. 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.2. CUtexref texRef). cuTexRefSetAddress.3 cuTexRefGetAddress NAME cuTexRefGetAddress . cuTexRefGetFormat. cuTexRefGetFlags 186 . asynchronous launches. cuTexRefDestroy. cuTexRefGetAddressMode. cuTexRefSetFormat. cuTexRefSetFlags. cuTexRefGetFilterMode. cuTexRefSetArray. SEE ALSO cuTexRefCreate.

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

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

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

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

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

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

if dim is 1. CU_TR_ADDRESS_MODE_MIRROR = 2. and so on. int dim. CUaddress_mode mode).10 cuTexRefSetAddressMode NAME cuTexRefSetAddressMode . cuTexRefSetFormat. CUaddress_mode is defined as such: typedef enum CUaddress_mode_enum { CU_TR_ADDRESS_MODE_WRAP = 0. cuTexRefSetFilterMode. cuTexRefGetFlags 193 . cuTexRefGetFormat. cuTexRefGetAddressMode. SEE ALSO cuTexRefCreate. asynchronous launches. Note that this call has no effect if texRef is bound to linear memory. cuTexRefSetFlags. cuTexRefGetAddress. cuTexRefGetFilterMode. cuTexRefGetArray.2. cuTexRefSetAddress. DESCRIPTION Specifies the addressing mode mode for the given dimension of the texture reference texRef.9. the second. CU_TR_ADDRESS_MODE_CLAMP = 1.set the addressing mode for a texture-reference SYNOPSIS CUresult cuTexRefSetAddressMode(CUtexref texRef. the addressing mode is applied to the first parameter of the functions used to fetch from the texture. cuTexRefSetArray. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. } CUaddress_mode. If dim is zero. 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. DESCRIPTION Binds the CUDA array array to the texture reference texRef. cuTexRefGetFormat. cuTexRefGetFlags 194 . Any previous address or CUDA array state associated with the texture reference is superseded by this function. cuTexRefSetAddressMode. cuTexRefDestroy.11 cuTexRefSetArray NAME cuTexRefSetArray . Any CUDA array previously bound to texRef is unbound. asynchronous launches.binds an array to a texture-reference SYNOPSIS CUresult cuTexRefSetArray(CUtexref texRef. CUarray array. cuTexRefSetFlags. cuTexRefGetAddressMode. unsigned int flags). SEE ALSO cuTexRefCreate. cuTexRefSetFormat. cuTexRefSetFilterMode. cuTexRefGetArray.2.9. cuTexRefGetFilterMode. flags must be set to CU_TRSA_OVERRIDE_FORMAT. cuTexRefGetAddress.

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. CUfilter_mode mode). cuTexRefGetAddress. SEE ALSO cuTexRefCreate.9. cuTexRefGetAddressMode. cuTexRefSetFormat. cuTexRefSetFlags. CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0. cuTexRefSetAddress.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef. cuTexRefGetFlags 195 . cuTexRefSetArray. cuTexRefDestroy.2. cuTexRefGetFilterMode. asynchronous launches. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefSetAddressMode. Note that this call has no effect if texRef is bound to linear memory.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . cuTexRefGetArray.

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

cuTexRefSetAddress. cuTexRefDestroy.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef.9. cuTexRefSetArray. cuTexRefGetAddressMode. cuTexRefSetFlags.14 cuTexRefSetFormat NAME cuTexRefSetFormat . asynchronous launches. cuTexRefGetFilterMode. 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. CUarray_format format. cuTexRefGetFlags 197 . cuTexRefSetFilterMode. SEE ALSO cuTexRefCreate. 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.2. cuTexRefGetAddress. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. cuTexRefSetAddressMode. cuTexRefGetArray.

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

cuGLUnregisterBufferObject 199 . SEE ALSO cuCtxCreate. DESCRIPTION Creates a new CUDA context. asynchronous launches. and associates the CUDA context with the calling thread. initializes OpenGL interoperability. For usage of the Flags parameter.10. cuGLMapBufferObject. see cuCtxCreate. It must be called before performing any other OpenGL interoperability operations. cuGLUnmapBufferObject. CUdevice device).2. cuGLInit cuGLRegisterBufferObject.1 cuGLCtxCreate NAME cuGLCtxCreate . It may fail if the needed OpenGL driver facilities are not available.create a CUDA context for interoperability with OpenGL SYNOPSIS CUresult cuGLCtxCreate(CUcontext *pCtx. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. unsigned int Flags.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

For a 2D surface the byte offset of the sample of at position x.y from the base pointer of the surface is If pResource is not of type IDirect3DBaseTexture9 or one of its sub-types or if pResource has not been registered for use with CUDA then CUDA_ERROR_INVALID_HANDLE is returned. asynchronous launches. unsigned int Face. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVALID_HANDLE is returned.y.11. If pResource is not mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned.z from the base pointer of the surface is z*slicePitch + y*pitch + (bytes per pixel)*x Both parameters pPitch and pPitchSlice are optional and may be set to NULL. 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. 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. y*pitch + (bytes per pixel)*x For a 3D surface the byte offset of the sample of at position x. The values set in pPitch and pPitchSlice may change every time that pResource is mapped.get the pitch of a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS CUresult cuD3D9ResourceGetMappedPitch(unsigned int* pPitch.2.12 cuD3D9ResourceGetMappedPitch NAME cuD3D9ResourceGetMappedPitch . unsigned int Level). unsigned int* pPitchSlice. IDirect3DResource pResource. The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows. For usage requirements of Face and Level parameters see cuD3D9ResourceGetMappedPointer.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful