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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.1 cudaGetLastError NAME cudaGetLastError .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.10.1. 95 .

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.3. asynchronous launches.8 cuCtxSynchronize NAME cuCtxSynchronize . DESCRIPTION Blocks until the device has completed all preceding requested tasks. cuCtxAttach.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. cuCtxDetach. cuCtxSynchronize() returns an error if one of the preceding tasks failed. SEE ALSO cuCtxCreate.

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Returns CUDA_SUCCESS if the event has actually been recorded.6. or CUDA_ERROR_NOT_READY if not. cuEventElapsedTime 138 .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.2. cuEventSynchronize. cuEventDestroy. asynchronous launches. If cuEventRecord() has not been called on this event. cuEventRecord.4 cuEventQuery NAME cuEventQuery .

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

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

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

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

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

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

In this version of CUDA.7. cuParamSetv.2. cuParamSeti. cuParamSetf. cuLaunch. cuParamSetSize. cuLaunchGrid 145 .adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func. the texture reference must be obtained via cuModuleGetTexRef() and the texunit parameter must be set to CU_PARAM_TR_DEFAULT. SEE ALSO cuFuncSetBlockShape. cuFuncSetSharedSize. asynchronous launches. DESCRIPTION Makes the CUDA array or linear memory bound to the texture reference texRef available to a device program as a texture.4 cuParamSetTexRef NAME cuParamSetTexRef . CUtexref texRef). int texunit. 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 a floating point parameter that will be specified the next time the kernel corresponding to func will be invoked. cuParamSetSize. offset is a byte offset. SEE ALSO cuFuncSetBlockShape. cuParamSetv. cuLaunch. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuFuncSetSharedSize.2. float value).7. int offset.5 cuParamSetf NAME cuParamSetf . cuParamSetTexRef. cuParamSeti. asynchronous launches. cuLaunchGrid 146 .adds a floating-point parameter to the function’s argument list SYNOPSIS CUresult cuParamSetf(CUfunction func.

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

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

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

asynchronous launches. cuLaunch. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous.7.2. cuLaunchGrid 150 . cuParamSeti. cuParamSetSize. cuParamSetf. SEE ALSO cuFuncSetBlockShape. cuParamSetv.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. cuParamSetTexRef.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . unsigned int bytes). 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.

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

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

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

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

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

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

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

cuArrayGetDescriptor. SEE ALSO cuArrayCreate. asynchronous launches.2. DESCRIPTION Returns in *arrayDesc a descriptor containing information on the format and dimensions of the CUDA array array. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous.8.get a 3D CUDA array descriptor SYNOPSIS CUresult cuArray3DGetDescriptor(CUDA_ARRAY3D_DESC *arrayDesc. cuArrayDestroy 158 . cuArray3DCreate.5 cuArray3DGetDescriptor NAME cuArray3DGetDescriptor . 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. CUarray array).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefGetAddress.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef. cuTexRefGetArray. asynchronous launches. cuTexRefSetFormat.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . cuTexRefGetAddressMode. CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0. 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. cuTexRefGetFilterMode. cuTexRefGetFlags 195 . cuTexRefSetAddress. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefSetArray. SEE ALSO cuTexRefCreate. cuTexRefSetAddressMode. CUfilter_mode mode).9.2. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef. cuTexRefDestroy. cuTexRefSetFlags. Note that this call has no effect if texRef is bound to linear memory.

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

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

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

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

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

unsigned int* size. asynchronous launches. cuGLUnregisterBufferObject 201 . GLuint bufferObj). 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.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. 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. cuGLRegisterBufferObject. cuGLInit.10.2.3 cuGLMapBufferObject NAME cuGLMapBufferObject . SEE ALSO cuGLCtxCreate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1. SEE ALSO atomicAdd. DESCRIPTION Reads the 32.3 atomicExch NAME atomicExch . unsigned int atomicExch(unsigned int* address.atomic exchange SYNOPSIS int atomicExch(int* address.1 and higher.3. unsigned long long int atomicExch(unsigned long long int* address. unsigned int val). int val). unsigned long long 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. atomicMax. NOTES 32-bit atomic operations are only supported on devices of compute capability 1. atomicInc. These two operations are performed in one atomic transaction. atomicDec. atomicSub. 64-bit atomic operations are only supported on devices of compute capability 1. atomicMin. The function returns old.2 and higher. atomicCAS 226 .

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful