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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetDeviceCount.1. cudaSetDevice. 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.select compute-device which best matches criteria SYNOPSIS cudaError_t cudaChooseDevice( int* dev. cudaGetDevice. asynchronous launches.1. cudaGetDeviceProperties 8 .5 cudaChooseDevice NAME cudaChooseDevice .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D. cudaMalloc3D 51 .SEE ALSO cudaMemset.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2. 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.4 cuCtxDetach NAME cuCtxDetach . and must be current to the calling thread. The context must be a handle that was passed back by cuCtxCreate() or cuCtxAttach(). and destroys the context if the usage count goes to 0.3.decrement a context’s usage-count SYNOPSIS CUresult cuCtxDetach(CUcontext ctx). cuCtxPushCurrent. SEE ALSO cuCtxCreate. asynchronous launches. cuCtxPopCurrent 116 . DESCRIPTION Decrements the usage count of the context. cuCtxDestroy.

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

SEE ALSO cuStreamCreate.5.2. asynchronous launches.4 cuStreamSynchronize NAME cuStreamSynchronize . 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). 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemAllocHost.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. CUdeviceptr devPtr). cuMemAllocPitch. SEE ALSO cuMemGetInfo. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemFree. cuMemAlloc. it is ignored.2.11 cuMemGetAddressRange NAME cuMemGetAddressRange . cuMemset2D 165 . cuArrayGetDescriptor. cuArrayDestroy. If one of them is null. Both parameters basePtr and size are optional. cuMemFreeHost. cuArrayCreate. unsigned int* size. cuMemset. asynchronous launches.8. DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

8. dstDevPtr and srcHostPtr specify the base addresses of the destination and source. cuMemcpy2D 180 . 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. cuMemcpyDtoD. asynchronous launches. unsigned int count. cuMemcpyDtoA. DESCRIPTION Copies from host memory to device memory. CUresult cuMemcpyHtoDAsync(CUdeviceptr dstDevPtr. cuMemcpyAtoH. unsigned int count). cuMemcpyAtoA.22 cuMemcpyHtoD NAME cuMemcpyHtoD .2. const void *srcHostPtr.copy memory from Host to Device SYNOPSIS CUresult cuMemcpyHtoD(CUdeviceptr dstDevPtr. SEE ALSO cuMemcpyDtoH. respectively. count specifies the number of bytes to copy. cuMemcpyHtoA. cuMemcpyAtoD. const void *srcHostPtr. CUstream stream). 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. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuArrayGetDescriptor. DESCRIPTION Sets the memory range of count 8-.initializes device memory SYNOPSIS CUresult cuMemsetD8(CUdeviceptr dstDevPtr. cuMemset2D 181 . unsigned int count ). asynchronous launches. unsigned int value.23 cuMemset NAME cuMemset . cuMemAllocHost. cuArrayCreate. cuMemFree. unsigned char value. unsigned short value. CUresult cuMemsetD16(CUdeviceptr dstDevPtr. unsigned int count ).2.8. unsigned int count ). cuMemFreeHost. cuMemGetAddressRange. SEE ALSO cuMemGetInfo. cuMemAlloc. or 32-bit values to the specified value value. CUresult cuMemsetD32(CUdeviceptr dstDevPtr. 16-. cuArrayDestroy.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cuGLCtxCreate. 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_MAP_FAILED Note that this function may also return error codes from previous. cuGLRegisterBufferObject.3 cuGLMapBufferObject NAME cuGLMapBufferObject .10.2. unsigned int* size. cuGLInit. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping. cuGLUnregisterBufferObject 201 . GLuint bufferObj). asynchronous launches.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr.

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful