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

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

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

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

. . . . . . . . . 235 vii . . . . . . . . . . . . . .3.2. . . . . .3 atomicXor . . . . . . . . . . . . . . .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. cudaStreamQuery 15 .3 cudaStreamSynchronize NAME cudaStreamSynchronize . cudaStreamDestroy. SEE ALSO cudaStreamCreate.3.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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

const struct cudaArray* srcArray. cudaMemcpyHostToDevice. cudaMemcpy2DArrayToArray. size_t srcX. where kind is one of cudaMemcpyHostToHost.1. 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.copies data between host and device SYNOPSIS cudaError_t cudaMemcpyFromArray(void* dst. cudaMemcpyArrayToArray. or cudaMemcpyDeviceToDevice. size_t count. srcY) to the memory area pointed to by dst. asynchronous launches. enum cudaMemcpyKind kind.5. cudaMemcpyToArray. size_t srcY. cudaMemcpy2DToArray. cudaMemcpy2DFromArray. cudaMemcpy2D. SEE ALSO cudaMemcpy. size_t srcY. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. cudaMemcpyFromSymbol 38 .14 cudaMemcpyFromArray NAME cudaMemcpyFromArray . cudaStream_t stream) DESCRIPTION Copies count bytes from the CUDA array srcArray starting at the upper left corner (srcX. cudaMemcpyToSymbol. size_t count. cudaMemcpyDeviceToHost. const struct cudaArray* srcArray. size_t srcX. enum cudaMemcpyKind kind) cudaError_t cudaMemcpyFromArrayAsync(void* dst.

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

cudaUnbindTexture. const struct cudaArray* array).cudaGetChannelDesc NAME cudaGetChannelDesc . cudaBindTexture. DESCRIPTION Returns in *desc the channel descriptor of the CUDA array array. 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 cudaGetChannelDesc(struct cudaChannelFormatDesc* desc. cudaGetTextureReference. cudaGetTextureAlignmentOffset 57 . asynchronous launches. cudaBindTextureToArray. SEE ALSO cudaCreateChannelDesc.

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

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

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

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

const struct textureReference* texRef). cudaBindTextureToArray. cudaGetChannelDesc. cudaUnbindTexture 62 . SEE ALSO cudaCreateChannelDesc. 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. asynchronous launches. cudaGetTextureReference.cudaGetTextureAlignmentOffset NAME cudaGetTextureAlignmentOffset . RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidTexture cudaErrorInvalidTextureBinding Note that this function may also return error codes from previous. cudaBindTexture.

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

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

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

Any CUDA array previously bound to texRef is unbound. dim. const struct cudaChannelFormatDesc& desc) DESCRIPTION Binds the CUDA array array to texture reference texRef. SEE ALSO cudaCreateChannelDesc_HL 66 . const struct cudaArray* cuArray. const struct cudaArray* cuArray). 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. enum cudaTextureReadMode readMode E<gt> static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture E<lt> T. int dim. enum cudaTextureReadMode readMode > static __inline__ __host__ cudaError_t cudaBindTextureToArray( const struct texture < T. The channel descriptor is inherited from the CUDA array.High-level texture API SYNOPSIS template < class T. int dim. Any CUDA array previously bound to texRef is unbound. readMode >& texRef. asynchronous launches. desc describes how the memory is interpreted when fetching values from the texture. readMode E<gt>& texRef. binds the CUDA array array to texture reference texRef. dim.cudaBindTextureToArray HL NAME cudaBindTextureToArray .

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

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

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

asynchronous launches. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. entry can either be a function that executes on the device. cudaSetupArgument 70 .7.2 cudaLaunch NAME cudaLaunch . or it can be a character string. 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. SEE ALSO cudaConfigureCall. cudaLaunch() must be preceded by a call to cudaConfigureCall() since it pops the data that was pushed by cudaConfigureCall() from the execution stack. naming a function that executes on the device.1.

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

RETURN VALUE Relevant return values: cudaSuccess cudaErrorInitializationError cudaErrorLaunchFailure cudaErrorPriorLaunchFailure cudaErrorLaunchTimeout cudaErrorLaunchOutOfResources cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration cudaErrorInvalidDevice cudaErrorInvalidValue cudaErrorInvalidDevicePointer cudaErrorInvalidTexture cudaErrorInvalidTextureBinding cudaErrorInvalidChannelDescriptor cudaErrorTextureFetchFailed cudaErrorTextureNotBound cudaErrorSynchronizationError cudaErrorUnknown cudaErrorInvalidResourceHandle cudaErrorNotReady Note that this function may also return error codes from previous asynchronous launches.1 cudaGetLastError NAME cudaGetLastError .1. 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 .

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

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

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

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

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

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

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

• CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X: maximum x-dimension of a block.2. • CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y: maximum y-dimension of a grid. • CU_DEVICE_ATTRIBUTE_WARP_SIZE: warp size in threads. • CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT: number of multiprocessors on the device. • CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X: maximum x-dimension of a grid. • CU_DEVICE_ATTRIBUTE_MAX_PITCH: maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through cuMemAllocPitch().2.returns information about the device SYNOPSIS CUresult cuDeviceGetAttribute(int* value. • CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY: total amount of constant memory available on the device in bytes. • CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z: maximum z-dimension of a grid. • CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z: maximum z-dimension of a block. DESCRIPTION Returns in *value the integer value of the attribute attrib on device dev. this amount is shared by all thread blocks simultaneously resident on a multiprocessor.3 cuDeviceGetAttribute NAME cuDeviceGetAttribute . The supported attributes are: • CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK: maximum number of threads per block. this number is shared by all thread blocks simultaneously resident on a multiprocessor. • CU_DEVICE_ATTRIBUTE_CLOCK_RATE: clock frequency in kilohertz. 104 . 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_MAX_BLOCK_DIM_Y: maximum y-dimension of a block. CUdevice dev). CUdevice_attribute attrib. • CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT: alignment requirement. • CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK: maximum amount of shared memory available to a thread block in bytes. • CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK: maximum number of 32-bit registers available to a thread block. or 0 if not.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

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

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

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

DESCRIPTION Destroys the event. SEE ALSO cuEventCreate. cuEventElapsedTime 136 .2 cuEventDestroy NAME cuEventDestroy . cuEventRecord.destroys an event SYNOPSIS CUresult cuEventDestroy(CUevent event). cuEventQuery.6. 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. cuEventSynchronize.2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemcpyHtoA. cuMemcpyAtoH. cuMemcpyDtoH. cuMemcpy3D 169 . cuMemcpyDtoA. SEE ALSO cuMemcpyHtoD. cuMemcpyDtoD. cuMemcpyAtoD. 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. cuMemcpyAtoA.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.13 cuTexRefSetFlags NAME cuTexRefSetFlags . unsigned int Flags). cuTexRefGetFilterMode. cuTexRefSetAddressMode. which suppresses the default behavior of having the texture promote integer data to floating point data in the range [0.0) reference the entire breadth of the array dimension RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetFormat. cuTexRefSetAddress. SEE ALSO cuTexRefCreate. cuTexRefSetFormat. which suppresses the default behavior of having the texture coordinates range from [0. cuTexRefSetArray. • CU_TRSF_NORMALIZED_COORDINATES. cuTexRefSetFilterMode. The valid flags are: • CU_TRSF_READ_AS_INTEGER.sets flags for a texture-reference SYNOPSIS CUresult cuTexRefSetFlags(CUtexref texRef. Dim) where Dim is the width or height of the CUDA array.9. 1. 1]. cuTexRefGetAddress. asynchronous launches. cuTexRefGetFlags 196 . cuTexRefDestroy. Instead. cuTexRefGetArray. DESCRIPTION Specifies optional flags to control the behavior of data returned through the texture reference. cuTexRefGetAddressMode. the texture coordinates [0.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful