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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMemset2D. cudaMalloc3D 51 .

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

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

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

enum cudaChannelFormatKind f. cudaBindTextureToArray. cudaChannelFormatKindUnsigned. cudaBindTexture. and w. y. RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. cudaChannelFormatKindFloat.cudaCreateChannelDesc NAME cudaCreateChannelDesc . w. asynchronous launches. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. int y. y. cudaGetTextureAlignmentOffset 56 . }. cudaGetTextureReference. SEE ALSO cudaGetChannelDesc. 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. z. int w. int z. z.Low-level texture API SYNOPSIS struct cudaChannelFormatDesc cudaCreateChannelDesc(int x. enum cudaChannelFormatKin f). cudaUnbindTexture.

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

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

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

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

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

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

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

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

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

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

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

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

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. This data contains the dimension for the grid and thread blocks. asynchronous launches.1 cudaConfigureCall NAME cudaConfigureCall . dim3 blockDim.7. cudaSetupArgument 69 .configure a device-launch SYNOPSIS cudaError_t cudaConfigureCall(dim3 gridDim. cudaConfigureCall() is stack based. SEE ALSO cudaLaunch. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidConfiguration Note that this function may also return error codes from previous.1. together with any arguments for the call. size_t sharedMem = 0.

2 cudaLaunch NAME cudaLaunch . asynchronous launches. entry can either be a function that executes on the device. cudaLaunch() must be preceded by a call to cudaConfigureCall() since it pops the data that was pushed by cudaConfigureCall() from the execution stack. SEE ALSO cudaConfigureCall. entry must be declared as a __global__ function.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. or it can be a character string.1.7. cudaSetupArgument 70 . naming a function that executes on the device.

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

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

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

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

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

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

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

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

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

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

cudaD3D9UnmapResources. cudaD3D9ResourceSetMapF cudaD3D9ResourceGetMappedPointer. cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetMappedSize. SEE ALSO cudaD3D9GetDevice. cudaD3D9ResourceGetMappedPitch 84 . DESCRIPTION Unregisters the Direct3D resource pResource so it is not accessable by CUDA unless registered again. 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). cudaD3D9MapResources.9.5 cudaD3D9UnregisterResource NAME cudaD3D9UnregisterResource .1. cudaD3D9SetDirect3DDevice. asynchronous launches. cudaD3D9ResourceGetSurfaceDimensions. If pResource is not registered then cudaErrorInvalidHandle is returned. cudaD3D9RegisterResource.

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5 cuCtxGetDevice NAME cuCtxGetDevice . DESCRIPTION Returns in *device the ordinal of the current context’s device. SEE ALSO cuCtxCreate. cuCtxSynchronize 117 .3. cuCtxAttach.return device-ID for current context SYNOPSIS CUresult cuCtxGetDevice(CUdevice* device). 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. cuCtxDetach.

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

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

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

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

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

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

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

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

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

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_OUT_OF_MEMORY Note that this function may also return error codes from previous. At present. cuStreamDestroy 130 . unsigned int flags).5. SEE ALSO cuStreamQuery. cuStreamSynchronize.1 cuStreamCreate NAME cuStreamCreate . DESCRIPTION Creates a stream. flags is required to be 0. asynchronous launches.create a stream SYNOPSIS CUresult cuStreamCreate(CUstream* stream.

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

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

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

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

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

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

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

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

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

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

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

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

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

unsigned int numbytes). DESCRIPTION Sets through numbytes the total size in bytes needed by the function parameters of function func. cuParamSetf. cuParamSetTexRef. asynchronous launches. cuParamSetv. cuLaunchGrid 144 . SEE ALSO cuFuncSetBlockShape.7.3 cuParamSetSize NAME cuParamSetSize .2.sets the parameter-size for the function SYNOPSIS CUresult cuParamSetSize(CUfunction func. cuFuncSetSharedSize. 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. cuParamSeti.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr. 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. cuMemset. cuArrayCreate. it is ignored. cuMemFree. cuMemset2D 165 . unsigned int* size.8. If one of them is null. Both parameters basePtr and size are optional. cuMemAllocHost. cuArrayDestroy. SEE ALSO cuMemGetInfo. CUdeviceptr devPtr). cuMemAllocPitch.2.11 cuMemGetAddressRange NAME cuMemGetAddressRange . cuArrayGetDescriptor.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. cuMemAlloc. asynchronous launches. cuMemFreeHost.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

For all other types Level must be 0. 217 . If pResource is not mapped then CUDA_ERROR_NOT_MAPPED is returned. If Level is invalid then CUDA_ERROR_INVALID_VALUE is returned.11. For all other types Face must be 0.10 cuD3D9ResourceGetMappedPointer NAME cuD3D9ResourceGetMappedPointer . asynchronous launches. unsigned int Level). If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned.2. If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level. IDirect3DResource9* pResource. DESCRIPTION Returns in *pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. At present only mipmap level 0 is supported. The value set in pDevPtr may change every time that pResource is mapped. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVA is returned. If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. If Face is invalid then CUDA_ERROR_INVALID_V is returned.get a pointer through which to access a subresource of a Direct3D resource which has been mapped for access by CUDA SYNOPSIS CUresult cuD3D9ResourceGetMappedPointer(CUdeviceptr* pDevPtr. unsigned int 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.

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

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

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

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

1 and higher.2 and higher. BitwiseFunctions 222 .3 AtomicFunctions NAME Atomic Functions DESCRIPTION Atomic functions can only be used in device functions. 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. SEE ALSO ArithmeticFunctions.

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.3.

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful