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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaStreamSynchronize. asynchronous launches.1.create an async stream SYNOPSIS cudaError_t cudaStreamCreate( cudaStream_t* stream ) DESCRIPTION Creates a stream. SEE ALSO cudaStreamQuery.1 cudaStreamCreate NAME cudaStreamCreate . cudaStreamDestroy 13 . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue Note that this function may also return error codes from previous.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. or cudaErrorNotReady if not.1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorNotReady cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous. SEE ALSO cudaStreamCreate.2 cudaStreamQuery NAME cudaStreamQuery . cudaStreamDestroy. cudaStreamSynchronize 14 . asynchronous launches.3.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5. *devPtr is unchanged and an error is returned. If symbol cannot be found.finds the address associated with a CUDA symbol SYNOPSIS template < class T > cudaError_t cudaGetSymbolAddress(void** devPtr. asynchronous launches.20 cudaGetSymbolAddress NAME cudaGetSymbolAddress . 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 memory space. symbol can either be a variable that resides in global memory space. SEE ALSO cudaGetSymbolSize 44 .1. const T& symbol) DESCRIPTION Returns in *devPtr the address of symbol symbol on the device. or if symbol is not declared in global memory space.

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

*pHeight. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer.get the dimensions of a registered surface SYNOPSIS cudaError_t cudaD3D9ResourceGetSurfaceDimensions(size_t* pWidth. For 2D surfaces.1. size_t *pDepth. SEE ALSO cudaD3D9GetDevice.9 cudaD3D9ResourceGetSurfaceDimensions NAME cudaD3D9ResourceGetSurfaceDimensions . pHeight. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle Note that this function may also return error codes from previous. cudaD3D9MapResources. and pDepth are optional. cudaD3D9UnregisterResource. cudaD3D9ResourceGetMappedPitch 89 . The parameters pWidth. size_t* pHeight. DESCRIPTION Returns in *pWidth. the value returned in *pDepth will be 0.9. IDirect3DResource9* pResource. asynchronous launches. and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. cudaD3D9ResourceGetMappedSize. unsigned int Face. 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. cudaD3D9RegisterResource. cudaD3D9UnmapResources. cudaD3D9ResourceGetMappedPointer. cudaD3D9ResourceSetMapFlags. unsigned int Level). cudaD3D9GetDirect3DDevice. cudaD3D9SetDirect3DDevice. 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. If Level is invalid then cudaErrorInvalidValue is returned. If pResource was not registered with usage flags cudaD3D9RegisterFlagsNone then cudaErrorInvalidHandle is returned. unsigned int Level). If pResource is not mapped then cudaErrorUnknown is returned. If pResource is not registered then cudaErrorInvalidHandle is returned. asynchronous launches. cudaD3D9ResourceGetMappedPitch 90 . 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.10 cudaD3D9ResourceGetMappedPointer NAME cudaD3D9ResourceGetMappedPointer .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. cudaD3D9UnmapResources. cudaD3D9ResourceGetMappedSize. Only mipmap level 0 is supported for now. cudaD3D9UnregisterResource. IDirect3DResource9* pResource. If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level. If Face is invalid then cudaErrorInvalidValue is returned. SEE ALSO cudaD3D9GetDevice. cudaD3D9SetDirect3DDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. cudaD3D9MapResources. If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. cudaD3D9RegisterResource. For all other types Level must be 0. cudaD3D9ResourceGetSurfaceDimensio cudaD3D9ResourceSetMapFlags.1. For all other types Face must be 0. unsigned int Face. cudaD3D9GetDirect3DDevice.

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

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

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

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

1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorLaunchFailure cudaErrorPriorLaunchFailure cudaErrorLaunchTimeout cudaErrorLaunchOutOfResources cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration cudaErrorInvalidDevice cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture cudaErrorInvalidTextureBinding cudaErrorInvalidChannelDescriptor cudaErrorTextureFetchFailed cudaErrorTextureNotBound cudaErrorSynchronizationError cudaErrorUnknown cudaErrorInvalidResourceHandle cudaErrorNotReady Note that this function may also return error codes from previous asynchronous launches.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 cudaGetLastError NAME cudaGetLastError . 95 .10.

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. cuEventQuery. asynchronous launches.1 cuEventCreate NAME cuEventCreate .2. At present. cuEventElapsedTime 135 . cuEventDestroy. SEE ALSO cuEventRecord.6. cuEventSynchronize. DESCRIPTION Creates an event.creates an event SYNOPSIS CUresult cuEventCreate(CUevent* event. unsigned int flags).

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

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

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. or CUDA_ERROR_NOT_READY if not. SEE ALSO cuEventCreate.queries an event’s status SYNOPSIS CUresult cuEventQuery(CUevent event). asynchronous launches. cuEventDestroy.6.4 cuEventQuery NAME cuEventQuery . cuEventElapsedTime 138 . cuEventRecord.2. cuEventSynchronize. DESCRIPTION Returns CUDA_SUCCESS if the event has actually been recorded. If cuEventRecord() has not been called on this event.

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

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

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

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

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

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

cuParamSetv. cuParamSetSize. cuLaunchGrid 145 . 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.2. In this version of CUDA.adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func. int texunit. the texture reference must be obtained via cuModuleGetTexRef() and the texunit parameter must be set to CU_PARAM_TR_DEFAULT. asynchronous launches. cuParamSeti.4 cuParamSetTexRef NAME cuParamSetTexRef . cuParamSetf. SEE ALSO cuFuncSetBlockShape. DESCRIPTION Makes the CUDA array or linear memory bound to the texture reference texRef available to a device program as a texture. cuFuncSetSharedSize.7. CUtexref texRef).

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

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

cuFuncSetSharedSize.7 cuParamSetv NAME 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.2.7. cuLaunchGrid 148 . unsigned int numbytes). asynchronous launches.adds arbitrary data to the function’s argument list SYNOPSIS CUresult cuParamSetv(CUfunction func. offset is a byte offset. SEE ALSO cuFuncSetBlockShape. DESCRIPTION Copies an arbitrary amount of data into the parameter space of the kernel corresponding to func. cuParamSetSize. void* ptr. cuParamSeti. int offset. cuParamSetTexRef. cuLaunch. cuParamSetf.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

19 cuMemcpyDtoD NAME cuMemcpyDtoD .8. cuMemcpyHtoA.copies memory from Device to Device SYNOPSIS CUresult cuMemcpyDtoD(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. cuMemcpyAtoD. count specifies the number of bytes to copy. respectively. cuMemcpy2D 177 . SEE ALSO cuMemcpyHtoD.2. CUdeviceptr srcDevPtr. DESCRIPTION Copies from device memory to device memory. cuMemcpyDtoH. cuMemcpyAtoH. unsigned int count). asynchronous launches. dstDevice and srcDevPtr are the base pointers of the destination and source. cuMemcpyAtoA. cuMemcpyDtoA.

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

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

SEE ALSO cuMemcpyDtoH. cuMemcpyHtoDAsync() is asynchronous and can optionally be associated to a stream by passing a nonzero stream argument. count specifies the number of bytes to copy. cuMemcpy2D 180 . 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. cuMemcpyAtoD. cuMemcpyDtoD. const void *srcHostPtr. CUstream stream). unsigned int count).2. DESCRIPTION Copies from host memory to device memory. cuMemcpyAtoH. asynchronous launches. cuMemcpyHtoA.8. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. const void *srcHostPtr. cuMemcpyDtoA.copy memory from Host to Device SYNOPSIS CUresult cuMemcpyHtoD(CUdeviceptr dstDevPtr. cuMemcpyAtoA.22 cuMemcpyHtoD NAME cuMemcpyHtoD . respectively. CUresult cuMemcpyHtoDAsync(CUdeviceptr dstDevPtr. unsigned int count. dstDevPtr and srcHostPtr specify the base addresses of the destination and source.

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

or 32-bit values to the specified value value. unsigned int height ). 16-. unsigned int width. CUresult cuMemsetD2D32(CUdeviceptr dstDevPtr. cuMemAllocHost. unsigned int width. cuMemFreeHost. unsigned int dstPitch.24 cuMemset2D NAME cuMemset2D . unsigned int height ). CUresult cuMemsetD2D16(CUdeviceptr dstDevPtr. 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. cuMemset 182 . asynchronous launches.2. unsigned int dstPitch. height specifies the number of rows to set. SEE ALSO cuMemGetInfo.8. unsigned char value. cuMemGetAddressRange. unsigned int dstPitch. These functions perform fastest when the pitch is one that has been passed back by cuMemAllocPitch(). cuArrayGetDescriptor.initializes device memory SYNOPSIS CUresult cuMemsetD2D8(CUdeviceptr dstDevPtr. cuArrayCreate. unsigned int height ). unsigned int value. cuMemAllocPitch. and dstPitch specifies the number of bytes between each row. DESCRIPTION Sets the 2D memory range of width 8-. cuArrayDestroy. cuMemAlloc. unsigned int width. unsigned short value.

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

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

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

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

CUtexref texRef. SEE ALSO cuTexRefCreate.2.gets the addressing mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetAddressMode(CUaddress_mode* mode. cuTexRefSetFilterMode. 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. Currently the only valid values for dim are 0 and 1. cuTexRefGetAddress. cuTexRefDestroy. cuTexRefGetFlags 187 . DESCRIPTION Returns in *mode the addressing mode corresponding to the dimension dim of the texture reference texRef. cuTexRefSetArray. cuTexRefGetFilterMode. cuTexRefGetFormat. cuTexRefGetArray. cuTexRefSetFormat. cuTexRefSetAddress.9.4 cuTexRefGetAddressMode NAME cuTexRefGetAddressMode . cuTexRefSetAddressMode. asynchronous launches. int dim).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful