MUSA Runtime API Reference
1. Introduction
The MUSA Runtime API is the application-level musa* interface for device, memory, stream, event, execution, graph, and interoperability operations.
This reference describes the MUSA Runtime APIs supported in MUSA SDK 5.2.0. Use it as the compatibility reference for the functions, types, structures, fields, constants, and status values documented here.
Note: Some Runtime API declarations may appear in the headers but are not described in this reference. These declarations are experimental in MUSA SDK 5.2.0 and are provided for reference only.
2. Using the Runtime API
Use the Runtime API as the default application-facing interface. Use the Driver API when you need lower-level mu* control over contexts, modules, entry points, or Driver-owned objects.
Runtime entries may cross-reference Driver APIs when the two layers expose related behavior. When mixing layers, check the context, stream, and object ownership rules in the relevant function entries before passing handles between APIs.
Synchronization behavior, asynchronous error reporting, object lifetime, and thread-safety constraints are documented in the function entries. For Stream Management, Event Management, Memory Management, Execution Control, and Graph Management APIs, read the Returns and Note sections before relying on host-side completion or object sharing.
Use Version Management for Runtime version checks. Use Interactions with the MUSA Driver API when a Runtime entry interacts with Driver-level objects.
3. Modules
The API reference is organized by capability module.
Module List
- 3.1 Profiler Control
- 3.2 Device Management
- 3.3 Device Management [DEPRECATED]
- 3.4 Thread Management [DEPRECATED]
- 3.5 Error Handling
- 3.6 Stream Management
- 3.7 Event Management
- 3.8 External Resource Interoperability
- 3.9 Execution Control
- 3.10 Execution Control [DEPRECATED]
- 3.11 Occupancy
- 3.12 Memory Management
- 3.13 Memory Management [DEPRECATED]
- 3.14 Stream Ordered Memory Allocator
- 3.15 Unified Addressing
- 3.16 Peer Device Memory Access
- 3.17 Graphics Interoperability
- 3.18 Texture Reference Management [DEPRECATED]
- 3.19 Surface Reference Management [DEPRECATED]
- 3.20 Texture Object Management
- 3.21 Surface Object Management
- 3.22 Version Management
- 3.23 Graph Management
- 3.24 Driver Entry Point Access
- 3.25 Library Management
- 3.26 Error Log Management
- 3.27 Interactions with the MUSA Driver API
- 3.28 Memory Atomic Management
3.1 Profiler Control
musaProfilerStart
musaError_t musaProfilerStart(void)
Description
- Enable profiling.
- Enables profile collection by the active profiling tool for the current context. If profiling is already enabled, then musaProfilerStart() has no effect.
- musaProfilerStart and musaProfilerStop APIs are used to programmatically control the profiling granularity by allowing profiling to be done only on selective pieces of code.
Parameters
(unnamed)(void)
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
See also
musaProfilerStop
musaError_t musaProfilerStop(void)
Description
- Disable profiling.
- Disables profile collection by the active profiling tool for the current context. If profiling is already disabled, then musaProfilerStop() has no effect.
- musaProfilerStart and musaProfilerStop APIs are used to programmatically control the profiling granularity by allowing profiling to be done only on selective pieces of code.
Parameters
(unnamed)(void)
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
See also
3.2 Device Management
musaDeviceReset
musaError_t musaDeviceReset(void)
Description
- Destroy all allocations and reset all state on the current device in the current process.
- Explicitly destroys and cleans up all resources associated with the current device in the current process. It is the caller's responsibility to ensure that the resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These resources include MUSA types musaStream_t, musaEvent_t, musaArray_t, musaMipmappedArray_t, musaPitchedPtr, musaTextureObject_t, musaSurfaceObject_t, textureReference, surfaceReference, musaExternalMemory_t, musaExternalSemaphore_t and musaGraphicsResource_t. These resources also include memory allocations by musaMalloc, musaMallocHost, musaMallocManaged and musaMallocPitch. Any subsequent API call to this device will reinitialize the device.
- Note that this function will reset the device immediately. It is the caller's responsibility to ensure that the device is not being accessed by any other host threads from the process when this function is called.
Parameters
(unnamed)(void)
Returns
- musaSuccess
Note
- musaDeviceReset() will not destroy memory allocations by musaMallocAsync() and musaMallocFromPoolAsync(). These memory allocations need to be destroyed explicitly.
- If a non-primary MUcontext is current to the thread, musaDeviceReset() will destroy only the internal MUSA RT state for that MUcontext.
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaDeviceSynchronize
musaError_t musaDeviceSynchronize(void)
Description
- Wait for compute device to finish.
- Blocks until the device has completed all preceding requested tasks. musaDeviceSynchronize() returns an error if one of the preceding tasks has failed. If the musaDeviceScheduleBlockingSync flag was set for this device, the host thread will block until the device has finished its work.
Parameters
(unnamed)(void)
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- This API is deprecated for device-wide synchronization control.
See also
musaDeviceSetLimit
musaError_t musaDeviceSetLimit(enum musaLimit limit, size_t value)
Description
- Set resource limits.
- Setting limit to value is a request by the application to update the current limit maintained by the device. The driver is free to modify the requested value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size, etc). The application can use musaDeviceGetLimit() to find out exactly what the limit has been set to.
- Setting each musaLimit has its own specific restrictions, so each is discussed here.
- musaLimitStackSize controls the stack size in bytes of each GPU thread. musaLimitPrintfFifoSize controls the size in bytes of the shared FIFO used by the printf() device system call. Setting musaLimitPrintfFifoSize must not be performed after launching any kernel that uses the printf() device system call - in such case musaErrorInvalidValue will be returned. musaLimitMallocHeapSize controls the size in bytes of the heap used by the malloc() and free() device system calls. Setting musaLimitMallocHeapSize must not be performed after launching any kernel that uses the malloc() or free() device system calls - in such case musaErrorInvalidValue will be returned. musaLimitDevRuntimeSyncDepth controls the maximum nesting depth of a grid at which a thread can safely call musaDeviceSynchronize(). Setting this limit must be performed before any launch of a kernel that uses the device runtime and calls musaDeviceSynchronize() above the default sync depth, two levels of grids. Calls to musaDeviceSynchronize() will fail with error code musaErrorSyncDepthExceeded if the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When setting this limit, keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device memory which can no longer be used for user allocations. If these reservations of device memory fail, musaDeviceSetLimit will return musaErrorMemoryAllocation, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability < 9.0. Attempting to set this limit on devices of other compute capability will results in error musaErrorUnsupportedLimit being returned. musaLimitDevRuntimePendingLaunchCount controls the maximum number of outstanding device runtime launches that can be made from the current device. A grid is outstanding from the point of launch up until the grid is known to have been completed. Device runtime launches which violate this limitation fail and return musaErrorLaunchPendingCountExceeded when musaGetLastError() is called after launch. If more pending launches than the default (2048 launches) are needed for a module using the device runtime, this limit can be increased. Keep in mind that being able to sustain additional pending launches will require the runtime to reserve larger amounts of device memory upfront which can no longer be used for allocations. If these reservations fail, musaDeviceSetLimit will return musaErrorMemoryAllocation, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability 3.5 and higher. Attempting to set this limit on devices of compute capability less than 3.5 will result in the error musaErrorUnsupportedLimit being returned. musaLimitMaxL2FetchGranularity controls the L2 cache fetch granularity. Values can range from 0B to 128B. This is purely a performance hint and it can be ignored or clamped depending on the platform. musaLimitPersistingL2CacheSize controls size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped depending on the platform.
Parameters
limit(enum musaLimit): Limit to setvalue(size_t): Size of limit
Returns
- musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue, musaErrorMemoryAllocation
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaDeviceGetLimit
musaError_t musaDeviceGetLimit(size_t *pValue, enum musaLimit limit)
Description
- Return resource limits.
- Returns in *pValue the current size of limit. The following musaLimit values are supported. musaLimitStackSize is the stack size in bytes of each GPU thread. musaLimitPrintfFifoSize is the size in bytes of the shared FIFO used by the printf() device system call. musaLimitMallocHeapSize is the size in bytes of the heap used by the malloc() and free() device system calls. musaLimitDevRuntimeSyncDepth is the maximum grid depth at which a thread can isssue the device runtime call musaDeviceSynchronize() to wait on child grid launches to complete. This functionality is removed for devices of compute capability >= 9.0, and hence will return error musaErrorUnsupportedLimit on such devices. musaLimitDevRuntimePendingLaunchCount is the maximum number of outstanding device runtime launches. musaLimitMaxL2FetchGranularity is the L2 cache fetch granularity. musaLimitPersistingL2CacheSize is the persisting L2 cache size in bytes.
Parameters
pValue(size_t *): Returned size of the limitlimit(enum musaLimit): Limit to query
Returns
- musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaDeviceGetTexture1DLinearMaxWidth
musaError_t musaDeviceGetTexture1DLinearMaxWidth(size_t *maxWidthInElements, const struct musaChannelFormatDesc *fmtDesc, int device)
Description
- Returns the maximum number of elements allocatable in a 1D linear texture for a given element size.
- Returns in maxWidthInElements the maximum number of elements allocatable in a 1D linear texture for given format descriptor fmtDesc.
Parameters
maxWidthInElements(size_t *): Returns maximum number of texture elements allocatable for given fmtDesc.fmtDesc(const struct musaChannelFormatDesc *): Texture format description.device(int)
Returns
- musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaDeviceGetCacheConfig
musaError_t musaDeviceGetCacheConfig(enum musaFuncCache *pCacheConfig)
Description
- Returns the preferred cache configuration for the current device.
- On devices where the L1 cache and shared memory use the same hardware resources, this returns through pCacheConfig the preferred cache configuration for the current device. 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 functions.
- This will return a pCacheConfig of musaFuncCachePreferNone on devices where the size of the L1 cache and shared memory are fixed.
- The supported cache configurations are: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory musaFuncCachePreferEqual: prefer equal size L1 cache and shared memory
Parameters
pCacheConfig(enum musaFuncCache *): Returned cache configuration
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaDeviceSetCacheConfig, musaFuncSetCacheConfig (C API), musaFuncSetCacheConfig (C++ API), muCtxGetCacheConfig
musaDeviceGetStreamPriorityRange
musaError_t musaDeviceGetStreamPriorityRange(int *leastPriority, int *greatestPriority)
Description
- Returns numerical values that correspond to the least and greatest stream priorities.
- Returns in *leastPriority and *greatestPriority the numerical values that correspond to the least and greatest stream priorities respectively. Stream priorities follow a convention where lower numbers imply greater priorities. The range of meaningful stream priorities is given by [*greatestPriority, *leastPriority]. If the user attempts to create a stream with a priority value that is outside the the meaningful range as specified by this API, the priority is automatically clamped down or up to either *leastPriority or *greatestPriority respectively. See musaStreamCreateWithPriority for details on creating a priority stream. A NULL may be passed in for *leastPriority or *greatestPriority if the value is not desired.
- This function will return '0' in both *leastPriority and *greatestPriority if the current context's device does not support stream priorities (see musaDeviceGetAttribute).
Parameters
leastPriority(int *): Pointer to an int in which the numerical value for least stream priority is returnedgreatestPriority(int *): Pointer to an int in which the numerical value for greatest stream priority is returned
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaDeviceSetCacheConfig
musaError_t musaDeviceSetCacheConfig(enum musaFuncCache cacheConfig)
Description
- Sets the preferred cache configuration for the current device.
- On devices where the L1 cache and shared memory use the same hardware resources, this sets through cacheConfig the preferred cache configuration for the current device. 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 the function. Any function preference set via musaFuncSetCacheConfig (C API) or musaFuncSetCacheConfig (C++ API) will be preferred over this device-wide setting. Setting the device-wide cache configuration to musaFuncCachePreferNone will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel.
- 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: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory musaFuncCachePreferEqual: prefer equal size L1 cache and shared memory
Parameters
cacheConfig(enum musaFuncCache): Requested cache configuration
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaDeviceGetCacheConfig, musaFuncSetCacheConfig (C API), musaFuncSetCacheConfig (C++ API), muCtxSetCacheConfig
musaDeviceGetByPCIBusId
musaError_t musaDeviceGetByPCIBusId(int *device, const char *pciBusId)
Description
- Returns a handle to a compute device.
- Returns in *device a device ordinal given a PCI bus ID string.
Parameters
device(int *): Returned device ordinalpciBusId(const char *): String in one of the following forms:
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaDeviceGetPCIBusId
musaError_t musaDeviceGetPCIBusId(char *pciBusId, int len, int device)
Description
- Returns a PCI Bus Id string for the device.
- Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by pciBusId. len specifies the maximum length of the string that may be returned.
Parameters
pciBusId(char *): Returned identifier string for the device in the following formatlen(int): Maximum length of string to store in namedevice(int): Device to get identifier string for
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaIpcGetEventHandle
musaError_t musaIpcGetEventHandle(musaIpcEventHandle_t *handle, musaEvent_t event)
Description
- Gets an interprocess handle for a previously allocated event.
- Takes as input a previously allocated event. This event must have been created with the musaEventInterprocess and musaEventDisableTiming flags set. This opaque handle may be copied into other processes and opened with musaIpcOpenEventHandle to allow efficient hardware synchronization between GPU work in different processes.
- After the event has been been opened in the importing process, musaEventRecord, musaEventSynchronize, musaStreamWaitEvent and musaEventQuery may be used in either process. Performing operations on the imported event after the exported event has been freed with musaEventDestroy will result in undefined behavior.
- IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport
Parameters
handle(musaIpcEventHandle_t *): Pointer to a user allocated musaIpcEventHandle in which to return the opaque event handleevent(musaEvent_t): Event allocated with musaEventInterprocess and musaEventDisableTiming flags.
Returns
- musaSuccess, musaErrorInvalidResourceHandle, musaErrorMemoryAllocation, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue
Note
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaEventCreate, musaEventDestroy, musaEventSynchronize, musaEventQuery, musaStreamWaitEvent, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcGetEventHandle
musaIpcOpenEventHandle
musaError_t musaIpcOpenEventHandle(musaEvent_t *event, musaIpcEventHandle_t handle)
Description
- Opens an interprocess event handle for use in the current process.
- Opens an interprocess event handle exported from another process with musaIpcGetEventHandle. This function returns a musaEvent_t that behaves like a locally created event with the musaEventDisableTiming flag specified. This event must be freed with musaEventDestroy.
- Performing operations on the imported event after the exported event has been freed with musaEventDestroy will result in undefined behavior.
- IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport
Parameters
event(musaEvent_t *): Returns the imported eventhandle(musaIpcEventHandle_t): Interprocess handle to open
Returns
- musaSuccess, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue, musaErrorDeviceUninitialized
Note
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaEventCreate, musaEventDestroy, musaEventSynchronize, musaEventQuery, musaStreamWaitEvent, musaIpcGetEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcOpenEventHandle
musaIpcGetMemHandle
musaError_t musaIpcGetMemHandle(musaIpcMemHandle_t *handle, void *devPtr)
Description
- Gets an interprocess memory handle for an existing device memory allocation.
- Takes a pointer to the base of an existing device memory allocation created with musaMalloc and exports it for use in another process. This is a lightweight operation and may be called multiple times on an allocation without adverse effects.
- If a region of memory is freed with musaFree and a subsequent call to musaMalloc returns memory with the same device address, musaIpcGetMemHandle will return a unique handle for the new memory.
- IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport
Parameters
handle(musaIpcMemHandle_t *): Pointer to user allocated musaIpcMemHandle to return the handle in.devPtr(void *): Base pointer to previously allocated device memory
Returns
- musaSuccess, musaErrorMemoryAllocation, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue
Note
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcGetMemHandle
musaIpcOpenMemHandle
musaError_t musaIpcOpenMemHandle(void **devPtr, musaIpcMemHandle_t handle, unsigned int flags)
Description
- Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process.
- Maps memory exported from another process with musaIpcGetMemHandle into the current device address space. For contexts on different devices musaIpcOpenMemHandle can attempt to enable peer access between the devices as if the user called musaDeviceEnablePeerAccess. This behavior is controlled by the musaIpcMemLazyEnablePeerAccess flag. musaDeviceCanAccessPeer can determine if a mapping is possible.
- musaIpcOpenMemHandle can open handles to devices that may not be visible in the process calling the API.
- Contexts that may open musaIpcMemHandles are restricted in the following way. musaIpcMemHandles from each device in a given process may only be opened by one context per device per other process.
- If the memory handle has already been opened by the current context, the reference count on the handle is incremented by 1 and the existing device pointer is returned.
- Memory returned from musaIpcOpenMemHandle must be freed with musaIpcCloseMemHandle.
- Calling musaFree on an exported memory region before calling musaIpcCloseMemHandle in the importing context will result in undefined behavior.
- IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport
Parameters
devPtr(void **): Returned device pointerhandle(musaIpcMemHandle_t): musaIpcMemHandle to openflags(unsigned int): Flags for this operation. Must be specified as musaIpcMemLazyEnablePeerAccess
Returns
- musaSuccess, musaErrorMapBufferObjectFailed, musaErrorInvalidResourceHandle, musaErrorDeviceUninitialized, musaErrorTooManyPeers, musaErrorNotSupported, musaErrorInvalidValue
Note
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- No guarantees are made about the address returned in *devPtr. In particular, multiple processes may not receive the same address for the same handle.
See also
- musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcCloseMemHandle, musaDeviceEnablePeerAccess, musaDeviceCanAccessPeer, muIpcOpenMemHandle
musaIpcCloseMemHandle
musaError_t musaIpcCloseMemHandle(void *devPtr)
Description
- Attempts to close memory mapped with musaIpcOpenMemHandle.
- Decrements the reference count of the memory returnd by musaIpcOpenMemHandle by 1. When the reference count reaches 0, this API unmaps the memory. The original allocation in the exporting process as well as imported mappings in other processes will be unaffected.
- Any resources used to enable peer access will be freed if this is the last mapping using them.
- IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport
Parameters
devPtr(void *): Device pointer returned by musaIpcOpenMemHandle
Returns
- musaSuccess, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue
Note
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, muIpcCloseMemHandle
musaDeviceRegisterAsyncNotification
musaError_t musaDeviceRegisterAsyncNotification(int device, musaAsyncCallback callbackFunc, void *userData, musaAsyncCallbackHandle_t *callback)
Description
- Blocks until remote writes are visible to the specified scope.
- Blocks until remote writes to the target context via mappings created through GPUDirect RDMA APIs, like mthreads_p2p_get_pages (see https://docs.mthreads.com/musa/gpudirect-rdma for more information), are visible to the specified scope.
- If the scope equals or lies within the scope indicated by musaDevAttrGPUDirectRDMAWritesOrdering, the call will be a no-op and can be safely omitted for performance. This can be determined by comparing the numerical values between the two enums, with smaller scopes having smaller values.
- Users may query support for this API via musaDevAttrGPUDirectRDMAFlushWritesOptions.
- Registers callbackFunc to receive async notifications.
- The userData parameter is passed to the callback function at async notification time. Likewise, callback is also passed to the callback function to distinguish between multiple registered callbacks.
- The callback function being registered should be designed to return quickly (~10ms). Any long running tasks should be queued for execution on an application thread.
- Callbacks may not call musaDeviceRegisterAsyncNotification or musaDeviceUnregisterAsyncNotification. Doing so will result in musaErrorNotPermitted. Async notification callbacks execute in an undefined order and may be serialized.
- Returns in *callback a handle representing the registered callback instance.
Parameters
device(int): The device on which to register the callbackcallbackFunc(musaAsyncCallback): The function to register as a callbackuserData(void *): A generic pointer to user data. This is passed into the callback function.callback(musaAsyncCallbackHandle_t *): A handle representing the registered callback instance
Returns
- musaSuccess, musaErrorNotSupported
- musaSuccess musaErrorNotSupported musaErrorInvalidDevice musaErrorInvalidValue musaErrorNotPermitted musaErrorUnknown
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- muFlushGPUDirectRDMAWrites
- musaDeviceUnregisterAsyncNotification
musaDeviceUnregisterAsyncNotification
musaError_t musaDeviceUnregisterAsyncNotification(int device, musaAsyncCallbackHandle_t callback)
Description
- Unregisters an async notification callback.
- Unregisters callback so that the corresponding callback function will stop receiving async notifications.
Parameters
device(int): The device from which to remove callback.callback(musaAsyncCallbackHandle_t): The callback instance to unregister from receiving async notifications.
Returns
- musaSuccess musaErrorNotSupported musaErrorInvalidDevice musaErrorInvalidValue musaErrorNotPermitted musaErrorUnknown
Note
- This function may also return error codes from previous, asynchronous launches.
See also
musaGetDeviceCount
musaError_t musaGetDeviceCount(int *count)
Description
- Returns the number of compute-capable devices.
- Returns in *count the number of devices with compute capability greater or equal to 2.0 that are available for execution.
Parameters
count(int *): Returns the number of devices with compute capability greater or equal to 2.0
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetDevice, musaSetDevice, musaGetDeviceProperties, musaChooseDevice, musaInitDevice, muDeviceGetCount
musaGetDeviceProperties
musaError_t musaGetDeviceProperties(struct musaDeviceProp *prop, int device)
Description
- Returns information about the compute-device.
- Returns in *prop the properties of device dev. The musaDeviceProp structure is defined as:
struct musaDeviceProp {
char name[256];
musaUUID_t uuid;
size_t totalGlobalMem;
size_t sharedMemPerBlock;
int regsPerBlock;
int warpSize;
size_t memPitch;
int maxThreadsPerBlock;
int maxThreadsDim[3];
int maxGridSize[3];
int clockRate;
size_t totalConstMem;
int major;
int minor;
size_t textureAlignment;
size_t texturePitchAlignment;
int deviceOverlap;
int multiProcessorCount;
int kernelExecTimeoutEnabled;
int integrated;
int canMapHostMemory;
int computeMode;
int maxTexture1D;
int maxTexture1DMipmap;
int maxTexture1DLinear;
int maxTexture2D[2];
int maxTexture2DMipmap[2];
int maxTexture2DLinear[3];
int maxTexture2DGather[2];
int maxTexture3D[3];
int maxTexture3DAlt[3];
int maxTextureCubemap;
int maxTexture1DLayered[2];
int maxTexture2DLayered[3];
int maxTextureCubemapLayered[2];
int maxSurface1D;
int maxSurface2D[2];
int maxSurface3D[3];
int maxSurface1DLayered[2];
int maxSurface2DLayered[3];
int maxSurfaceCubemap;
int maxSurfaceCubemapLayered[2];
size_t surfaceAlignment;
int concurrentKernels;
int ECCEnabled;
int pciBusID;
int pciDeviceID;
int pciDomainID;
int tccDriver;
int asyncEngineCount;
int unifiedAddressing;
int memoryClockRate;
int memoryBusWidth;
int l2CacheSize;
int persistingL2CacheMaxSize;
int maxThreadsPerMultiProcessor;
int streamPrioritiesSupported;
int globalL1CacheSupported;
int localL1CacheSupported;
size_t sharedMemPerMultiprocessor;
int regsPerMultiprocessor;
int managedMemory;
int isMultiGpuBoard;
int multiGpuBoardGroupID;
int singleToDoublePrecisionPerfRatio;
int pageableMemoryAccess;
int concurrentManagedAccess;
int computePreemptionSupported;
int canUseHostPointerForRegisteredMem;
int cooperativeLaunch;
int cooperativeMultiDeviceLaunch;
int pageableMemoryAccessUsesHostPageTables;
int directManagedMemAccessFromHost;
int accessPolicyMaxWindowSize;
};
- where: name[256] is an ASCII string identifying the device. uuid is a 16-byte unique identifier. totalGlobalMem is the total amount of global memory available on the device in bytes. sharedMemPerBlock is the maximum amount of shared memory available to a thread block in bytes. regsPerBlock is the maximum number of 32-bit registers available to a thread block. warpSize is the warp size in threads. memPitch is the maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through musaMallocPitch(). maxThreadsPerBlock is the maximum number of threads per block. maxThreadsDim[3] contains the maximum size of each dimension of a block. maxGridSize[3] contains the maximum size of each dimension of a grid. clockRate is the clock frequency in kilohertz. totalConstMem is the total amount of constant memory available on the device in bytes. major, minor are the major and minor revision numbers defining the device's compute capability. textureAlignment is the alignment requirement; texture base addresses that are aligned to textureAlignment bytes do not need an offset applied to texture fetches. texturePitchAlignment is the pitch alignment requirement for 2D texture references that are bound to pitched memory. deviceOverlap is 1 if the device can concurrently copy memory between host and device while executing a kernel, or 0 if not. Deprecated, use instead asyncEngineCount. multiProcessorCount is the number of multiprocessors on the device. kernelExecTimeoutEnabled is 1 if there is a run time limit for kernels executed on the device, or 0 if not. integrated is 1 if the device is an integrated (motherboard) GPU and 0 if it is a discrete (card) component. canMapHostMemory is 1 if the device can map host memory into the MUSA address space for use with musaHostAlloc()/musaHostGetDevicePointer(), or 0 if not. computeMode is the compute mode that the device is currently in. Available modes are as follows: musaComputeModeDefault: Default mode - Device is not restricted and multiple threads can use musaSetDevice() with this device. musaComputeModeProhibited: Compute-prohibited mode - No threads can use musaSetDevice() with this device. musaComputeModeExclusiveProcess: Compute-exclusive-process mode - Many threads in one process will be able to use musaSetDevice() with this device. When an occupied exclusive mode device is chosen with musaSetDevice, all subsequent non-device management runtime functions will return musaErrorDevicesUnavailable. maxTexture1D is the maximum 1D texture size. maxTexture1DMipmap is the maximum 1D mipmapped texture texture size. maxTexture1DLinear is the maximum 1D texture size for textures bound to linear memory. maxTexture2D[2] contains the maximum 2D texture dimensions. maxTexture2DMipmap[2] contains the maximum 2D mipmapped texture dimensions. maxTexture2DLinear[3] contains the maximum 2D texture dimensions for 2D textures bound to pitch linear memory. maxTexture2DGather[2] contains the maximum 2D texture dimensions if texture gather operations have to be performed. maxTexture3D[3] contains the maximum 3D texture dimensions. maxTexture3DAlt[3] contains the maximum alternate 3D texture dimensions. maxTextureCubemap is the maximum cubemap texture width or height. maxTexture1DLayered[2] contains the maximum 1D layered texture dimensions. maxTexture2DLayered[3] contains the maximum 2D layered texture dimensions. maxTextureCubemapLayered[2] contains the maximum cubemap layered texture dimensions. maxSurface1D is the maximum 1D surface size. maxSurface2D[2] contains the maximum 2D surface dimensions. maxSurface3D[3] contains the maximum 3D surface dimensions. maxSurface1DLayered[2] contains the maximum 1D layered surface dimensions. maxSurface2DLayered[3] contains the maximum 2D layered surface dimensions. maxSurfaceCubemap is the maximum cubemap surface width or height. maxSurfaceCubemapLayered[2] contains the maximum cubemap layered surface dimensions. surfaceAlignment specifies the alignment requirements for surfaces. concurrentKernels is 1 if the device supports executing multiple kernels within the same context simultaneously, or 0 if not. It is not guaranteed that multiple kernels will be resident on the device concurrently so this feature should not be relied upon for correctness. ECCEnabled is 1 if the device has ECC support turned on, or 0 if not. pciBusID is the PCI bus identifier of the device. pciDeviceID is the PCI device (sometimes called slot) identifier of the device. pciDomainID is the PCI domain identifier of the device. tccDriver is 1 if the device is using a TCC driver or 0 if not. asyncEngineCount is 1 when the device can concurrently copy memory between host and device while executing a kernel. It is 2 when the device can concurrently copy memory between host and device in both directions and execute a kernel at the same time. It is 0 if neither of these is supported. unifiedAddressing is 1 if the device shares a unified address space with the host and 0 otherwise. memoryClockRate is the peak memory clock frequency in kilohertz. memoryBusWidth is the memory bus width in bits. l2CacheSize is L2 cache size in bytes. persistingL2CacheMaxSize is L2 cache's maximum persisting lines size in bytes. maxThreadsPerMultiProcessor is the number of maximum resident threads per multiprocessor. streamPrioritiesSupported is 1 if the device supports stream priorities, or 0 if it is not supported. globalL1CacheSupported is 1 if the device supports caching of globals in L1 cache, or 0 if it is not supported. localL1CacheSupported is 1 if the device supports caching of locals in L1 cache, or 0 if it is not supported. sharedMemPerMultiprocessor is the maximum amount of shared memory available to a multiprocessor in bytes; this amount is shared by all thread blocks simultaneously resident on a multiprocessor. regsPerMultiprocessor is the maximum number of 32-bit registers available to a multiprocessor; this number is shared by all thread blocks simultaneously resident on a multiprocessor. managedMemory is 1 if the device supports allocating managed memory on this system, or 0 if it is not supported. isMultiGpuBoard is 1 if the device is on a multi-GPU board (e.g. Gemini cards), and 0 if not; multiGpuBoardGroupID is a unique identifier for a group of devices associated with the same board. Devices on the same multi-GPU board will share the same identifier. hostNativeAtomicSupported is 1 if the link between the device and the host supports native atomic operations, or 0 if it is not supported. singleToDoublePrecisionPerfRatio is the ratio of single precision performance (in floating-point operations per second) to double precision performance. pageableMemoryAccess is 1 if the device supports coherently accessing pageable memory without calling musaHostRegister on it, and 0 otherwise. concurrentManagedAccess is 1 if the device can coherently access managed memory concurrently with the CPU, and 0 otherwise. computePreemptionSupported is 1 if the device supports Compute Preemption, and 0 otherwise. canUseHostPointerForRegisteredMem is 1 if the device can access host registered memory at the same virtual address as the CPU, and 0 otherwise. cooperativeLaunch is 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernel, and 0 otherwise. cooperativeMultiDeviceLaunch is 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernelMultiDevice, and 0 otherwise. sharedMemPerBlockOptin is the per device maximum shared memory per block usable by special opt in pageableMemoryAccessUsesHostPageTables is 1 if the device accesses pageable memory via the host's page tables, and 0 otherwise. directManagedMemAccessFromHost is 1 if the host can directly access managed memory on the device without migration, and 0 otherwise. maxBlocksPerMultiProcessor is the maximum number of thread blocks that can reside on a multiprocessor. accessPolicyMaxWindowSize is the maximum value of musaAccessPolicyWindow::num_bytes. reservedSharedMemPerBlock is the shared memory reserved by MUSA driver per block in bytes hostRegisterSupported is 1 if the device supports host memory registration via musaHostRegister, and 0 otherwise. sparseMusaArraySupported is 1 if the device supports sparse MUSA arrays and sparse MUSA mipmapped arrays, 0 otherwise hostRegisterReadOnlySupported is 1 if the device supports using the musaHostRegister flag musaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU timelineSemaphoreInteropSupported is 1 if external timeline semaphore interop is supported on the device, 0 otherwise memoryPoolsSupported is 1 if the device supports using the musaMallocAsync and musaMemPool family of APIs, 0 otherwise gpuDirectRDMASupported is 1 if the device supports GPUDirect RDMA APIs, 0 otherwise gpuDirectRDMAFlushWritesOptions is a bitmask to be interpreted according to the musaFlushGPUDirectRDMAWritesOptions enum gpuDirectRDMAWritesOrdering See the musaGPUDirectRDMAWritesOrdering enum for numerical values memoryPoolSupportedHandleTypes is a bitmask of handle types supported with mempool-based IPC deferredMappingMusaArraySupported is 1 if the device supports deferred mapping MUSA arrays and MUSA mipmapped arrays ipcEventSupported is 1 if the device supports IPC Events, and 0 otherwise unifiedFunctionPointers is 1 if the device support unified pointers, and 0 otherwise prop - Properties for the specified device device - Device number to get properties for musaSuccess, musaErrorInvalidDevice This function may also return error codes from previous, asynchronous launches. This call may initialize internal runtime state and may also return initialization-related errors. No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic. musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaDeviceGetAttribute, musaInitDevice, muDeviceGetAttribute, muDeviceGetName
Parameters
prop(struct musaDeviceProp *): Properties for the specified devicedevice(int): Device number to get properties for
Returns
- musaSuccess, musaErrorInvalidDevice
Note
- Additional exported symbol names in scope:
musaGetDeviceProperties_v2. - This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaDeviceGetAttribute, musaInitDevice, muDeviceGetAttribute, muDeviceGetName
musaDeviceGetAttribute
musaError_t musaDeviceGetAttribute(int *value, enum musaDeviceAttr attr, int device)
Description
- Returns information about the device.
- Returns in *value the integer value of the attribute attr on device device. The supported attributes are: musaDevAttrMaxThreadsPerBlock: Maximum number of threads per block musaDevAttrMaxBlockDimX: Maximum x-dimension of a block musaDevAttrMaxBlockDimY: Maximum y-dimension of a block musaDevAttrMaxBlockDimZ: Maximum z-dimension of a block musaDevAttrMaxGridDimX: Maximum x-dimension of a grid musaDevAttrMaxGridDimY: Maximum y-dimension of a grid musaDevAttrMaxGridDimZ: Maximum z-dimension of a grid musaDevAttrMaxSharedMemoryPerBlock: Maximum amount of shared memory available to a thread block in bytes musaDevAttrTotalConstantMemory: Memory available on device for constant variables in a MUSA C kernel in bytes musaDevAttrWarpSize: Warp size in threads musaDevAttrMaxPitch: Maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through musaMallocPitch() musaDevAttrMaxTexture1DWidth: Maximum 1D texture width musaDevAttrMaxTexture1DLinearWidth: Maximum width for a 1D texture bound to linear memory musaDevAttrMaxTexture1DMipmappedWidth: Maximum mipmapped 1D texture width musaDevAttrMaxTexture2DWidth: Maximum 2D texture width musaDevAttrMaxTexture2DHeight: Maximum 2D texture height musaDevAttrMaxTexture2DLinearWidth: Maximum width for a 2D texture bound to linear memory musaDevAttrMaxTexture2DLinearHeight: Maximum height for a 2D texture bound to linear memory musaDevAttrMaxTexture2DLinearPitch: Maximum pitch in bytes for a 2D texture bound to linear memory musaDevAttrMaxTexture2DMipmappedWidth: Maximum mipmapped 2D texture width musaDevAttrMaxTexture2DMipmappedHeight: Maximum mipmapped 2D texture height musaDevAttrMaxTexture3DWidth: Maximum 3D texture width musaDevAttrMaxTexture3DHeight: Maximum 3D texture height musaDevAttrMaxTexture3DDepth: Maximum 3D texture depth musaDevAttrMaxTexture3DWidthAlt: Alternate maximum 3D texture width, 0 if no alternate maximum 3D texture size is supported musaDevAttrMaxTexture3DHeightAlt: Alternate maximum 3D texture height, 0 if no alternate maximum 3D texture size is supported musaDevAttrMaxTexture3DDepthAlt: Alternate maximum 3D texture depth, 0 if no alternate maximum 3D texture size is supported musaDevAttrMaxTextureCubemapWidth: Maximum cubemap texture width or height musaDevAttrMaxTexture1DLayeredWidth: Maximum 1D layered texture width musaDevAttrMaxTexture1DLayeredLayers: Maximum layers in a 1D layered texture musaDevAttrMaxTexture2DLayeredWidth: Maximum 2D layered texture width musaDevAttrMaxTexture2DLayeredHeight: Maximum 2D layered texture height musaDevAttrMaxTexture2DLayeredLayers: Maximum layers in a 2D layered texture musaDevAttrMaxTextureCubemapLayeredWidth: Maximum cubemap layered texture width or height musaDevAttrMaxTextureCubemapLayeredLayers: Maximum layers in a cubemap layered texture musaDevAttrMaxSurface1DWidth: Maximum 1D surface width musaDevAttrMaxSurface2DWidth: Maximum 2D surface width musaDevAttrMaxSurface2DHeight: Maximum 2D surface height musaDevAttrMaxSurface3DWidth: Maximum 3D surface width musaDevAttrMaxSurface3DHeight: Maximum 3D surface height musaDevAttrMaxSurface3DDepth: Maximum 3D surface depth musaDevAttrMaxSurface1DLayeredWidth: Maximum 1D layered surface width musaDevAttrMaxSurface1DLayeredLayers: Maximum layers in a 1D layered surface musaDevAttrMaxSurface2DLayeredWidth: Maximum 2D layered surface width musaDevAttrMaxSurface2DLayeredHeight: Maximum 2D layered surface height musaDevAttrMaxSurface2DLayeredLayers: Maximum layers in a 2D layered surface musaDevAttrMaxSurfaceCubemapWidth: Maximum cubemap surface width musaDevAttrMaxSurfaceCubemapLayeredWidth: Maximum cubemap layered surface width musaDevAttrMaxSurfaceCubemapLayeredLayers: Maximum layers in a cubemap layered surface musaDevAttrMaxRegistersPerBlock: Maximum number of 32-bit registers available to a thread block musaDevAttrClockRate: Peak clock frequency in kilohertz musaDevAttrTextureAlignment: Alignment requirement; texture base addresses aligned to textureAlign bytes do not need an offset applied to texture fetches musaDevAttrTexturePitchAlignment: Pitch alignment requirement for 2D texture references bound to pitched memory musaDevAttrGpuOverlap: 1 if the device can concurrently copy memory between host and device while executing a kernel, or 0 if not musaDevAttrMultiProcessorCount: Number of multiprocessors on the device musaDevAttrKernelExecTimeout: 1 if there is a run time limit for kernels executed on the device, or 0 if not musaDevAttrIntegrated: 1 if the device is integrated with the memory subsystem, or 0 if not musaDevAttrCanMapHostMemory: 1 if the device can map host memory into the MUSA address space, or 0 if not musaDevAttrComputeMode: Compute mode is the compute mode that the device is currently in. Available modes are as follows: musaComputeModeDefault: Default mode - Device is not restricted and multiple threads can use musaSetDevice() with this device. musaComputeModeProhibited: Compute-prohibited mode - No threads can use musaSetDevice() with this device. musaComputeModeExclusiveProcess: Compute-exclusive-process mode - Many threads in one process will be able to use musaSetDevice() with this device. musaDevAttrConcurrentKernels: 1 if the device supports executing multiple kernels within the same context simultaneously, or 0 if not. It is not guaranteed that multiple kernels will be resident on the device concurrently so this feature should not be relied upon for correctness. musaDevAttrEccEnabled: 1 if error correction is enabled on the device, 0 if error correction is disabled or not supported by the device musaDevAttrPciBusId: PCI bus identifier of the device musaDevAttrPciDeviceId: PCI device (also known as slot) identifier of the device musaDevAttrTccDriver: 1 if the device is using a TCC driver. TCC is only available on Tesla hardware running Windows Vista or later. musaDevAttrMemoryClockRate: Peak memory clock frequency in kilohertz musaDevAttrGlobalMemoryBusWidth: Global memory bus width in bits musaDevAttrL2CacheSize: Size of L2 cache in bytes. 0 if the device doesn't have L2 cache. musaDevAttrMaxThreadsPerMultiProcessor: Maximum resident threads per multiprocessor musaDevAttrUnifiedAddressing: 1 if the device shares a unified address space with the host, or 0 if not musaDevAttrComputeCapabilityMajor: Major compute capability version number musaDevAttrComputeCapabilityMinor: Minor compute capability version number musaDevAttrStreamPrioritiesSupported: 1 if the device supports stream priorities, or 0 if not musaDevAttrGlobalL1CacheSupported: 1 if device supports caching globals in L1 cache, 0 if not musaDevAttrLocalL1CacheSupported: 1 if device supports caching locals in L1 cache, 0 if not musaDevAttrMaxSharedMemoryPerMultiprocessor: Maximum amount of shared memory available to a multiprocessor in bytes; this amount is shared by all thread blocks simultaneously resident on a multiprocessor musaDevAttrMaxRegistersPerMultiprocessor: Maximum number of 32-bit registers available to a multiprocessor; this number is shared by all thread blocks simultaneously resident on a multiprocessor musaDevAttrManagedMemory: 1 if device supports allocating managed memory, 0 if not musaDevAttrIsMultiGpuBoard: 1 if device is on a multi-GPU board, 0 if not musaDevAttrMultiGpuBoardGroupID: Unique identifier for a group of devices on the same multi-GPU board musaDevAttrHostNativeAtomicSupported: 1 if the link between the device and the host supports native atomic operations musaDevAttrSingleToDoublePrecisionPerfRatio: Ratio of single precision performance (in floating-point operations per second) to double precision performance musaDevAttrPageableMemoryAccess: 1 if the device supports coherently accessing pageable memory without calling musaHostRegister on it, and 0 otherwise musaDevAttrConcurrentManagedAccess: 1 if the device can coherently access managed memory concurrently with the CPU, and 0 otherwise musaDevAttrComputePreemptionSupported: 1 if the device supports Compute Preemption, 0 if not musaDevAttrCanUseHostPointerForRegisteredMem: 1 if the device can access host registered memory at the same virtual address as the CPU, and 0 otherwise musaDevAttrCooperativeLaunch: 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernel, and 0 otherwise musaDevAttrCooperativeMultiDeviceLaunch: 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernelMultiDevice, and 0 otherwise musaDevAttrCanFlushRemoteWrites: 1 if the device supports flushing of outstanding remote writes, and 0 otherwise musaDevAttrHostRegisterSupported: 1 if the device supports host memory registration via musaHostRegister, and 0 otherwise musaDevAttrPageableMemoryAccessUsesHostPageTables: 1 if the device accesses pageable memory via the host's page tables, and 0 otherwise musaDevAttrDirectManagedMemAccessFromHost: 1 if the host can directly access managed memory on the device without migration, and 0 otherwise musaDevAttrMaxSharedMemoryPerBlockOptin: Maximum per block shared memory size on the device. This value can be opted into when using musaFuncSetAttribute musaDevAttrMaxBlocksPerMultiprocessor: Maximum number of thread blocks that can reside on a multiprocessor musaDevAttrMaxPersistingL2CacheSize: Maximum L2 persisting lines capacity setting in bytes musaDevAttrMaxAccessPolicyWindowSize: Maximum value of musaAccessPolicyWindow::num_bytes musaDevAttrReservedSharedMemoryPerBlock: Shared memory reserved by MUSA driver per block in bytes musaDevAttrSparseMusaArraySupported: 1 if the device supports sparse MUSA arrays and sparse MUSA mipmapped arrays. musaDevAttrHostRegisterReadOnlySupported: Device supports using the musaHostRegister flag musaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU musaDevAttrMemoryPoolsSupported: 1 if the device supports using the musaMallocAsync and musaMemPool family of APIs, and 0 otherwise musaDevAttrGPUDirectRDMASupported: 1 if the device supports GPUDirect RDMA APIs, and 0 otherwise musaDevAttrGPUDirectRDMAFlushWritesOptions: bitmask to be interpreted according to the musaFlushGPUDirectRDMAWritesOptions enum musaDevAttrGPUDirectRDMAWritesOrdering: see the musaGPUDirectRDMAWritesOrdering enum for numerical values musaDevAttrMemoryPoolSupportedHandleTypes: Bitmask of handle types supported with mempool based IPC musaDevAttrDeferredMappingMusaArraySupported : 1 if the device supports deferred mapping MUSA arrays and MUSA mipmapped arrays. musaDevAttrIpcEventSupport: 1 if the device supports IPC Events. musaDevAttrNumaConfig: NUMA configuration of a device: value is of type musaDeviceNumaConfig enum musaDevAttrNumaId: NUMA node ID of the GPU memory musaDevAttrGpuPciDeviceId: The combined 16-bit PCI device ID and 16-bit PCI vendor ID. musaDevAttrGpuPciSubsystemId: The combined 16-bit PCI subsystem ID and 16-bit PCI vendor subsystem ID.
Parameters
value(int *): Returned device attribute valueattr(enum musaDeviceAttr): Device attribute to querydevice(int): Device number to query
Returns
- musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaGetDeviceProperties, musaInitDevice, muDeviceGetAttribute
musaDeviceGetDefaultMemPool
musaError_t musaDeviceGetDefaultMemPool(musaMemPool_t *memPool, int device)
Description
- Queries details about atomic operations supported between the device and host.
- Returns in *capabilities the details about requested atomic *operations over the the link between dev and the host. The allocated size of *operations and *capabilities must be count.
- For each musaAtomicOperation in *operations, the corresponding result in *capabilities will be a bitmask indicating which of musaAtomicOperationCapability the link supports natively.
- Returns musaErrorInvalidDevice if dev is not valid.
- Returns musaErrorInvalidValue if *capabilities or *operations is NULL, if count is 0, or if any of *operations is not valid.
- The default mempool of a device contains device memory from that device.
Parameters
memPool(musaMemPool_t *)device(int)
Returns
- musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue
- musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue musaErrorNotSupported
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaDeviceGetAttribute, musaDeviceGetP2PAtomicCapabilities, muDeviceGeHostAtomicCapabilities
- muDeviceGetDefaultMemPool, musaMallocAsync, musaMemPoolTrimTo, musaMemPoolGetAttribute, musaDeviceSetMemPool, musaMemPoolSetAttribute, musaMemPoolSetAccess
musaDeviceSetMemPool
musaError_t musaDeviceSetMemPool(int device, musaMemPool_t memPool)
Description
- Sets the current memory pool of a device.
- The memory pool must be local to the specified device. Unless a mempool is specified in the musaMallocAsync call, musaMallocAsync allocates from the current mempool of the provided stream's device. By default, a device's current memory pool is its default memory pool.
Parameters
device(int)memPool(musaMemPool_t)
Returns
- musaSuccess, musaErrorInvalidValue musaErrorInvalidDevice musaErrorNotSupported
Note
- Use musaMallocFromPoolAsync to specify asynchronous allocations from a device different than the one the stream runs on.
- This function may also return error codes from previous, asynchronous launches.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- muDeviceSetMemPool, musaDeviceGetMemPool, musaDeviceGetDefaultMemPool, musaMemPoolCreate, musaMemPoolDestroy, musaMallocFromPoolAsync
musaDeviceGetMemPool
musaError_t musaDeviceGetMemPool(musaMemPool_t *memPool, int device)
Description
- Gets the current mempool for a device.
- Returns the last pool provided to musaDeviceSetMemPool for this device or the device's default memory pool if musaDeviceSetMemPool has never been called. By default the current mempool is the default mempool for a device, otherwise the returned pool must have been set with muDeviceSetMemPool or musaDeviceSetMemPool.
Parameters
memPool(musaMemPool_t *)device(int)
Returns
- musaSuccess, musaErrorInvalidValue musaErrorNotSupported
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaMemGetDefaultMemPool
musaError_t musaMemGetDefaultMemPool(musaMemPool_t *memPool, struct musaMemLocation *location, enum musaMemAllocationType type)
Description
- Returns the default memory pool for a given location and allocation type.
- The memory location can be of one of musaMemLocationTypeDevice, musaMemLocationTypeHost or musaMemLocationTypeHostNuma. The allocation type can be one of musaMemAllocationTypePinned or musaMemAllocationTypeManaged. When the allocation type is musaMemAllocationTypeManaged, the location type can also be musaMemLocationTypeNone to indicate no preferred location for the managed memory pool. In all other cases, the call returns musaErrorInvalidValue.
Parameters
memPool(musaMemPool_t *): Returned default memory poollocation(struct musaMemLocation *): Memory location identifying the pooltype(enum musaMemAllocationType): Allocation type identifying the pool
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorNotSupported
Note
- Experimental in the current MUSA SDK 5.2.0 delivery scope.
- This function may also return error codes from previous, asynchronous launches.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- muMemAllocAsync, muMemPoolTrimTo, muMemPoolGetAttribute, muMemPoolSetAttribute, muMemPoolSetAccess, musaMemGetMemPool, musaMemPoolCreate
musaMemGetMemPool
musaError_t musaMemGetMemPool(musaMemPool_t *memPool, struct musaMemLocation *location, enum musaMemAllocationType type)
Description
- Gets the current memory pool for a given memory location and allocation type.
- The memory location can be of one of musaMemLocationTypeDevice, musaMemLocationTypeHost or musaMemLocationTypeHostNuma. The allocation type can be one of musaMemAllocationTypePinned or musaMemAllocationTypeManaged. When the allocation type is musaMemAllocationTypeManaged, the location type can also be musaMemLocationTypeNone to indicate no preferred location for the managed memory pool. In all other cases, the call returns musaErrorInvalidValue.
- Returns the last pool provided to musaMemSetMemPool or musaDeviceSetMemPool for this location and allocation type, or the location's default memory pool if musaMemSetMemPool or musaDeviceSetMemPool for that allocType and location has never been called. By default the current mempool of a location is the default mempool for a device that can be obtained via musaMemGetDefaultMemPool. Otherwise the returned pool must have been set with musaDeviceSetMemPool.
Parameters
memPool(musaMemPool_t *): Returned current memory poollocation(struct musaMemLocation *): Memory location identifying the pooltype(enum musaMemAllocationType): Allocation type identifying the pool
Returns
- musaSuccess, musaErrorInvalidValue
Note
- Experimental in the current MUSA SDK 5.2.0 delivery scope.
- This function may also return error codes from previous, asynchronous launches.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaMemSetMemPool
musaError_t musaMemSetMemPool(struct musaMemLocation *location, enum musaMemAllocationType type, musaMemPool_t memPool)
Description
- Sets the current memory pool for a memory location and allocation type.
- The memory location can be of one of musaMemLocationTypeDevice, musaMemLocationTypeHost or musaMemLocationTypeHostNuma. The allocation type can be one of musaMemAllocationTypePinned or musaMemAllocationTypeManaged. When the allocation type is musaMemAllocationTypeManaged, the location type can also be musaMemLocationTypeNone to indicate no preferred location for the managed memory pool. In all other cases, the call returns musaErrorInvalidValue.
- When a memory pool is set as the current memory pool, the location parameter should be the same as the location of the pool. If the location type or index do not match, the call returns musaErrorInvalidValue. The type of memory pool should also match the parameter type, else the call returns musaErrorInvalidValue. By default, a memory location's current memory pool is its default memory pool. If the location type is musaMemLocationTypeDevice and the allocation type is musaMemAllocationTypePinned, then this API is the equivalent of calling musaDeviceSetMemPool with the location id as the device.
Parameters
location(struct musaMemLocation *): Memory location for which to set the pooltype(enum musaMemAllocationType): Allocation type for which to set the poolmemPool(musaMemPool_t): Memory pool to set as current
Returns
- musaSuccess, musaErrorInvalidValue
Note
- Experimental in the current MUSA SDK 5.2.0 delivery scope.
- Use musaMallocFromPoolAsync to specify asynchronous allocations from a device different than the one the stream runs on.
- This function may also return error codes from previous, asynchronous launches.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- muDeviceGetDefaultMemPool, muDeviceGetMemPool, musaMemGetMemPool, musaMemPoolCreate, musaMemPoolDestroy, musaMallocFromPoolAsync
musaDeviceGetP2PAttribute
musaError_t musaDeviceGetP2PAttribute(int *value, enum musaDeviceP2PAttr attr, int srcDevice, int dstDevice)
Description
- Return MtSciSync attributes that this device can support.
- Returns in mtSciSyncAttrList, the properties of MtSciSync that this MUSA device, dev can support. The returned mtSciSyncAttrList can be used to create an MtSciSync that matches this device's capabilities.
- If MtSciSyncAttrKey_RequiredPerm field in mtSciSyncAttrList is already set this API will return musaErrorInvalidValue.
- The applications should set mtSciSyncAttrList to a valid MtSciSyncAttrList failing which this API will return musaErrorInvalidHandle.
- The flags controls how applications intends to use the MtSciSync created from the mtSciSyncAttrList. The valid flags are: musaMtSciSyncAttrSignal, specifies that the applications intends to signal an MtSciSync on this MUSA device. musaMtSciSyncAttrWait, specifies that the applications intends to wait on an MtSciSync on this MUSA device.
- At least one of these flags must be set, failing which the API returns musaErrorInvalidValue. Both the flags are orthogonal to one another: a developer may set both these flags that allows to set both wait and signal specific attributes in the same mtSciSyncAttrList.
- Note that this API updates the input mtSciSyncAttrList with values equivalent to the following public attribute key-values: MtSciSyncAttrKey_RequiredPerm is set to MtSciSyncAccessPerm_SignalOnly if musaMtSciSyncAttrSignal is set in flags. MtSciSyncAccessPerm_WaitOnly if musaMtSciSyncAttrWait is set in flags. MtSciSyncAccessPerm_WaitSignal if both musaMtSciSyncAttrWait and musaMtSciSyncAttrSignal are set in flags. MtSciSyncAttrKey_PrimitiveInfo is set to MtSciSyncAttrValPrimitiveType_SysmemSemaphore on any valid device. MtSciSyncAttrValPrimitiveType_Syncpoint if device is a Tegra device. MtSciSyncAttrValPrimitiveType_SysmemSemaphorePayload64b if device is GA10X+. MtSciSyncAttrKey_GpuId is set to the same UUID that is returned in musaDeviceProp.uuid from musaDeviceGetProperties for this device.
- Returns in *value the value of the requested attribute attrib of the link between srcDevice and dstDevice. The supported attributes are: musaDevP2PAttrPerformanceRank: A relative value indicating the performance of the link between two devices. Lower value means better performance (0 being the value used for most performant link). musaDevP2PAttrAccessSupported: 1 if peer access is enabled. musaDevP2PAttrNativeAtomicSupported: 1 if native atomic operations over the link are supported. musaDevP2PAttrMusaArrayAccessSupported: 1 if accessing MUSA arrays over the link is supported. musaDevP2PAttrOnlyPartialNativeAtomicSupported: 1 if some MUSA-valid atomic operations over the link are supported. Information about specific operations can be retrieved with musaDeviceGetP2PAtomicCapabilities.
- Returns musaErrorInvalidDevice if srcDevice or dstDevice are not valid or if they represent the same device.
- Returns musaErrorInvalidValue if attrib is not valid or if value is a null pointer.
Parameters
value(int *): Returned value of the requested attributeattr(enum musaDeviceP2PAttr)srcDevice(int): The source device of the target link.dstDevice(int): The destination device of the target link.
Returns
- musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaImportExternalSemaphore, musaDestroyExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync
- musaDeviceEnablePeerAccess, musaDeviceDisablePeerAccess, musaDeviceCanAccessPeer, muDeviceGetP2PAttribute
musaChooseDevice
musaError_t musaChooseDevice(int *device, const struct musaDeviceProp *prop)
Description
- Queries details about atomic operations supported between two devices.
- Returns in *capabilities the details about requested atomic *operations over the the link between srcDevice and dstDevice. The allocated size of *operations and *capabilities must be count.
- For each musaAtomicOperation in *operations, the corresponding result in *capabilities will be a bitmask indicating which of musaAtomicOperationCapability the link supports natively.
- Returns musaErrorInvalidDevice if srcDevice or dstDevice are not valid or if they represent the same device.
- Returns musaErrorInvalidValue if *capabilities or *operations is NULL, if count is 0, or if any of *operations is not valid.
- Returns in *device the device which has properties that best match *prop.
Parameters
device(int *): Device with best matchprop(const struct musaDeviceProp *): Desired device properties
Returns
- musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaDeviceGetP2PAttribute, muDeviceGetP2PAttribute, muDeviceGetP2PAtomicCapabilities
- musaGetDeviceCount, musaGetDevice, musaSetDevice, musaGetDeviceProperties, musaInitDevice
musaInitDevice
musaError_t musaInitDevice(int device, unsigned int deviceFlags, unsigned int flags)
Description
- Initialize device to be used for GPU executions.
- This function will initialize the MUSA Runtime structures and primary context on device when called, but the context will not be made current to device.
- When musaInitDeviceFlagsAreValid is set in flags, deviceFlags are applied to the requested device. The values of deviceFlags match those of the flags parameters in musaSetDeviceFlags. The effect may be verified by musaGetDeviceFlags.
- This function will return an error if the device is in musaComputeModeExclusiveProcess and is occupied by another process or if the device is in musaComputeModeProhibited.
Parameters
device(int): Device on which the runtime will initialize itself.deviceFlags(unsigned int): Parameters for device operation.flags(unsigned int): Flags for controlling the device initialization.
Returns
- musaSuccess, musaErrorInvalidDevice
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaChooseDevice, musaSetDevice muCtxSetCurrent
musaSetDevice
musaError_t musaSetDevice(int device)
Description
- Set device to be used for GPU executions.
- Sets device as the current device for the calling host thread. Valid device id's are 0 to (musaGetDeviceCount() - 1).
- Any device memory subsequently allocated from this host thread using musaMalloc(), musaMallocPitch() or musaMallocArray() will be physically resident on device. Any host memory allocated from this host thread using musaMallocHost() or musaHostAlloc() or musaHostRegister() will have its lifetime associated with device. Any streams or events created from this host thread will be associated with device. Any kernels launched from this host thread using the
<<<>>>operator or musaLaunchKernel() will be executed on device. - This call may be made from any host thread, to any device, and at any time. This function will do no synchronization with the previous or new device, and should only take significant time when it initializes the runtime's context state. This call will bind the primary context of the specified device to the calling thread and all the subsequent memory allocations, stream and event creations, and kernel launches will be associated with the primary context. This function will also immediately initialize the runtime state on the primary context, and the context will be current on device immediately. This function will return an error if the device is in musaComputeModeExclusiveProcess and is occupied by another process or if the device is in musaComputeModeProhibited.
Parameters
device(int): Device on which the active host thread should execute the device code.
Returns
- musaSuccess, musaErrorInvalidDevice, musaErrorDeviceUnavailable
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaChooseDevice, musaInitDevice, muCtxSetCurrent
musaGetDevice
musaError_t musaGetDevice(int *device)
Description
- Returns which device is currently being used.
- Returns in *device the current device for the calling host thread.
Parameters
device(int *): Returns the device on which the active host thread executes the device code.
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorDeviceUnavailable
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaSetDeviceFlags
musaError_t musaSetDeviceFlags(unsigned int flags)
Description
- Set a list of devices that can be used for MUSA.
- Sets a list of devices for MUSA execution in priority order using device_arr. The parameter len specifies the number of elements in the list. MUSA will try devices from the list sequentially until it finds one that works. If this function is not called, or if it is called with a len of 0, then MUSA will go back to its default behavior of trying devices sequentially from a default list containing all of the available MUSA devices in the system. If a specified device ID in the list does not exist, this function will return musaErrorInvalidDevice. If len is not 0 and device_arr is NULL or if len exceeds the number of devices in the system, then musaErrorInvalidValue is returned.
- Records flags as the flags for the current device. If the current device has been set and that device has already been initialized, the previous flags are overwritten. If the current device has not been initialized, it is initialized with the provided flags. If no device has been made current to the calling thread, a default device is selected and initialized with the provided flags.
- The three LSBs of the flags parameter can be used to control how the CPU thread interacts with the OS scheduler when waiting for results from the device.
- musaDeviceScheduleAuto: The default value if the flags parameter is zero, uses a heuristic based on the number of active MUSA contexts in the process C and the number of logical processors in the system P. If C > P, then MUSA will yield to other OS threads when waiting for the device, otherwise MUSA will not yield while waiting for results and actively spin on the processor. Additionally, on Tegra devices, musaDeviceScheduleAuto uses a heuristic based on the power profile of the platform and may choose musaDeviceScheduleBlockingSync for low-powered devices. musaDeviceScheduleSpin: Instruct MUSA to actively spin when waiting for results from the device. This can decrease latency when waiting for the device, but may lower the performance of CPU threads if they are performing work in parallel with the MUSA thread. musaDeviceScheduleYield: Instruct MUSA to yield its thread when waiting for results from the device. This can increase latency when waiting for the device, but can increase the performance of CPU threads performing work in parallel with the device. musaDeviceScheduleBlockingSync: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the device to finish work. musaDeviceBlockingSync: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the device to finish work. Deprecated: This flag was deprecated as of MUSA 4.0 and replaced with musaDeviceScheduleBlockingSync. musaDeviceMapHost: This flag enables allocating pinned host memory that is accessible to the device. It is implicit for the runtime but may be absent if a context is created using the driver API. If this flag is not set, musaHostGetDevicePointer() will always return a failure code. musaDeviceLmemResizeToMax: Instruct MUSA to not reduce local memory after resizing local memory for a kernel. This can prevent thrashing by local memory allocations when launching many kernels with high local memory usage at the cost of potentially increased memory usage. Deprecated: This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled. musaDeviceSyncMemops: Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation in the section titled "API Synchronization behavior" to learn more about cases when synchronous memory operations can exhibit asynchronous behavior.
Parameters
flags(unsigned int): Parameters for device operation
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetDeviceCount, musaSetDevice, musaGetDeviceProperties, musaSetDeviceFlags, musaChooseDevice
- musaGetDeviceFlags, musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaSetDevice, musaSetValidDevices, musaInitDevice, musaChooseDevice, muDevicePrimaryCtxSetFlags
musaGetDeviceFlags
musaError_t musaGetDeviceFlags(unsigned int *flags)
Description
- Gets the flags for the current device.
- Returns in flags the flags for the current device. If there is a current device for the calling thread, the flags for the device are returned. If there is no current device, the flags for the first device are returned, which may be the default flags. Compare to the behavior of musaSetDeviceFlags.
- Typically, the flags returned should match the behavior that will be seen if the calling thread uses a device after this call, without any change to the flags or current device inbetween by this or another thread. Note that if the device is not initialized, it is possible for another thread to change the flags for the current device before it is initialized. Additionally, when using exclusive mode, if this thread has not requested a specific device, it may use a device other than the first device, contrary to the assumption made by this function.
- If a context has been created via the driver API and is current to the calling thread, the flags for that context are always returned.
- Flags returned by this function may specifically include musaDeviceMapHost even though it is not accepted by musaSetDeviceFlags because it is implicit in runtime API flags. The reason for this is that the current context may have been created via the driver API in which case the flag is not implicit and may be unset.
Parameters
flags(unsigned int *): Pointer to store the device flags
Returns
- musaSuccess, musaErrorInvalidDevice
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetDevice, musaGetDeviceProperties, musaSetDevice, musaSetDeviceFlags, musaInitDevice, muCtxGetFlags, muDevicePrimaryCtxGetState
3.3 Device Management [DEPRECATED]
musaDeviceGetSharedMemConfig
musaError_t musaDeviceGetSharedMemConfig(enum musaSharedMemConfig *pConfig)
Description
- Returns the shared memory configuration for the current device.
- Deprecated
- This function will return in pConfig the current size of shared memory banks on the current device. On devices with configurable shared memory banks, musaDeviceSetSharedMemConfig can be used to change this setting, so that all subsequent kernel launches will by default use the new bank size. When musaDeviceGetSharedMemConfig is called on devices without configurable shared memory, it will return the fixed bank size of the hardware.
- The returned bank configurations can be either: musaSharedMemBankSizeFourByte - shared memory bank width is four bytes. musaSharedMemBankSizeEightByte - shared memory bank width is eight bytes.
Parameters
pConfig(enum musaSharedMemConfig *): Returned cache configuration
Returns
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaDeviceSetSharedMemConfig, musaFuncSetCacheConfig, muCtxGetSharedMemConfig
musaDeviceSetSharedMemConfig
musaError_t musaDeviceSetSharedMemConfig(enum musaSharedMemConfig config)
Description
- Sets the shared memory configuration for the current device.
- Deprecated
- On devices with configurable shared memory banks, this function will set the shared memory bank size which is used for all subsequent kernel launches. Any per-function setting of shared memory set via musaFuncSetSharedMemConfig will override the device wide setting.
- Changing the shared memory configuration between launches may introduce a device side synchronization point.
- Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what kinds of accesses to shared memory will result in bank conflicts.
- This function will do nothing on devices with fixed shared memory bank size.
- The supported bank configurations are: musaSharedMemBankSizeDefault: set bank width the device default (currently, four bytes) musaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively. musaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively.
Parameters
config(enum musaSharedMemConfig): Requested cache configuration
Returns
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaDeviceGetSharedMemConfig, musaFuncSetCacheConfig, muCtxSetSharedMemConfig
3.4 Thread Management [DEPRECATED]
musaThreadExit
musaError_t musaThreadExit(void)
Description
- Exit and clean up from MUSA launches.
- Deprecated
- Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceReset(), which should be used instead.
- Explicitly destroys all cleans up all resources associated with the current device in the current process. Any subsequent API call to this device will reinitialize the device.
- Note that this function will reset the device immediately. It is the caller's responsibility to ensure that the device is not being accessed by any other host threads from the process when this function is called.
Parameters
(unnamed)(void)
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaThreadSynchronize
musaError_t musaThreadSynchronize(void)
Description
- Wait for compute device to finish.
- Deprecated
- Note that this function is deprecated because its name does not reflect its behavior. Its functionality is similar to the non-deprecated function musaDeviceSynchronize(), which should be used instead.
- Blocks until the device has completed all preceding requested tasks. musaThreadSynchronize() returns an error if one of the preceding tasks has failed. If the musaDeviceScheduleBlockingSync flag was set for this device, the host thread will block until the device has finished its work.
Parameters
(unnamed)(void)
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaThreadSetLimit
musaError_t musaThreadSetLimit(enum musaLimit limit, size_t value)
Description
- Set resource limits.
- Deprecated
- Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceSetLimit(), which should be used instead.
- Setting limit to value is a request by the application to update the current limit maintained by the device. The driver is free to modify the requested value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size, etc). The application can use musaThreadGetLimit() to find out exactly what the limit has been set to.
- Setting each musaLimit has its own specific restrictions, so each is discussed here.
- musaLimitStackSize controls the stack size of each GPU thread. musaLimitPrintfFifoSize controls the size of the shared FIFO used by the printf() device system call. Setting musaLimitPrintfFifoSize must be performed before launching any kernel that uses the printf() device system call, otherwise musaErrorInvalidValue will be returned. musaLimitMallocHeapSize controls the size of the heap used by the malloc() and free() device system calls. Setting musaLimitMallocHeapSize must be performed before launching any kernel that uses the malloc() or free() device system calls, otherwise musaErrorInvalidValue will be returned.
Parameters
limit(enum musaLimit): Limit to setvalue(size_t): Size in bytes of limit
Returns
- musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaThreadGetLimit
musaError_t musaThreadGetLimit(size_t *pValue, enum musaLimit limit)
Description
- Returns resource limits.
- Deprecated
- Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceGetLimit(), which should be used instead.
- Returns in *pValue the current size of limit. The supported musaLimit values are: musaLimitStackSize: stack size of each GPU thread; musaLimitPrintfFifoSize: size of the shared FIFO used by the printf() device system call. musaLimitMallocHeapSize: size of the heap used by the malloc() and free() device system calls;
Parameters
pValue(size_t *): Returned size in bytes of limitlimit(enum musaLimit): Limit to query
Returns
- musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaThreadGetCacheConfig
musaError_t musaThreadGetCacheConfig(enum musaFuncCache *pCacheConfig)
Description
- Returns the preferred cache configuration for the current device.
- Deprecated
- Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceGetCacheConfig(), which should be used instead.
- On devices where the L1 cache and shared memory use the same hardware resources, this returns through pCacheConfig the preferred cache configuration for the current device. 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 functions.
- This will return a pCacheConfig of musaFuncCachePreferNone on devices where the size of the L1 cache and shared memory are fixed.
- The supported cache configurations are: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory
Parameters
pCacheConfig(enum musaFuncCache *): Returned cache configuration
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
musaThreadSetCacheConfig
musaError_t musaThreadSetCacheConfig(enum musaFuncCache cacheConfig)
Description
- Sets the preferred cache configuration for the current device.
- Deprecated
- Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceSetCacheConfig(), which should be used instead.
- On devices where the L1 cache and shared memory use the same hardware resources, this sets through cacheConfig the preferred cache configuration for the current device. 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 the function. Any function preference set via musaFuncSetCacheConfig (C API) or musaFuncSetCacheConfig (C++ API) will be preferred over this device-wide setting. Setting the device-wide cache configuration to musaFuncCachePreferNone will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel.
- 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: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory
Parameters
cacheConfig(enum musaFuncCache): Requested cache configuration
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
3.5 Error Handling
musaGetLastError
musaError_t musaGetLastError(void)
Description
- Returns the last error from a runtime call.
- Returns the last error that has been produced by any of the runtime calls in the same instance of the MUSA Runtime library in the host thread and resets it to musaSuccess.
- Note: Multiple instances of the MUSA Runtime library can be present in an application when using a library that statically links the MUSA Runtime.
Parameters
(unnamed)(void)
Returns
- musaSuccess, musaErrorMissingConfiguration, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidSymbol, musaErrorUnmapBufferObjectFailed, musaErrorInvalidDevicePointer, musaErrorInvalidTexture, musaErrorInvalidTextureBinding, musaErrorInvalidChannelDescriptor, musaErrorInvalidMemcpyDirection, musaErrorInvalidFilterSetting, musaErrorInvalidNormSetting, musaErrorUnknown, musaErrorInvalidResourceHandle, musaErrorInsufficientDriver, musaErrorNoDevice, musaErrorSetOnActiveProcess, musaErrorStartupFailure, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaPeekAtLastError, musaGetErrorName, musaGetErrorString, musaError
musaPeekAtLastError
musaError_t musaPeekAtLastError(void)
Description
- Returns the last error from a runtime call.
- Returns the last error that has been produced by any of the runtime calls in the same instance of the MUSA Runtime library in the host thread. This call does not reset the error to musaSuccess like musaGetLastError().
- Note: Multiple instances of the MUSA Runtime library can be present in an application when using a library that statically links the MUSA Runtime.
Parameters
(unnamed)(void)
Returns
- musaSuccess, musaErrorMissingConfiguration, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidSymbol, musaErrorUnmapBufferObjectFailed, musaErrorInvalidDevicePointer, musaErrorInvalidTexture, musaErrorInvalidTextureBinding, musaErrorInvalidChannelDescriptor, musaErrorInvalidMemcpyDirection, musaErrorInvalidFilterSetting, musaErrorInvalidNormSetting, musaErrorUnknown, musaErrorInvalidResourceHandle, musaErrorInsufficientDriver, musaErrorNoDevice, musaErrorSetOnActiveProcess, musaErrorStartupFailure, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaGetLastError, musaGetErrorName, musaGetErrorString, musaError
musaGetErrorName
const char* musaGetErrorName(musaError_t error)
Description
- Returns the string representation of an error code enum name.
- Returns a string containing the name of an error code in the enum. If the error code is not recognized, "unrecognized error code" is returned.
Parameters
error(musaError_t): Error code to convert to string
Returns
- char* pointer to a NULL-terminated string
See also
- musaGetErrorString, musaGetLastError, musaPeekAtLastError, musaError, muGetErrorName
musaGetErrorString
const char* musaGetErrorString(musaError_t error)
Description
- Returns the description string for an error code.
- Returns the description string for an error code. If the error code is not recognized, "unrecognized error code" is returned.
Parameters
error(musaError_t): Error code to convert to string
Returns
- char* pointer to a NULL-terminated string
See also
- musaGetErrorName, musaGetLastError, musaPeekAtLastError, musaError, muGetErrorString
3.6 Stream Management
musaStreamCreate
musaError_t musaStreamCreate(musaStream_t *pStream)
Description
- Create an asynchronous stream.
- Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it.
Parameters
pStream(musaStream_t *): Pointer to new stream identifier
Returns
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetFlags, musaStreamGetDevice, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamAddCallback, musaSetDevice, musaStreamDestroy, muStreamCreate
musaStreamCreateWithFlags
musaError_t musaStreamCreateWithFlags(musaStream_t *pStream, unsigned int flags)
Description
- Create an asynchronous stream.
- Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. The flags argument determines the behaviors of the stream. Valid values for flags are musaStreamDefault: Default stream creation flag. musaStreamNonBlocking: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that the created stream should perform no implicit synchronization with stream 0.
Parameters
pStream(musaStream_t *): Pointer to new stream identifierflags(unsigned int): Parameters for stream creation
Returns
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaStreamCreate, musaStreamCreateWithPriority, musaStreamGetFlags, musaStreamGetDevice, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamAddCallback, musaSetDevice, musaStreamDestroy, muStreamCreate
musaStreamCreateWithPriority
musaError_t musaStreamCreateWithPriority(musaStream_t *pStream, unsigned int flags, int priority)
Description
- Create an asynchronous stream with the specified priority.
- Creates a stream with the specified priority and returns a handle in pStream. The stream is created on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. This affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially run work with higher priority when possible, but do not preempt already-running work or provide any other functional guarantee on execution order.
- priority follows a convention where lower numbers represent higher priorities. '0' represents default priority. The range of meaningful numerical priorities can be queried using musaDeviceGetStreamPriorityRange. If the specified priority is outside the numerical range returned by musaDeviceGetStreamPriorityRange, it will automatically be clamped to the lowest or the highest number in the range.
Parameters
pStream(musaStream_t *): Pointer to new stream identifierflags(unsigned int): Flags for stream creation. See musaStreamCreateWithFlags for a list of valid flags that can be passedpriority(int): Priority of the stream. Lower numbers represent higher priorities. See musaDeviceGetStreamPriorityRange for more information about the meaningful stream priorities that can be passed.
Returns
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- Stream priorities are supported only on GPUs with compute capability 3.5 or higher.
- In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream priorities have no effect on host-to-device and device-to-host memory operations.
See also
- musaStreamCreate, musaStreamCreateWithFlags, musaDeviceGetStreamPriorityRange, musaStreamGetPriority, musaStreamQuery, musaStreamWaitEvent, musaStreamAddCallback, musaStreamSynchronize, musaSetDevice, musaStreamDestroy, muStreamCreateWithPriority
musaStreamGetPriority
musaError_t musaStreamGetPriority(musaStream_t hStream, int *priority)
Description
- Query the priority of a stream.
- Query the priority of a stream. The priority is returned in in priority. Note that if the stream was created with a priority outside the meaningful numerical range returned by musaDeviceGetStreamPriorityRange, this function returns the clamped priority. See musaStreamCreateWithPriority for details about priority clamping.
Parameters
hStream(musaStream_t): Handle to the stream to be queriedpriority(int *): Pointer to a signed integer in which the stream's priority is returned
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaStreamCreateWithPriority, musaDeviceGetStreamPriorityRange, musaStreamGetFlags, musaStreamGetDevice, muStreamGetPriority
musaStreamGetFlags
musaError_t musaStreamGetFlags(musaStream_t hStream, unsigned int *flags)
Description
- Query the flags of a stream.
- Query the flags of a stream. The flags are returned in flags. See musaStreamCreateWithFlags for a list of valid flags.
Parameters
hStream(musaStream_t): Handle to the stream to be queriedflags(unsigned int *): Pointer to an unsigned integer in which the stream's flags are returned
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- See the default-stream note for NULL stream semantics.
See also
- musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetDevice, muStreamGetFlags
musaStreamGetId
musaError_t musaStreamGetId(musaStream_t hStream, unsigned long long *streamId)
Description
- Query the Id of a stream.
- Query the Id of a stream. The Id is returned in streamId. The Id is unique for the life of the program.
- The stream handle hStream can refer to any of the following: a stream created via any of the MUSA runtime APIs such as musaStreamCreate, musaStreamCreateWithFlags and musaStreamCreateWithPriority, or their driver API equivalents such as muStreamCreate or muStreamCreateWithPriority. Passing an invalid handle will result in undefined behavior. any of the special streams such as the NULL stream, musaStreamLegacy and musaStreamPerThread respectively. The driver API equivalents of these are also accepted which are NULL, MU_STREAM_LEGACY and MU_STREAM_PER_THREAD.
Parameters
hStream(musaStream_t): Handle to the stream to be queriedstreamId(unsigned long long *): Pointer to an unsigned long long in which the stream Id is returned
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- See the default-stream note for NULL stream semantics.
See also
- musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetFlags, muStreamGetId
musaStreamGetDevice
musaError_t musaStreamGetDevice(musaStream_t hStream, int *device)
Description
- Query the device of a stream.
- Returns in *device the device of the stream.
Parameters
hStream(musaStream_t): Handle to the stream to be querieddevice(int *): Returns the device to which the stream belongs
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorDeviceUnavailable
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- See the default-stream note for NULL stream semantics.
See also
- musaSetDevice, musaGetDevice, musaStreamCreate, musaStreamGetPriority, musaStreamGetFlags, muStreamGetId
musaCtxResetPersistingL2Cache
musaError_t musaCtxResetPersistingL2Cache(void)
Description
- Resets all persisting lines in cache to normal status.
- Resets all persisting lines in cache to normal status. Takes effect on function return.
Parameters
(unnamed)(void)
Returns
- musaSuccess
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- musaAccessPolicyWindow
musaStreamCopyAttributes
musaError_t musaStreamCopyAttributes(musaStream_t dst, musaStream_t src)
Description
- Copies attributes from source stream to destination stream.
- Copies attributes from source stream src to destination stream dst. Both streams must have the same context.
Parameters
dst(musaStream_t): Destination streamsrc(musaStream_t): Source stream For attributes see musaStreamAttrID
Returns
- musaSuccess, musaErrorNotSupported
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- musaAccessPolicyWindow
musaStreamGetAttribute
musaError_t musaStreamGetAttribute(musaStream_t hStream, musaStreamAttrID attr, musaStreamAttrValue *value_out)
Description
- Queries stream attribute.
- Queries attribute attr from hStream and stores it in corresponding member of value_out.
Parameters
hStream(musaStream_t)attr(musaStreamAttrID)value_out(musaStreamAttrValue *)
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- musaAccessPolicyWindow
musaStreamSetAttribute
musaError_t musaStreamSetAttribute(musaStream_t hStream, musaStreamAttrID attr, const musaStreamAttrValue *value)
Description
- Sets stream attribute.
- Sets attribute attr on hStream from corresponding attribute of value. The updated attribute will be applied to subsequent work submitted to the stream. It will not affect previously submitted work.
Parameters
hStream(musaStream_t)attr(musaStreamAttrID)value(const musaStreamAttrValue *)
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- musaAccessPolicyWindow
musaStreamDestroy
musaError_t musaStreamDestroy(musaStream_t stream)
Description
- Destroys and cleans up an asynchronous stream.
- Destroys and cleans up the asynchronous stream specified by stream.
- In case the device is still doing work in the stream stream when musaStreamDestroy() is called, the function will return immediately and the resources associated with stream will be released automatically once the device has completed all work in stream.
Parameters
stream(musaStream_t): Stream identifier
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- Destroying the target object while work is still pending results in undefined behavior.
- See the default-stream note for NULL stream semantics.
See also
- musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, muStreamDestroy
musaStreamWaitEvent
musaError_t musaStreamWaitEvent(musaStream_t stream, musaEvent_t event, unsigned int flags)
Description
- Make a compute stream wait on an event.
- Makes all future work submitted to stream wait for all work captured in event. See musaEventRecord() for details on what is captured by an event. The synchronization will be performed efficiently on the device when applicable. event may be from a different device than stream.
- flags include: musaEventWaitDefault: Default event creation flag. musaEventWaitExternal: Event is captured in the graph as an external event node when performing stream capture.
Parameters
stream(musaStream_t): Stream to waitevent(musaEvent_t): Event to wait onflags(unsigned int): Parameters for the operation(See above)
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- See the default-stream note for NULL stream semantics.
See also
- musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, muStreamWaitEvent
musaStreamAddCallback
musaError_t musaStreamAddCallback(musaStream_t stream, musaStreamCallback_t callback, void *userData, unsigned int flags)
Description
- Add a callback to a compute stream.
- The callback may be passed musaSuccess or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate musaError_t.
- Callbacks must not make any MUSA API calls. Attempting to use MUSA APIs may result in musaErrorNotPermitted. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized.
- For the purposes of Unified Memory, callback execution makes a number of guarantees: The callback stream is considered idle for the duration of the callback. Thus, for example, a callback may always use memory attached to the callback stream. The start of execution of a callback has the same effect as synchronizing an event recorded in the same stream immediately prior to the callback. It thus synchronizes streams which have been "joined" prior to the callback. Adding device work to any stream does not have the effect of making the stream active until all preceding callbacks have executed. Thus, for example, a callback might use global attached memory even if work has been added to another stream, if it has been properly ordered with an event. Completion of a callback does not cause a stream to become active except as described above. The callback stream will remain idle if no device work follows the callback, and will remain idle across consecutive callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a callback at the end of the stream.
Parameters
stream(musaStream_t): Stream to add callback tocallback(musaStreamCallback_t): The function to call once preceding stream operations are completeuserData(void *): User specified data to be passed to the callback functionflags(unsigned int): Reserved for future use, must be 0
Returns
- musaSuccess, musaErrorInvalidResourceHandle, musaErrorInvalidValue, musaErrorNotSupported
Note
- This function is slated for eventual deprecation and removal. If you do not require the callback to execute in case of a device error, consider using musaLaunchHostFunc. Additionally, this function is not supported with musaStreamBeginCapture and musaStreamEndCapture, unlike musaLaunchHostFunc.
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- See the default-stream note for NULL stream semantics.
See also
- musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamDestroy, musaMallocManaged, musaStreamAttachMemAsync, musaLaunchHostFunc, muStreamAddCallback
musaStreamSynchronize
musaError_t musaStreamSynchronize(musaStream_t stream)
Description
- Waits for stream tasks to complete.
- Blocks until stream has completed all operations. If the musaDeviceScheduleBlockingSync flag was set for this device, the host thread will block until the stream is finished with all of its tasks.
Parameters
stream(musaStream_t): Stream identifier
Returns
- musaSuccess, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- See the default-stream note for NULL stream semantics.
See also
- musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamWaitEvent, musaStreamAddCallback, musaStreamDestroy, muStreamSynchronize
musaStreamQuery
musaError_t musaStreamQuery(musaStream_t stream)
Description
- Queries an asynchronous stream for completion status.
- Returns musaSuccess if all operations in stream have completed, or musaErrorNotReady if not.
- For the purposes of Unified Memory, a return value of musaSuccess is equivalent to having called musaStreamSynchronize().
Parameters
stream(musaStream_t): Stream identifier
Returns
- musaSuccess, musaErrorNotReady, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
- See the default-stream note for NULL stream semantics.
See also
- musaStreamCreate, musaStreamCreateWithFlags, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, muStreamQuery
musaStreamAttachMemAsync
musaError_t musaStreamAttachMemAsync(musaStream_t stream, void *devPtr, size_t length, unsigned int flags)
Description
- 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 dependent 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 musaMallocManaged. 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 musaDevAttrPageableMemoryAccess.
- 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.
- For pageable allocations, length must be non-zero.
- The stream association is specified using flags which must be one of musaMemAttachGlobal, musaMemAttachHost or musaMemAttachSingle. The default value for flags is musaMemAttachSingle If the musaMemAttachGlobal flag is specified, the memory can be accessed by any stream on any device. If the musaMemAttachHost 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 musaDevAttrConcurrentManagedAccess. If the musaMemAttachSingle flag is specified and stream is associated with a device that has a zero value for the device attribute musaDevAttrConcurrentManagedAccess, 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 undefined 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 musaStreamAttachMemAsync via events, synchronization or other means to ensure legal access to memory at all times. Data visibility and coherency 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 association reverts to the default visibility of the allocation as specified at musaMallocManaged. For managed variables, the default association is always musaMemAttachGlobal. Note that destroying 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.
Parameters
stream(musaStream_t): Stream in which to enqueue the attach operationdevPtr(void *): Pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated memory)length(size_t): Length of memory (defaults to zero)flags(unsigned int): Must be one of musaMemAttachGlobal, musaMemAttachHost or musaMemAttachSingle (defaults to musaMemAttachSingle)
Returns
- musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaStreamCreate, musaStreamCreateWithFlags, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, musaMallocManaged, muStreamAttachMemAsync
musaStreamBeginCapture
musaError_t musaStreamBeginCapture(musaStream_t stream, enum musaStreamCaptureMode mode)
Description
- Begins graph capture on a stream.
- Begin graph capture on stream. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into a graph, which will be returned via musaStreamEndCapture. Capture may not be initiated if stream is musaStreamLegacy. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode. The capture mode may be queried via musaStreamIsCapturing. A unique id representing the capture sequence may be queried via musaStreamGetCaptureInfo.
- If mode is not musaStreamCaptureModeRelaxed, musaStreamEndCapture must be called on this stream from the same thread.
Parameters
stream(musaStream_t): Stream in which to initiate capturemode(enum musaStreamCaptureMode): Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see musaThreadExchangeStreamCaptureMode.
Returns
- musaSuccess, musaErrorInvalidValue
Note
- Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
- This function may also return error codes from previous, asynchronous launches.
See also
musaStreamBeginCaptureToGraph
musaError_t musaStreamBeginCaptureToGraph(musaStream_t stream, musaGraph_t graph, const musaGraphNode_t *dependencies, const musaGraphEdgeData *dependencyData, size_t numDependencies, enum musaStreamCaptureMode mode)
Description
- Begins graph capture on a stream to an existing graph.
- Begin graph capture on stream. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into graph, which will be returned via musaStreamEndCapture.
- Capture may not be initiated if stream is musaStreamLegacy. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode. The capture mode may be queried via musaStreamIsCapturing. A unique id representing the capture sequence may be queried via musaStreamGetCaptureInfo.
- If mode is not musaStreamCaptureModeRelaxed, musaStreamEndCapture must be called on this stream from the same thread.
Parameters
stream(musaStream_t): Stream in which to initiate capture.graph(musaGraph_t): Graph to capture into.dependencies(const musaGraphNode_t *): Dependencies of the first node captured in the stream. Can be NULL if numDependencies is 0.dependencyData(const musaGraphEdgeData *): Optional array of data associated with each dependency.numDependencies(size_t): Number of dependencies.mode(enum musaStreamCaptureMode): Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see musaThreadExchangeStreamCaptureMode.
Returns
- musaSuccess, musaErrorInvalidValue
Note
- Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
- This function may also return error codes from previous, asynchronous launches.
See also
musaThreadExchangeStreamCaptureMode
musaError_t musaThreadExchangeStreamCaptureMode(enum musaStreamCaptureMode *mode)
Description
- Swaps the stream capture interaction mode for a thread.
- Sets the calling thread's stream capture interaction mode to the value contained in *mode, and overwrites *mode with the previous mode for the thread. To facilitate deterministic behavior across function or module boundaries, callers are encouraged to use this API in a push-pop fashion:musaStreamCaptureModemode=desiredMode; musaThreadExchangeStreamCaptureMode(&mode); ... musaThreadExchangeStreamCaptureMode(&mode);//restorepreviousmode
- During stream capture (see musaStreamBeginCapture), some actions, such as a call to musaMalloc, may be unsafe. In the case of musaMalloc, the operation is not enqueued asynchronously to a stream, and is not observed by stream capture. Therefore, if the sequence of operations captured via musaStreamBeginCapture depended on the allocation being replayed whenever the graph is launched, the captured graph would be invalid.
- Therefore, stream capture places restrictions on API calls that can be made within or concurrently to a musaStreamBeginCapture-musaStreamEndCapture sequence. This behavior can be controlled via this API and flags to musaStreamBeginCapture.
- A thread's mode is one of the following: musaStreamCaptureModeGlobal: This is the default mode. If the local thread has an ongoing capture sequence that was not initiated with musaStreamCaptureModeRelaxed at muStreamBeginCapture, or if any other thread has a concurrent capture sequence initiated with musaStreamCaptureModeGlobal, this thread is prohibited from potentially unsafe API calls. musaStreamCaptureModeThreadLocal: If the local thread has an ongoing capture sequence not initiated with musaStreamCaptureModeRelaxed, it is prohibited from potentially unsafe API calls. Concurrent capture sequences in other threads are ignored. musaStreamCaptureModeRelaxed: The local thread is not prohibited from potentially unsafe API calls. Note that the thread is still prohibited from API calls which necessarily conflict with stream capture, for example, attempting musaEventQuery on an event that was last recorded inside a capture sequence.
Parameters
mode(enum musaStreamCaptureMode *): Pointer to mode value to swap with the current mode
Returns
- musaSuccess, musaErrorInvalidValue
Note
- This function may also return error codes from previous, asynchronous launches.
See also
musaStreamEndCapture
musaError_t musaStreamEndCapture(musaStream_t stream, musaGraph_t *pGraph)
Description
- Ends capture on a stream, returning the captured graph.
- End capture on stream, returning the captured graph via pGraph. Capture must have been initiated on stream via a call to musaStreamBeginCapture. If capture was invalidated, due to a violation of the rules of stream capture, then a NULL graph will be returned.
- If the mode argument to musaStreamBeginCapture was not musaStreamCaptureModeRelaxed, this call must be from the same thread as musaStreamBeginCapture.
Parameters
stream(musaStream_t): Stream to querypGraph(musaGraph_t *): The captured graph
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureWrongThread
Note
- This function may also return error codes from previous, asynchronous launches.
See also
musaStreamIsCapturing
musaError_t musaStreamIsCapturing(musaStream_t stream, enum musaStreamCaptureStatus *pCaptureStatus)
Description
- Returns a stream's capture status.
- Return the capture status of stream via pCaptureStatus. After a successful call, *pCaptureStatus will contain one of the following: musaStreamCaptureStatusNone: The stream is not capturing. musaStreamCaptureStatusActive: The stream is capturing. musaStreamCaptureStatusInvalidated: The stream was capturing but an error has invalidated the capture sequence. The capture sequence must be terminated with musaStreamEndCapture on the stream where it was initiated in order to continue using stream.
- Note that, if this is called on musaStreamLegacy (the "null stream") while a blocking stream on the same device is capturing, it will return musaErrorStreamCaptureImplicit and *pCaptureStatus is unspecified after the call. The blocking stream capture is not invalidated.
- When a blocking stream is capturing, the legacy stream is in an unusable state until the blocking stream capture is terminated. The legacy stream is not supported for stream capture, but attempted use would have an implicit dependency on the capturing stream(s).
Parameters
stream(musaStream_t): Stream to querypCaptureStatus(enum musaStreamCaptureStatus *): Returns the stream's capture status
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit
Note
- This function may also return error codes from previous, asynchronous launches.
See also
musaStreamGetCaptureInfo
musaError_t musaStreamGetCaptureInfo(musaStream_t stream, enum musaStreamCaptureStatus *captureStatus_out, unsigned long long *id_out, musaGraph_t *graph_out, const musaGraphNode_t **dependencies_out, size_t *numDependencies_out)
Description
- Query a stream's capture state.
- Query stream state related to stream capture.
- If called on musaStreamLegacy (the "null stream") while a stream not created with musaStreamNonBlocking is capturing, returns musaErrorStreamCaptureImplicit.
- Valid data (other than capture status) is returned only if both of the following are true: the call returns musaSuccess the returned capture status is musaStreamCaptureStatusActive
Parameters
stream(musaStream_t): The stream to querycaptureStatus_out(enum musaStreamCaptureStatus *): Location to return the capture status of the stream; requiredid_out(unsigned long long *): Optional location to return an id for the capture sequence, which is unique over the lifetime of the processgraph_out(musaGraph_t *): Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred or destroyed at musaStreamEndCapture. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable from the original stream at musaStreamEndCapture due to direct actions on the graph do not trigger musaErrorStreamCaptureUnjoined.dependencies_out(const musaGraphNode_t **): Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream) without copying.numDependencies_out(size_t *): Optional location to store the size of the array returned in dependencies_out.
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit
Note
- Additional exported symbol names in scope:
musaStreamGetCaptureInfo_v2. - This function may also return error codes from previous, asynchronous launches.
- Graph objects are not thread-safe.
See also
- musaStreamGetCaptureInfo_v3, musaStreamBeginCapture, musaStreamIsCapturing, musaStreamUpdateCaptureDependencies
musaStreamGetCaptureInfo_v3
musaError_t musaStreamGetCaptureInfo_v3(musaStream_t stream, enum musaStreamCaptureStatus *captureStatus_out, unsigned long long *id_out, musaGraph_t *graph_out, const musaGraphNode_t **dependencies_out, const musaGraphEdgeData **edgeData_out, size_t *numDependencies_out)
Description
- Query a stream's capture state (12.3+)
- Query stream state related to stream capture.
- If called on musaStreamLegacy (the "null stream") while a stream not created with musaStreamNonBlocking is capturing, returns musaErrorStreamCaptureImplicit.
- Valid data (other than capture status) is returned only if both of the following are true: the call returns musaSuccess the returned capture status is musaStreamCaptureStatusActive
- If edgeData_out is non-NULL then dependencies_out must be as well. If dependencies_out is non-NULL and edgeData_out is NULL, but there is non-zero edge data for one or more of the current stream dependencies, the call will return musaErrorLossyQuery.
Parameters
stream(musaStream_t): The stream to querycaptureStatus_out(enum musaStreamCaptureStatus *): Location to return the capture status of the stream; requiredid_out(unsigned long long *): Optional location to return an id for the capture sequence, which is unique over the lifetime of the processgraph_out(musaGraph_t *): Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred or destroyed at musaStreamEndCapture. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable from the original stream at musaStreamEndCapture due to direct actions on the graph do not trigger musaErrorStreamCaptureUnjoined.dependencies_out(const musaGraphNode_t **): Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream) without copying.edgeData_out(const musaGraphEdgeData **): Optional location to store a pointer to an array of graph edge data. This array parallels dependencies_out; the next node to be added has an edge to dependencies_out[i] with annotation edgeData_out[i] for each i. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated.numDependencies_out(size_t *): Optional location to store the size of the array returned in dependencies_out.
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit, musaErrorLossyQuery
Note
- This function may also return error codes from previous, asynchronous launches.
- Graph objects are not thread-safe.
See also
musaStreamUpdateCaptureDependencies
musaError_t musaStreamUpdateCaptureDependencies(musaStream_t stream, musaGraphNode_t *dependencies, size_t numDependencies, unsigned int flags)
Description
- Update the set of dependencies in a capturing stream (11.3+)
- Modifies the dependency set of a capturing stream. The dependency set is the set of nodes that the next captured node in the stream will depend on.
- Valid flags are musaStreamAddCaptureDependencies and musaStreamSetCaptureDependencies. These control whether the set passed to the API is added to the existing set or replaces it. A flags value of 0 defaults to musaStreamAddCaptureDependencies.
- Nodes that are removed from the dependency set via this API do not result in musaErrorStreamCaptureUnjoined if they are unreachable from the stream at musaStreamEndCapture.
- Returns musaErrorIllegalState if the stream is not capturing.
- This API is new in MUSA 11.3. Developers requiring compatibility across minor versions of the MUSA driver to 11.0 should not use this API or provide a fallback.
Parameters
stream(musaStream_t): The stream to updatedependencies(musaGraphNode_t *): The set of dependencies to addnumDependencies(size_t): The size of the dependencies arrayflags(unsigned int): See above
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorIllegalState
Note
- This function may also return error codes from previous, asynchronous launches.
See also
3.7 Event Management
musaEventCreate
musaError_t musaEventCreate(musaEvent_t *event)
Description
- Creates an event object.
- Creates an event object for the current device using musaEventDefault.
Parameters
event(musaEvent_t *): Newly created event
Returns
- musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure, musaErrorMemoryAllocation
Note
- This function may also return error codes from previous, asynchronous launches.
- This call may initialize internal runtime state and may also return initialization-related errors.
- No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.
See also
- musaEventCreate (C++ API), musaEventCreateWithFlags, musaEventRecord, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, muEventCreate