NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

Contents
1 RuntimeApiReference 1.1 DeviceManagement RT 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

cudaGetDeviceCount

cudaSetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGetDeviceProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaChooseDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ThreadManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 1.2.2 cudaThreadSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaThreadExit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.3

StreamManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 1.3.2 1.3.3 1.3.4 cudaStreamCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaStreamDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.4

EventManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 cudaEventCreate cudaEventRecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaEventDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaEventElapsedTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

cudaMalloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMallocArray

cudaFreeArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMallocHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaFreeHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaMemset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaMemset2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

i

1.5.10 cudaMemcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.11 cudaMemcpy2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34 35 36 37 38 39 40 41 42 43 44 45 46 48 50 52 54 55 63 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

1.5.12 cudaMemcpyToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.13 cudaMemcpy2DToArray 1.5.14 cudaMemcpyFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.15 cudaMemcpy2DFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.16 cudaMemcpyArrayToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.17 cudaMemcpy2DArrayToArray 1.5.18 cudaMemcpyToSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.19 cudaMemcpyFromSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.20 cudaGetSymbolAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.21 cudaGetSymbolSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.22 cudaMalloc3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.23 cudaMalloc3DArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5.24 cudaMemset3D 1.5.25 cudaMemcpy3D 1.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

TextureReferenceManagement RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.6.1 1.6.2 LowLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HighLevelApi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

cudaConfigureCall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaLaunch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaSetupArgument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.8

OpenGlInteroperability RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 cudaGLSetGLDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLRegisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLMapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaGLUnmapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaGLUnregisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

cudaD3D9SetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9GetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9RegisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

84 85 86 87 89 90 91 92 94 95 97 98 99

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

cudaD3D9UnmapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceSetMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cudaD3D9ResourceGetSurfaceDimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

. . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.9.12 cudaD3D9ResourceGetMappedPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10 ErrorHandling RT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.1 cudaGetLastError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.2 cudaGetErrorString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 DriverApiReference 2.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 2.2

cuInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

cuDeviceGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 cuDeviceGetAttribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 cuDeviceGetCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 cuDeviceGetName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 cuDeviceGetProperties cuDeviceTotalMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

cuCtxAttach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 cuCtxCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 cuCtxDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

cuCtxDetach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 cuCtxGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 cuCtxPopCurrent cuCtxPushCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

cuCtxSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

2.4

ModuleManagement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 2.4.1 cuModuleGetFunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

iii

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

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

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

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

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

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

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

cudaGetDevice. SEE ALSO cudaGetDeviceCount. cudaChooseDevice 4 . asynchronous launches.1. cudaGetDeviceProperties.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.2 cudaSetDevice NAME cudaSetDevice .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

size_t sharedMem = 0.1. cudaSetupArgument 69 .7. cudaConfigureCall() is stack based. asynchronous launches.configure a device-launch SYNOPSIS cudaError_t cudaConfigureCall(dim3 gridDim. This data contains the dimension for the grid and thread blocks. SEE ALSO cudaLaunch. together with any arguments for the call.1 cudaConfigureCall NAME cudaConfigureCall . Each call pushes data on top of an execution stack. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. 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.1. or it can be a character string. cudaSetupArgument 70 .2 cudaLaunch NAME cudaLaunch .launches a device function SYNOPSIS template < class T > cudaError_t cudaLaunch(T entry) DESCRIPTION Launches the function entry on the device. entry must be declared as a __global__ function. entry can either be a function that executes on the device. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidDeviceFunction cudaErrorInvalidConfiguration Note that this function may also return error codes from previous. cudaLaunch() must be preceded by a call to cudaConfigureCall() since it pops the data that was pushed by cudaConfigureCall() from the execution stack.7. naming a function that executes on the device. SEE ALSO cudaConfigureCall.

SEE ALSO cudaConfigureCall.7. size_t offset) template < class T > cudaError_t cudaSetupArgument(T arg.3 cudaSetupArgument NAME cudaSetupArgument .configure a device-launch SYNOPSIS cudaError_t cudaSetupArgument(void* arg.1. size_t count. asynchronous launches. which starts at offset 0. 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. 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(). The arguments are stored in the top of the execution stack. cudaLaunch 71 .

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

If any of ppResources are not presently mapped for access by CUDA then cudaErrorUnknown is returned. cudaD3D9ResourceGetMappedSize. asynchronous launches. IDirect3DResource9** ppResources). cudaD3D9ResourceGetMappedPitch 86 .7 cudaD3D9UnmapResources NAME cudaD3D9UnmapResources .9. 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.unmap Direct3D resources SYNOPSIS cudaError_t cudaD3D9UnmapResources(unsigned int count. cudaD3D9UnregisterResource. cudaD3D9RegisterResource. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned.1. cudaD3D9GetDirect3DDevice. SEE ALSO cudaD3D9GetDevice. RETURN VALUE Relevant return values: cudaSuccess cudaErrorInvalidHandle cudaErrorUnknown Note that this function may also return error codes from previous. cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9ResourceSetMa cudaD3D9ResourceGetMappedPointer. cudaD3D9MapResources. cudaD3D9SetDirect3DDevice.

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

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

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

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

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

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

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

Execution Management.10 ErrorHandling RT NAME Error Handling DESCRIPTION This section describes the CUDA runtime application programming interface. Direct3D Interoperability. Memory Management. Stream Management. Error Handling 94 . cudaGetLastError cudaGetErrorString SEE ALSO Device Management. OpenGL Interoperability. Thread Management. Texture Reference Management.1. Event 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.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. 95 .1.1 cudaGetLastError NAME cudaGetLastError .10.

cudaError 96 .SEE ALSO cudaGetErrorString.

10. DESCRIPTION Returns a message string from an error code.1.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).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

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

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

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

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

unsigned int flags).2. flags is required to be 0. SEE ALSO cuEventRecord. DESCRIPTION Creates an event. cuEventDestroy. asynchronous launches. cuEventSynchronize.1 cuEventCreate NAME cuEventCreate .6.creates an event SYNOPSIS CUresult cuEventCreate(CUevent* event. 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. cuEventQuery. At present. cuEventElapsedTime 135 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

desc. cuArray3DGetDescriptor. cuMemGetAddressRange.Width = width.NumChannels = 4. desc. desc. desc. cuMemFree. SEE ALSO cuMemGetInfo. desc.Width = 2048. 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.Width = 64. cuMemFreeHost. cuArrayDestroy 155 . cuMemAllocHost. desc. desc. desc.NumChannels = 1. asynchronous launches. cuMemAllocPitch. desc.Depth = depth.FormatFlags = CU_AD_FORMAT_HALF.Depth = 0.Height = 64. desc. desc. desc. • Description for a 64 x 64 CUDA array of floats: CUDA_ARRAY3D_DESCRIPTOR desc.Height = height.Height = 0. 4x16-bit float16’s: CUDA_ARRAY_DESCRIPTOR desc.• Description for a CUDA array of 2048 floats: CUDA_ARRAY3D_DESCRIPTOR desc. cuMemAlloc.Format = CU_AD_FORMAT_FLOAT.Depth = 0.NumChannels = 1.Format = CU_AD_FORMAT_FLOAT. desc. desc. • Description for a width x height x depth CUDA array of 64-bit.

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

cuArrayDestroy 157 . cuArray3DGetDescriptor. cuArray3DCreate. It is useful for subroutines that have been passed a CUDA array.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_INVALID_HANDLE Note that this function may also return error codes from previous.4 cuArrayGetDescriptor NAME cuArrayGetDescriptor . asynchronous launches.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. SEE ALSO cuArrayCreate.get a 1D or 2D CUDA array descriptor SYNOPSIS CUresult cuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR* arrayDesc.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefDestroy. cuTexRefSetFormat. CUtexref texRef). cuTexRefSetAddressMode. cuTexRefSetFlags. cuTexRefSetFilterMode.gets the flags used by a texture-reference SYNOPSIS CUresult cuTexRefGetFlags(unsigned int* flags. 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. cuTexRefGetAddressMode.2.7 cuTexRefGetFlags NAME cuTexRefGetFlags .9. cuTexRefGetArray. cuTexRefSetAddress. cuTexRefGetFormat 190 . asynchronous launches. DESCRIPTION Returns in *flags the flags of the texture reference texRef. cuTexRefSetArray. 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. cuTexRefSetArray. cuTexRefSetAddress. int* numPackedComponents. cuTexRefSetFormat. cuTexRefSetAddressMode.2. cuTexRefGetArray. it will be ignored. DESCRIPTION Returns in *format and *numPackedComponents the format and number of components of the CUDA array bound to the texture reference texRef.8 cuTexRefGetFormat NAME cuTexRefGetFormat . cuTexRefGetAddress. asynchronous launches. cuTexRefSetFilterMode. cuTexRefSetFlags. cuTexRefGetAddressMode.gets the format used by a texture-reference SYNOPSIS CUresult cuTexRefGetFormat(CUarray_format* format. If format or numPackedComponents is null. cuTexRefGetFlags 191 . SEE ALSO cuTexRefCreate. cuTexRefDestroy.9. cuTexRefGetFilterMode. CUtexref texRef).

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

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. asynchronous launches. cuTexRefGetFormat. 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. int dim. cuTexRefGetFilterMode. CU_TR_ADDRESS_MODE_CLAMP = 1. If dim is zero. cuTexRefSetFlags. the second. cuTexRefGetAddressMode. cuTexRefSetFilterMode. cuTexRefDestroy.9. Note that this call has no effect if texRef is bound to linear memory.10 cuTexRefSetAddressMode NAME cuTexRefSetAddressMode . cuTexRefGetAddress. the addressing mode is applied to the first parameter of the functions used to fetch from the texture. and so on. cuTexRefGetArray. CU_TR_ADDRESS_MODE_MIRROR = 2. cuTexRefSetAddress.set the addressing mode for a texture-reference SYNOPSIS CUresult cuTexRefSetAddressMode(CUtexref texRef. cuTexRefSetArray.2. if dim is 1. cuTexRefGetFlags 193 . CUaddress_mode mode). } CUaddress_mode.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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.

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

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

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

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

These three operations are performed in one atomic transaction. atomicMin.3.1. unsigned int val). computes the maximum of old and val.atomic maximum SYNOPSIS int atomicMax(int* address.5 atomicMax NAME atomicMax . unsigned int atomicMax(unsigned int* address. NOTES Atomic operations are only supported on devices of compute capability 1. atomicExch. atomicInc. SEE ALSO atomicAdd. 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. atomicCAS 228 . The function returns old. atomicSub. int val).1 and higher. atomicDec.

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful