CUDA Runtime API Reference Manual (Release 13.5, 2026) - page 1

 

  Index      Manuals     CUDA Runtime API Reference Manual (Release 13.5, 2026)

 

Search            copyright infringement  

    

 

   

 

   

 

Content      ..      1       2         ..

 

 

CUDA Runtime API Reference Manual (Release 13.5, 2026) - page 1

 

 

Contents
1
Difference between the driver and runtime APIs
1
2
API Synchronization behavior
3
3
Stream synchronization behavior
5
4
Graph object thread safety
7
5
Rules for version mixing
9
6
APIs
11
6.1
C++ API Routines
11
6.1.1
Functions
20
6.2
Data types used by CUDA Runtime
71
6.2.1
Macros
85
6.2.2
Enumerations
92
6.2.3
Typedefs
169
6.3
Device Management
171
6.3.1
Functions
173
6.4
Device Management [DEPRECATED]
200
6.4.1
Functions
201
6.5
Direct3D 10 Interoperability
203
6.5.1
Enumerations
203
6.5.2
Functions
204
6.6
Direct3D 10 Interoperability [DEPRECATED]
207
6.6.1
Enumerations
208
6.6.2
Functions
208
6.7
Direct3D 11 Interoperability
217
6.7.1
Enumerations
218
6.7.2
Functions
218
6.8
Direct3D 11 Interoperability [DEPRECATED]
221
6.8.1
Functions
222
6.9
Direct3D 9 Interoperability
223
6.9.1
Enumerations
223
6.9.2
Functions
224
6.10
Direct3D 9 Interoperability [DEPRECATED]
228
6.10.1
Enumerations
229
6.10.2
Functions
230
6.11
Driver Entry Point Access
238
6.11.1
Functions
239
6.12
EGL Interoperability
242
6.12.1
Functions
243
6.13
Error Handling
249
6.13.1
Functions
250
i
6.14
Error Log Management Functions
252
6.14.1
Functions
253
6.14.2
Typedefs
255
6.15
Event Management
255
6.15.1
Functions
256
6.16
Execution Context Management
263
6.16.1
Overview
263
6.16.2
Lifetime of CUDA Resources
264
6.16.3
APIs Operating on Current Context
264
6.16.3.1
APIs Operating on Device Resources
264
6.16.3.2
APIs Operating on Context Resources
264
6.16.4
Green Contexts
264
6.16.5
Functions
267
6.17
Execution Control
281
6.17.1
Functions
282
6.18
Execution Control [DEPRECATED]
296
6.18.1
Functions
297
6.19
External Resource Interoperability
298
6.19.1
Functions
299
6.20
Graph Management
311
6.20.1
Functions
318
6.21
Graphics Interoperability
411
6.21.1
Functions
412
6.22
Interactions with the CUDA Driver API
418
6.22.1
Execution Contexts
418
6.22.2
Primary Context (aka Device Execution Context)
418
6.22.3
Initialization and Tear-Down
418
6.22.4
CUcontext Interoperability
419
6.22.5
Interactions between CUstream and cudaStream_t
419
6.22.6
Interactions between CUevent and cudaEvent_t
419
6.22.7
Interactions between CUarray and cudaArray_t
420
6.22.8
Interactions between CUgraphicsResource and cudaGraphicsResource_t
420
6.22.9
Interactions between CUtexObject and cudaTextureObject_t
420
6.22.10 Interactions between CUsurfObject and cudaSurfaceObject_t
420
6.22.11 Interactions between CUfunction and cudaFunction_t
421
6.22.12 Interactions between CUkernel and cudaKernel_t
421
6.22.13 Functions
421
6.23
Library Management
422
6.23.1
Functions
423
6.24
Logical Endpoint
430
6.24.1
Functions
430
6.25
Memory Management
431
6.25.1
Functions
435
6.26
Memory Management [DEPRECATED]
508
6.26.1
Functions
509
6.27
Occupancy
514
6.27.1
Functions
515
6.28
OpenGL Interoperability
521
6.28.1
Enumerations
522
6.28.2
Functions
522
6.28.3
Typedefs
525
6.29
OpenGL Interoperability [DEPRECATED]
525
6.29.1
Enumerations
526
6.29.2
Functions
527
ii
6.30
Peer Device Memory Access
531
6.30.1
Functions
532
6.31
Profiler Control
534
6.31.1
Functions
534
6.32
Stream Management
535
6.32.1
Functions
537
6.32.2
Typedefs
557
6.33
Stream Ordered Memory Allocator
558
6.33.1
overview
558
6.33.2
Supported Platforms
558
6.33.3
Functions
559
6.34
Surface Object Management
571
6.34.1
Functions
572
6.35
Texture Object Management
573
6.35.1
Functions
574
6.36
Unified Addressing
582
6.36.1
Overview
582
6.36.2
Supported Platforms
583
6.36.3
Looking Up Information from Pointer Values
583
6.36.4
Automatic Mapping of Host Allocated Host Memory
583
6.36.5
Direct Access of Peer Memory
583
6.36.6
Exceptions, Disjoint Addressing
584
6.36.7
Functions
584
6.37
VDPAU Interoperability
585
6.37.1
Functions
586
6.38
Version Management
589
6.38.1
Functions
589
7
Structs
593
7.1
CUuuid_st
593
7.2
cudaAccessPolicyWindow
593
7.3
cudaArrayMemoryRequirements
594
7.4
cudaArraySparseProperties
594
7.5
cudaAsyncNotificationInfo_t
595
7.6
cudaChannelFormatDesc
596
7.7
cudaChildGraphNodeParams
596
7.8
cudaConditionalNodeParams
597
7.9
cudaDevResource
598
7.10
cudaDevSmResource
599
7.11
cudaDevSmResourceGroupParams
599
7.12
cudaDevWorkqueueConfigResource
600
7.13
cudaDevWorkqueueResource
601
7.14
cudaDeviceProp
601
7.15
cudaEglFrame
607
7.16
cudaEglPlaneDesc
608
7.17
cudaEventRecordNodeParams
609
7.18
cudaEventWaitNodeParams
610
7.19
cudaExtent
610
7.20
cudaExternalMemoryBufferDesc
610
7.21
cudaExternalMemoryHandleDesc
611
7.22
cudaExternalMemoryMipmappedArrayDesc
612
7.23
cudaExternalSemaphoreHandleDesc
613
7.24
cudaExternalSemaphoreSignalNodeParams
614
7.25
cudaExternalSemaphoreSignalNodeParamsV2
615
iii
7.26
cudaExternalSemaphoreSignalParams
615
7.27
cudaExternalSemaphoreWaitNodeParams
616
7.28
cudaExternalSemaphoreWaitNodeParamsV2
616
7.29
cudaExternalSemaphoreWaitParams
617
7.30
cudaFuncAttributes
618
7.31
cudaGraphEdgeData
621
7.32
cudaGraphExecUpdateResultInfo
622
7.33
cudaGraphInstantiateParams
622
7.34
cudaGraphKernelNodeUpdate
623
7.35
cudaGraphNodeParams
624
7.36
cudaGraphRecaptureCallbackData
625
7.37
cudaHostNodeParams
626
7.38
cudaHostNodeParamsV2
626
7.39
cudaIpcEventHandle_t
627
7.40
cudaIpcMemHandle_t
627
7.41
cudaKernelNodeParams
627
7.42
cudaKernelNodeParamsV2
628
7.43
cudaLaunchAttribute
629
7.44
cudaLaunchConfig_t
629
7.45
cudaLaunchMemSyncDomainMap
630
7.46
cudaMemAccessDesc
630
7.47
cudaMemAllocNodeParams
631
7.48
cudaMemAllocNodeParamsV2
631
7.49
cudaMemFabricHandle_t
632
7.50
cudaMemFreeNodeParams
632
7.51
cudaMemLocation
632
7.52
cudaMemPoolProps
633
7.53
cudaMemPoolPtrExportData
634
7.54
cudaMemcpy3DBatchOp
634
7.55
cudaMemcpy3DOperand
635
7.56
cudaMemcpy3DParms
636
7.57
cudaMemcpy3DPeerParms
637
7.58
cudaMemcpyAttributes
637
7.59
cudaMemcpyBatchNodeParams
638
7.60
cudaMemcpyNodeParams
639
7.61
cudaMemsetParams
640
7.62
cudaMemsetParamsV2
640
7.63
cudaOffset3D
641
7.64
cudaPitchedPtr
642
7.65
cudaPointerAttributes
642
7.66
cudaPos
643
7.67
cudaResourceDesc
644
7.68
cudaResourceViewDesc
645
7.69
cudaTextureDesc
646
7.70
cudalibraryHostUniversalFunctionAndDataTable . .
647
8
Deprecated List
651
9
Notices
655
9.1
Notice
655
9.2
OpenCL
656
9.3
Trademarks
656
iv
Chapter 1. Difference between the
driver and runtime APIs
The driver and runtime APIs are very similar and can for the most part be used interchangeably. How-
ever, there are some key differences worth noting between the two.
Complexity vs. control
The runtime API eases device code management by providing implicit primary context initialization
and management, and implicit module management. This leads to simpler code, but it also lacks the
level of control that the driver API has.
In comparison, the driver API offers more fine-grained control, especially over module loading. Kernel
launches are much more complex to implement, as the execution configuration and kernel parameters
must be specified with explicit function calls. However, unlike the runtime, where all the kernels are
automatically loaded during initialization and stay loaded for as long as the program runs, with the
driver API it is possible to only keep the modules that are currently needed loaded, or even dynamically
reload modules. The driver API is also language-independent as it only deals with cubin objects.
Context management
Unless an execution context cudaExecutionContext_t is specified, the runtime API decides itself which
context to use for a thread: if a context has been made current to the calling thread through the driver
API, the runtime will use that, but if there is no such context, it uses the device execution context
which is a “primary context.” Primary contexts are created as needed, one per device per process, are
reference-counted, and are then destroyed when there are no more references to them. Within one
process, all users of the runtime API will share the primary context, unless a context has been made
current to each thread or an explicit execution context is specified to the runtime APIs.
Using the runtime API with primary contexts has its tradeoffs, however. It can cause trouble for users
writing plug-ins for larger software packages, for example, because if all plug-ins run in the same
process, they will all share a context but will likely have no way to communicate with each other. So,
if one of them calls cudaDeviceReset() after finishing all its CUDA work, the other plug-ins will fail
because the context they were using was destroyed without their knowledge. To avoid this issue, CUDA
clients can use the driver API to create and set the current context, and then use the runtime API to
work with it. However, contexts may consume significant resources, such as device memory, extra
host threads, and performance costs of context switching on the device. This runtime-driver context
sharing is important when using the driver API in conjunction with libraries built on the runtime API,
such as cuBLAS or cuFFT.
1
Chapter 2. API Synchronization behavior
The API provides memcpy/memset functions in both synchronous and asynchronous forms, the latter
having an “Async” suffix. This is a misnomer as each function may exhibit synchronous or asynchronous
behavior depending on the arguments passed to the function. The synchronous forms of these APIs
issue these copies through the default stream.
Any CUDA API call may block or synchronize for various reasons such as contention for or unavailability
of internal resources. Such behavior is subject to change and undocumented behavior should not be
relied upon.
Memcpy
In the reference documentation, each memcpy function is categorized as synchronous or asyn-
chronous, corresponding to the definitions below.
Synchronous
1. For transfers from pageable host memory to device memory, a stream sync is performed before
the copy is initiated. The function will return once the pageable buffer has been copied to the
staging memory for DMA transfer to device memory, but the DMA to final destination may not
have completed.
2. For transfers from pinned host memory to device memory, the function is synchronous with
respect to the host.
3. For transfers from device to either pageable or pinned host memory, the function returns only
once the copy has completed.
4. For transfers from device memory to device memory, no host-side synchronization is performed.
5. For transfers from any host memory to any host memory, the function is fully synchronous with
respect to the host.
Asynchronous
1. For transfers between device memory and pageable host memory, the function might be syn-
chronous with respect to host.
2. For transfers from any host memory to any host memory, the function is fully synchronous with
respect to the host.
3. If pageable memory must first be staged to pinned memory, the driver may synchronize with the
stream and stage the copy into pinned memory.
4. For all other transfers, the function should be fully asynchronous.
3
CUDA Runtime API Reference Manual, Release 13.5
Memset
The cudaMemset functions are asynchronous with respect to the host except when the target memory
is pinned host memory. The Async versions are always asynchronous with respect to the host.
Kernel Launches
Kernel launches are asynchronous with respect to the host. Details of concurrent kernel execution
and data transfers can be found in the CUDA Programmers Guide.
4
Chapter 2. API Synchronization behavior
Chapter 3. Stream synchronization
behavior
Default stream
The default stream, used when 0 is passed as a cudaStream_t or by APIs that operate on a stream
implicitly, can be configured to have either legacy or per-thread synchronization behavior as described
below.
The behavior can be controlled per compilation unit with the
--default-stream
nvcc option.
Alternatively,
per-thread behavior can be enabled by defining the
CUDA_API_PER_THREAD_DEFAULT_STREAM macro before including any CUDA headers.
Either
way, the CUDA_API_PER_THREAD_DEFAULT_STREAM macro will be defined in compilation units using
per-thread synchronization behavior.
Legacy default stream
The legacy default stream is an implicit stream which synchronizes with all other streams in the same
CUcontext except for non-blocking streams, described below. (For applications using the runtime
APIs only, there will be one context per device.) When an action is taken in the legacy stream such as a
kernel launch or cudaStreamWaitEvent(), the legacy stream first waits on all blocking streams, the
action is queued in the legacy stream, and then all blocking streams wait on the legacy stream.
For example, the following code launches a kernel k_1 in stream s, then k_2 in the legacy stream, then
k_3 in stream s:
k_1<<<1, 1, 0, s>>>();
k_2<<<1, 1>>>();
k_3<<<1, 1, 0, s>>>();
The resulting behavior is that k_2 will block on k_1 and k_3 will block on k_2.
Non-blocking streams which do not synchronize with the legacy stream can be created using the cu-
daStreamNonBlocking flag with the stream creation APIs.
The legacy default stream can be used explicitly with the CUstream (cudaStream_t) handle
CU_STREAM_LEGACY (cudaStreamLegacy).
5
CUDA Runtime API Reference Manual, Release 13.5
Per-thread default stream
The per-thread default stream is an implicit stream local to both the thread and the CUcontext, and
which does not synchronize with other streams (just like explicitly created streams). The per-thread
default stream is not a non-blocking stream and will synchronize with the legacy default stream if both
are used in a program.
The per-thread default stream can be used explicitly with the CUstream (cudaStream_t) handle
CU_STREAM_PER_THREAD (cudaStreamPerThread).
6
Chapter 3. Stream synchronization behavior
Chapter 4. Graph object thread safety
Graph objects (cudaGraph_t, CUgraph) are not internally synchronized and must not be accessed
concurrently from multiple threads. API calls accessing the same graph object must be serialized
externally.
Note that this includes APIs which may appear to be read-only, such as cudaGraphClone()
(cuGraphClone()) and cudaGraphInstantiate() (cuGraphInstantiate()). No API or pair of
APIs is guaranteed to be safe to call on the same graph object from two different threads without
serialization.
7
Chapter 5. Rules for version mixing
1. Starting with CUDA 11.0, the ABI version for the CUDA runtime is bumped every major release.
CUDA-defined types, whether opaque handles or structures like cudaDeviceProp, have their
ABI tied to the major release of the CUDA runtime. It is unsafe to pass them from function A to
function B if those functions have been compiled with different major versions of the toolkit and
linked together into the same device executable.
2. The CUDA Driver API has a per-function ABI denoted with a _v* extension. CUDA-defined types
(e.g structs) should not be passed across different ABI versions. For example, an application
calling cuMemcpy2D_v2(const CUDA_MEMCPY2D_v2 *pCopy) and using the older version of
the struct CUDA_MEMCPY2D_v1 instead of CUDA_MEMCPY2D_v2.
3. Users should not arbitrarily mix different API versions during the lifetime of a resource. These
resources include IPC handles, memory, streams, contexts, events, etc. For example, a user who
wants to allocate CUDA memory using cuMemAlloc_v2 should free the memory using cuMem-
Free_v2 and not cuMemFree.
9
Chapter 6. APIs
6.1. C++ API Routines
impl_private
This section describes the C++ high level API functions of the CUDA runtime application programming
interface. To use these functions, your application needs to be compiled with the nvcc compiler.
C++-style interface built on top of CUDA runtime API
Classes
__cudaOccupancyB2DHelper
Helper functor for cudaOccupancyMaxPotentialBlockSize.
Functions
__host__ cudaChannelFormatDesc cudaCreateChannelDesc(void)
Returns a channel descriptor using the specified format.
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< char >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< char1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< char2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< char4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindNV12 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedBlock-
Compressed4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedBlock-
Compressed5 >(void)
11
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedBlock-
Compressed6H >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedNor-
malized16X1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedNor-
malized16X2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedNor-
malized16X4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedNor-
malized8X1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedNor-
malized8X2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindSignedNor-
malized8X4 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed16Planar420 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed16Planar422 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed16Planar444 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed16SemiPlanar420 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed16SemiPlanar422 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed16SemiPlanar444 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8Packed422 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8Packed444 >(void)
12
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8Planar420 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8Planar422 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8Planar444 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8SemiPlanar420 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8SemiPlanar422 >(void)
__host__
cudaChannelFormatDesc
cudaCreateChannelDesc<
cudaChannelFormatKindUn-
signed8SemiPlanar444 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed1SRGB >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed2SRGB >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed3 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed3SRGB >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed5 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<
cudaChannelFormatKindUnsigned-
BlockCompressed6H >(void)
6.1. C++ API Routines
13
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsigned-
BlockCompressed7 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsigned-
BlockCompressed7SRGB >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsignedNor-
malized1010102 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsignedNor-
malized16X1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsignedNor-
malized16X2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsignedNor-
malized16X4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsignedNor-
malized8X1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsignedNor-
malized8X2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< cudaChannelFormatKindUnsignedNor-
malized8X4 >(void)
else __host__ cudaChannelFormatDesc cudaCreateChannelDesc< float >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< float1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< float2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< float4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< int >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< int1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< int2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< int4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< long >(void)
14
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< long1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< long2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< long4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< short >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< short1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< short2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< short4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< signed char >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< uchar1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< uchar2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< uchar4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< uint1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< uint2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< uint4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< ulong1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< ulong2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< ulong4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< unsigned char >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< unsigned int >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< unsigned long >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< unsigned short >(void)
6.1. C++ API Routines
15
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< ushort1 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< ushort2 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDesc< ushort4 >(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf1(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf2(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf4(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescNV12(void)
__host__ cudaError_t cudaEventCreate(cudaEvent_t *event, unsigned int flags)
Creates an event object with the specified flags.
__host__ cudaError_t cudaFuncGetAttributes(struct cudaFuncAttributes *attr, T *entry)
Find out attributes for a given function.
__host__ cudaError_t cudaFuncGetName(const char **name, T *func)
Returns the function name for a device entry function pointer.
__host__ cudaError_t cudaFuncSetAttribute(T *func, enum cudaFuncAttribute attr, int value)
Set attributes for a given function.
__host__ cudaError_t cudaFuncSetCacheConfig(T *func, enum cudaFuncCache cacheConfig)
Sets the preferred cache configuration for a device function.
__host__ cudaError_t cudaFuncSetSharedMemConfig(T *func, enum cudaSharedMemConfig config)
__host__ cudaError_t cudaGetKernel(cudaKernel_t *kernelPtr, T *func)
Get pointer to device kernel that matches entry function entryFuncAddr .
__host__ cudaError_t cudaGetSymbolAddress(void **devPtr, const T &symbol)
Finds the address associated with a CUDA symbol.
__host__ cudaError_t cudaGetSymbolSize(size_t *size, const T &symbol)
Finds the size of the object associated with a CUDA symbol.
__host__ cudaError_t cudaGraphAddMemcpyNodeFromSymbol(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph, const cudaGraphNode_t *pDependencies, size_t numDependencies, void
*dst, const T &symbol, size_t count, size_t offset, enum cudaMemcpyKind kind)
Creates a memcpy node to copy from a symbol on the device and adds it to a graph.
__host__ cudaError_t cudaGraphAddMemcpyNodeToSymbol(cudaGraphNode_t *pGraphNode, cud-
aGraph_t graph, const cudaGraphNode_t *pDependencies, size_t numDependencies, const T
&symbol, const void *src, size_t count, size_t offset, enum cudaMemcpyKind kind)
Creates a memcpy node to copy to a symbol on the device and adds it to a graph.
__host__
cudaError_t
cudaGraphExecMemcpyNodeSetParamsFromSymbol(cudaGraphExec_t
hGraphExec, cudaGraphNode_t node, void *dst, const T &symbol, size_t count, size_t
16
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
offset, enum cudaMemcpyKind kind)
Sets the parameters for a memcpy node in the given graphExec to copy from a symbol on the
device.
__host__
cudaError_t
cudaGraphExecMemcpyNodeSetParamsToSymbol(cudaGraphExec_t
hGraphExec, cudaGraphNode_t node, const T &symbol, const void *src, size_t count, size_t
offset, enum cudaMemcpyKind kind)
Sets the parameters for a memcpy node in the given graphExec to copy to a symbol on the
device.
__host__ cudaError_t cudaGraphExecUpdate(cudaGraphExec_t hGraphExec, cudaGraph_t hGraph,
cudaGraphNode_t *hErrorNode_out, enum cudaGraphExecUpdateResult *updateResult_out)
__host__ cudaError_t cudaGraphInstantiate(cudaGraphExec_t *pGraphExec, cudaGraph_t graph,
cudaGraphNode_t *pErrorNode, char *pLogBuffer, size_t bufferSize)
Creates an executable graph from a graph.
__host__ cudaError_t cudaGraphMemcpyNodeSetParamsFromSymbol(cudaGraphNode_t node, void
*dst, const T &symbol, size_t count, size_t offset, enum cudaMemcpyKind kind)
Sets a memcpy node's parameters to copy from a symbol on the device.
__host__ cudaError_t cudaGraphMemcpyNodeSetParamsToSymbol(cudaGraphNode_t node, const T
&symbol, const void *src, size_t count, size_t offset, enum cudaMemcpyKind kind)
Sets a memcpy node's parameters to copy to a symbol on the device.
__host__ cudaError_t cudaHostAlloc(T **ptr, size_t size, unsigned int flags)
__host__ cudaError_t cudaHostGetDevicePointer(T **pDevice, void *pHost, unsigned int flags)
__host__ cudaError_t cudaLaunchCooperativeKernel(T *func, dim3 gridDim, dim3 blockDim, void
**args, size_t sharedMem=0, cudaStream_t stream=0)
Launches a device function.
__host__ cudaError_t cudaLaunchKernel(T *func, dim3 gridDim, dim3 blockDim, void **args, size_t
sharedMem=0, cudaStream_t stream=0)
Launches a device function.
__host__ cudaError_t cudaLaunchKernelEx(const cudaLaunchConfig_t *config, const cudaKernel_t
kernel, ActTypes &&… args)
Launches a CUDA function with launch-time configuration.
__host__
cudaError_t
cudaLaunchKernelEx(const
cudaLaunchConfig_t
*config,
void(*kernel)(ExpTypes…), ActTypes &&… args)
Launches a CUDA function with launch-time configuration.
__host__ cudaError_t cudaLibraryGetGlobal(T **dptr, size_t *bytes, cudaLibrary_t library, const char
*name)
Returns a global device pointer.
__host__ cudaError_t cudaLibraryGetManaged(T **dptr, size_t *bytes, cudaLibrary_t library, const
char *name)
Returns a pointer to managed memory.
__host__ cudaError_t cudaLibraryGetUnifiedFunction(T **fptr, cudaLibrary_t library, const char
*symbol)
Returns a pointer to a unified function.
6.1. C++ API Routines
17
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaError_t cudaMalloc(T **devPtr, size_t size)
__host__ cudaError_t cudaMallocAsync(T **ptr, size_t size, cudaStream_t stream)
__host__ cudaError_t cudaMallocAsync(void **ptr, size_t size, cudaMemPool_t memPool, cudaS-
tream_t stream)
Allocate from a pool.
__host__ cudaError_t cudaMallocAsync(T **ptr, size_t size, cudaMemPool_t memPool, cudaStream_t
stream)
__host__ cudaError_t cudaMallocFromPoolAsync(T **ptr, size_t size, cudaMemPool_t memPool,
cudaStream_t stream)
__host__ cudaError_t cudaMallocHost(T **ptr, size_t size, unsigned int flags=0)
__host__ cudaError_t cudaMallocHost(void **ptr, size_t size, unsigned int flags)
Allocates page-locked memory on the host.
__host__ cudaError_t cudaMallocManaged(T **devPtr, size_t size, unsigned int flags=0x01)
Allocates memory that will be automatically managed by the Unified Memory system.
__host__ cudaError_t cudaMallocPitch(T **devPtr, size_t *pitch, size_t width, size_t height)
__host__ cudaError_t cudaMemDiscardAndPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t count,
struct cudaMemLocation prefetchLocs, unsigned long long flags, cudaStream_t stream)
Performs a batch of memory discard and prefetches asynchronously.
__host__ cudaError_t cudaMemDiscardAndPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t count,
struct cudaMemLocation*prefetchLocs, size_t*prefetchLocIdxs, size_tnumPrefetchLocs, un-
signed long long flags, cudaStream_t stream)
Performs a batch of memory discard and prefetches asynchronously.
__host__ cudaError_t cudaMemPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t count, struct cu-
daMemLocation prefetchLocs, unsigned long long flags, cudaStream_t stream)
Performs a batch of memory prefetches asynchronously.
__host__ cudaError_t cudaMemPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t count, struct cu-
daMemLocation *prefetchLocs, size_t *prefetchLocIdxs, size_t numPrefetchLocs, unsigned
long long flags, cudaStream_t stream)
Performs a batch of memory prefetches asynchronously.
__host__ cudaError_t cudaMemcpyAsync(T dst, U src, const size_t size, struct cudaMemcpyAt-
tributes *attr, cudaStream_t hStream)
Performs a memory copy asynchronously.
__host__ cudaError_t cudaMemcpyBatchAsync(T *const *dsts, U *const *srcs, const size_t *sizes,
size_t count, struct cudaMemcpyAttributes *attrs, size_t *attrsIdxs, size_t numAttrs, cudaS-
tream_t hStream)
Performs a batch of memory copies asynchronously.
__host__ cudaError_t cudaMemcpyBatchAsync(T *const *dsts, U *const *srcs, const size_t *sizes,
size_t count, struct cudaMemcpyAttributes attr, cudaStream_t hStream)
Performs a batch of memory copies asynchronously.
18
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaError_t cudaMemcpyFromSymbol(void *dst, const T &symbol, size_t count, size_t off-
set=0, enum cudaMemcpyKind kind=cudaMemcpyDeviceToHost)
Copies data from the given symbol on the device.
__host__ cudaError_t cudaMemcpyFromSymbolAsync(void *dst, const T &symbol, size_t count,
size_t offset=0, enum cudaMemcpyKind kind=cudaMemcpyDeviceToHost, cudaStream_t
stream=0)
Copies data from the given symbol on the device.
__host__ cudaError_t cudaMemcpyToSymbol(const T &symbol, const void *src, size_t count, size_t
offset=0, enum cudaMemcpyKind kind=cudaMemcpyHostToDevice)
Copies data to the given symbol on the device.
__host__ cudaError_t cudaMemcpyToSymbolAsync(const T &symbol, const void *src, size_t count,
size_t offset=0, enum cudaMemcpyKind kind=cudaMemcpyHostToDevice, cudaStream_t
stream=0)
Copies data to the given symbol on the device.
__host__ cudaError_t cudaOccupancyAvailableDynamicSMemPerBlock(size_t *dynamicSmemSize, T
*func, int numBlocks, int blockSize)
Returns dynamic shared memory available per block when launching numBlocks blocks on SM.
__host__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, T func, int
blockSize, size_t dynamicSMemSize)
Returns occupancy for a device function.
__host__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks,
T func, int blockSize, size_t dynamicSMemSize, unsigned int flags)
Returns occupancy for a device function with the specified flags.
__host__ cudaError_t cudaOccupancyMaxActiveClusters(int *numClusters, T *func, const cud-
aLaunchConfig_t *config)
Given the kernel function ( func ) and launch configuration ( config ), return the maximum num-
ber of clusters that could co-exist on the target device in *numClusters .
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSize(int *minGridSize, int *block-
Size, T func, size_t dynamicSMemSize=0, int blockSizeLimit=0)
Returns grid and block size that achieves maximum potential occupancy for a device function.
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSizeVariableSMem(int *minGrid-
Size, int *blockSize, T func, UnaryFunction blockSizeToDynamicSMemSize, int blockSize-
Limit=0)
Returns grid and block size that achieves maximum potential occupancy for a device function.
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags(int
*minGridSize, int *blockSize, T func, UnaryFunction blockSizeToDynamicSMemSize, int block-
SizeLimit=0, unsigned int flags=0)
Returns grid and block size that achieves maximum potential occupancy for a device function.
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSizeWithFlags(int *minGridSize,
int *blockSize, T func, size_t dynamicSMemSize=0, int blockSizeLimit=0, unsigned int flags=0)
Returns grid and block size that achived maximum potential occupancy for a device function with
the specified flags.
__host__ cudaError_t cudaOccupancyMaxPotentialClusterSize(int *clusterSize, T *func, const cud-
aLaunchConfig_t *config)
Given the kernel function ( func ) and launch configuration ( config ), return the maximum clus-
ter size in *clusterSize .
6.1. C++ API Routines
19
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaError_t cudaStreamAttachMemAsync(cudaStream_t stream, T *devPtr, size_t
length=0, unsigned int flags=0x04)
Attach memory to a stream asynchronously.
6.1.1. Functions
template<class T>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc(void)
Returns a channel descriptor using the specified format.
Returns a channel descriptor with format f and number of bits of each component x, y, z, and
w. The cudaChannelFormatDesc is defined as:
struct cudaChannelFormatDesc {
int x, y, z, w;
enum cudaChannelFormatKind f;
};
where cudaChannelFormatKind is one of cudaChannelFormatKindSigned, cudaChannelFor-
matKindUnsigned,
cudaChannelFormatKindFloat,
cudaChannelFormatKindSignedNormal-
ized8X1,
cudaChannelFormatKindSignedNormalized8X2,
cudaChannelFormatKindSignedNor-
malized8X4,
cudaChannelFormatKindUnsignedNormalized8X1,
cudaChannelFormatKindUn-
signedNormalized8X2,
cudaChannelFormatKindUnsignedNormalized8X4,
cudaChannelFor-
matKindSignedNormalized16X1,
cudaChannelFormatKindSignedNormalized16X2,
cudaChan-
nelFormatKindSignedNormalized16X4,
cudaChannelFormatKindUnsignedNormalized16X1,
cudaChannelFormatKindUnsignedNormalized16X2,
cudaChannelFormatKindUnsignedNor-
malized16X4,
cudaChannelFormatKindUnsignedNormalized1010102
or
cudaChannelFor-
matKindNV12.
cudaChannelFormatKindUnsigned8Packed422, cudaChannelFormatKindUn-
signed8Packed444, cudaChannelFormatKindUnsigned8SemiPlanar420, cudaChannelFormatKin-
dUnsigned16SemiPlanar420,
cudaChannelFormatKindUnsigned8SemiPlanar422,
cudaChan-
nelFormatKindUnsigned16SemiPlanar422, cudaChannelFormatKindUnsigned8SemiPlanar444, cu-
daChannelFormatKindUnsigned16SemiPlanar444, cudaChannelFormatKindUnsigned8Planar420,
cudaChannelFormatKindUnsigned16Planar420,
cudaChannelFormatKindUnsigned8Planar422,
cudaChannelFormatKindUnsigned16Planar422,
cudaChannelFormatKindUnsigned8Planar444,
and cudaChannelFormatKindUnsigned16Planar444.
The format is specified by the template specialization.
The template function specializes for the following scalar types: char, signed char, unsigned
char, short, unsigned short, int, unsigned int, long, unsigned long, and float. The template
function specializes for the following vector types: char{1|2|4}, uchar{1|2|4}, short{1|2|4},
ushort{1|2|4}, int{1|2|4}, uint{1|2|4}, long{1|2|4}, ulong{1|2|4}, float{1|2|4}.
The template
function specializes for following cudaChannelFormatKind enum values: cudaChannelFor-
matKind{Uns|S}ignedNormalized{8|16}X{1|2|4},
cudaChannelFormatKindUnsignedNormal-
ized1010102 cudaChannelFormatKindNV12, cudaChannelFormatKindUnsigned8Packed422, cu-
daChannelFormatKindUnsigned8Packed444, cudaChannelFormatKindUnsigned8SemiPlanar420,
cudaChannelFormatKindUnsigned16SemiPlanar420,
cudaChannelFormatKindUn-
signed8SemiPlanar422, cudaChannelFormatKindUnsigned16SemiPlanar422, cudaChannelFor-
matKindUnsigned8SemiPlanar444,
cudaChannelFormatKindUnsigned16SemiPlanar444,
cu-
daChannelFormatKindUnsigned8Planar420,
cudaChannelFormatKindUnsigned16Planar420,
cudaChannelFormatKindUnsigned8Planar422, cudaChannelFormatKindUnsigned16Planar422, cu-
daChannelFormatKindUnsigned8Planar444, and cudaChannelFormatKindUnsigned16Planar444.
20
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Invoking the function on a type without a specialization defaults to creating a channel format of
kind cudaChannelFormatKindNone
See also:
cudaCreateChannelDesc (Low level), cudaGetChannelDesc,
Returns
Channel descriptor with format f
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<char>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<char1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<char2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<char4>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindNV12>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed4>(v
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed5>(v
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedBlockCompressed6H>(
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X1>(void
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X2>(void
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized16X4>(void
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindSignedNormalized8X4>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned16Planar420>(void)
template<>
6.1. C++ API Routines
21
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned16Planar422>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned16Planar444>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned16SemiPlanar420>(
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned16SemiPlanar422>(
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned16SemiPlanar444>(
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8Packed422>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8Packed444>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8Planar420>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8Planar422>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8Planar444>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8SemiPlanar420>(vo
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8SemiPlanar422>(vo
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsigned8SemiPlanar444>(vo
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed1>
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed1S
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed2>
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed2S
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed3>
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed3S
template<>
22
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed4>
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed5>
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed6H
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed7>
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedBlockCompressed7S
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized1010102
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X1>(vo
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X2>(vo
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized16X4>(vo
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X1>(voi
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X2>(voi
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<cudaChannelFormatKindUnsignedNormalized8X4>(voi
Warning: doxygenfunction: Unable to resolve function “cudaCreateChannelDesc< float >” with
arguments “(void)”. Candidate function could not be parsed. Parsing error is Error when parsing
function declaration. If the function has no return type: Error in declarator or parameters-and-
qualifiers Invalid C++ declaration: Expected identifier in nested name, got keyword: else [error at
15] template<> else __host__ cudaChannelFormatDesc cudaCreateChannelDesc< float > (void) -
----^ If the function has a return type: Invalid C++ declaration: Expected identifier in nested
name, got keyword: else [error at 15] template<> else __host__ cudaChannelFormatDesc cudaCre-
ateChannelDesc< float > (void) -----^
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<float1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<float2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<float4>(void)
template<>
6.1. C++ API Routines
23
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<int>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<int1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<int2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<int4>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<long>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<long1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<long2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<long4>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<short>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<short1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<short2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<short4>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<signed char>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<uchar1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<uchar2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<uchar4>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<uint1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<uint2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<uint4>(void)
template<>
24
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<ulong1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<ulong2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<ulong4>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned char>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned int>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned long>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<unsigned short>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<ushort1>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<ushort2>(void)
template<>
__host__ cudaChannelFormatDesc cudaCreateChannelDesc<ushort4>(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf1(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf2(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescHalf4(void)
__host__ cudaChannelFormatDesc cudaCreateChannelDescNV12(void)
__host__ cudaError_t cudaEventCreate(cudaEvent_t *event, unsigned int flags)
Creates an event object with the specified flags.
Creates an event object with the specified flags. Valid flags include:
▶ cudaEventDefault: Default event creation flag.
▶ cudaEventBlockingSync: Specifies that event should use blocking synchronization. A host
thread that uses cudaEventSynchronize() to wait on an event created with this flag will block
until the event actually completes.
▶ cudaEventDisableTiming: Specifies that the created event does not need to record timing
data. Events created with this flag specified and the cudaEventBlockingSync flag not spec-
ified will provide the best performance when used with cudaStreamWaitEvent() and cud-
aEventQuery().
See also:
cudaEventCreate (C API), cudaEventCreateWithFlags, cudaEventRecord, cudaEventQuery, cud-
aEventSynchronize, cudaEventDestroy, cudaEventElapsedTime, cudaStreamWaitEvent
6.1. C++ API Routines
25
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ event - - Newly created event
▶ flags - - Flags for new event
Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorLaunchFailure, cudaErrorMemoryAllo-
cation
template<class T>
__host__ cudaError_t cudaFuncGetAttributes(struct cudaFuncAttributes *attr, T *entry)
Find out attributes for a given function.
This function obtains the attributes of a function specified via entry. The parameter entry
must be a pointer to a function that executes on the device. The parameter specified by entry
must be declared as a __global__ function. The fetched attributes are placed in attr. If the
specified function does not exist, then cudaErrorInvalidDeviceFunction is returned.
Note that some function attributes such as maxThreadsPerBlock may vary based on the device
that is currently being used.
cudaLaunchKernel (C++ API), cudaFuncSetCacheConfig (C++ API), cudaFuncGetAttributes (C API),
::cudaSetDoubleForDevice, ::cudaSetDoubleForHost
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
26
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ attr - - Return pointer to function’s attributes
▶ entry - - Function to get attributes of
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction
template<class T>
__host__ cudaError_t cudaFuncGetName(const char **name, T *func)
Returns the function name for a device entry function pointer.
Returns in **name the function name associated with the symbol func . The function name is
returned as a null-terminated string. This API may return a mangled name if the function is not
declared as having C linkage. If **name is NULL, cudaErrorInvalidValue is returned. If func is not
a device entry function, cudaErrorInvalidDeviceFunction is returned.
cudaFuncGetName (C API)
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
6.1. C++ API Routines
27
CUDA Runtime API Reference Manual, Release 13.5
Parameters
▶ name - - The returned name of the function
▶ func - - The function pointer to retrieve name for
Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDeviceFunction
template<class T>
__host__ cudaError_t cudaFuncSetAttribute(T *func, enum cudaFuncAttribute attr, int value)
Set attributes for a given function.
This function sets the attributes of a function specified via entry. The parameter entry must
be a pointer to a function that executes on the device. The parameter specified by entry must
be declared as a __global__ function. The enumeration defined by attr is set to the value
defined by value. If the specified function does not exist, then cudaErrorInvalidDeviceFunction
is returned. If the specified attribute cannot be written, or if the value is incorrect, then cudaEr-
rorInvalidValue is returned.
Valid values for attr are:
▶ cudaFuncAttributeMaxDynamicSharedMemorySize - The requested maximum size in bytes
of dynamically-allocated shared memory. The sum of this value and the function attribute
::sharedSizeBytes cannot exceed the device attribute cudaDevAttrMaxSharedMemoryPer-
BlockOptin. The maximal size of requestable dynamic shared memory may differ by GPU
architecture.
▶ cudaFuncAttributePreferredSharedMemoryCarveout - On devices where the L1 cache and
shared memory use the same hardware resources, this sets the shared memory carveout
preference, in percent of the total shared memory. See cudaDevAttrMaxSharedMemoryPer-
Multiprocessor. This is only a hint, and the driver can choose a different ratio if required to
execute the function.
▶ cudaFuncAttributeRequiredClusterWidth: The required cluster width in blocks. The width,
height, and depth values must either all be 0 or all be positive. The validity of the cluster
dimensions is checked at launch time. If the value is set during compile time, it cannot be
set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
▶ cudaFuncAttributeRequiredClusterHeight: The required cluster height in blocks. The width,
height, and depth values must either all be 0 or all be positive. The validity of the cluster
dimensions is checked at launch time. If the value is set during compile time, it cannot be
set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
▶ cudaFuncAttributeRequiredClusterDepth: The required cluster depth in blocks. The width,
height, and depth values must either all be 0 or all be positive. The validity of the cluster
dimensions is checked at launch time. If the value is set during compile time, it cannot be
set at runtime. Setting it at runtime will return cudaErrorNotPermitted.
▶ cudaFuncAttributeNonPortableClusterSizeAllowed: Indicates whether the function can be
launched with non-portable cluster size. 1 is allowed, 0 is disallowed.
▶ cudaFuncAttributeClusterSchedulingPolicyPreference: The block scheduling policy of a func-
tion. The value type is cudaClusterSchedulingPolicy.
cudaLaunchKernel (C++ API), cudaFuncSetCacheConfig (C++ API), cudaFuncGetAttributes (C API),
::cudaSetDoubleForDevice, ::cudaSetDoubleForHost
28
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ entry - - Function to get attributes of
▶ attr - - Attribute to set
▶ value - - Value to set
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidValue
template<class T>
__host__ cudaError_t cudaFuncSetCacheConfig(T *func, enum cudaFuncCache cacheConfig)
Sets the preferred cache configuration for a device function.
On devices where the L1 cache and shared memory use the same hardware resources, this sets
through cacheConfig the preferred cache configuration for the function specified via func.
This is only a preference. The runtime will use the requested configuration if possible, but it is
free to choose a different configuration if required to execute func.
func must be a pointer to a function that executes on the device. The parameter specified by
func must be declared as a __global__ function. If the specified function does not exist, then
cudaErrorInvalidDeviceFunction is returned.
This setting does nothing on devices where the size of the L1 cache and shared memory are
fixed.
Launching a kernel with a different preference than the most recent preference setting may
insert a device-side synchronization point.
The supported cache configurations are:
6.1. C++ API Routines
29
CUDA Runtime API Reference Manual, Release 13.5
▶ cudaFuncCachePreferNone: no preference for shared memory or L1 (default)
▶ cudaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache
▶ cudaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory
cudaLaunchKernel (C++ API), cudaFuncSetCacheConfig (C API), cudaFuncGetAttributes (C++
API), ::cudaSetDoubleForDevice, ::cudaSetDoubleForHost, ::cudaThreadGetCacheConfig, ::cud-
aThreadSetCacheConfig
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ func - - device function pointer
▶ cacheConfig - - Requested cache configuration
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction
template<class T>
__host__ cudaError_t cudaFuncSetSharedMemConfig(T *func, enum cudaSharedMemConfig
config)
template<class T>
__host__ cudaError_t cudaGetKernel(cudaKernel_t *kernelPtr, T *func)
Get pointer to device kernel that matches entry function entryFuncAddr.
Returns in kernelPtr the device kernel corresponding to the entry function entryFuncAddr.
See also:
cudaGetKernel (C API)
Parameters
▶ kernelPtr - - Returns the device kernel
▶ entryFuncAddr - - Address of device entry function to search kernel for
Returns
cudaSuccess
template<class T>
30
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaError_t cudaGetSymbolAddress(void **devPtr, const T &symbol)
Finds the address associated with a CUDA symbol.
Returns in *devPtr the address of symbol symbol on the device. symbol can either be a vari-
able that resides in global or constant memory space. If symbol cannot be found, or if symbol
is not declared in the global or constant memory space, *devPtr is unchanged and the error
cudaErrorInvalidSymbol is returned.
See also:
cudaGetSymbolAddress (C API), cudaGetSymbolSize (C++ API)
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ devPtr - - Return device pointer associated with symbol
▶ symbol - - Device symbol reference
Returns
cudaSuccess, cudaErrorInvalidSymbol, cudaErrorNoKernelImageForDevice
template<class T>
__host__ cudaError_t cudaGetSymbolSize(size_t *size, const T &symbol)
Finds the size of the object associated with a CUDA symbol.
Returns in *size the size of symbol symbol. symbol must be a variable that resides in global
or constant memory space. If symbol cannot be found, or if symbol is not declared in global or
constant memory space, *size is unchanged and the error cudaErrorInvalidSymbol is returned.
See also:
cudaGetSymbolAddress (C++ API), cudaGetSymbolSize (C API)
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
6.1. C++ API Routines
31
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ size - - Size of object associated with symbol
▶ symbol - - Device symbol reference
Returns
cudaSuccess, cudaErrorInvalidSymbol, cudaErrorNoKernelImageForDevice
template<class T>
__host__ cudaError_t cudaGraphAddMemcpyNodeFromSymbol(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph, const
cudaGraphNode_t *pDependencies,
size_t numDependencies, void *dst,
const T &symbol, size_t count, size_t
offset, enum cudaMemcpyKind kind)
Creates a memcpy node to copy from a symbol on the device and adds it to a graph.
Creates a new memcpy node to copy from symbol and adds it to graph with numDependencies
dependencies specified via pDependencies. It is possible for numDependencies to be 0, in
which case the node will be placed at the root of the graph. pDependencies may not have any
duplicate entries. A handle to the new node will be returned in pGraphNode.
When the graph is launched, the node will copy 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. The
memory areas may not overlap. symbol is a variable that resides in global or constant memory
space. kind can be either cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, or cudaMem-
cpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is
inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that
support unified virtual addressing.
Memcpy nodes have some additional restrictions with regards to managed memory, if the system
contains at least one device which has a zero value for the device attribute cudaDevAttrConcur-
rentManagedAccess.
See also:
cudaMemcpyFromSymbol, cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeToSymbol,
cudaGraphMemcpyNodeGetParams, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyN-
odeSetParamsFromSymbol, cudaGraphMemcpyNodeSetParamsToSymbol, cudaGraphCreate, cud-
aGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAdd-
KernelNode, cudaGraphAddHostNode, cudaGraphAddMemsetNode
Note: Graph objects are not threadsafe. More here.
Note: Note that this function may also return error codes from previous, asynchronous launches.
32
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ pGraphNode - - Returns newly created node
▶ graph - - Graph to which to add the node
▶ pDependencies - - Dependencies of the node
▶ numDependencies - - Number of dependencies
▶ dst - - Destination memory address
▶ symbol - - Device symbol address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
Returns
cudaSuccess, cudaErrorInvalidValue
template<class T>
__host__ cudaError_t cudaGraphAddMemcpyNodeToSymbol(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph, const
cudaGraphNode_t *pDependencies,
size_t numDependencies, const T
&symbol, const void *src, size_t count,
size_t offset, enum cudaMemcpyKind
kind)
Creates a memcpy node to copy to a symbol on the device and adds it to a graph.
Creates a new memcpy node to copy to symbol and adds it to graph with numDependencies
dependencies specified via pDependencies. It is possible for numDependencies to be 0, in
which case the node will be placed at the root of the graph. pDependencies may not have any
duplicate entries. A handle to the new node will be returned in pGraphNode.
When the graph is launched, the node will copy 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. The
memory areas may not overlap. symbol is a variable that resides in global or constant memory
space. kind can be either cudaMemcpyHostToDevice, cudaMemcpyDeviceToDevice, or cudaMem-
cpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is
inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that
support unified virtual addressing.
Memcpy nodes have some additional restrictions with regards to managed memory, if the system
contains at least one device which has a zero value for the device attribute cudaDevAttrConcur-
rentManagedAccess.
6.1. C++ API Routines
33
CUDA Runtime API Reference Manual, Release 13.5
See also:
cudaMemcpyToSymbol, cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeFromSymbol,
cudaGraphMemcpyNodeGetParams, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyN-
odeSetParamsToSymbol, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphCreate, cud-
aGraphDestroyNode, cudaGraphAddChildGraphNode, cudaGraphAddEmptyNode, cudaGraphAdd-
KernelNode, cudaGraphAddHostNode, cudaGraphAddMemsetNode
Note: Graph objects are not threadsafe. More here.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ pGraphNode - - Returns newly created node
▶ graph - - Graph to which to add the node
▶ pDependencies - - Dependencies of the node
▶ numDependencies - - Number of dependencies
▶ symbol - - Device symbol address
▶ src - - Source memory address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
Returns
cudaSuccess, cudaErrorInvalidValue
template<class T>
__host__ cudaError_t cudaGraphExecMemcpyNodeSetParamsFromSymbol(cudaGraphExec_t
hGraphExec,
cudaGraphNode_t node,
void *dst, const T
&symbol, size_t count,
size_t offset, enum
cudaMemcpyKind kind)
34
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Sets the parameters for a memcpy node in the given graphExec to copy from a symbol on the
device.
Updates the work represented by node in hGraphExec as though node had contained the
given params at instantiation. node must remain in the graph which was used to instantiate
hGraphExec. Changed edges to and from node are ignored.
symbol and dst must be allocated from the same contexts as the original source and desti-
nation memory. The instantiation-time memory operands must be 1-dimensional. Zero-length
operations are not supported.
The modifications only affect future launches of hGraphExec. Already enqueued or running
launches of hGraphExec are not affected by this call. node is also not modified by this call.
Returns cudaErrorInvalidValue if the memory operands’ mappings changed or the original mem-
ory operands are multidimensional.
See also:
cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeFromSymbol, cudaGraphMemcpyNode-
SetParams, cudaGraphMemcpyNodeSetParamsFromSymbol, cudaGraphInstantiate, cudaGraphEx-
ecMemcpyNodeSetParams, cudaGraphExecMemcpyNodeSetParamsToSymbol, cudaGraphExecK-
ernelNodeSetParams,
cudaGraphExecMemsetNodeSetParams,
cudaGraphExecHostNodeSet-
Params
Note: Graph objects are not threadsafe. More here.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ hGraphExec - - The executable graph in which to set the specified node
▶ node - - Memcpy node from the graph which was used to instantiate graphExec
▶ dst - - Destination memory address
▶ symbol - - Device symbol address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
6.1. C++ API Routines
35
CUDA Runtime API Reference Manual, Release 13.5
Returns
cudaSuccess, cudaErrorInvalidValue
template<class T>
__host__ cudaError_t cudaGraphExecMemcpyNodeSetParamsToSymbol(cudaGraphExec_t
hGraphExec,
cudaGraphNode_t node,
const T &symbol, const
void *src, size_t count,
size_t offset, enum
cudaMemcpyKind kind)
Sets the parameters for a memcpy node in the given graphExec to copy to a symbol on the device.
Updates the work represented by node in hGraphExec as though node had contained the
given params at instantiation. node must remain in the graph which was used to instantiate
hGraphExec. Changed edges to and from node are ignored.
src and symbol must be allocated from the same contexts as the original source and desti-
nation memory. The instantiation-time memory operands must be 1-dimensional. Zero-length
operations are not supported.
The modifications only affect future launches of hGraphExec. Already enqueued or running
launches of hGraphExec are not affected by this call. node is also not modified by this call.
Returns cudaErrorInvalidValue if the memory operands’ mappings changed or the original mem-
ory operands are multidimensional.
See also:
cudaGraphAddMemcpyNode, cudaGraphAddMemcpyNodeToSymbol, cudaGraphMemcpyNode-
SetParams, cudaGraphMemcpyNodeSetParamsToSymbol, cudaGraphInstantiate, cudaGraphEx-
ecMemcpyNodeSetParams, cudaGraphExecMemcpyNodeSetParamsFromSymbol, cudaGraphEx-
ecKernelNodeSetParams, cudaGraphExecMemsetNodeSetParams, cudaGraphExecHostNodeSet-
Params
Note: Graph objects are not threadsafe. More here.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ hGraphExec - - The executable graph in which to set the specified node
36
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
▶ node - - Memcpy node from the graph which was used to instantiate graphExec
▶ symbol - - Device symbol address
▶ src - - Source memory address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
Returns
cudaSuccess, cudaErrorInvalidValue
__host__ cudaError_t cudaGraphExecUpdate(cudaGraphExec_t hGraphExec, cudaGraph_t hGraph,
cudaGraphNode_t *hErrorNode_out, enum
cudaGraphExecUpdateResult *updateResult_out)
__host__ cudaError_t cudaGraphInstantiate(cudaGraphExec_t *pGraphExec, cudaGraph_t graph,
cudaGraphNode_t *pErrorNode, char *pLogBuffer,
size_t bufferSize)
Creates an executable graph from a graph.
Instantiates graph as an executable graph. The graph is validated for any structural constraints
or intra-node constraints which were not previously validated. If instantiation is successful, a
handle to the instantiated graph is returned in pGraphExec.
If there are any errors, diagnostic information may be returned in pErrorNode and pLogBuffer.
This is the primary way to inspect instantiation errors. The output will be null terminated unless
the diagnostics overflow the buffer. In this case, they will be truncated, and the last byte can be
inspected to determine if truncation occurred.
See also:
cudaGraphInstantiateWithFlags, cudaGraphCreate, cudaGraphUpload, cudaGraphLaunch, cuda-
GraphExecDestroy
Note: Graph objects are not threadsafe. More here.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
6.1. C++ API Routines
37
CUDA Runtime API Reference Manual, Release 13.5
▶ pGraphExec - - Returns instantiated graph
▶ graph - - Graph to instantiate
▶ pErrorNode - - In case of an instantiation error, this may be modified to indicate
a node contributing to the error
▶ pLogBuffer - - A character buffer to store diagnostic messages
▶ bufferSize - - Size of the log buffer in bytes
Returns
cudaSuccess, cudaErrorInvalidValue
template<class T>
__host__ cudaError_t cudaGraphMemcpyNodeSetParamsFromSymbol(cudaGraphNode_t node, void
*dst, const T &symbol, size_t
count, size_t offset, enum
cudaMemcpyKind kind)
Sets a memcpy node’s parameters to copy from a symbol on the device.
Sets the parameters of memcpy node node to the copy described by the provided parameters.
When the graph is launched, the node will copy 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. The
memory areas may not overlap. symbol is a variable that resides in global or constant memory
space. kind can be either cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice, or cudaMem-
cpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is
inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that
support unified virtual addressing.
See also:
cudaMemcpyFromSymbol,
cudaGraphMemcpyNodeSetParams,
cudaGraphMemcpyNodeSet-
ParamsToSymbol, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams
Note: Graph objects are not threadsafe. More here.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ node - - Node to set the parameters for
38
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
▶ dst - - Destination memory address
▶ symbol - - Device symbol address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
Returns
cudaSuccess, cudaErrorInvalidValue
template<class T>
__host__ cudaError_t cudaGraphMemcpyNodeSetParamsToSymbol(cudaGraphNode_t node, const
T &symbol, const void *src,
size_t count, size_t offset,
enum cudaMemcpyKind kind)
Sets a memcpy node’s parameters to copy to a symbol on the device.
Sets the parameters of memcpy node node to the copy described by the provided parameters.
When the graph is launched, the node will copy 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. The
memory areas may not overlap. symbol is a variable that resides in global or constant memory
space. kind can be either cudaMemcpyHostToDevice, cudaMemcpyDeviceToDevice, or cudaMem-
cpyDefault. Passing cudaMemcpyDefault is recommended, in which case the type of transfer is
inferred from the pointer values. However, cudaMemcpyDefault is only allowed on systems that
support unified virtual addressing.
See also:
cudaMemcpyToSymbol, cudaGraphMemcpyNodeSetParams, cudaGraphMemcpyNodeSetParams-
FromSymbol, cudaGraphAddMemcpyNode, cudaGraphMemcpyNodeGetParams
Note: Graph objects are not threadsafe. More here.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ node - - Node to set the parameters for
▶ symbol - - Device symbol address
6.1. C++ API Routines
39
CUDA Runtime API Reference Manual, Release 13.5
▶ src - - Source memory address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
Returns
cudaSuccess, cudaErrorInvalidValue
template<class T>
__host__ cudaError_t cudaHostAlloc(T **ptr, size_t size, unsigned int flags)
template<class T>
__host__ cudaError_t cudaHostGetDevicePointer(T **pDevice, void *pHost, unsigned int flags)
template<class T>
__host__ cudaError_t cudaLaunchCooperativeKernel(T *func, dim3 gridDim, dim3 blockDim, void
**args, size_t sharedMem = 0,
cudaStream_t stream = 0)
Launches a device function.
The function invokes kernel func on gridDim (gridDim.xgridDim.ygridDim.z) grid of blocks.
Each block contains blockDim (blockDim.xblockDim.yblockDim.z) threads.
The device on which this kernel is invoked must have a non-zero value for the device attribute
cudaDevAttrCooperativeLaunch.
The total number of blocks launched cannot exceed the maximum number of blocks per multi-
processor as returned by cudaOccupancyMaxActiveBlocksPerMultiprocessor (or cudaOccupancy-
MaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors as specified
by the device attribute cudaDevAttrMultiProcessorCount.
The kernel cannot make use of CUDA dynamic parallelism.
If the kernel has N parameters the args should point to array of N pointers. Each pointer, from
args[0] to args[N - 1], point to the region of memory from which the actual parameter will
be copied.
sharedMem sets the amount of dynamic shared memory that will be available to each thread
block.
stream specifies a stream the invocation is associated to.
cudaLaunchCooperativeKernel (C API)
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: This function exhibits asynchronous behavior for most use cases.
Note: This function uses standard default stream semantics.
40
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ func - - Device function symbol
▶ gridDim - - Grid dimentions
▶ blockDim - - Block dimentions
▶ args - - Arguments
▶ sharedMem - - Shared memory (defaults to 0)
▶ stream - - Stream identifier (defaults to NULL)
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidConfiguration, cu-
daErrorLaunchFailure, cudaErrorLaunchTimeout, cudaErrorLaunchOutOfResources,
cudaErrorSharedObjectInitFailed
template<class T>
__host__ cudaError_t cudaLaunchKernel(T *func, dim3 gridDim, dim3 blockDim, void **args, size_t
sharedMem = 0, cudaStream_t stream = 0)
Launches a device function.
The function invokes kernel func on gridDim (gridDim.xgridDim.ygridDim.z) grid of blocks.
Each block contains blockDim (blockDim.xblockDim.yblockDim.z) threads.
If the kernel has N parameters the args should point to array of N pointers. Each pointer, from
args[0] to args[N - 1], point to the region of memory from which the actual parameter will
be copied.
sharedMem sets the amount of dynamic shared memory that will be available to each thread
block.
stream specifies a stream the invocation is associated to.
6.1. C++ API Routines
41
CUDA Runtime API Reference Manual, Release 13.5
cudaLaunchKernel (C API)
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: This function exhibits asynchronous behavior for most use cases.
Note: This function uses standard default stream semantics.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ func - - Device function symbol
▶ gridDim - - Grid dimentions
▶ blockDim - - Block dimentions
▶ args - - Arguments
▶ sharedMem - - Shared memory (defaults to 0)
▶ stream - - Stream identifier (defaults to NULL)
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidConfiguration, cud-
aErrorLaunchFailure, cudaErrorLaunchTimeout, cudaErrorLaunchOutOfResources,
cudaErrorSharedObjectInitFailed, cudaErrorInvalidPtx, cudaErrorUnsupportedP-
txVersion,
cudaErrorNoKernelImageForDevice,
cudaErrorJitCompilerNotFound,
cudaErrorJitCompilationDisabled
template<typename ...ActTypes>
42
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaError_t cudaLaunchKernelEx(const cudaLaunchConfig_t *config, const cudaKernel_t
kernel, ActTypes&&... args)
Launches a CUDA function with launch-time configuration.
Invokes the kernel kernel on config->gridDim (config->gridDim.xconfig->gridDim.
yconfig->gridDim.z) grid of blocks.
Each block contains config->blockDim
(config->blockDim.xconfig->blockDim.yconfig->blockDim.z) threads.
config->dynamicSmemBytes sets the amount of dynamic shared memory that will be available
to each thread block.
config->stream specifies a stream the invocation is associated to.
Configuration beyond grid and block dimensions, dynamic shared memory size, and stream can
be provided with the following two fields of config:
config->attrs is an array of config->numAttrs contiguous cudaLaunchAttribute elements.
The value of this pointer is not considered if config->numAttrs is zero. However, in that case,
it is recommended to set the pointer to NULL. config->numAttrs is the number of attributes
populating the first config->numAttrs positions of the config->attrs array.
The kernel arguments should be passed as arguments to this function via the args parameter
pack.
The C API version of this function, cudaLaunchKernelExC, is also available for pre-C++11 com-
pilers and for use cases where the ability to pass kernel parameters via void* array is preferable.
See also:
cudaLaunchKernelEx (C API), ::cuLaunchKernelEx
Note: This function uses standard default stream semantics.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ config - - Launch configuration
▶ func - - Kernel to launch
▶ args - - Parameter pack of kernel parameters
6.1. C++ API Routines
43
CUDA Runtime API Reference Manual, Release 13.5
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidConfiguration, cud-
aErrorLaunchFailure, cudaErrorLaunchTimeout, cudaErrorLaunchOutOfResources,
cudaErrorSharedObjectInitFailed, cudaErrorInvalidPtx, cudaErrorUnsupportedP-
txVersion,
cudaErrorNoKernelImageForDevice,
cudaErrorJitCompilerNotFound,
cudaErrorJitCompilationDisabled
template<typename ...ExpTypes, typename ...ActTypes>
__host__ cudaError_t cudaLaunchKernelEx(const cudaLaunchConfig_t *config, void
(*kernel)(ExpTypes...), ActTypes&&... args)
Launches a CUDA function with launch-time configuration.
Invokes the kernel kernel on config->gridDim (config->gridDim.xconfig->gridDim.
yconfig->gridDim.z) grid of blocks.
Each block contains config->blockDim
(config->blockDim.xconfig->blockDim.yconfig->blockDim.z) threads.
config->dynamicSmemBytes sets the amount of dynamic shared memory that will be available
to each thread block.
config->stream specifies a stream the invocation is associated to.
Configuration beyond grid and block dimensions, dynamic shared memory size, and stream can
be provided with the following two fields of config:
config->attrs is an array of config->numAttrs contiguous cudaLaunchAttribute elements.
The value of this pointer is not considered if config->numAttrs is zero. However, in that case,
it is recommended to set the pointer to NULL. config->numAttrs is the number of attributes
populating the first config->numAttrs positions of the config->attrs array.
The kernel arguments should be passed as arguments to this function via the args parameter
pack.
The C API version of this function, cudaLaunchKernelExC, is also available for pre-C++11 com-
pilers and for use cases where the ability to pass kernel parameters via void* array is preferable.
See also:
cudaLaunchKernelEx (C API), ::cuLaunchKernelEx
Note: This function uses standard default stream semantics.
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
44
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ config - - Launch configuration
▶ kernel - - Kernel to launch
▶ args - - Parameter pack of kernel parameters
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidConfiguration, cud-
aErrorLaunchFailure, cudaErrorLaunchTimeout, cudaErrorLaunchOutOfResources,
cudaErrorSharedObjectInitFailed, cudaErrorInvalidPtx, cudaErrorUnsupportedP-
txVersion,
cudaErrorNoKernelImageForDevice,
cudaErrorJitCompilerNotFound,
cudaErrorJitCompilationDisabled
template<class T>
__host__ cudaError_t cudaLibraryGetGlobal(T **dptr, size_t *bytes, cudaLibrary_t library, const
char *name)
Returns a global device pointer.
Returns in *dptr and *bytes the base pointer and size of the global with name name for the
requested library library and the current device. If no global for the requested name name
exists, the call returns cudaErrorSymbolNotFound. One of the parameters dptr or bytes (not
both) can be NULL in which case it is ignored.
See also:
cudaLibraryLoadData, cudaLibraryLoadFromFile, cudaLibraryUnload, cudaLibraryGetManaged
Parameters
▶ dptr - - Returned global device pointer for the requested library
▶ bytes - - Returned global size in bytes
▶ library - - Library to retrieve global from
▶ name - - Name of global to retrieve
Returns
cudaSuccess, cudaErrorCudartUnloading, cudaErrorInitializationError, cudaError-
InvalidValue, cudaErrorInvalidResourceHandle, cudaErrorSymbolNotFound cudaEr-
rorDeviceUninitialized, cudaErrorContextIsDestroyed
6.1. C++ API Routines
45
CUDA Runtime API Reference Manual, Release 13.5
template<class T>
__host__ cudaError_t cudaLibraryGetManaged(T **dptr, size_t *bytes, cudaLibrary_t library, const
char *name)
Returns a pointer to managed memory.
Returns in *dptr and *bytes the base pointer and size of the managed memory with name name
for the requested library library. If no managed memory with the requested name name exists,
the call returns cudaErrorSymbolNotFound. One of the parameters dptr or bytes (not both) can
be NULL in which case it is ignored. Note that managed memory for library library is shared
across devices and is registered when the library is loaded.
See also:
cudaLibraryLoadData, cudaLibraryLoadFromFile, cudaLibraryUnload, cudaLibraryGetGlobal
Parameters
▶ dptr - - Returned pointer to the managed memory
▶ bytes - - Returned memory size in bytes
▶ library - - Library to retrieve managed memory from
▶ name - - Name of managed memory to retrieve
Returns
cudaSuccess, cudaErrorCudartUnloading, cudaErrorInitializationError, cudaErrorIn-
validValue, cudaErrorInvalidResourceHandle, cudaErrorSymbolNotFound
template<class T>
__host__ cudaError_t cudaLibraryGetUnifiedFunction(T **fptr, cudaLibrary_t library, const char
*symbol)
Returns a pointer to a unified function.
Returns in *fptr the function pointer to a unified function denoted by symbol. If no unified
function with name symbol exists, the call returns cudaErrorSymbolNotFound. If there is no de-
vice with attribute cudaDeviceProp::unifiedFunctionPointers present in the system, the call may
return cudaErrorSymbolNotFound.
See also:
cudaLibraryLoadData, cudaLibraryLoadFromFile, cudaLibraryUnload
Parameters
▶ fptr - - Returned pointer to a unified function
▶ library - - Library to retrieve function pointer memory from
▶ symbol - - Name of function pointer to retrieve
Returns
cudaSuccess, cudaErrorCudartUnloading, cudaErrorInitializationError, cudaErrorIn-
validValue, cudaErrorInvalidResourceHandle, cudaErrorSymbolNotFound
template<class T>
46
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaError_t cudaMalloc(T **devPtr, size_t size)
template<class T>
__host__ cudaError_t cudaMallocAsync(T **ptr, size_t size, cudaStream_t stream)
__host__ cudaError_t cudaMallocAsync(void **ptr, size_t size, cudaMemPool_t memPool,
cudaStream_t stream)
Allocate from a pool.
This is an alternate spelling for cudaMallocFromPoolAsync made available through function over-
loading.
See also:
cudaMallocFromPoolAsync, cudaMallocAsync (C API)
template<class T>
__host__ cudaError_t cudaMallocAsync(T **ptr, size_t size, cudaMemPool_t memPool,
cudaStream_t stream)
template<class T>
__host__ cudaError_t cudaMallocFromPoolAsync(T **ptr, size_t size, cudaMemPool_t memPool,
cudaStream_t stream)
template<class T>
__host__ cudaError_t cudaMallocHost(T **ptr, size_t size, unsigned int flags = 0)
__host__ cudaError_t cudaMallocHost(void **ptr, size_t size, unsigned int flags)
Allocates page-locked memory on the host.
Allocates size bytes of host memory that is page-locked and accessible to the device. The driver
tracks the virtual memory ranges allocated with this function and automatically accelerates calls
to functions such as cudaMemcpy(). Since the memory can be accessed directly by the device, it
can be read or written with much higher bandwidth than pageable memory obtained with func-
tions such as ::malloc(). Allocating excessive amounts of pinned memory may degrade system
performance, since it reduces the amount of memory available to the system for paging. As a
result, this function is best used sparingly to allocate staging areas for data exchange between
host and device.
The flags parameter enables different options to be specified that affect the allocation, as fol-
lows.
▶ cudaHostAllocDefault: This flag’s value is defined to be 0.
▶ cudaHostAllocPortable: The memory returned by this call will be considered as pinned mem-
ory by all CUDA contexts, not just the one that performed the allocation.
▶ cudaHostAllocMapped: Maps the allocation into the CUDA address space. The device pointer
to the memory may be obtained by calling cudaHostGetDevicePointer().
▶ cudaHostAllocWriteCombined: Allocates the memory as write-combined (WC). WC memory
can be transferred across the PCI Express bus more quickly on some system configurations,
but cannot be read efficiently by most CPUs. WC memory is a good option for buffers that
will be written by the CPU and read by the device via mapped pinned memory or host->device
transfers.
All of these flags are orthogonal to one another: a developer may allocate memory that is
portable, mapped and/or write-combined with no restrictions.
6.1. C++ API Routines
47
CUDA Runtime API Reference Manual, Release 13.5
cudaSetDeviceFlags() must have been called with the cudaDeviceMapHost flag in order for the
cudaHostAllocMapped flag to have any effect.
The cudaHostAllocMapped flag may be specified on CUDA contexts for devices that do not sup-
port mapped pinned memory. The failure is deferred to cudaHostGetDevicePointer() because
the memory may be mapped into other CUDA contexts via the cudaHostAllocPortable flag.
Memory allocated by this function must be freed with cudaFreeHost().
See also:
cudaSetDeviceFlags, cudaMallocHost (C API), cudaFreeHost, cudaHostAlloc
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ ptr - - Device pointer to allocated memory
▶ size - - Requested allocation size in bytes
▶ flags - - Requested properties of allocated memory
Returns
cudaSuccess, cudaErrorMemoryAllocation
template<class T>
__host__ cudaError_t cudaMallocManaged(T **devPtr, size_t size, unsigned int flags = 0x01)
Allocates memory that will be automatically managed by the Unified Memory system.
Allocates size bytes of managed memory on the device and returns in *devPtr a pointer to
the allocated memory. If the device doesn’t support allocating managed memory, cudaErrorNot-
Supported is returned. Support for managed memory can be queried using the device attribute
cudaDevAttrManagedMemory. The allocated memory is suitably aligned for any kind of variable.
The memory is not cleared. If size is 0, cudaMallocManaged returns cudaErrorInvalidValue. The
pointer is valid on the CPU and on all GPUs in the system that support managed memory. All
accesses to this pointer must obey the Unified Memory programming model.
flags specifies the default stream association for this allocation. flags must be one of cu-
daMemAttachGlobal or cudaMemAttachHost. The default value for flags is cudaMemAttach-
Global. If cudaMemAttachGlobal is specified, then this memory is accessible from any stream on
any device. If cudaMemAttachHost is specified, then the allocation should not be accessed from
devices that have a zero value for the device attribute cudaDevAttrConcurrentManagedAccess;
an explicit call to cudaStreamAttachMemAsync will be required to enable access on such devices.
48
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
If the association is later changed via cudaStreamAttachMemAsync to a single stream, the default
association, as specifed during cudaMallocManaged, is restored when that stream is destroyed.
For managed variables, the default association is always cudaMemAttachGlobal. Note that de-
stroying a stream is an asynchronous operation, and as a result, the change to default association
won’t happen until all work in the stream has completed.
Memory allocated with cudaMallocManaged should be released with cudaFree.
Device memory oversubscription is possible for GPUs that have a non-zero value for the device at-
tribute cudaDevAttrConcurrentManagedAccess. Managed memory on such GPUs may be evicted
from device memory to host memory at any time by the Unified Memory driver in order to make
room for other allocations.
In a multi-GPU system where all GPUs have a non-zero value for the device attribute cudaDevAt-
trConcurrentManagedAccess, managed memory may not be populated when this API returns and
instead may be populated on access. In such systems, managed memory can migrate to any pro-
cessor’s memory at any time. The Unified Memory driver will employ heuristics to maintain data
locality and prevent excessive page faults to the extent possible. The application can also guide
the driver about memory usage patterns via cudaMemAdvise. The application can also explicitly
migrate memory to a desired processor’s memory via cudaMemPrefetchAsync.
In a multi-GPU system where all of the GPUs have a zero value for the device attribute cudaDe-
vAttrConcurrentManagedAccess and all the GPUs have peer-to-peer support with each other,
the physical storage for managed memory is created on the GPU which is active at the time cu-
daMallocManaged is called. All other GPUs will reference the data at reduced bandwidth via peer
mappings over the PCIe bus. The Unified Memory driver does not migrate memory among such
GPUs.
In a multi-GPU system where not all GPUs have peer-to-peer support with each other and where
the value of the device attribute cudaDevAttrConcurrentManagedAccess is zero for at least one of
those GPUs, the location chosen for physical storage of managed memory is system-dependent.
▶ On Linux, the location chosen will be device memory as long as the current set of active
contexts are on devices that either have peer-to-peer support with each other or have a
non-zero value for the device attribute cudaDevAttrConcurrentManagedAccess. If there is
an active context on a GPU that does not have a non-zero value for that device attribute
and it does not have peer-to-peer support with the other devices that have active contexts
on them, then the location for physical storage will be ‘zero-copy’ or host memory. Note
that this means that managed memory that is located in device memory is migrated to host
memory if a new context is created on a GPU that doesn’t have a non-zero value for the
device attribute and does not support peer-to-peer with at least one of the other devices
that has an active context. This in turn implies that context creation may fail if there is
insufficient host memory to migrate all managed allocations.
▶ On Windows, the physical storage is always created in ‘zero-copy’ or host memory. All GPUs
will reference the data at reduced bandwidth over the PCIe bus. In these circumstances,
use of the environment variable CUDA_VISIBLE_DEVICES is recommended to restrict CUDA
to only use those GPUs that have peer-to-peer support. Alternatively, users can also set
CUDA_MANAGED_FORCE_DEVICE_ALLOC to a non-zero value to force the driver to always
use device memory for physical storage. When this environment variable is set to a non-zero
value, all devices used in that process that support managed memory have to be peer-to-
peer compatible with each other. The error cudaErrorInvalidDevice will be returned if a device
that supports managed memory is used and it is not peer-to-peer compatible with any of
the other managed memory supporting devices that were previously used in that process,
even if cudaDeviceReset has been called on those devices. These environment variables are
described in the CUDA programming guide under the “CUDA environment variables” section.
▶ On ARM, managed memory is not available on discrete gpu with Drive PX-2.
6.1. C++ API Routines
49
CUDA Runtime API Reference Manual, Release 13.5
See also:
cudaMallocPitch, cudaFree, cudaMallocArray, cudaFreeArray, cudaMalloc3D, cudaMalloc3DArray,
cudaMallocHost (C API), cudaFreeHost, cudaHostAlloc, cudaDeviceGetAttribute, cudaStreamAt-
tachMemAsync
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ flags - Memory can be accessed by any stream on any device
▶ devPtr - - Pointer to allocated device memory
▶ size - - Requested allocation size in bytes
▶ flags - - Must be either cudaMemAttachGlobal or cudaMemAttachHost (de-
faults to cudaMemAttachGlobal)
Returns
cudaSuccess, cudaErrorMemoryAllocation, cudaErrorNotSupported, cudaErrorIn-
validValue
template<class T>
__host__ cudaError_t cudaMallocPitch(T **devPtr, size_t *pitch, size_t width, size_t height)
template<typename T>
__host__ cudaError_t cudaMemDiscardAndPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t
count, struct cudaMemLocation
prefetchLocs, unsigned long
long flags, cudaStream_t
stream)
Performs a batch of memory discard and prefetches asynchronously.
This is an alternate spelling for cudaMemDiscardAndPrefetchBatchAsync made available
through function overloading.
The cudaMemLocation specified by prefetchLocs are applicable for all the operations in the
batch.
See also:
cudaMemDiscardAndPrefetchBatchAsync
template<typename T>
50
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ cudaError_t cudaMemDiscardAndPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t
count, struct cudaMemLocation
*prefetchLocs, size_t
*prefetchLocIdxs, size_t
numPrefetchLocs, unsigned long
long flags, cudaStream_t
stream)
Performs a batch of memory discard and prefetches asynchronously.
This is an alternate spelling for cudaMemDiscardAndPrefetchBatchAsync made available
through function overloading.
See also:
cudaMemDiscardAndPrefetchBatchAsync
template<typename T>
__host__ cudaError_t cudaMemPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t count, struct
cudaMemLocation prefetchLocs, unsigned
long long flags, cudaStream_t stream)
Performs a batch of memory prefetches asynchronously.
This is an alternate spelling for cudaMemPrefetchBatchAsync made available through function
overloading.
The cudaMemLocation specified by prefetchLocs are applicable for all the prefetches specified
in the batch.
See also:
cudaMemPrefetchBatchAsync
template<typename T>
__host__ cudaError_t cudaMemPrefetchBatchAsync(T **dptrs, size_t *sizes, size_t count, struct
cudaMemLocation *prefetchLocs, size_t
*prefetchLocIdxs, size_t numPrefetchLocs,
unsigned long long flags, cudaStream_t
stream)
Performs a batch of memory prefetches asynchronously.
This is an alternate spelling for cudaMemPrefetchBatchAsync made available through function
overloading.
See also:
cudaMemPrefetchBatchAsync
template<typename T, typename U>
__host__ cudaError_t cudaMemcpyAsync(T dst, U src, const size_t size, struct
cudaMemcpyAttributes *attr, cudaStream_t hStream)
Performs a memory copy asynchronously.
Allows specifying attributes for the copy.
This is an alternate spelling for cudaMemcpyAsync made available through function overloading.
6.1. C++ API Routines
51
CUDA Runtime API Reference Manual, Release 13.5
See also:
cudaMemcpyAsync cudaMemcpyBatchAsync cudaMemcpyWithAttributesAsync
template<typename T, typename U>
__host__ cudaError_t cudaMemcpyBatchAsync(T *const *dsts, U *const *srcs, const size_t *sizes,
size_t count, struct cudaMemcpyAttributes *attrs,
size_t *attrsIdxs, size_t numAttrs, cudaStream_t
hStream)
Performs a batch of memory copies asynchronously.
This is an alternate spelling for cudaMemcpyBatchAsync made available through function over-
loading.
See also:
cudaMemcpyBatchAsync
template<typename T, typename U>
__host__ cudaError_t cudaMemcpyBatchAsync(T *const *dsts, U *const *srcs, const size_t *sizes,
size_t count, struct cudaMemcpyAttributes attr,
cudaStream_t hStream)
Performs a batch of memory copies asynchronously.
This is an alternate spelling for cudaMemcpyBatchAsync made available through function over-
loading.
The cudaMemcpyAttributes specified by attr are applicable for all the copies specified in the
batch.
See also:
cudaMemcpyBatchAsync
template<class T>
__host__ cudaError_t cudaMemcpyFromSymbol(void *dst, const T &symbol, size_t count, size_t
offset = 0, enum cudaMemcpyKind kind =
cudaMemcpyDeviceToHost)
Copies data from the given symbol on the device.
Copies count bytes from the memory area offset bytes from the start of symbol symbol to
the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable
that resides in global or constant memory space. kind can be either cudaMemcpyDeviceToHost
or cudaMemcpyDeviceToDevice.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpy2DToArray, cudaMemcpy2DFromArray, cudaMem-
cpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cud-
aMemcpy2DToArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cud-
aMemcpyFromSymbolAsync
Note: Note that this function may also return error codes from previous, asynchronous launches.
52
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Note: This function exhibits synchronous behavior for most use cases.
Note: Use of a string naming a variable as the symbol parameter was deprecated in CUDA 4.1
and removed in CUDA 5.0.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ dst - - Destination memory address
▶ symbol - - Device symbol reference
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidMem-
cpyDirection, cudaErrorNoKernelImageForDevice
template<class T>
__host__ cudaError_t cudaMemcpyFromSymbolAsync(void *dst, const T &symbol, size_t count,
size_t offset = 0, enum cudaMemcpyKind kind
= cudaMemcpyDeviceToHost, cudaStream_t
stream = 0)
Copies data from the given symbol on the device.
Copies count bytes from the memory area offset bytes from the start of symbol symbol to
the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable
that resides in global or constant memory space. kind can be either cudaMemcpyDeviceToHost
or cudaMemcpyDeviceToDevice.
cudaMemcpyFromSymbolAsync() is asynchronous with respect to the host, so the call may return
before the copy is complete. The copy can optionally be associated to a stream by passing a non-
zero stream argument. If kind is cudaMemcpyDeviceToHost and stream is non-zero, the copy
may overlap with operations in other streams.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpy2DToArray, cudaMemcpy2DFromArray, cudaMem-
cpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cud-
6.1. C++ API Routines
53
CUDA Runtime API Reference Manual, Release 13.5
aMemcpy2DAsync, cudaMemcpy2DToArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpy-
ToSymbolAsync
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: This function exhibits asynchronous behavior for most use cases.
Note: Use of a string naming a variable as the symbol parameter was deprecated in CUDA 4.1
and removed in CUDA 5.0.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ dst - - Destination memory address
▶ symbol - - Device symbol reference
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
▶ stream - - Stream identifier
Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidMem-
cpyDirection, cudaErrorNoKernelImageForDevice
template<class T>
__host__ cudaError_t cudaMemcpyToSymbol(const T &symbol, const void *src, size_t count, size_t
offset = 0, enum cudaMemcpyKind kind =
cudaMemcpyHostToDevice)
Copies data to the given symbol on the device.
Copies count bytes from the memory area pointed to by src to the memory area offset bytes
from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that
resides in global or constant memory space. kind can be either cudaMemcpyHostToDevice or
cudaMemcpyDeviceToDevice.
54
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpy2DToArray, cudaMemcpy2DFromArray, cudaMem-
cpy2DArrayToArray, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cud-
aMemcpy2DToArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cud-
aMemcpyFromSymbolAsync
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: This function exhibits synchronous behavior for most use cases.
Note: Use of a string naming a variable as the symbol parameter was deprecated in CUDA 4.1
and removed in CUDA 5.0.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ symbol - - Device symbol reference
▶ src - - Source memory address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidMem-
cpyDirection, cudaErrorNoKernelImageForDevice
template<class T>
__host__ cudaError_t cudaMemcpyToSymbolAsync(const T &symbol, const void *src, size_t count,
size_t offset = 0, enum cudaMemcpyKind kind =
cudaMemcpyHostToDevice, cudaStream_t
stream = 0)
Copies data to the given symbol on the device.
Copies count bytes from the memory area pointed to by src to the memory area offset bytes
from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that
resides in global or constant memory space. kind can be either cudaMemcpyHostToDevice or
cudaMemcpyDeviceToDevice.
6.1. C++ API Routines
55
CUDA Runtime API Reference Manual, Release 13.5
cudaMemcpyToSymbolAsync() is asynchronous with respect to the host, so the call may return
before the copy is complete. The copy can optionally be associated to a stream by passing a non-
zero stream argument. If kind is cudaMemcpyHostToDevice and stream is non-zero, the copy
may overlap with operations in other streams.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpy2DToArray, cudaMemcpy2DFromArray, cudaMem-
cpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cu-
daMemcpy2DAsync, cudaMemcpy2DToArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMem-
cpyFromSymbolAsync
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: This function exhibits asynchronous behavior for most use cases.
Note: Use of a string naming a variable as the symbol parameter was deprecated in CUDA 4.1
and removed in CUDA 5.0.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ symbol - - Device symbol reference
▶ src - - Source memory address
▶ count - - Size in bytes to copy
▶ offset - - Offset from start of symbol in bytes
▶ kind - - Type of transfer
▶ stream - - Stream identifier
Returns
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidMem-
cpyDirection, cudaErrorNoKernelImageForDevice
template<class T>
__host__ cudaError_t cudaOccupancyAvailableDynamicSMemPerBlock(size_t
*dynamicSmemSize, T
*func, int numBlocks, int
blockSize)
56
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Returns dynamic shared memory available per block when launching numBlocks blocks on SM.
Returns in *dynamicSmemSize the maximum size of dynamic shared memory to allow num-
Blocks blocks per SM.
See also:
cudaOccupancyMaxPotentialBlockSize
See also:
cudaOccupancyMaxPotentialBlockSizeWithFlags
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessor
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ dynamicSmemSize - - Returned maximum dynamic shared memory
6.1. C++ API Routines
57
CUDA Runtime API Reference Manual, Release 13.5
▶ func - - Kernel function for which occupancy is calculated
▶ numBlocks - - Number of blocks to fit on SM
▶ blockSize - - Size of the block
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidDeviceFunction, cudaErrorIn-
validValue, cudaErrorUnknown,
template<class T>
__host__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, T
func, int blockSize,
size_t dynamic-
SMemSize)
Returns occupancy for a device function.
Returns in *numBlocks the maximum number of active blocks per streaming multiprocessor for
the device function.
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
See also:
cudaOccupancyMaxPotentialBlockSize
See also:
cudaOccupancyMaxPotentialBlockSizeWithFlags
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
See also:
cudaOccupancyAvailableDynamicSMemPerBlock
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
58
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ numBlocks - - Returned occupancy
▶ func - - Kernel function for which occupancy is calulated
▶ blockSize - - Block size the kernel is intended to be launched with
▶ dynamicSMemSize - - Per-block dynamic shared memory usage intended, in
bytes
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidDeviceFunction, cudaErrorIn-
validValue, cudaErrorUnknown,
template<class T>
__host__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int
*num-
Blocks,
T func,
int
block-
Size,
size_t
dynam-
ic-
SMem-
Size,
un-
signed
int
flags)
Returns occupancy for a device function with the specified flags.
Returns in *numBlocks the maximum number of active blocks per streaming multiprocessor for
the device function.
The flags parameter controls how special cases are handled. Valid flags include:
▶ cudaOccupancyDefault: keeps the default behavior as cudaOccupancyMaxActiveBlocksPer-
Multiprocessor
▶ cudaOccupancyDisableCachingOverride: suppresses the default behavior on platform where
global caching affects occupancy. On such platforms, if caching is enabled, but per-block
SM resource usage would result in zero occupancy, the occupancy calculator will calculate
the occupancy as if caching is disabled. Setting this flag makes the occupancy calculator
6.1. C++ API Routines
59
CUDA Runtime API Reference Manual, Release 13.5
to return 0 in such cases. More information can be found about this feature in the “Unified
L1/Texture Cache” section of the Maxwell tuning guide.
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessor
See also:
cudaOccupancyMaxPotentialBlockSize
See also:
cudaOccupancyMaxPotentialBlockSizeWithFlags
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
See also:
cudaOccupancyAvailableDynamicSMemPerBlock
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ numBlocks - - Returned occupancy
▶ func - - Kernel function for which occupancy is calulated
60
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
▶ blockSize - - Block size the kernel is intended to be launched with
▶ dynamicSMemSize - - Per-block dynamic shared memory usage intended, in
bytes
▶ flags - - Requested behavior for the occupancy calculator
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidDeviceFunction, cudaErrorIn-
validValue, cudaErrorUnknown,
template<class T>
__host__ cudaError_t cudaOccupancyMaxActiveClusters(int *numClusters, T *func, const
cudaLaunchConfig_t *config)
Given the kernel function (func) and launch configuration (config), return the maximum number
of clusters that could co-exist on the target device in *numClusters.
If the function has required cluster size already set (see cudaFuncGetAttributes), the cluster size
from config must either be unspecified or match the required size. Without required sizes, the
cluster size must be specified in config, else the function will return an error.
Note that various attributes of the kernel function may affect occupancy calculation. Runtime
environment may affect how the hardware schedules the clusters, so the calculated occupancy
is not guaranteed to be achievable.
See also:
cudaFuncGetAttributes
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
6.1. C++ API Routines
61
CUDA Runtime API Reference Manual, Release 13.5
Parameters
▶ numClusters - - Returned maximum number of clusters that could co-exist on
the target device
▶ func - - Kernel function for which maximum number of clusters are calculated
▶ config - - Launch configuration for the given kernel function
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidValue, cudaErrorIn-
validClusterSize, cudaErrorUnknown,
template<class T>
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSize(int *minGridSize, int
*blockSize, T func,
size_t
dynamicSMemSize =
0, int blockSizeLimit =
0)
Returns grid and block size that achieves maximum potential occupancy for a device function.
Returns in *minGridSize and *blocksize a suggested grid / block size pair that achieves the
best potential occupancy (i.e. the maximum number of active warps with the smallest number
of blocks).
Use
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem if the amount of per-block dynamic shared
memory changes with different block sizes.
See also:
cudaOccupancyMaxPotentialBlockSizeWithFlags
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessor
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
See also:
cudaOccupancyAvailableDynamicSMemPerBlock
Note: Note that this function may also return error codes from previous, asynchronous launches.
62
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ minGridSize - - Returned minimum grid size needed to achieve the best po-
tential occupancy
▶ blockSize - - Returned block size
▶ func - - Device function symbol
▶ dynamicSMemSize - - Per-block dynamic shared memory usage intended, in
bytes
▶ blockSizeLimit - - The maximum block size func is designed to work with. 0
means no limit.
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidDeviceFunction, cudaErrorIn-
validValue, cudaErrorUnknown,
template<typename UnaryFunction, class T>
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSizeVariableSMem(int
*min-
Grid-
Size,
int
*block-
Size, T
func,
Unary-
Func-
tion
block-
SizeTo-
Dy-
namic-
SMem-
Size,
int
block-
Size-
Limit =
0)
Returns grid and block size that achieves maximum potential occupancy for a device function.
Returns in *minGridSize and *blocksize a suggested grid / block size pair that achieves the
best potential occupancy (i.e. the maximum number of active warps with the smallest number
6.1. C++ API Routines
63
CUDA Runtime API Reference Manual, Release 13.5
of blocks).
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessor
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
See also:
cudaOccupancyMaxPotentialBlockSize
See also:
cudaOccupancyMaxPotentialBlockSizeWithFlags
See also:
cudaOccupancyAvailableDynamicSMemPerBlock
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ minGridSize - - Returned minimum grid size needed to achieve the best po-
tential occupancy
▶ blockSize - - Returned block size
▶ func - - Device function symbol
▶ blockSizeToDynamicSMemSize - - A unary function / functor that takes block
size, and returns the size, in bytes, of dynamic shared memory needed for a
block
▶ blockSizeLimit - - The maximum block size func is designed to work with. 0
means no limit.
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidDeviceFunction, cudaErrorIn-
validValue, cudaErrorUnknown,
template<typename UnaryFunction, class T>
64
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags(int
*min-
Grid-
Size,
int
*block-
Size,
T
func,
Unary-
Func-
tion
block-
Size-
To-
Dy-
nam-
ic-
SMem-
Size,
int
block-
Size-
Limit
=
0,
un-
signed
int
flags
=
0)
Returns grid and block size that achieves maximum potential occupancy for a device function.
Returns in *minGridSize and *blocksize a suggested grid / block size pair that achieves the
best potential occupancy (i.e. the maximum number of active warps with the smallest number
of blocks).
The flags parameter controls how special cases are handled. Valid flags include:
▶ cudaOccupancyDefault: keeps the default behavior as cudaOccupancyMaxPotentialBlock-
SizeVariableSMemWithFlags
▶ cudaOccupancyDisableCachingOverride: This flag suppresses the default behavior on plat-
form where global caching affects occupancy. On such platforms, if caching is enabled, but
per-block SM resource usage would result in zero occupancy, the occupancy calculator will
calculate the occupancy as if caching is disabled. Setting this flag makes the occupancy
calculator to return 0 in such cases. More information can be found about this feature in
the “Unified L1/Texture Cache” section of the Maxwell tuning guide.
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem
6.1. C++ API Routines
65
CUDA Runtime API Reference Manual, Release 13.5
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessor
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
See also:
cudaOccupancyMaxPotentialBlockSize
See also:
cudaOccupancyMaxPotentialBlockSizeWithFlags
See also:
cudaOccupancyAvailableDynamicSMemPerBlock
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ minGridSize - - Returned minimum grid size needed to achieve the best po-
tential occupancy
▶ blockSize - - Returned block size
▶ func - - Device function symbol
▶ blockSizeToDynamicSMemSize - - A unary function / functor that takes block
size, and returns the size, in bytes, of dynamic shared memory needed for a
block
▶ blockSizeLimit - - The maximum block size func is designed to work with. 0
means no limit.
▶ flags - - Requested behavior for the occupancy calculator
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidDeviceFunction, cudaErrorIn-
validValue, cudaErrorUnknown,
template<class T>
66
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
__host__ __device__ cudaError_t cudaOccupancyMaxPotentialBlockSizeWithFlags(int *min-
GridSize,
int
*blockSize,
T func,
size_t
dynamic-
SMemSize
= 0, int
blockSize-
Limit = 0,
unsigned
int flags =
0)
Returns grid and block size that achived maximum potential occupancy for a device function with
the specified flags.
Returns in *minGridSize and *blocksize a suggested grid / block size pair that achieves the
best potential occupancy (i.e. the maximum number of active warps with the smallest number
of blocks).
The flags parameter controls how special cases are handle. Valid flags include:
▶ cudaOccupancyDefault: keeps the default behavior as cudaOccupancyMaxPotentialBlockSize
▶ cudaOccupancyDisableCachingOverride: This flag suppresses the default behavior on plat-
form where global caching affects occupancy. On such platforms, if caching is enabled, but
per-block SM resource usage would result in zero occupancy, the occupancy calculator will
calculate the occupancy as if caching is disabled. Setting this flag makes the occupancy
calculator to return 0 in such cases. More information can be found about this feature in
the “Unified L1/Texture Cache” section of the Maxwell tuning guide.
Use
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem if the amount of per-block dynamic shared
memory changes with different block sizes.
See also:
cudaOccupancyMaxPotentialBlockSize
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessor
See also:
cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMem
See also:
cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags
See also:
cudaOccupancyAvailableDynamicSMemPerBlock
6.1. C++ API Routines
67
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ minGridSize - - Returned minimum grid size needed to achieve the best po-
tential occupancy
▶ blockSize - - Returned block size
▶ func - - Device function symbol
▶ dynamicSMemSize - - Per-block dynamic shared memory usage intended, in
bytes
▶ blockSizeLimit - - The maximum block size func is designed to work with. 0
means no limit.
▶ flags - - Requested behavior for the occupancy calculator
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidDeviceFunction, cudaErrorIn-
validValue, cudaErrorUnknown,
template<class T>
__host__ cudaError_t cudaOccupancyMaxPotentialClusterSize(int *clusterSize, T *func, const
cudaLaunchConfig_t *config)
Given the kernel function (func) and launch configuration (config), return the maximum cluster
size in *clusterSize.
The cluster dimensions in config are ignored. If func has a required cluster size set (see cuda-
FuncGetAttributes),*clusterSize will reflect the required cluster size.
By default this function will always return a value that’s portable on future hardware. A higher
value may be returned if the kernel function allows non-portable cluster sizes.
This function will respect the compile time launch bounds.
See also:
cudaFuncGetAttributes
Note: Note that this function may also return error codes from previous, asynchronous launches.
68
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLi-
braryGetKernel() or cudaGetKernel and then passing it to the API by casting to void*. The symbol
entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same
CUDA Runtime instance.
Note: Passing a symbol that belongs that belongs to a different runtime instance will result in
undefined behavior. The only type that can be reliably passed to a different runtime instance is
cudaKernel_t
Parameters
▶ clusterSize - - Returned maximum cluster size that can be launched for the
given kernel function and launch configuration
▶ func - - Kernel function for which maximum cluster size is calculated
▶ config - - Launch configuration for the given kernel function
Returns
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidValue, cudaErrorUnk-
nown,
template<class T>
__host__ cudaError_t cudaStreamAttachMemAsync(cudaStream_t stream, T *devPtr, size_t length
= 0, unsigned int flags = 0x04)
Attach memory to a stream asynchronously.
Enqueues an operation in stream to specify stream association of length bytes of memory
starting from devPtr. This function is a stream-ordered operation, meaning that it is depen-
dent on, and will only take effect when, previous work in stream has completed. Any previous
association is automatically replaced.
devPtr must point to an one of the following types of memories:
▶ managed memory declared using the managed keyword or allocated with cudaMallocMan-
aged.
▶ a valid host-accessible region of system-allocated pageable memory. This type of memory
may only be specified if the device associated with the stream reports a non-zero value for
the device attribute cudaDevAttrPageableMemoryAccess.
For managed allocations, length must be either zero or the entire allocation’s size. Both indicate
that the entire allocation’s stream association is being changed. Currently, it is not possible to
change stream association for a portion of a managed allocation.
6.1. C++ API Routines
69
CUDA Runtime API Reference Manual, Release 13.5
For pageable allocations, length must be non-zero.
The stream association is specified using flags which must be one of cudaMemAttachGlobal,
cudaMemAttachHost or cudaMemAttachSingle. The default value for flags is cudaMemAttachS-
ingle If the cudaMemAttachGlobal flag is specified, the memory can be accessed by any stream
on any device. If the cudaMemAttachHost flag is specified, the program makes a guarantee that
it won’t access the memory on the device from any stream on a device that has a zero value for
the device attribute cudaDevAttrConcurrentManagedAccess. If the cudaMemAttachSingle flag is
specified and stream is associated with a device that has a zero value for the device attribute
cudaDevAttrConcurrentManagedAccess, the program makes a guarantee that it will only access
the memory on the device from stream. It is illegal to attach singly to the NULL stream, because
the NULL stream is a virtual global stream and not a specific stream. An error will be returned in
this case.
When memory is associated with a single stream, the Unified Memory system will allow CPU
access to this memory region so long as all operations in stream have completed, regardless of
whether other streams are active. In effect, this constrains exclusive ownership of the managed
memory region by an active GPU to per-stream activity instead of whole-GPU activity.
Accessing memory on the device from streams that are not associated with it will produce un-
defined results. No error checking is performed by the Unified Memory system to ensure that
kernels launched into other streams do not access this region.
It is a program’s responsibility to order calls to cudaStreamAttachMemAsync via events, synchro-
nization or other means to ensure legal access to memory at all times. Data visibility and co-
herency will be changed appropriately for all kernels which follow a stream-association change.
If stream is destroyed while data is associated with it, the association is removed and the asso-
ciation reverts to the default visibility of the allocation as specified at cudaMallocManaged. For
managed variables, the default association is always cudaMemAttachGlobal. Note that destroy-
ing a stream is an asynchronous operation, and as a result, the change to default association
won’t happen until all work in the stream has completed.
See also:
cudaStreamCreate, cudaStreamCreateWithFlags, cudaStreamWaitEvent, cudaStreamSynchronize,
cudaStreamAddCallback, cudaStreamDestroy, cudaMallocManaged
Note: Note that this function may also return error codes from previous, asynchronous launches.
Note: Note that this function may also return cudaErrorInitializationError, cudaErrorInsufficient-
Driver or cudaErrorNoDevice if this call tries to initialize internal CUDA RT state.
Note: Note that as specified by cudaStreamAddCallback no CUDA function may be called from
callback. cudaErrorNotPermitted may, but is not guaranteed to, be returned as a diagnostic in
such case.
Parameters
▶ flags - Memory can only be accessed by a single stream on the associated
device
70
Chapter 6. APIs
CUDA Runtime API Reference Manual, Release 13.5
▶ stream - - Stream in which to enqueue the attach operation
▶ devPtr - - Pointer to memory (must be a pointer to managed memory or to a
valid host-accessible region of system-allocated memory)
▶ length - - Length of memory (defaults to zero)
▶ flags - - Must be one of cudaMemAttachGlobal, cudaMemAttachHost or cud-
aMemAttachSingle (defaults to cudaMemAttachSingle)
Returns
cudaSuccess, cudaErrorNotReady, cudaErrorInvalidValue, cudaErrorInvalidResource-
Handle
6.2. Data types used by CUDA Runtime
Macros
CUDART_CB
CUDA_EGL_MAX_PLANES
Maximum number of planes per frame.
CUDA_IPC_HANDLE_SIZE
CUDA IPC Handle Size.
CU_UUID_HAS_BEEN_DEFINED
CUDA UUID types.
RESOURCE_ABI_BYTES
cudaArrayColorAttachment
Must be set in cudaExternalMemoryGetMappedMipmappedArray if the mipmapped array is used
as a color target in a graphics API.
cudaArrayCubemap
Must be set in cudaMalloc3DArray to create a cubemap CUDA array.
cudaArrayDefault
Default CUDA array allocation flag.
cudaArrayDeferredMapping
Must be set in cudaMallocArray, cudaMalloc3DArray or cudaMallocMipmappedArray in order to
create a deferred mapping CUDA array or CUDA mipmapped array.
cudaArrayLayered
Must be set in cudaMalloc3DArray to create a layered CUDA array.
cudaArraySparse
Must be set in cudaMallocArray, cudaMalloc3DArray or cudaMallocMipmappedArray in order to
create a sparse CUDA array or CUDA mipmapped array.
cudaArraySparsePropertiesSingleMipTail
Indicates that the layered sparse CUDA array or CUDA mipmapped array has a single mip tail
region for all layers.
6.2. Data types used by CUDA Runtime
71
CUDA Runtime API Reference Manual, Release 13.5
cudaArraySurfaceLoadStore
Must be set in cudaMallocArray or cudaMalloc3DArray in order to bind surfaces to the CUDA
array.
cudaArrayTextureGather
Must be set in cudaMallocArray or cudaMalloc3DArray in order to perform texture gather oper-
ations on the CUDA array.
cudaCpuDeviceId
Device id that represents the CPU.
cudaDevSmResourceGroupLocalityDomainIdAny
Special value for localityDomainId when cudaDevSmResourceSplit is called with cudaDevSmRe-
sourceGroupLocalityDomainId. Selects SMs from the union of all available locality domains in the
input SM resource. See also: cudaDevSmResourceGroupLocalityDomainId for the set of SMs in
a single locality domain.
cudaDeviceBlockingSync
Device flag - Use blocking synchronization.
cudaDeviceLmemResizeToMax
Device flag - Keep local memory allocation after launch.
cudaDeviceMapHost
Device flag - Support mapped pinned allocations.
cudaDeviceMask
Device flags mask.
cudaDeviceScheduleAuto
Device flag - Automatic scheduling.
cudaDeviceScheduleBlockingSync
Device flag - Use blocking synchronization.
cudaDeviceScheduleMask
Device schedule flags mask.
cudaDeviceScheduleSpin
Device flag - Spin default scheduling.
cudaDeviceScheduleYield
Device flag - Yield default scheduling.
cudaDeviceSyncMemops
Device flag - Ensure synchronous memory operations on this context will synchronize.
cudaEventBlockingSync
Event uses blocking synchronization.
cudaEventDefault
Default event flag.
cudaEventDisableTiming
Event will not record timing data.
cudaEventInterprocess
Event is suitable for interprocess use.
cudaEventRecordDefault
Default event record flag.
72
Chapter 6. APIs

 

 

 

 

 

 

 

 

Content      ..      1       2         ..

 

//////////////////////////////////////////