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

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

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

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

. .2.3. . . . . . . . . . . . . . . . . . . . . . . . . . 235 vii . . . . . . . .3 atomicXor . . . . . . . .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetSymbolSize 44 .1.finds the address associated with a CUDA symbol SYNOPSIS template < class T > cudaError_t cudaGetSymbolAddress(void** devPtr. If symbol cannot be found. or it can be a character string.20 cudaGetSymbolAddress NAME cudaGetSymbolAddress .5. 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. symbol can either be a variable that resides in global memory space. *devPtr is unchanged and an error is returned. 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. naming a variable that resides in global memory space.

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

asynchronous launches. cuDeviceTotalMem 105 . 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. cuDeviceGetName. cuDeviceGet. cuDeviceGetProperties.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

destroys a stream SYNOPSIS CUresult cuStreamDestroy(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.2 cuStreamDestroy NAME cuStreamDestroy . cuStreamQuery.5. SEE ALSO cuStreamCreate. DESCRIPTION Destroys the stream. cuStreamSynchronize 131 . asynchronous launches.2.

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

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

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

cuEventDestroy. SEE ALSO cuEventRecord.creates an event SYNOPSIS CUresult cuEventCreate(CUevent* event. cuEventElapsedTime 135 .6.1 cuEventCreate NAME cuEventCreate . flags is required to be 0. cuEventQuery. asynchronous launches. DESCRIPTION Creates an event. 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. cuEventSynchronize.2. unsigned int flags).

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

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

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

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

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

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

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

CUresult cuLaunchGridAsync(CUfunction func. DESCRIPTION Invokes the kernel on a grid_width x grid_height grid of blocks. int grid_width. cuParamSeti. cuFuncSetSharedSize. cuLaunchGridAsync() can optionally be associated to a stream by passing a non-zero stream argument. cuParamSetTexRef. CUstream stream).2. cuParamSetf. SEE ALSO cuFuncSetBlockShape.launches a CUDA function SYNOPSIS CUresult cuLaunchGrid(CUfunction func.7.2 cuLaunchGrid NAME cuLaunchGrid . int grid_height. cuLaunch 143 . int grid_width. cuParamSetv. cuParamSetSize. asynchronous launches. Each block contains the number of threads specified by a previous call to cuFuncSetBlockShape(). int grid_height). 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. cuGLUnregisterBufferObject 201 . cuGLInit. GLuint bufferObj). 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.2. SEE ALSO cuGLCtxCreate. cuGLRegisterBufferObject. cuGLUnmapBufferObject.10.3 cuGLMapBufferObject NAME cuGLMapBufferObject . unsigned int* size. asynchronous launches.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr.

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

DESCRIPTION
This section describes the atomic bitwise functions. atomicAnd atomicOr atomicXor

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

SYNOPSIS
int atomicAnd(int* address, int val); unsigned int atomicAnd(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old & val), and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

SYNOPSIS
int atomicOr(int* address, int val); unsigned int atomicOr(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old , and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

SYNOPSIS
int atomicXor(int* address, int val); unsigned int atomicXor(unsigned int* address, unsigned int val);

DESCRIPTION
Reads the 32-bit word old located at the address address in global memory, computes (old ˆ val), and stores the result back to global memory at the same address. These three operations are performed in one atomic transaction. The function returns old.

NOTES
Atomic operations are only supported on devices of compute capability 1.1 and higher.

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful