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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1. cudaFreeHost 26 . The intended usage of pitch is as a separate parameter of the allocation. it is recommended that programmers consider performing pitch allocations using cudaMallocPitch().2 cudaMallocPitch NAME cudaMallocPitch . 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. For allocations of 2D arrays. 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). SEE ALSO cudaMalloc. cudaMallocHost. the address is computed as T* pElement = (T*)((char*)BaseAddress + Row * pitch) + Column. cudaFreeArray. cudaMallocArray. Given the row and column of an array element of type T. size_t height ) DESCRIPTION Allocates at least widthInBytes*height bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory.allocates memory on the GPU SYNOPSIS cudaError_t cudaMallocPitch( void** devPtr. size_t widthInBytes. cudaFree.5. used to compute addresses within the 2D array. size_t* pitch. The pitch returned in *pitch by cudaMallocPitch() is the width in bytes of the allocation. asynchronous launches. Due to pitch alignment restrictions in the hardware.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

symbol can either be a variable that resides in global or constant memory space. SEE ALSO cudaGetSymbolAddress 45 . or it can be a character string. 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.finds the size of the object associated with a CUDA symbol SYNOPSIS template < class T > cudaError_t cudaGetSymbolSize(size_t* size. If symbol cannot be found. cudaGetSymbolSize() returns cudaErrorInvalidSymbol in case of failure.21 cudaGetSymbolSize NAME cudaGetSymbolSize .1. or if symbol is not declared in global or constant memory space. asynchronous launches. const T& symbol) DESCRIPTION Returns in *size the size of symbol symbol.5. naming a variable that resides in global or constant memory space.

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

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

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

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

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

cudaMalloc3D 51 .SEE ALSO cudaMemset. cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.2 cudaLaunch NAME cudaLaunch . entry must be declared as a __global__ function. entry can either be a function that executes on the device. 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. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. naming a function that executes on the device. SEE ALSO cudaConfigureCall.7. cudaSetupArgument 70 . or it can be a character string.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 Note that this function may also return error codes from previous. which starts at offset 0. size_t count. cudaSetupArgument() must be preceded by a call to cudaConfigureCall().configure a device-launch SYNOPSIS cudaError_t cudaSetupArgument(void* arg. The arguments are stored in the top of the execution stack. size_t offset) DESCRIPTION Pushes count bytes of the argument pointed to by arg at offset bytes from the start of the parameter passing area.3 cudaSetupArgument NAME cudaSetupArgument . SEE ALSO cudaConfigureCall.1. size_t offset) template < class T > cudaError_t cudaSetupArgument(T arg. cudaLaunch 71 .7. asynchronous launches.

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9RegisterResource. 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. cudaD3D9ResourceGetMappedPointer. cudaD3D9SetDirect3DDevice. cudaD3D9UnmapResources. The resources in ppResources may be accessed in CUDA kernels until they are unmapped. cudaD3D9UnregisterResource. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned. asynchronous launches.1. This function provides the synchronization guarantee that any Direct3D calls issued before cudaD3D9MapResources will complete before any CUDA kernels issued after cudaD3D9MapResources begin.map Direct3D resources for access by CUDA SYNOPSIS cudaError_t cudaD3D9MapResources(unsigned int count. cudaD3D9ResourceGetMappedPitch 85 . SEE ALSO cudaD3D9GetDevice.9. cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetMappedSize. If an application does so the results are undefined. If any of ppResources are presently mapped for access by CUDA then cudaErrorUnknown is returned. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. IDirect3DResource9 **ppResources). cudaD3D9ResourceSetMapFlags.6 cudaD3D9MapResources NAME cudaD3D9MapResources .

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

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

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

cudaD3D9MapResources. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidValue cudaErrorInvalidHandle Note that this function may also return error codes from previous. and *pDepth the dimensions of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. DESCRIPTION Returns in *pWidth. size_t* pHeight.1. cudaD3D9ResourceSetMapFlags. *pHeight. cudaD3D9ResourceGetMappedPitch 89 . IDirect3DResource9* pResource. cudaD3D9ResourceGetMappedPointer. the value returned in *pDepth will be 0. pHeight. cudaD3D9SetDirect3DDevice. cudaD3D9GetDirect3DDevice. size_t *pDepth. 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. SEE ALSO cudaD3D9GetDevice.9. cudaD3D9RegisterResource. The parameters pWidth.9 cudaD3D9ResourceGetSurfaceDimensions NAME cudaD3D9ResourceGetSurfaceDimensions . Because anti-aliased surfaces may have multiple samples per pixel it is possible that the dimensions of a resource will be an integer factor larger than the dimensions reported by the Direct3D runtime. cudaD3D9ResourceGetMappedSize. For usage requirements of Face and Level parameters see cudaD3D9ResourceGetMappedPointer. cudaD3D9UnregisterResource. unsigned int Face. and pDepth are optional. unsigned int Level). cudaD3D9UnmapResources. For 2D surfaces. asynchronous launches.

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

the event is recorded after all preceding operations in the stream have been completed. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. this function returns CUDA_ERROR_INVALID_VALUE.5 cuEventRecord NAME cuEventRecord . it is recorded after all preceding operations in the CUDA context have been completed. cuEventQuery() and/or cuEventSynchronize() must be used to determine when the event has actually been recorded.2. cuEventDestroy. Since this operation is asynchronous. SEE ALSO cuEventCreate. cuEventElapsedTime 139 . DESCRIPTION Records an event. asynchronous launches. otherwise.6. CUstream stream). cuEventQuery. If cuEventRecord() has previously been called and the event has not been recorded yet. cuEventSynchronize. If stream is non-zero.records an event SYNOPSIS CUresult cuEventRecord(CUevent event.

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

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

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

int grid_height). cuParamSetf. CUresult cuLaunchGridAsync(CUfunction func.7. int grid_width. cuParamSetTexRef. cuFuncSetSharedSize. cuParamSetSize.launches a CUDA function SYNOPSIS CUresult cuLaunchGrid(CUfunction func. cuLaunch 143 . cuParamSeti. int grid_width. asynchronous launches.2 cuLaunchGrid NAME cuLaunchGrid . SEE ALSO cuFuncSetBlockShape. CUstream stream). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING Note that this function may also return error codes from previous. 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(). cuParamSetv. int grid_height.2. DESCRIPTION Invokes the kernel on a grid_width x grid_height grid of blocks.

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

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

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

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

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

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

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. unsigned int bytes).9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . cuParamSetv. SEE ALSO cuFuncSetBlockShape. cuLaunch. cuParamSetTexRef. asynchronous launches.2. cuParamSetf. 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. cuLaunchGrid 150 . cuParamSetSize.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. cuParamSeti.7.

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

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

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

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

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

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

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

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

cuMemFreeHost.8.allocates device memory SYNOPSIS CUresult cuMemAlloc(CUdeviceptr* devPtr. asynchronous launches. DESCRIPTION Allocates count bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. cuMemFree. cuMemAlloc() returns CUDA_ERROR_INVALID_VALUE. cuArrayCreate. cuArrayDestroy.6 cuMemAlloc NAME cuMemAlloc . cuMemGetAddressRange. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. cuArrayGetDescriptor. unsigned int count). cuMemset.2. cuMemAllocHost. cuMemset2D 159 . SEE ALSO cuMemGetInfo. cuMemAllocPitch. The memory is not cleared. If count is 0. The allocated memory is suitably aligned for any kind of variable.

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

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

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

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

Both parameters basePtr and size are optional. cuArrayDestroy. asynchronous launches. cuMemset2D 165 .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. cuMemAllocPitch. cuMemFreeHost.11 cuMemGetAddressRange NAME cuMemGetAddressRange . CUdeviceptr devPtr). cuArrayGetDescriptor. 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. cuArrayCreate.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. unsigned int* size. it is ignored. cuMemset.8. SEE ALSO cuMemGetInfo. If one of them is null. cuMemAllocHost. cuMemAlloc.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

MemoryManagement. EventManagement. TextureReferenceManagement. Direct3dInteroperability 198 . DeviceManagement. StreamManagement. ExecutionControl. ModuleManagement. OpenGLInteroperability.2. ContextManagement.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.

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

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

SEE ALSO cuGLCtxCreate. cuGLUnmapBufferObject. cuGLUnregisterBufferObject 201 . 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. GLuint bufferObj). cuGLRegisterBufferObject. unsigned int* size. 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_MAP_FAILED Note that this function may also return error codes from previous. cuGLInit.3 cuGLMapBufferObject NAME cuGLMapBufferObject .2.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr.10.

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

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

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

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

cuD3D9UnmapResources.2. const char* adapterName). cuD3D9GetDirect3DDevice.11.1 cuD3D9GetDevice NAME cuD3D9GetDevice . cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. SEE ALSO cuD3D9CtxCreate. 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. cuD3D9UnregisterResource. cuD3D9RegisterResource. cuD3D9ResourceGetMappedPitch 206 . cuD3D9ResourceGetSurfaceDimensions. cuD3D9ResourceSetMapFlags.gets the device number for an adapter SYNOPSIS CUresult cuD3D9GetDevice(CUdevice* dev. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_VALUE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9MapResources. asynchronous launches.

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

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

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

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

SEE ALSO cuD3D9GetDevice.2. cuD3D9CtxCreate. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. cuD3D9ResourceGetMappedPitch 211 . cuD3D9RegisterResource. cuD3D9ResourceSetMapFlags. cuD3D9MapResources. cuD3D9GetDirect3DDevice. cuD3D9ResourceGetSurfaceDimensions.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource . If pResource is not registered 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_HANDLE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous.11.unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). cuD3D9UnmapResources. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful