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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMalloc.6 cudaMallocHost NAME cudaMallocHost . asynchronous launches.5. size_t size ) DESCRIPTION Allocates size bytes of host memory that is page-locked and accessible to the device. since it reduces the amount of memory available to the system for paging. cudaFreeHost 30 . 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. cudaMallocPitch. cudaFreeArray. Allocating excessive amounts of memory with cudaMallocHost() may degrade system performance. Since the memory can be accessed directly by the device.1. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as cudaMemcpy*(). cudaFree. cudaMallocArray.allocates page-locked memory on the host SYNOPSIS cudaError_t cudaMallocHost( void** hostPtr. it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). As a result.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3. cuCtxAttach() fails if there is no context current to the thread. Currently. 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. unsigned int Flags). the Flags parameter must be 0. asynchronous launches.1 cuCtxAttach NAME cuCtxAttach . cuCtxGetDevice. cuCtxDetach.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. 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 Note that this function may also return error codes from previous.2. cuCtxSynchronize 112 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5.determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream). cuStreamSynchronize. or CUDA_ERROR_NOT_READY if not. 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.3 cuStreamQuery NAME cuStreamQuery . SEE ALSO cuStreamCreate. DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed. cuStreamDestroy 132 . asynchronous launches.2.

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Sets through numbytes the total size in bytes needed by the function parameters of function func. cuFuncSetSharedSize. cuLaunchGrid 144 . cuParamSetv.2. cuParamSetTexRef. cuParamSetf.sets the parameter-size for the function SYNOPSIS CUresult cuParamSetSize(CUfunction func. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.7. asynchronous launches. unsigned int numbytes).3 cuParamSetSize NAME cuParamSetSize . cuParamSeti. cuLaunch. 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. cuParamSetSize. cuLaunch. DESCRIPTION Makes the CUDA array or linear memory bound to the texture reference texRef available to a device program as a texture.2. SEE ALSO cuFuncSetBlockShape. cuParamSeti. 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. cuLaunchGrid 145 . CUtexref texRef).adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func. In this version of CUDA. cuFuncSetSharedSize.4 cuParamSetTexRef NAME cuParamSetTexRef . cuParamSetv.7. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefGetFilterMode. cuTexRefSetAddressMode.9. cuTexRefGetArray. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetFlags. SEE ALSO cuTexRefCreate. cuTexRefGetAddressMode. cuTexRefSetFormat. cuTexRefDestroy. asynchronous launches.2.7 cuTexRefGetFlags NAME cuTexRefGetFlags . cuTexRefSetFilterMode.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. cuTexRefGetFormat 190 . cuTexRefSetArray. cuTexRefGetAddress. CUtexref texRef). cuTexRefSetAddress.

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

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

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

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

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

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

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

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

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

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

GLuint bufferObj).10. unsigned int* size.2. cuGLRegisterBufferObject. 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. cuGLUnregisterBufferObject 201 . cuGLInit. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr.3 cuGLMapBufferObject NAME cuGLMapBufferObject . asynchronous launches. SEE ALSO cuGLCtxCreate. cuGLUnmapBufferObject.

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

int val). unsigned int val). atomicInc. 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. atomicMax.3. atomicDec. The function returns b<old>. and stores the result back to global memory at the same address.1. SEE ALSO atomicAdd. atomicCAS 227 . atomicSub. computes the minimum of old and val. atomicExch.atomic minimum SYNOPSIS int atomicMin(int* address. unsigned int atomicMin(unsigned int* address.1 and higher.4 atomicMin NAME atomicMin . These three operations are performed in one atomic transaction.

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful