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

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

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

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

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

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

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

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

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

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

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

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. or 0 if not. cudaSetDevice. clockRate is the clock frequency in kilohertz. texture base addresses that are aligned to textureAlignment bytes do not need an offset applied to texture fetches. asynchronous launches. maxThreadsDim[3] is the maximum sizes of each dimension of a block. maxThreadsPerBlock is the maximum number of threads per block. maxGridSize[3] is the maximum sizes of each dimension of a grid.memPitch is the maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through cudaMallocPitch(). SEE ALSO cudaGetDeviceCount. deviceOverlap is 1 if the device can concurrently copy memory between host and device while executing a kernel. multiProcessorCount is the number of multiprocessors on the device. cudaGetDevice. totalConstMem is the total amount of constant memory available on the device in bytes. cudaChooseDevice 7 . textureAlignment is the alignment requirement. major.

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

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

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

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

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

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

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

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

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

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

cudaEventElapsedTime 18 .4. 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 . cudaEventQuery.1. asynchronous launches. cudaEventSynchronzie. cudaEventDestroy. SEE ALSO cudaEventRecord.creates an event-object SYNOPSIS cudaError_t cudaEventCreate( cudaEvent_t* event ) DESCRIPTION Creates an event object.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

*size is unchanged and an error is returned. symbol can either be a variable that resides in global or constant memory space. cudaGetSymbolSize() returns cudaErrorInvalidSymbol in case of failure. naming a variable that resides in global or constant memory space. asynchronous launches.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. const T& symbol) DESCRIPTION Returns in *size the size of symbol symbol. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidSymbol Note that this function may also return error codes from previous. or if symbol is not declared in global or constant memory space.5. or it can be a character string.1.21 cudaGetSymbolSize NAME cudaGetSymbolSize . SEE ALSO cudaGetSymbolAddress 45 .

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

Memory Management. OpenGL Interoperability. Stream Management. Execution Management.1. Texture Reference Management. Event Management. Thread 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. Direct3D Interoperability. Error Handling 54 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

size_t offset) template < class T > cudaError_t cudaSetupArgument(T arg. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. which starts at offset 0. cudaLaunch 71 . size_t count.7. 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.3 cudaSetupArgument NAME cudaSetupArgument .1. size_t offset) DESCRIPTION Pushes count bytes of the argument pointed to by arg at offset bytes from the start of the parameter passing area. SEE ALSO cudaConfigureCall. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cuCtxCreate.2. cuCtxDetach.3. cuCtxGetDevice.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxAttach() fails if there is no context current to the thread. the Flags parameter must be 0. Currently.1 cuCtxAttach NAME cuCtxAttach . 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. cuCtxSynchronize 112 . 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.

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

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

3 cuStreamQuery NAME cuStreamQuery . SEE ALSO cuStreamCreate. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_READY Note that this function may also return error codes from previous. asynchronous launches. DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed. cuStreamSynchronize.5. cuStreamDestroy 132 .2. or CUDA_ERROR_NOT_READY if not.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 Note that this function may also return error codes from previous. cuStreamDestroy 133 . DESCRIPTION Blocks until the device has completed all operations in the stream. cuStreamQuery.block until a stream’s tasks are completed SYNOPSIS CUresult cuStreamSynchronize(CUstream stream). SEE ALSO cuStreamCreate.5.4 cuStreamSynchronize NAME cuStreamSynchronize . asynchronous launches.2.

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

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

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

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

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

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

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

ExecutionControl. TextureReferenceManagement. Direct3dInteroperability 141 . OpenGlInteroperability. DeviceManagement. StreamManagement. ContextManagement. ModuleManagement.7 ExecutionControl NAME Execution Control DESCRIPTION This section describes the low-level CUDA driver application programming interface. MemoryManagement.2. EventManagement. cuLaunch cuLaunchGrid cuParamSetSize cuParamSetTexRef cuParamSetf cuParamSeti cuParamSetv cuFuncSetBlockShape cuFuncSetSharedSize 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_LAUNCH_INCOMPATIBLE_TEXTURING Note that this function may also return error codes from previous. DESCRIPTION Invokes the kernel func on a 1ÃŮ1 grid of blocks. cuParamSetSize. cuLaunchGrid 142 .1 cuLaunch NAME cuLaunch . cuParamSetTexRef. The block contains the number of threads specified by a previous call to cuFuncSetBlockShape(). cuParamSetv. cuParamSeti.2. SEE ALSO cuFuncSetBlockShape. asynchronous launches. cuFuncSetSharedSize. cuParamSetf.7.launches a CUDA function SYNOPSIS CUresult cuLaunch(CUfunction func).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.8. this function is best used sparingly to allocate staging areas for data exchange between host and device. cuMemset2D 160 . Allocating excessive amounts of memory with cuMemAllocHost() may degrade system performance. cuMemAlloc. asynchronous launches.7 cuMemAllocHost NAME cuMemAllocHost . As a result. Since the memory can be accessed directly by the device. cuArrayDestroy. it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). cuArrayCreate. cuMemset. DESCRIPTION Allocates count bytes of host memory that is page-locked and accessible to the device. unsigned int count). cuMemFree. SEE ALSO cuMemGetInfo. cuMemGetAddressRange. cuMemFreeHost. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as cuMemcpy(). cuArrayGetDescriptor.allocates page-locked host memory SYNOPSIS CUresult cuMemAllocHost(void** hostPtr. since it reduces the amount of memory available to the system for paging. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_OUT_OF_MEMORY Note that this function may also return error codes from previous. cuMemAllocPitch.

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

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

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

cuMemset. cuMemFree. asynchronous launches. which must have been returned by a previous call to cuMemAllocHost(). DESCRIPTION Frees the memory space pointed to by hostPtr. cuMemset2D 164 . cuMemAllocPitch.10 cuMemFreeHost NAME cuMemFreeHost . SEE ALSO cuMemGetInfo.8. cuMemAllocHost. cuMemGetAddressRange. cuMemAlloc. cuArrayGetDescriptor. cuArrayCreate. cuArrayDestroy.2.frees page-locked host memory SYNOPSIS CUresult cuMemFreeHost(void* hostPtr). 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. cuArrayCreate.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.11 cuMemGetAddressRange NAME cuMemGetAddressRange .2. cuMemset2D 165 . Both parameters basePtr and size are optional. unsigned int* size. If one of them is null. cuMemFreeHost. cuMemAllocHost. cuArrayGetDescriptor. cuMemset. CUdeviceptr devPtr). cuMemFree. cuArrayDestroy. DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr. cuMemAlloc. SEE ALSO cuMemGetInfo. it is ignored. asynchronous launches.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. SEE ALSO cuTexRefCreate. cuTexRefGetFormat. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef.9. cuTexRefGetFilterMode. cuTexRefGetFlags 197 .sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.14 cuTexRefSetFormat NAME cuTexRefSetFormat .2. cuTexRefSetArray. cuTexRefDestroy. cuTexRefGetAddress. cuTexRefSetAddress. format and numPackedComponents are exactly analogous to the Format and NumChannels members of the CUDA_ARRAY_DESCRIPTOR structure: They specify the format of each component and the number of components per array element. CUarray_format format. cuTexRefSetFlags. cuTexRefGetAddressMode. cuTexRefSetFilterMode. cuTexRefGetArray. cuTexRefSetAddressMode.

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

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

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

SEE ALSO cuGLCtxCreate.10.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. asynchronous launches. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping. 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. GLuint bufferObj). cuGLUnregisterBufferObject 201 . cuGLRegisterBufferObject. cuGLUnmapBufferObject. unsigned int* size.2.3 cuGLMapBufferObject NAME cuGLMapBufferObject .

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

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

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

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

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

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

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

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

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

cuD3D9RegisterResource. cuD3D9MapResources.2. cuD3D9ResourceSetMapFlags.5 cuD3D9UnregisterResource NAME cuD3D9UnregisterResource .unregister a Direct3D resource SYNOPSIS CUresult cuD3D9UnregisterResource(IDirect3DResource9* pResource). RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9ResourceGetMappedPitch 211 . DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again.11. cuD3D9GetDirect3DDevice. cuD3D9UnmapResources. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. cuD3D9ResourceGetSurfaceDimensions. asynchronous launches. SEE ALSO cuD3D9GetDevice. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9CtxCreate.

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

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

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

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

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

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

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

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

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 .

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful