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

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

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

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

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

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

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

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

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

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

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

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

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

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

wait for compute-device to finish SYNOPSIS cudaError_t cudaThreadSynchronize(void) DESCRIPTION Blocks until the device has completed all preceding requested tasks. SEE ALSO cudaThreadExit 10 .2.1. asynchronous launches. 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.1 cudaThreadSynchronize NAME cudaThreadSynchronize .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

size_t width. cudaFreeArray.4 cudaMallocArray NAME cudaMallocArray . SEE ALSO cudaMalloc. const struct cudaChannelFormatDesc* desc. }. cudaMallocPitch. size_t height ) DESCRIPTION Allocates a CUDA array according to the cudaChannelFormatDesc structure desc and returns a handle to the new CUDA array in *array. cudaChannelFormatKindUnsigned. enum cudaChannelFormatKind f. cudaFree. z.1. RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous.allocate an array on the GPU SYNOPSIS cudaError_t cudaMallocArray( struct cudaArray** array. cudaFreeHost 28 .5. y. The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. w. asynchronous launches. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. cudaMallocHost. cudaChannelFormatKindFloat.

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidDevicePointer Note that this function may also return error codes from previous. asynchronous launches.1. size_t width.9 cudaMemset2D NAME cudaMemset2D . pitch is the width in memory in bytes of the 2D array pointed to by dstPtr.initializes or sets GPU memory to a value SYNOPSIS cudaError_t cudaMemset2D( void* dstPtr. SEE ALSO cudaMemset.5. size_t height ) DESCRIPTION Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. size_t pitch. int value. 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(). cudaMemset3D 33 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.1 cudaGetLastError NAME cudaGetLastError . 95 . 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.10.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.

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

2. cuDeviceGetAttribute.2. cuDeviceGetCount()-1]. int ordinal). cuDeviceGetCount.returns a device-handle SYNOPSIS CUresult cuDeviceGet(CUdevice* dev. cuDeviceGetProperties. DESCRIPTION Returns in *dev a device handle given an ordinal in the range [0. SEE ALSO cuDeviceComputeCapability. asynchronous launches. cuDeviceTotalMem 103 .2 cuDeviceGet NAME cuDeviceGet . 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.

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

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

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

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

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

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

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

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

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

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

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

or the context is current to any CPU thread other than the current one.3 cuCtxDestroy NAME cuCtxDestroy . cuCtxDetach. cuCtxPushCurrent. DESCRIPTION Destroys the given CUDA context. Floating contexts (detached from a CPU thread via cuCtxPopCurrent()) may be destroyed by this function.2. SEE ALSO cuCtxCreate. cuCtxAttach. If the context usage count is not equal to 1.3. cuCtxPopCurrent 115 . asynchronous launches. this function fails.destroy the current context context or a floating CuDA context SYNOPSIS CUresult cuCtxDestroy(CUcontext ctx). 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.3. and destroys the context if the usage count goes to 0. SEE ALSO cuCtxCreate. cuCtxAttach. DESCRIPTION Decrements the usage count of the context. cuCtxDestroy.decrement a context’s usage-count SYNOPSIS CUresult cuCtxDetach(CUcontext ctx). and must be current to the calling thread. asynchronous launches. cuCtxPushCurrent.4 cuCtxDetach NAME cuCtxDetach . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. The context must be a handle that was passed back by cuCtxCreate() or cuCtxAttach(). cuCtxPopCurrent 116 .

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

SYNOPSIS
CUresult cuModuleGetTexRef(CUtexref* texRef, CUmodule hmod, const char* texrefname);

DESCRIPTION
Returns in *texref the handle of the texture reference of name texrefname in the module mod. If no texture reference of that name exists, cuModuleGetTexRef() returns CUDA_ERROR_NOT_FOUND. This texture reference handle should not be destroyed, since it will be destroyed when the module is unloaded.

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

SEE ALSO
cuModuleLoad, cuModuleLoadData, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

SYNOPSIS
CUresult cuModuleLoad(CUmodule* mod, const char* filename);

DESCRIPTION
Takes a file name filename and loads the corresponding module mod into the current context. The CUDA driver API does not attempt to lazily allocate the resources needed by a module; if the memory for functions and data (constant and global) needed by the module cannot be allocated, cuModuleLoad() fails. The file should be a cubin file as output by nvcc.

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

SEE ALSO
cuModuleLoadData, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

SYNOPSIS
CUresult cuModuleLoadData(CUmodule* mod, const void* image);

DESCRIPTION
Takes a pointer image and loads the corresponding module mod into the current context. The pointer may be obtained by mapping a cubin file, passing a cubin file as a text string, or incorporating a cubin object into the executable resources and using operation system calls such as WindowsâĂŹ FindResource() to obtain the pointer.

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

SEE ALSO
cuModuleLoad, cuModuleLoadFatBinary, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

SYNOPSIS
CUresult cuModuleLoadFatBinary(CUmodule* mod, const void* fatBin);

DESCRIPTION
Takes a pointer fatBin and loads the corresponding module mod into the current context. The pointer represents a fat binary object, which is a collection of different cubin files, all representing the same device code but compiled and optimized for different architectures. There is currently no documented API for constructing and using fat binary objects by programmers, and therefore this function is an internal function in this version of CUDA. More information can be found in the nvcc document.

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

SEE ALSO
cuModuleLoad, cuModuleLoadData, cuModuleUnload, cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef

127

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemAllocPitch. cuArrayDestroy.2. SEE ALSO cuMemGetInfo. cuMemFreeHost. cuMemset. cuMemset2D 165 . Both parameters basePtr and size are optional.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. it is ignored.8. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. CUdeviceptr devPtr). cuMemAlloc. If one of them is null. unsigned int* size. cuArrayCreate. cuMemAllocHost. cuArrayGetDescriptor. asynchronous launches.11 cuMemGetAddressRange NAME cuMemGetAddressRange . 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. cuArrayGetDescriptor. cuMemAllocPitch. SEE ALSO cuMemAlloc. cuArrayCreate. cuMemAllocHost. in bytes. the free and total amount of memory available for allocation by the CUDA context. cuMemFreeHost.gets free and total memory SYNOPSIS CUresult cuMemGetInfo(unsigned int* free.12 cuMemGetInfo NAME cuMemGetInfo . cuMemset. unsigned int* total).2. cuArrayDestroy. asynchronous launches. cuMemset2D 166 . cuMemGetAddressRange. DESCRIPTION Returns in *free and *total respectively. cuMemFree. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefGetFilterMode.3 cuTexRefGetAddress NAME 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. CUtexref texRef).gets the address associated with a texture-reference SYNOPSIS CUresult cuTexRefGetAddress(CUdeviceptr* devPtr. cuTexRefDestroy. cuTexRefSetAddressMode.2. cuTexRefGetAddressMode. asynchronous launches. cuTexRefGetArray. cuTexRefGetFormat. cuTexRefSetAddress. DESCRIPTION Returns in *devPtr the base address bound to the texture reference texRef. cuTexRefGetFlags 186 . cuTexRefSetFilterMode. cuTexRefSetFlags. SEE ALSO cuTexRefCreate. cuTexRefSetArray.9. or returns CUDA_ERROR_INVALID_VA if the texture reference is not bound to any device memory range. cuTexRefSetFormat.

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

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

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

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

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

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

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

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

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

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

cuTexRefGetArray. cuTexRefDestroy. cuTexRefSetAddress.2. cuTexRefSetFlags. CUarray_format format. cuTexRefGetAddressMode. asynchronous launches.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. SEE ALSO cuTexRefCreate. cuTexRefSetFilterMode. cuTexRefGetFlags 197 . int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefSetAddressMode. cuTexRefGetFilterMode. 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.14 cuTexRefSetFormat NAME cuTexRefSetFormat . cuTexRefGetFormat. cuTexRefSetArray.9. cuTexRefGetAddress.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

unsigned int val).6 atomicInc NAME atomicInc .1 and higher. computes ((old >= val) ? 0 : (old+1)). 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. atomicMin. atomicDec. atomicSub. and stores the result back to global memory at the same address. DESCRIPTION Reads the 32-bit word old located at the address address in global memory.1. SEE ALSO atomicAdd. atomicExch.3.atomic increment SYNOPSIS unsigned int atomicInc(unsigned int* address. atomicMax. atomicCAS 229 .

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful