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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMalloc3D 51 . cudaMemset2D.SEE ALSO cudaMemset.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.7 cudaD3D9UnmapResources NAME cudaD3D9UnmapResources .9. cudaD3D9ResourceSetMa cudaD3D9ResourceGetMappedPointer. cudaD3D9UnregisterResource. SEE ALSO cudaD3D9GetDevice. cudaD3D9ResourceGetMappedPitch 86 . cudaD3D9RegisterResource. cudaD3D9ResourceGetSurfaceDimensions. DESCRIPTION Unmaps the count Direct3D resources in ppResources. If any of ppResources have not been registered for use with CUDA or if ppResources contains any duplicate entries then cudaErrorInvalidHandle is returned.unmap Direct3D resources SYNOPSIS cudaError_t cudaD3D9UnmapResources(unsigned int count. cudaD3D9MapResources. cudaD3D9ResourceGetMappedSize. cudaD3D9SetDirect3DDevice. asynchronous launches. If any of ppResources are not presently mapped for access by CUDA then cudaErrorUnknown is returned. IDirect3DResource9** ppResources). 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. cudaD3D9GetDirect3DDevice.

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

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

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

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

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

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

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

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

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.10. 95 .1 cudaGetLastError NAME cudaGetLastError .returns the last error from a run-time call SYNOPSIS cudaError_t cudaGetLastError( void ) DESCRIPTION Returns the last error that was returned from any of the runtime calls in the same host thread and resets it to cudaSuccess.

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

2.1. 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. SEE ALSO 100 . Currently. any function from the driver API will return CUDA_ERROR_NOT_INITIALIZED.initialize the CUDA driver API SYNOPSIS CUresult cuInit( unsigned int Flags ).1 cuInit NAME cuInit . asynchronous launches. the Flags parameters must be 0. DESCRIPTION Initializes the driver API and must be called before any other function from the driver API. If cuInit() has not been called.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cuCtxDetach. cuCtxAttach.3. asynchronous launches.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.block for a context’s tasks to complete SYNOPSIS CUresult cuCtxSynchronize(void).2. cuCtxSynchronize() returns an error if one of the preceding tasks failed. SEE ALSO cuCtxCreate. cuCtxGetDevice 120 . DESCRIPTION Blocks until the device has completed all preceding requested tasks.

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

cuStreamQuery.2 cuStreamDestroy NAME cuStreamDestroy .5.2.destroys a stream SYNOPSIS CUresult cuStreamDestroy(CUstream stream). 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. cuStreamSynchronize 131 . asynchronous launches. SEE ALSO cuStreamCreate.

2.3 cuStreamQuery NAME cuStreamQuery . or CUDA_ERROR_NOT_READY if not. SEE ALSO cuStreamCreate.5. asynchronous launches.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. cuStreamSynchronize. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_READY Note that this function may also return error codes from previous.

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

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

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

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

cuEventQuery. asynchronous launches.computes the elapsed time between two events SYNOPSIS CUresult cuEventDestroy(float* time. CUevent start. the result is undefined. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. DESCRIPTION Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds).2. If either event has not been recorded yet.3 cuEventElapsedTime NAME cuEventElapsedTime .6. cuEventDestroy 137 . If either event has been recorded with a non-zero stream. cuEventRecord. CUevent end). this function returns CUDA_ERROR_INVALID_VALUE. cuEventSynchronize. SEE ALSO cuEventCreate.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

which must have been returned by a previous call to cuMemAllocHost().8. SEE ALSO cuMemGetInfo. cuMemset2D 164 . cuArrayDestroy. cuMemAlloc. cuArrayGetDescriptor. cuMemset. DESCRIPTION Frees the memory space pointed to by hostPtr. cuMemAllocHost. cuMemAllocPitch.10 cuMemFreeHost NAME cuMemFreeHost .2. cuMemFree. cuMemGetAddressRange. cuArrayCreate. asynchronous launches.frees page-locked host memory SYNOPSIS CUresult cuMemFreeHost(void* hostPtr). 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. cuArrayDestroy. cuMemAllocHost. cuMemFreeHost. 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* size. cuMemAllocPitch. If one of them is null. cuMemFree.11 cuMemGetAddressRange NAME cuMemGetAddressRange . SEE ALSO cuMemGetInfo. CUdeviceptr devPtr). DESCRIPTION Returns the base address in *basePtr and size and *size of the allocation by cuMemAlloc() or cuMemAllocPitch() that contains the input pointer devPtr. cuArrayGetDescriptor. it is ignored. cuArrayCreate. cuMemset2D 165 . cuMemset.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. Both parameters basePtr and size are optional.8. cuMemAlloc. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

CUtexref texRef. cuTexRefGetFlags 187 . int dim). 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.9.4 cuTexRefGetAddressMode NAME cuTexRefGetAddressMode .2. cuTexRefSetAddressMode. cuTexRefSetFilterMode. cuTexRefSetFormat. cuTexRefSetAddress. cuTexRefGetFilterMode. cuTexRefGetArray. cuTexRefDestroy. DESCRIPTION Returns in *mode the addressing mode corresponding to the dimension dim of the texture reference texRef.gets the addressing mode used by a texture-reference SYNOPSIS CUresult cuTexRefGetAddressMode(CUaddress_mode* mode. Currently the only valid values for dim are 0 and 1. cuTexRefSetArray. SEE ALSO cuTexRefCreate. asynchronous launches. cuTexRefGetFormat. cuTexRefSetFlags.

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

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

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

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

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

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

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

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

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

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

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

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

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

cuGLUnmapBufferObject. unsigned int* size.2. cuGLUnregisterBufferObject 201 .3 cuGLMapBufferObject NAME cuGLMapBufferObject . SEE ALSO cuGLCtxCreate. cuGLInit.10. GLuint bufferObj). cuGLRegisterBufferObject. DESCRIPTION Maps the buffer object of ID bufferObj into the address space of the current CUDA context and returns in *devPtr and *size the base pointer and size of the resulting mapping. asynchronous launches.maps a GL buffer object SYNOPSIS CUresult cuGLMapBufferObject(CUdeviceptr* devPtr. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_MAP_FAILED Note that this function may also return error codes from previous.

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

SEE ALSO cuGLCtxCreate. asynchronous launches. cuGLUnregisterBufferObject 203 .unmaps a GL buffer object SYNOPSIS CUresult cuGLUnmapBufferObject(GLuint bufferObj).5 cuGLUnmapBufferObject NAME cuGLUnmapBufferObject . cuGLInit. cuGLRegisterBufferObject.10. cuGLMapBufferObject. 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.2.

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

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

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

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

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

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

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

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

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

2.11.7

cuD3D9UnmapResources

NAME
cuD3D9UnmapResources - unmap Direct3D resources

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

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

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

SEE ALSO

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

213

2.11.8

cuD3D9ResourceSetMapFlags

NAME
cuD3D9ResourceSetMapFlags - set usage flags for mapping a Direct3D resource

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

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

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

214

SEE ALSO

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

215

2.11.9

cuD3D9ResourceGetSurfaceDimensions

NAME
cuD3D9ResourceGetSurfaceDimensions - get the dimensions of a registered surface

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

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

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

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

216

For all other types Level must be 0.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.10 cuD3D9ResourceGetMappedPointer NAME cuD3D9ResourceGetMappedPointer .11. 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. IDirect3DResource9* pResource. If Face is invalid then CUDA_ERROR_INVALID_V is returned. If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level. If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE then CUDA_ERROR_INVA is returned. The value set in pDevPtr may change every time that pResource is mapped. If Level is invalid then CUDA_ERROR_INVALID_VALUE is returned. If pResource is not mapped then CUDA_ERROR_NOT_MAPPED is returned. unsigned int Face.2. For all other types Face must be 0. 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. At present only mipmap level 0 is supported. If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. 217 . asynchronous launches. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned.

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

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

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

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

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

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 .

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

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

NOTES 32-bit atomic operations are only supported on devices of compute capability 1.2 and higher.1 and higher. atomicSub.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).atomic exchange SYNOPSIS int atomicExch(int* address. atomicDec. DESCRIPTION Reads the 32. atomicCAS 226 . unsigned long long int atomicExch(unsigned long long int* address.3. These two operations are performed in one atomic transaction. The function returns old. unsigned int val). unsigned int atomicExch(unsigned int* address. atomicInc.3 atomicExch NAME atomicExch . unsigned long long int val). SEE ALSO atomicAdd. 64-bit atomic operations are only supported on devices of compute capability 1. atomicMax.1. atomicMin.

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

SEE ALSO atomicAdd.5 atomicMax NAME atomicMax . atomicSub. int val). computes the maximum of old and val. unsigned int atomicMax(unsigned int* address. and stores the result back to global memory at the same address. unsigned int val).3. atomicExch. atomicDec. 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. These three operations are performed in one atomic transaction. atomicMin.atomic maximum SYNOPSIS int atomicMax(int* address.1 and higher. atomicCAS 228 .1. The function returns old. atomicInc.

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

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

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

3.2

BitwiseFunctions

NAME
Bitwise Functions

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

SEE ALSO
ArithmeticFunctions

232

3.2.1

atomicAnd

NAME
atomicAnd - atomic bitwise-and

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

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

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

SEE ALSO
atomicOr, atomicXor

233

3.2.2

atomicOr

NAME
atomicOr - atomic bitwise-or

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

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

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

SEE ALSO
atomicAnd, atomicXor

234

3.2.3

atomicXor

NAME
atomicXor - atomic bitwise-xor

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

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

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

SEE ALSO
atomicAnd, atomicOr

235

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

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

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

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)//-->