P. 1
CudaReferenceManual_2.0

CudaReferenceManual_2.0

|Views: 2,053|Likes:
Published by Craig Surbrook

More info:

Published by: Craig Surbrook on May 08, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

12/09/2012

pdf

text

original

Sections

  • 1 RuntimeApiReference
  • 1.1 DeviceManagement RT
  • 1.1.1 cudaGetDeviceCount
  • 1.1.2 cudaSetDevice
  • 1.1.3 cudaGetDevice
  • 1.1.4 cudaGetDeviceProperties
  • 1.1.5 cudaChooseDevice
  • 1.2 ThreadManagement RT
  • 1.2.1 cudaThreadSynchronize
  • 1.2.2 cudaThreadExit
  • 1.3 StreamManagement RT
  • 1.3.1 cudaStreamCreate
  • 1.3.2 cudaStreamQuery
  • 1.3.3 cudaStreamSynchronize
  • 1.3.4 cudaStreamDestroy
  • 1.4 EventManagement RT
  • 1.4.1 cudaEventCreate
  • 1.4.2 cudaEventRecord
  • 1.4.3 cudaEventQuery
  • 1.4.4 cudaEventSynchronize
  • 1.4.5 cudaEventDestroy
  • 1.4.6 cudaEventElapsedTime
  • 1.5 MemoryManagement RT
  • 1.5.1 cudaMalloc
  • 1.5.2 cudaMallocPitch
  • 1.5.3 cudaFree
  • 1.5.4 cudaMallocArray
  • 1.5.5 cudaFreeArray
  • 1.5.6 cudaMallocHost
  • 1.5.7 cudaFreeHost
  • 1.5.8 cudaMemset
  • 1.5.9 cudaMemset2D
  • 1.5.10 cudaMemcpy
  • 1.5.11 cudaMemcpy2D
  • 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 LowLevelApi
  • 1.6.2 HighLevelApi
  • 1.7 ExecutionControl RT
  • 1.7.1 cudaConfigureCall
  • 1.7.2 cudaLaunch
  • 1.7.3 cudaSetupArgument
  • 1.8 OpenGlInteroperability RT
  • 1.8.1 cudaGLSetGLDevice
  • 1.8.2 cudaGLRegisterBufferObject
  • 1.8.3 cudaGLMapBufferObject
  • 1.8.4 cudaGLUnmapBufferObject
  • 1.8.5 cudaGLUnregisterBufferObject
  • 1.9 Direct3dInteroperability RT
  • 1.9.1 cudaD3D9GetDevice
  • 1.9.2 cudaD3D9SetDirect3DDevice
  • 1.9.3 cudaD3D9GetDirect3DDevice
  • 1.9.4 cudaD3D9RegisterResource
  • 1.9.5 cudaD3D9UnregisterResource
  • 1.9.6 cudaD3D9MapResources
  • 1.9.7 cudaD3D9UnmapResources
  • 1.9.8 cudaD3D9ResourceSetMapFlags
  • 1.9.9 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 cuInit
  • 2.2 DeviceManagement
  • 2.2.1 cuDeviceComputeCapability
  • 2.2.2 cuDeviceGet
  • 2.2.3 cuDeviceGetAttribute
  • 2.2.4 cuDeviceGetCount
  • 2.2.5 cuDeviceGetName
  • 2.2.6 cuDeviceGetProperties
  • 2.2.7 cuDeviceTotalMem
  • 2.3 ContextManagement
  • 2.3.1 cuCtxAttach
  • 2.3.2 cuCtxCreate
  • 2.3.3 cuCtxDestroy
  • 2.3.4 cuCtxDetach
  • 2.3.5 cuCtxGetDevice
  • 2.3.6 cuCtxPopCurrent
  • 2.3.7 cuCtxPushCurrent
  • 2.3.8 cuCtxSynchronize
  • 2.4 ModuleManagement
  • 2.4.1 cuModuleGetFunction
  • 2.4.2 cuModuleGetGlobal
  • 2.4.3 cuModuleGetTexRef
  • 2.4.4 cuModuleLoad
  • 2.4.5 cuModuleLoadData
  • 2.4.6 cuModuleLoadFatBinary
  • 2.4.7 cuModuleUnload
  • 2.5 StreamManagement
  • 2.5.1 cuStreamCreate
  • 2.5.2 cuStreamDestroy
  • 2.5.3 cuStreamQuery
  • 2.5.4 cuStreamSynchronize
  • 2.6 EventManagement
  • 2.6.1 cuEventCreate
  • 2.6.2 cuEventDestroy
  • 2.6.3 cuEventElapsedTime
  • 2.6.4 cuEventQuery
  • 2.6.5 cuEventRecord
  • 2.6.6 cuEventSynchronize
  • 2.7 ExecutionControl
  • 2.7.1 cuLaunch
  • 2.7.2 cuLaunchGrid
  • 2.7.3 cuParamSetSize
  • 2.7.4 cuParamSetTexRef
  • 2.7.5 cuParamSetf
  • 2.7.6 cuParamSeti
  • 2.7.7 cuParamSetv
  • 2.7.8 cuFuncSetBlockShape
  • 2.7.9 cuFuncSetSharedSize
  • 2.8 MemoryManagement
  • 2.8.1 cuArrayCreate
  • 2.8.2 cuArray3DCreate
  • 2.8.3 cuArrayDestroy
  • 2.8.4 cuArrayGetDescriptor
  • 2.8.5 cuArray3DGetDescriptor
  • 2.8.6 cuMemAlloc
  • 2.8.7 cuMemAllocHost
  • 2.8.8 cuMemAllocPitch
  • 2.8.9 cuMemFree
  • 2.8.10 cuMemFreeHost
  • 2.8.11 cuMemGetAddressRange
  • 2.8.12 cuMemGetInfo
  • 2.8.13 cuMemcpy2D
  • 2.8.14 cuMemcpy3D
  • 2.8.15 cuMemcpyAtoA
  • 2.8.16 cuMemcpyAtoD
  • 2.8.17 cuMemcpyAtoH
  • 2.8.18 cuMemcpyDtoA
  • 2.8.19 cuMemcpyDtoD
  • 2.8.20 cuMemcpyDtoH
  • 2.8.21 cuMemcpyHtoA
  • 2.8.22 cuMemcpyHtoD
  • 2.8.23 cuMemset
  • 2.8.24 cuMemset2D
  • 2.9 TextureReferenceManagement
  • 2.9.1 cuTexRefCreate
  • 2.9.2 cuTexRefDestroy
  • 2.9.3 cuTexRefGetAddress
  • 2.9.4 cuTexRefGetAddressMode
  • 2.9.5 cuTexRefGetArray
  • 2.9.6 cuTexRefGetFilterMode
  • 2.9.7 cuTexRefGetFlags
  • 2.9.8 cuTexRefGetFormat
  • 2.9.9 cuTexRefSetAddress
  • 2.9.10 cuTexRefSetAddressMode
  • 2.9.11 cuTexRefSetArray
  • 2.9.12 cuTexRefSetFilterMode
  • 2.9.13 cuTexRefSetFlags
  • 2.9.14 cuTexRefSetFormat
  • 2.10 OpenGlInteroperability
  • 2.10.1 cuGLCtxCreate
  • 2.10.2 cuGLInit
  • 2.10.3 cuGLMapBufferObject
  • 2.10.4 cuGLRegisterBufferObject
  • 2.10.5 cuGLUnmapBufferObject
  • 2.10.6 cuGLUnregisterBufferObject
  • 2.11 Direct3dInteroperability
  • 2.11.1 cuD3D9GetDevice
  • 2.11.2 cuD3D9CtxCreate
  • 2.11.3 cuD3D9GetDirect3DDevice
  • 2.11.4 cuD3D9RegisterResource
  • 2.11.5 cuD3D9UnregisterResource
  • 2.11.6 cuD3D9MapResources
  • 2.11.7 cuD3D9UnmapResources
  • 2.11.8 cuD3D9ResourceSetMapFlags
  • 2.11.9 cuD3D9ResourceGetSurfaceDimensions
  • 2.11.10 cuD3D9ResourceGetMappedPointer
  • 2.11.11 cuD3D9ResourceGetMappedSize
  • 2.11.12 cuD3D9ResourceGetMappedPitch
  • 3 AtomicFunctions
  • Atomic Functions
  • 3.1 ArithmeticFunctions
  • 3.1.1 atomicAdd
  • 3.1.2 atomicSub
  • 3.1.3 atomicExch
  • 3.1.4 atomicMin
  • 3.1.5 atomicMax
  • 3.1.6 atomicInc
  • 3.1.7 atomicDec
  • 3.1.8 atomicCAS
  • 3.2 BitwiseFunctions
  • 3.2.1 atomicAnd
  • 3.2.2 atomicOr

NVIDIA CUDA Compute Unified Device Architecture

Reference Manual

Version 2.0
June 2008

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

cudaGetDeviceCount

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

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

1.3

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

1.4

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

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

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

1.5

MemoryManagement RT 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9

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

cudaMallocArray

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

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

i

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

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

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

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

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

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

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

1.7

ExecutionControl RT 1.7.1 1.7.2 1.7.3

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

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

1.8

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

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

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

1.9

Direct3dInteroperability RT 1.9.1 1.9.2 1.9.3 1.9.4 cudaD3D9GetDevice

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

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

1.9.5 1.9.6 1.9.7 1.9.8 1.9.9

cudaD3D9UnregisterResource cudaD3D9MapResources

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

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

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

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

1.9.10 cudaD3D9ResourceGetMappedPointer 1.9.11 cudaD3D9ResourceGetMappedSize

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

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

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

DeviceManagement 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7

cuDeviceComputeCapability

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

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

2.3

ContextManagement 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8

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

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

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

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

2.4

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

iii

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3 cudaEventQuery NAME cudaEventQuery . or cudaErrorNotReady if not. asynchronous launches. SEE ALSO cudaEventCreate.4. 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. cudaEventSynchronize. RETURN VALUE Relevant return values: cudaSuccess cudaErrorNotReady cudaErrorInitializationError cudaErrorPriorLaunchFailure cudaErrorInvalidValue cudaErrorInvalidResourceHandle Note that this function may also return error codes from previous.1. cudaEventRecord. the function returns cudaErrorInvalidValue. cudaEventElapsedTime 20 . If cudaEventRecord() has not been called on this event.

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

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

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

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

cudaMalloc() returns cudaErrorMemoryAllocation in case of failure.allocate memory on the GPU SYNOPSIS cudaError_t cudaMalloc( void** devPtr. cudaFree. cudaMallocHost.1. asynchronous launches. cudaMallocArray.1 cudaMalloc NAME cudaMalloc . RETURN VALUE Relevant return values: cudaSuccess cudaErrorMemoryAllocation Note that this function may also return error codes from previous. cudaFreeArray. size_t count ) 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. cudaFreeHost 25 .5. The memory is not cleared. SEE ALSO cudaMallocPitch.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. size_t count. symbol can either be a variable that resides in global or constant memory space.5. cudaMemcpy2D.1. cudaMemcpyToSymbol 43 . cudaMemcpyArrayToArray. naming a variable that resides in global or constant memory space. size_t offset.copies data from GPU to host memory SYNOPSIS template < class T > cudaError_t cudaMemcpyFromSymbol( void *dst. cudaMemcpy2DFromArray.19 cudaMemcpyFromSymbol NAME cudaMemcpyFromSymbol . cudaMemcpy2DArrayToArray. asynchronous launches. or it can be a character string. cudaMemcpyToArray. const T& symbol. 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. cudaMemcpy2DToArray. cudaMemcpyFromArray. kind can be either cudaMemcpyDeviceToHost or cudaMemcpyDeviceToDevice. SEE ALSO cudaMemcpy.

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

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

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

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

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

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

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

cudaMemset2D.SEE ALSO cudaMemset. cudaMalloc3D 51 .

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

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

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

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

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

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

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

If the device memory pointer was returned from cudaMalloc(). cudaGetChannelDesc. Since the hardware enforces an alignment requirement on texture base addresses.Low-level texture API SYNOPSIS cudaError_t cudaBindTexture(size_t* offset. Any memory previously bound to texRef is unbound. cudaGetTextureReference. const void* devPtr. size_t size = UINT_MAX). SEE ALSO cudaCreateChannelDesc. DESCRIPTION Binds size bytes of the memory area pointed to by devPtr to the texture reference texRef. 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. desc describes how the memory is interpreted when fetching values from the texture.cudaBindTexture NAME cudaBindTexture . cudaGetTextureAlignmentOffset 59 . const struct cudaChannelFormatDesc* desc. asynchronous launches. cudaUnbindTexture. the offset is guaranteed to be 0 and NULL may be passed as the offset parameter. cudaBindTextureToArray. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function. const struct textureReference* texRef.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaError 96 .SEE ALSO cudaGetErrorString.

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

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

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

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

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

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

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

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

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

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

cuDeviceTotalMem 107 .5 cuDeviceGetName NAME cuDeviceGetName . int len.2. cuDeviceGetProperties. cuDeviceGetCount. SEE ALSO cuDeviceComputeCapability. CUdevice dev).returns an identifier string SYNOPSIS CUresult cuDeviceGetName(char* name. 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. DESCRIPTION Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name. cuDeviceGet. cuDeviceGetAttribute. len specifies the maximum length of the string that may be returned.2.

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

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

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

cuCtxGetDevice.2.1 cuCtxAttach NAME cuCtxAttach . unsigned int Flags). cuCtxAttach() fails if there is no context current to the thread. DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context. SEE ALSO cuCtxCreate. asynchronous launches. the Flags parameter must be 0. Currently. cuCtxDetach.3. 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.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

In this version of CUDA. CUtexref texRef).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. cuParamSetv. int texunit. SEE ALSO cuFuncSetBlockShape. cuLaunch. cuParamSetSize.adds a texture-reference to the function’s argument list SYNOPSIS CUresult cuParamSetTexRef(CUfunction func. cuParamSeti.2.7. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuLaunchGrid 145 . the texture reference must be obtained via cuModuleGetTexRef() and the texunit parameter must be set to CU_PARAM_TR_DEFAULT. cuParamSetf. cuFuncSetSharedSize. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuMemcpyAtoA. dstDevPtr specifies the base pointer of the destination and must be naturally aligned with the CUDA array elements. SEE ALSO cuMemcpyHtoD.16 cuMemcpyAtoD NAME cuMemcpyAtoD . unsigned int srcIndex. cuMemcpy2D 174 . cuMemcpyHtoA. cuMemcpyAtoH. DESCRIPTION Copies from a 1D CUDA array to device memory. cuMemcpyDtoD. unsigned int count). CUarray srcArray. count specifies the number of bytes to copy and must be evenly divisible by the array element 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. cuMemcpyDtoA.2.copies memory from Array to Device SYNOPSIS CUresult cuMemcpyAtoD(CUdeviceptr dstDevPtr. asynchronous launches. cuMemcpyDtoH. srcArray and srcIndex specify the CUDA array handle and the index (in array elements) of the array element where the copy is to begin.

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

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

2. DESCRIPTION Copies from device memory to device memory. unsigned int count). CUdeviceptr srcDevPtr. cuMemcpyDtoA. asynchronous launches. count specifies the number of bytes to copy.copies memory from Device to Device SYNOPSIS CUresult cuMemcpyDtoD(CUdeviceptr dstDevPtr. cuMemcpyAtoD. cuMemcpyDtoH. cuMemcpyHtoA.19 cuMemcpyDtoD NAME cuMemcpyDtoD . SEE ALSO cuMemcpyHtoD. cuMemcpyAtoA. cuMemcpyAtoH. cuMemcpy2D 177 . 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. dstDevice and srcDevPtr are the base pointers of the destination and source.8. respectively.

CUdeviceptr srcDevPtr. cuMemcpyAtoA. cuMemcpyAtoH. cuMemcpyHtoA. asynchronous launches. MemcpyDtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. 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. unsigned int count.copies memory from Device to Host SYNOPSIS CUresult cuMemcpyDtoH(void* dstHostPtr. countspecifies the number of bytes to copy. CUresult cuMemcpyDtoHAsync(void* dstHostPtr. DESCRIPTION Copies from device to host memory.20 cuMemcpyDtoH NAME cuMemcpyDtoH . cuMemcpyAtoD. dstHostPtr and srcDevPtrspecify the base addresses of the source and destination. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemcpyDtoD. CUdeviceptr srcDevPtr. CUstream stream).2. respectively. unsigned int count). cuMemcpy2D 178 .8.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuTexRefSetAddress. cuTexRefSetArray.12 cuTexRefSetFilterMode NAME cuTexRefSetFilterMode .sets the mode for a texture-reference SYNOPSIS CUresult cuTexRefSetFilterMode(CUtexref texRef. cuTexRefSetFormat. asynchronous launches.9. cuTexRefSetAddressMode. cuTexRefSetFlags. cuTexRefGetAddressMode. Note that this call has no effect if texRef is bound to linear memory.2. cuTexRefGetArray. cuTexRefDestroy. cuTexRefGetFormat. CUfilter_mode_enum is defined as such: typedef enum CUfilter_mode_enum { CU_TR_FILTER_MODE_POINT = 0. SEE ALSO cuTexRefCreate. DESCRIPTION Specifies the filtering mode mode to be used when reading memory through the texture reference texRef. CUfilter_mode mode). CU_TR_FILTER_MODE_LINEAR = 1 } CUfilter_mode. cuTexRefGetFilterMode. cuTexRefGetAddress. cuTexRefGetFlags 195 . 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 196 . cuTexRefSetArray. cuTexRefDestroy. Instead. cuTexRefSetAddressMode. cuTexRefGetFormat.9. asynchronous launches. cuTexRefSetAddress.sets flags for a texture-reference SYNOPSIS CUresult cuTexRefSetFlags(CUtexref texRef.13 cuTexRefSetFlags NAME cuTexRefSetFlags . 1]. SEE ALSO cuTexRefCreate. Dim) where Dim is the width or height of the CUDA array. 1. The valid flags are: • CU_TRSF_READ_AS_INTEGER. cuTexRefSetFilterMode. which suppresses the default behavior of having the texture coordinates range from [0. DESCRIPTION Specifies optional flags to control the behavior of data returned through the texture reference.2. cuTexRefGetArray. cuTexRefSetFormat. cuTexRefGetFilterMode. unsigned int Flags). • CU_TRSF_NORMALIZED_COORDINATES. cuTexRefGetAddress.0) reference the entire breadth of the array dimension RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. the texture coordinates [0. which suppresses the default behavior of having the texture promote integer data to floating point data in the range [0.

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

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

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

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

3 cuGLMapBufferObject NAME cuGLMapBufferObject . RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. cuGLUnmapBufferObject. asynchronous launches.10. 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. cuGLInit.2. GLuint bufferObj). unsigned int* size. cuGLUnregisterBufferObject 201 . cuGLRegisterBufferObject.

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

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

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->