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

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

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

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

235 vii . . . . . . . . . .3. . . . . . . . . . . . . . .2.3 atomicXor . . . . . . . . . . . . . . . . . . .

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

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

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

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

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

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

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

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

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

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

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

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

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

1.3.2 cudaStreamQuery NAME cudaStreamQuery . or cudaErrorNotReady if not. cudaStreamDestroy. asynchronous launches. cudaStreamSynchronize 14 . 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. SEE ALSO cudaStreamCreate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaMemset. cudaMalloc3D 51 . cudaMemset2D.

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

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

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

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

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

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

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

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

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

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

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

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

The cudaChannelFormatDesc is defined as: struct cudaChannelFormatDesc { int x. SEE ALSO 64 . y. z. where cudaChannelFormatKind is one of cudaChannelFormatKindSigned. and w.cudaCreateChannelDesc HL NAME cudaCreateChannelDesc . cudaChannelFormatKindUnsigned. y. 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. enum cudaChannelFormatKind f. asynchronous launches.High-level texture API SYNOPSIS template < class T > struct cudaChannelFormatDesc cudaCreateChannelDesc <T >(). z. }. cudaChannelFormatKindFloat. w.

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

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

RETURN VALUE Relevant return values: cudaSuccess Note that this function may also return error codes from previous. asynchronous launches. int dim. dim.High-level texture API SYNOPSIS template < class T. 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.cudaUnbindTexture HL NAME cudaUnbindTexture .

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaD3D9GetDevice. cudaD3D9ResourceGetMappedSize. Direct3D should not access any resources while they are mapped by CUDA. 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.6 cudaD3D9MapResources NAME cudaD3D9MapResources . The resources in ppResources may be accessed in CUDA kernels until they are unmapped. cudaD3D9ResourceGetMappedPointer. cudaD3D9ResourceGetSurfaceDimensions. cudaD3D9RegisterResource.map Direct3D resources for access by CUDA SYNOPSIS cudaError_t cudaD3D9MapResources(unsigned int count. cudaD3D9SetDirect3DDevice. DESCRIPTION Maps the count Direct3D resources in ppResources for access by CUDA. cudaD3D9ResourceSetMapFlags.1. cudaD3D9UnregisterResource. cudaD3D9GetDirect3DDevice. cudaD3D9ResourceGetMappedPitch 85 . asynchronous launches. If an application does so the results are undefined. cudaD3D9UnmapResources. If any of ppResources are presently mapped for access by CUDA then cudaErrorUnknown is returned. IDirect3DResource9 **ppResources).9. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned.

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

SEE ALSO 100 . the Flags parameters must be 0. asynchronous launches.1 cuInit NAME cuInit . 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.1.initialize the CUDA driver API SYNOPSIS CUresult cuInit( unsigned int Flags ). Currently.2. If cuInit() has not been called. 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.

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

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

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

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

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

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

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

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

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

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

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

cuCtxSynchronize 112 . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. unsigned int Flags).3. SEE ALSO cuCtxCreate. 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.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxGetDevice.1 cuCtxAttach NAME cuCtxAttach . the Flags parameter must be 0. cuCtxAttach() fails if there is no context current to the thread.2. cuCtxDetach. Currently. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

cuModuleLoadFatBinary.returns a global pointer from a module SYNOPSIS CUresult cuModuleGetGlobal(CUdeviceptr* devPtr. cuModuleUnload. const char* globalname). it is ignored. If one of them is null. If no variable of that name exists. CUmodule mod. cuModuleLoadData.2 cuModuleGetGlobal NAME cuModuleGetGlobal . cuModuleGetGlobal() returns CUDA_ERROR_NOT_FOUND. Both parameters devPtr and bytes are optional. SEE ALSO cuModuleLoad. 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_NOT_FOUND Note that this function may also return error codes from previous.4. cuModuleGetTexRef 123 .2. cuModuleGetFunction. unsigned int* bytes. DESCRIPTION Returns in *devPtr and *bytes the base pointer and size of the global of name globalname located in module mod.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuLaunch. cuParamSetTexRef.sets the shared-memory size for the function SYNOPSIS CUresult cuFuncSetSharedSize(CUfunction func. cuParamSetSize. cuLaunchGrid 150 .2.7. asynchronous launches. unsigned int bytes). cuParamSeti. cuParamSetf. 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.9 cuFuncSetSharedSize NAME cuFuncSetSharedSize . cuParamSetv. DESCRIPTION Sets through bytes the amount of shared memory that will be available to each thread block when the kernel given by func is launched. SEE ALSO cuFuncSetBlockShape.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2. cuTexRefDestroy.sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef. cuTexRefSetFlags. 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. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetAddress. cuTexRefSetArray. cuTexRefSetAddressMode. CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef.9. cuTexRefSetAddress. cuTexRefGetFormat. cuTexRefGetFilterMode. cuTexRefGetAddressMode. cuTexRefGetArray. asynchronous launches. cuTexRefSetFormat. SEE ALSO cuTexRefCreate.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode . cuTexRefGetFlags 195 . CUfilter_mode mode).

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

2. SEE ALSO cuTexRefCreate. cuTexRefGetAddress. cuTexRefSetArray. format and numPackedComponents are exactly analogous to the Format and NumChannels members of the CUDA_ARRAY_DESCRIPTOR structure: They specify the format of each component and the number of components per array element. cuTexRefSetFlags.9. cuTexRefGetArray.sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. cuTexRefGetFormat. cuTexRefSetAddressMode. cuTexRefSetFilterMode. CUarray_format format. cuTexRefSetAddress. cuTexRefGetFilterMode. int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuTexRefGetAddressMode. cuTexRefGetFlags 197 . asynchronous launches.14 cuTexRefSetFormat NAME cuTexRefSetFormat . cuTexRefDestroy.

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

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

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

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

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

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

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

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

gets the device number for an adapter SYNOPSIS CUresult cuD3D9GetDevice(CUdevice* dev. cuD3D9UnregisterResource. If no device on the adapter with name adapterName is CUDA-compatible then the call will fail. SEE ALSO cuD3D9CtxCreate. cuD3D9ResourceSetMapFlags. cuD3D9RegisterResource. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_VALUE CUDA_ERROR_UNKNOWN Note that this function may also return error codes from previous. cuD3D9ResourceGetSurfaceDimensions.11. cuD3D9ResourceGetMappedPitch 206 . const char* adapterName). cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. cuD3D9UnmapResources. DESCRIPTION Returns in *dev the CUDA-compatible device corresponding to the adapter name adapterName obtained from EnumDisplayDevices or IDirect3D9::GetAdapterIdentifier(). cuD3D9GetDirect3DDevice.1 cuD3D9GetDevice NAME cuD3D9GetDevice . asynchronous launches.2. cuD3D9MapResources.

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

Sign up to vote on this title
UsefulNot useful