NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

Contents
1 RuntimeApiReference 1.1 DeviceManagement RT 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

cudaGetDeviceCount

cudaSetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDeviceProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaChooseDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ThreadManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 1.2.2 cudaThreadSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaThreadExit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.3

StreamManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 1.3.2 1.3.3 1.3.4 cudaStreamCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.4

EventManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 cudaEventCreate cudaEventRecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventElapsedTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

cudaMalloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMallocArray

cudaFreeArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFreeHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMemset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMemset2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

i

1.5.10 cudaMemcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.11 cudaMemcpy2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34 35 36 37 38 39 40 41 42 43 44 45 46 48 50 52 54 55 63 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

1.5.12 cudaMemcpyToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.13 cudaMemcpy2DToArray 1.5.14 cudaMemcpyFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.15 cudaMemcpy2DFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.16 cudaMemcpyArrayToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.17 cudaMemcpy2DArrayToArray 1.5.18 cudaMemcpyToSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.19 cudaMemcpyFromSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.20 cudaGetSymbolAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.21 cudaGetSymbolSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.22 cudaMalloc3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.23 cudaMalloc3DArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.24 cudaMemset3D 1.5.25 cudaMemcpy3D 1.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

TextureReferenceManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6.1 1.6.2 LowLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HighLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

cudaConfigureCall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaLaunch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaSetupArgument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.8

OpenGlInteroperability RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 cudaGLSetGLDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLRegisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLMapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLUnmapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLUnregisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

cudaD3D9SetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9GetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9RegisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

84 85 86 87 89 90 91 92 94 95 97 98 99

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9UnmapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceSetMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceGetSurfaceDimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

. . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.12 cudaD3D9ResourceGetMappedPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10 ErrorHandling RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.1 cudaGetLastError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.2 cudaGetErrorString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 DriverApiReference 2.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 2.2

cuInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

cuDeviceGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 cuDeviceGetAttribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 cuDeviceGetCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 cuDeviceGetName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 cuDeviceGetProperties cuDeviceTotalMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

cuCtxAttach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 cuCtxCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 cuCtxDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

cuCtxDetach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 cuCtxGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 cuCtxPopCurrent cuCtxPushCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

cuCtxSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

2.4

ModuleManagement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 2.4.1 cuModuleGetFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

iii

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.1.2 cudaThreadExit NAME cudaThreadExit . cudaThreadExit() is implicitly called on host thread exit. 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. Any subsequent API call reinitializes the runtime. SEE ALSO cudaThreadSynchronize 11 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

Stream Management. Texture Reference Management. OpenGL Interoperability. Memory Management. Execution Management.1. 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. Error Handling 54 . Thread Management. Direct3D Interoperability. Event Management.

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

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

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

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

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

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

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

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

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. 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 . int dim.

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

cudaSetupArgument 69 .1. together with any arguments for the call.7. asynchronous launches. Each call pushes data on top of an execution stack. This data contains the dimension for the grid and thread blocks. cudaConfigureCall() is stack based. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. SEE ALSO cudaLaunch.configure a device-launch SYNOPSIS cudaError_t cudaConfigureCall(dim3 gridDim.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. size_t sharedMem = 0. dim3 blockDim.

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

asynchronous launches. cudaD3D9ResourceGetSurfaceDimensions. IDirect3DResource9** ppResources). If any of ppResources are not presently mapped for access by CUDA then cudaErrorUnknown is returned.unmap Direct3D resources SYNOPSIS cudaError_t cudaD3D9UnmapResources(unsigned int count. cudaD3D9MapResources. 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. cudaD3D9GetDirect3DDevice.9. This function provides the synchronization guarantee that any CUDA kernels issued before cudaD3D9UnmapResources will complete before any Direct3D calls issued after cudaD3D9UnmapResources begin. cudaD3D9UnregisterResource. DESCRIPTION Unmaps the count Direct3D resources in ppResources. cudaD3D9ResourceSetMa cudaD3D9ResourceGetMappedPointer. cudaD3D9ResourceGetMappedSize. SEE ALSO cudaD3D9GetDevice.1. cudaD3D9RegisterResource. cudaD3D9SetDirect3DDevice.7 cudaD3D9UnmapResources NAME cudaD3D9UnmapResources . cudaD3D9ResourceGetMappedPitch 86 .

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1 cuCtxAttach NAME cuCtxAttach . DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context.3. SEE ALSO cuCtxCreate. the Flags parameter must be 0. cuCtxDetach.2. cuCtxAttach() fails if there is no context current to the thread. cuCtxSynchronize 112 . asynchronous launches.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxGetDevice. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. unsigned int Flags). Currently.

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

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

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

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

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

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

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

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

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

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

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

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

cuModuleLoadData.4. cuModuleGetTexRef 128 . SEE ALSO cuModuleLoad.unloads a module SYNOPSIS CUresult cuModuleUnload(CUmodule mod). cuModuleLoadFatBinary. asynchronous launches.7 cuModuleUnload NAME cuModuleUnload . cuModuleGetFunction. DESCRIPTION Unloads a module mod from the current context. cuModuleGetGlobal. 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.

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Blocks until the event has actually been recorded. cuEventElapsedTime 140 . cuEventDestroy. cuEventRecord.2. If cuEventRecord() has not been called on this event.waits for an event to complete SYNOPSIS CUresult cuEventSynchronize(CUevent event). the function returns CUDA_ERROR_INVALID_VALUE.6. asynchronous launches.6 cuEventSynchronize NAME cuEventSynchronize . SEE ALSO cuEventCreate. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous. cuEventQuery.

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

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

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

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

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

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

offset is a byte offset. cuParamSetTexRef. cuParamSetv. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuLaunch.7.2. SEE ALSO cuFuncSetBlockShape. cuLaunchGrid 147 . cuParamSetf. DESCRIPTION Sets an integer parameter that will be specified the next time the kernel corresponding to func will be invoked. int offset. cuFuncSetSharedSize. unsigned int value). cuParamSetSize.6 cuParamSeti NAME cuParamSeti .adds an integer parameter to the function’s argument list SYNOPSIS CUresult cuParamSeti(CUfunction func. 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.adds arbitrary data to the function’s argument list SYNOPSIS CUresult cuParamSetv(CUfunction func. cuLaunchGrid 148 . DESCRIPTION Copies an arbitrary amount of data into the parameter space of the kernel corresponding to func. cuParamSetf. cuParamSetSize.2. cuParamSeti. cuLaunch. offset is a byte offset.7 cuParamSetv NAME cuParamSetv . int offset. cuParamSetTexRef.7. asynchronous launches. cuFuncSetSharedSize. SEE ALSO cuFuncSetBlockShape. void* ptr. unsigned int numbytes).

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

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

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

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

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

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

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

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

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

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

The memory is not cleared. cuArrayDestroy.2.8. cuMemAllocPitch.6 cuMemAlloc NAME cuMemAlloc .allocates device memory SYNOPSIS CUresult cuMemAlloc(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_OUT_OF_MEMORY Note that this function may also return error codes from previous. cuMemGetAddressRange. The allocated memory is suitably aligned for any kind of variable. DESCRIPTION Allocates count bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. cuMemFree. cuArrayGetDescriptor. unsigned int count). cuMemset. asynchronous launches. cuArrayCreate. cuMemAlloc() returns CUDA_ERROR_INVALID_VALUE. cuMemFreeHost. cuMemAllocHost. cuMemset2D 159 . SEE ALSO cuMemGetInfo. If count is 0.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefSetAddressMode. cuTexRefGetFlags 197 . cuTexRefGetFormat. cuTexRefGetArray. SEE ALSO cuTexRefCreate. cuTexRefGetAddressMode.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(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.9. asynchronous launches.14 cuTexRefSetFormat NAME cuTexRefSetFormat . cuTexRefDestroy. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. cuTexRefGetAddress. format and numPackedComponents are exactly analogous to the Format and NumChannels members of the CUDA_ARRAY_DESCRIPTOR structure: They specify the format of each component and the number of components per array element. cuTexRefGetFilterMode. cuTexRefSetArray. cuTexRefSetFlags. cuTexRefSetFilterMode. CUarray_format format.2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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