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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D. cudaMalloc3D 51 .SEE ALSO cudaMemset.

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

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

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

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

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

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

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

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

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

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

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

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

z. SEE ALSO 64 . RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. z. asynchronous launches. y. and w.High-level texture API SYNOPSIS template < class T > struct cudaChannelFormatDesc cudaCreateChannelDesc <T >(). w. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. enum cudaChannelFormatKind f.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. cudaChannelFormatKindUnsigned. y. cudaChannelFormatKindFloat.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1 cudaGetLastError NAME cudaGetLastError .returns the last error from a run-time call SYNOPSIS cudaError_t cudaGetLastError( void ) DESCRIPTION Returns the last error that was returned from any of the runtime calls in the same host thread and resets it to cudaSuccess.10.1. 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. 95 .

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

cuDeviceGet. cuDeviceGetProperties. cuDeviceGetName. asynchronous launches.1 cuDeviceComputeCapability NAME cuDeviceComputeCapability .2. int* minor. DESCRIPTION Returns in *major and *minor the major and minor revision numbers that define the compute capability of device dev. CUdevice dev). SEE ALSO cuDeviceGetAttribute. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_DEVICE Note that this function may also return error codes from previous. cuDeviceTotalMem 102 .returns the compute capability of the device SYNOPSIS CUresult cuDeviceComputeCapability(int* major. cuDeviceGetCount.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.2.2. int ordinal).2 cuDeviceGet NAME cuDeviceGet . cuDeviceGetProperties. cuDeviceGetCount. asynchronous launches. cuDeviceGetCount()-1]. cuDeviceTotalMem 103 .returns a device-handle SYNOPSIS CUresult cuDeviceGet(CUdevice* dev. cuDeviceGetAttribute. cuDeviceGetName. SEE ALSO cuDeviceComputeCapability. DESCRIPTION Returns in *dev a device handle given an ordinal in the range [0.

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

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

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

cuDeviceGetCount. 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. CUdevice dev).5 cuDeviceGetName NAME cuDeviceGetName . cuDeviceTotalMem 107 . cuDeviceGet. cuDeviceGetAttribute. len specifies the maximum length of the string that may be returned. asynchronous launches. DESCRIPTION Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name. int len.2.returns an identifier string SYNOPSIS CUresult cuDeviceGetName(char* name. SEE ALSO cuDeviceComputeCapability. cuDeviceGetProperties.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuEventElapsedTime 140 . asynchronous launches. SEE ALSO cuEventCreate. cuEventQuery. cuEventDestroy. If cuEventRecord() has not been called on this event.2. cuEventRecord. the function returns CUDA_ERROR_INVALID_VALUE. DESCRIPTION Blocks until the event has actually been recorded. 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.

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

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

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

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

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

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

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

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

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

cuParamSetv.7. cuParamSetTexRef. SEE ALSO cuFuncSetBlockShape. 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. cuParamSetSize. cuParamSetf.2. unsigned int bytes). asynchronous launches.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . cuLaunchGrid 150 . cuParamSeti.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. cuGLUnregisterBufferObject 201 . cuGLUnmapBufferObject. 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. cuGLInit. unsigned int* size.3 cuGLMapBufferObject NAME cuGLMapBufferObject . DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping.10. asynchronous launches. SEE ALSO cuGLCtxCreate. GLuint bufferObj). cuGLRegisterBufferObject.

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

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

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

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

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

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

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

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

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

11.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceSetMapFlags.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). asynchronous launches.2. cuD3D9RegisterResource. cuD3D9GetDirect3DDevice. cuD3D9ResourceGetMappedPitch 211 . cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9ResourceGetSurfaceDimensions. cuD3D9UnmapResources. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. cuD3D9CtxCreate. cuD3D9MapResources. If pResource is not 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_HANDLE CUDA_ERROR_ALREADY_MAPPED CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9UnregisterResource. This function provides the synchronization guarantee that any Direct3D calls issued before cuD3D9MapResources will complete before any CUDA kernels issued after cuD3D9MapResources begin.6 cuD3D9MapResources NAME cuD3D9MapResources . If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then CUDA_ERROR_INVALID_HANDLE is returned.2. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. cuD3D9ResourceGetSurfaceDimensions. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. cuD3D9ResourceSetMapFlags. cuD3D9CtxCreate. Direct3D should not access any resources while they are mapped by CUDA. cuD3D9ResourceGetMappedPitch 212 . If any of ppResources are presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned. asynchronous launches. cuD3D9RegisterResource.11. cuD3D9GetDirect3DDevice. IDirect3DResource9 **ppResources). cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. If an application does so the results are undefined.map Direct3D resources for access by CUDA SYNOPSIS CUresult cuD3D9MapResources(unsigned int count. SEE ALSO cuD3D9GetDevice. cuD3D9UnmapResources.

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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