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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.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.1 cudaThreadSynchronize NAME cudaThreadSynchronize . cudaThreadSynchronize() returns an error if one of the preceding tasks failed. asynchronous launches. SEE ALSO cudaThreadExit 10 .2.

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

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

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

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

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

4 cudaStreamDestroy NAME cudaStreamDestroy . cudaStreamDestroy 16 . SEE ALSO cudaStreamCreate.3.1. cudaStreamSychronize.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. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

cudaMemset2D. cudaMalloc3D 51 .SEE ALSO cudaMemset.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.9

Direct3dInteroperability RT

NAME
Direct3D Interoperability

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

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

78

1.9.1

cudaD3D9GetDevice

NAME
cudaD3D9GetDevice - gets the device number for an adapter

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

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

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

SEE ALSO

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

79

1.9.2

cudaD3D9SetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9SetDirect3DDevice(IDirect3DDevice9* pDxDevice);

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

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

SEE ALSO

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

80

1.9.3

cudaD3D9GetDirect3DDevice

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

SYNOPSIS
cudaError_t cudaD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice);

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

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

SEE ALSO

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

81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEE ALSO cudaGetErrorString. cudaError 96 .

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

asynchronous launches. cuCtxDetach. SEE ALSO cuCtxCreate. DESCRIPTION Increments the usage count of the context and passes back a context handle in *pCtx that must be passed to cuCtxDetach() when the application is done with the context. Currently.2.3. the Flags parameter must be 0. cuCtxSynchronize 112 . cuCtxGetDevice.increment context usage-count SYNOPSIS CUresult cuCtxAttach(CUcontext* pCtx. cuCtxAttach() fails if there is no context current to the thread. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. unsigned int Flags).1 cuCtxAttach NAME cuCtxAttach .

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

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

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

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

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

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

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

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

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

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

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

2.4.3

cuModuleGetTexRef

NAME
cuModuleGetTexRef - gets a handle to a texture-reference

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

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

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

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

124

2.4.4

cuModuleLoad

NAME
cuModuleLoad - loads a compute module

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

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

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

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

125

2.4.5

cuModuleLoadData

NAME
cuModuleLoadData - loads a module’s data

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

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

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

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

126

2.4.6

cuModuleLoadFatBinary

NAME
cuModuleLoadFatBinary - loads a fat-binary object

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

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

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

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

127

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

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

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

5. 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 .2. DESCRIPTION Destroys the stream.destroys a stream SYNOPSIS CUresult cuStreamDestroy(CUstream stream). asynchronous launches. SEE ALSO cuStreamCreate.2 cuStreamDestroy NAME cuStreamDestroy . cuStreamQuery.

determine status of a compute stream SYNOPSIS CUresult cuStreamQuery(CUstream stream). asynchronous launches. SEE ALSO cuStreamCreate. cuStreamSynchronize. DESCRIPTION Returns CUDA_SUCCESS if all operations in the stream have completed.5. cuStreamDestroy 132 .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_NOT_READY Note that this function may also return error codes from previous.3 cuStreamQuery NAME cuStreamQuery . or CUDA_ERROR_NOT_READY if not.

asynchronous launches. DESCRIPTION Blocks until the device has completed all operations in the stream. cuStreamQuery.block until a stream’s tasks are completed SYNOPSIS CUresult cuStreamSynchronize(CUstream stream).2. SEE ALSO cuStreamCreate.5.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. cuStreamDestroy 133 .

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

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

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

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

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

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

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

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

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

