CudaReferenceManual_2.0 | Integer (Computer Science) | Pointer (Computer Programming)

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

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

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

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

. . . . . . . . . . . . . . . . . . . . . . . . . . .3.2. . . .3 atomicXor . . . . . 235 vii . . . . . . . .

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

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

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

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

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

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

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

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

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

asynchronous launches.1.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.2. cudaThreadSynchronize() returns an error if one of the preceding tasks failed. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. SEE ALSO cudaThreadExit 10 .

cudaThreadExit() is implicitly called on host thread exit.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 cudaThreadExit NAME cudaThreadExit .2. SEE ALSO cudaThreadSynchronize 11 . RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous.1. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

cuDeviceTotalMem 105 . 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. SEE ALSO cuDeviceComputeCapability. asynchronous launches. cuDeviceGetCount. cuDeviceGet. cuDeviceGetProperties.

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

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

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

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

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

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

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

If a context is already current to the thread. but can increase the performance of CPU threads performing work in parallel with the GPU.2. but may lower the performance of CPU threads if they are performing work in parallel with the CUDA thread.create a CUDA context SYNOPSIS CUresult cuCtxCreate(CUcontext* pCtx. If C > P then CUDA will yield to other OS threads when waiting for the GPU.2 cuCtxCreate NAME cuCtxCreate . • CU_CTX_SCHED_AUTO: The default value if the Flags parameter is zero. otherwise CUDA will not yield while waiting for results and actively spin on the processor. 113 . This can decrease latency when waiting for the GPU. The context is created with a usage count of 1 and the caller of cuCtxCreate() must call cuCtxDestroy() or cuCtxDetach() when done using the context. DESCRIPTION Creates a new CUDA context and associates it with the calling thread. 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. The Flags parameter is described below. 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. asynchronous launches. This can increase latency when waiting for the GPU. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_DEVICE CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.3. • CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for results from the GPU. it is supplanted by the newly created context and may be restored by a subsequent call to cuCtxPopCurrent(). CUdevice dev). unsigned int Flags. • CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for results from the GPU.

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

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

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

3.5 cuCtxGetDevice NAME cuCtxGetDevice . 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.return device-ID for current context SYNOPSIS CUresult cuCtxGetDevice(CUdevice* device). cuCtxAttach. cuCtxDetach.2. asynchronous launches. SEE ALSO cuCtxCreate. cuCtxSynchronize 117 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuParamSeti. cuLaunchGrid 144 . cuParamSetTexRef. SEE ALSO cuFuncSetBlockShape. cuLaunch. cuParamSetv. cuParamSetf. DESCRIPTION Sets through numbytes the total size in bytes needed by the function parameters of function func.2.7.3 cuParamSetSize NAME cuParamSetSize . cuFuncSetSharedSize. unsigned int numbytes). 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.sets the parameter-size for the function SYNOPSIS CUresult cuParamSetSize(CUfunction func. asynchronous launches.

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

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

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

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

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

SEE ALSO cuFuncSetBlockShape. cuParamSetf. cuLaunchGrid 150 . 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. cuLaunch.7.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . cuParamSetTexRef. unsigned int bytes).2. asynchronous launches. DESCRIPTION Sets through bytes the amount of shared memory that will be available to each thread block when the kernel given by func is launched. cuParamSetSize. cuParamSetv.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. cuParamSeti.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemcpyDtoH. cuMemcpyHtoA. cuMemcpyAtoH. asynchronous launches. cuMemcpyAtoD. cuMemcpyAtoA. cuMemcpyDtoD.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. cuMemcpyDtoA. cuMemcpy3D 169 .

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

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

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

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

cuMemcpyHtoA.8. cuMemcpyDtoD. unsigned int count). cuMemcpy2D 174 . DESCRIPTION Copies from a 1D CUDA array to device memory.16 cuMemcpyAtoD NAME cuMemcpyAtoD . 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.2. count specifies the number of bytes to copy and must be evenly divisible by the array element size. SEE ALSO cuMemcpyHtoD. cuMemcpyAtoH. cuMemcpyAtoA. CUarray srcArray. cuMemcpyDtoH. asynchronous launches. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. dstDevPtr specifies the base pointer of the destination and must be naturally aligned with the CUDA array elements. cuMemcpyDtoA. unsigned int srcIndex.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefGetFormat. cuTexRefGetArray. cuTexRefDestroy. If dim is zero. CU_TR_ADDRESS_MODE_MIRROR = 2. CUaddress_mode is defined as such: typedef enum CUaddress_mode_enum { CU_TR_ADDRESS_MODE_WRAP = 0. cuTexRefSetFilterMode. cuTexRefSetFlags.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. the second.10 cuTexRefSetAddressMode NAME cuTexRefSetAddressMode . cuTexRefGetAddressMode. DESCRIPTION Specifies the addressing mode mode for the given dimension of the texture reference texRef. CUaddress_mode mode). cuTexRefGetAddress. Note that this call has no effect if texRef is bound to linear memory.9. } CUaddress_mode. int dim. cuTexRefSetFormat. cuTexRefSetArray.2. asynchronous launches. cuTexRefGetFilterMode. CU_TR_ADDRESS_MODE_CLAMP = 1. cuTexRefSetAddress. SEE ALSO cuTexRefCreate. if dim is 1. the addressing mode is applied to the first parameter of the functions used to fetch from the texture. cuTexRefGetFlags 193 . and so on.

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

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

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

SEE ALSO cuTexRefCreate. asynchronous launches. cuTexRefSetAddressMode.9. cuTexRefGetFilterMode.14 cuTexRefSetFormat NAME cuTexRefSetFormat . CUarray_format format. 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. 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. cuTexRefSetArray. cuTexRefSetFlags.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. cuTexRefGetFlags 197 . cuTexRefGetAddress. cuTexRefSetFilterMode. cuTexRefDestroy. cuTexRefGetArray.2. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. cuTexRefGetAddressMode. cuTexRefSetAddress.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful