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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaEventQuery.1. 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. cudaEventElapsedTime 18 . SEE ALSO cudaEventRecord. cudaEventDestroy.1 cudaEventCreate NAME cudaEventCreate .4. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous. SEE ALSO cudaMemset2D.5.initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset( void* devPtr.1. cudaMemset3D 32 . int value. 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.8 cudaMemset NAME cudaMemset .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Unregisters the buffer object of ID bufferObj for access by CUDA.1.8.OpenGL interoperability SYNOPSIS cudaError_t cudaGLUnregisterBufferObject(GLuint bufferObj). cudaGLRegisterBufferObject. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. SEE ALSO cudaGLSetGLDevice.5 cudaGLUnregisterBufferObject NAME cudaGLUnregisterBufferObject . cudaGLMapBufferObject. asynchronous launches. 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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.0 that are available for execution.2. If there is no such device. asynchronous launches. cuDeviceGetName.returns the number of compute-capable devices SYNOPSIS CUresult cuDeviceGetCount(int* count). SEE ALSO cuDeviceComputeCapability. cuDeviceGetAttribute.2.4 cuDeviceGetCount NAME cuDeviceGetCount . cuDeviceGetProperties. cuDeviceGetCount() returns 0. cuDeviceTotalMem 106 . cuDeviceGet. DESCRIPTION Returns in *count the number of devices with compute capability greater or equal to 1.

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

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

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

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

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

cuCtxGetDevice.1 cuCtxAttach NAME cuCtxAttach . asynchronous launches. SEE ALSO cuCtxCreate. DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context.3. 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 Flags parameter must be 0.2.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. Currently. cuCtxSynchronize 112 . unsigned int Flags). cuCtxDetach. cuCtxAttach() fails if there is no context current to the thread.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuParamSetTexRef. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.5 cuParamSetf NAME cuParamSetf . cuParamSeti.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. cuLaunchGrid 146 . cuParamSetv. cuLaunch.2. cuParamSetSize. SEE ALSO cuFuncSetBlockShape. int offset.7. cuFuncSetSharedSize. offset is a byte offset. asynchronous launches. float value).

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

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

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

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

EventManagement. OpenGlInteroperability. StreamManagement. ExecutionControl.8 MemoryManagement NAME Memory Management DESCRIPTION This section describes the low-level CUDA driver application programming interface. ContextManagement. TextureReferenceManagement. DeviceManagement. ModuleManagement. MemoryManagement. Direct3dInteroperability 151 .2. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

SEE ALSO ArithmeticFunctions. 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.2 and higher.1 and higher.3 AtomicFunctions NAME Atomic Functions DESCRIPTION Atomic functions can only be used in device functions.

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

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

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

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

3. These three operations are performed in one atomic transaction. NOTES Atomic operations are only supported on devices of compute capability 1. atomicDec. atomicExch.atomic minimum SYNOPSIS int atomicMin(int* address. 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. unsigned int atomicMin(unsigned int* address. SEE ALSO atomicAdd.1. int val). The function returns b<old>. unsigned int val). atomicMax.1 and higher. atomicCAS 227 .4 atomicMin NAME atomicMin . computes the minimum of old and val. atomicInc. atomicSub.

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

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

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

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

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

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

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

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