CUstream stream). int grid_height. SEE ALSO cuFuncSetBlockShape. int grid_height).2 cuLaunchGrid NAME cuLaunchGrid . asynchronous launches. cuLaunch 143 . int grid_width.7. CUresult cuLaunchGridAsync(CUfunction func. int grid_width. cuParamSetv. cuFuncSetSharedSize.launches a CUDA function SYNOPSIS CUresult cuLaunchGrid(CUfunction func. cuParamSeti. Each block contains the number of threads specified by a previous call to cuFuncSetBlockShape(). cuParamSetf. cuParamSetSize. cuLaunchGridAsync() can optionally be associated to a stream by passing a non-zero stream argument.2. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING Note that this function may also return error codes from previous. DESCRIPTION Invokes the kernel on a grid_width x grid_height grid of blocks. cuParamSetTexRef.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. cuMemAlloc. Both parameters basePtr and size are optional. cuMemFree. asynchronous launches. cuArrayDestroy. cuMemset. unsigned int* size. it is ignored.8. cuArrayCreate.get information on memory allocations SYNOPSIS CUresult cuMemGetAddressRange(CUdeviceptr* basePtr. SEE ALSO cuMemGetInfo. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT CUDA_ERROR_INVALID_VALUE Note that this function may also return error codes from previous. cuMemFreeHost. cuMemset2D 165 . If one of them is null.2. cuMemAllocHost. cuArrayGetDescriptor.11 cuMemGetAddressRange NAME cuMemGetAddressRange . cuMemAllocPitch.

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

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

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

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

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

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

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

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

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

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

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

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

dstHostPtr and srcDevPtrspecify the base addresses of the source and destination. countspecifies the number of bytes to copy.8. respectively. unsigned int count. CUdeviceptr srcDevPtr.copies memory from Device to Host SYNOPSIS CUresult cuMemcpyDtoH(void* dstHostPtr. cuMemcpyHtoA. cuMemcpyDtoA. SEE ALSO cuMemcpyHtoD. cuMemcpyAtoD. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. CUresult cuMemcpyDtoHAsync(void* dstHostPtr.20 cuMemcpyDtoH NAME cuMemcpyDtoH . MemcpyDtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream argument. asynchronous launches. 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. CUstream stream). DESCRIPTION Copies from device to host memory. CUdeviceptr srcDevPtr.2. unsigned int count). cuMemcpy2D 178 . cuMemcpyAtoH. cuMemcpyAtoA.

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

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

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

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

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

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

cuTexRefSetAddressMode. cuTexRefSetAddress. cuTexRefGetFlags 185 . cuTexRefGetFilterMode. cuTexRefGetAddress.2.2 cuTexRefDestroy NAME cuTexRefDestroy . 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. asynchronous launches. cuTexRefSetFlags. cuTexRefSetArray.9. cuTexRefGetArray. cuTexRefSetFormat. DESCRIPTION Destroys the texture reference. cuTexRefGetFormat. cuTexRefGetAddressMode. cuTexRefSetFilterMode.destroys a texture-reference SYNOPSIS CUresult cuTexRefDestroy(CUtexref texRef).

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

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

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

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

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

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

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

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

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

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

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

cuTexRefGetFormat. cuTexRefSetFilterMode.9. cuTexRefSetFlags. cuTexRefGetFlags 197 .sets the format for a texture-reference SYNOPSIS CUresult cuTexRefSetFormat(CUtexref texRef. cuTexRefGetFilterMode. CUarray_format format.14 cuTexRefSetFormat NAME cuTexRefSetFormat . int numPackedComponents) DESCRIPTION Specifies the format of the data to be read by the texture reference texRef. cuTexRefGetArray. cuTexRefGetAddress. 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.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. cuTexRefSetAddress. cuTexRefDestroy. cuTexRefSetArray. cuTexRefSetAddressMode. SEE ALSO cuTexRefCreate. cuTexRefGetAddressMode. asynchronous launches.

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

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

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

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

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

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

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

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

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

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

cuD3D9ResourceGetSurfaceDimensions. cuD3D9RegisterResource. SEE ALSO cuD3D9GetDevice. DESCRIPTION Returns in *ppDxDevice the Direct3D device against which this CUDA context was created in cuD3D9CtxCreate. cuD3D9MapResources.11.3 cuD3D9GetDirect3DDevice NAME cuD3D9GetDirect3DDevice .get the Direct3D device against which the current CUDA context was created SYNOPSIS CUresult cuD3D9GetDirect3DDevice(IDirect3DDevice9** ppDxDevice). cuD3D9CtxCreate. cuD3D9ResourceGetMappe cuD3D9ResourceGetMappedSize. RETURN VALUE Relevant return values: CUDA_SUCCESS CUDA_ERROR_DEINITIALIZED CUDA_ERROR_NOT_INITIALIZED CUDA_ERROR_INVALID_CONTEXT Note that this function may also return error codes from previous. cuD3D9ResourceGetMappedPitch 208 . asynchronous launches. cuD3D9UnmapResources. cuD3D9ResourceSetMapFlags.2. cuD3D9UnregisterResource.

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

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

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

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

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

217 .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. DESCRIPTION Returns in *pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource which corresponds to Face and Level. If pResource is not mapped 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_VALUE CUDA_ERROR_INVALID_HANDLE CUDA_ERROR_NOT_MAPPED Note that this function may also return error codes from previous. If Face is invalid then CUDA_ERROR_INVALID_V is returned. For all other types Level must be 0. asynchronous launches. unsigned int Level). If pResource is of type IDirect3DCubeTexture9 then Face must one of the values enumerated by type D3DCUBEMAP_FACES. IDirect3DResource9* pResource.2. unsigned int Face. If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. At present only mipmap level 0 is supported. 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. For all other types Face must be 0.10 cuD3D9ResourceGetMappedPointer NAME cuD3D9ResourceGetMappedPointer . If Level is invalid then CUDA_ERROR_INVALID_VALUE is returned. If pResource is of type IDirect3DBaseTexture9 then Level must correspond to a valid mipmap level.11.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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