MUSA Driver API Reference
1. Introduction
The MUSA Driver API is the low-level mu* interface for applications and libraries that need direct control over devices, contexts, modules, memory, streams, events, graphs, and interoperability objects.
This reference describes the MUSA Driver APIs supported in MUSA SDK 5.2.0. Use it as the compatibility reference for the functions, types, structures, fields, constants, and result values documented here.
Note: Some Driver 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 Driver API
Start with the Runtime API when you want the application-level musa* interface. Use this Driver reference when you need lower-level mu* control, or when a Runtime entry points to a Driver-level object or equivalent.
Driver API use depends on initialization and context state. Review Initialization, Primary Context Management, and Context Management before allocating memory, loading modules, launching work, or sharing resources across 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 Driver version checks and Driver Entry Point Access to resolve Driver symbols dynamically.
3. Modules
The API reference is organized by capability module.
Module List
- 3.1 Error Handling
- 3.2 Initialization
- 3.3 Version Management
- 3.4 Device Management
- 3.5 Device Management [DEPRECATED]
- 3.6 Primary Context Management
- 3.7 Context Management
- 3.8 Context Management [DEPRECATED]
- 3.9 Module Management
- 3.10 Module Management [DEPRECATED]
- 3.11 Library Management
- 3.12 Memory Management
- 3.13 Virtual Memory Management
- 3.14 Stream Ordered Memory Allocator
- 3.15 Unified Addressing
- 3.16 Stream Management
- 3.17 Event Management
- 3.18 External Resource Interoperability
- 3.19 Stream Memory Operations
- 3.20 Execution Control
- 3.21 Execution Control [DEPRECATED]
- 3.22 Graph Management
- 3.23 Occupancy
- 3.24 Texture Reference Management [DEPRECATED]
- 3.25 Surface Reference Management [DEPRECATED]
- 3.26 Texture Object Management
- 3.27 Surface Object Management
- 3.28 Tensor Map Object Management
- 3.29 Peer Context Memory Access
- 3.30 Graphics Interoperability
- 3.31 Driver Entry Point Access
- 3.32 Memory Atomic Management
- 3.33 Coredump Attributes Control API
- 3.34 Green Contexts
- 3.35 Error Log Management
- 3.36 OpenGL Interoperability
- 3.37 Profiler Control
3.1 Error Handling
muGetErrorString
MUresult muGetErrorString(MUresult error, const char **pStr)
Description
- Gets the string description of an error code.
- Sets *pStr to the address of a NULL-terminated string description of the error code error. If the error code is not recognized, MUSA_ERROR_INVALID_VALUE will be returned and *pStr will be set to the NULL address.
Parameters
error(MUresult): Error code to convert to stringpStr(const char **): Address of the string pointer.
Returns
- MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE
See also
- MUresult, musaGetErrorString
muGetErrorName
MUresult muGetErrorName(MUresult error, const char **pStr)
Description
- Gets the string representation of an error code enum name.
- Sets *pStr to the address of a NULL-terminated string representation of the name of the enum error code error. If the error code is not recognized, MUSA_ERROR_INVALID_VALUE will be returned and *pStr will be set to the NULL address.
Parameters
error(MUresult): Error code to convert to stringpStr(const char **): Address of the string pointer.
Returns
- MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE
See also
- MUresult, musaGetErrorName
3.2 Initialization
muInit
MUresult muInit(unsigned int Flags)
Description
- Initialize the MUSA driver API Initializes the driver API and must be called before any other function from the driver API in the current process. Currently, the Flags parameter must be 0. If muInit() has not been called, any function from the driver API will return MUSA_ERROR_NOT_INITIALIZED.
- Note: muInit preloads various libraries needed for JIT compilation. To opt-out of this behavior, set the environment variable MUSA_FORCE_PRELOAD_LIBRARIES=0. MUSA will lazily load JIT libraries as needed. To disable JIT entirely, set the environment variable MUSA_DISABLE_JIT=1.
Parameters
Flags(unsigned int): Initialization flag for MUSA.
Returns
- MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_SYSTEM_DRIVER_MISMATCH, MUSA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
3.3 Version Management
muDriverGetVersion
MUresult muDriverGetVersion(int *driverVersion)
Description
- Returns the latest MUSA version supported by driver.
- Returns in *driverVersion the version of MUSA supported by the driver. The version is returned as (1000 major + 10 minor). For example, MUSA 9.2 would be represented by 9020.
- This function automatically returns MUSA_ERROR_INVALID_VALUE if driverVersion is NULL.
Parameters
driverVersion(int *): Returns the MUSA driver version
Returns
- MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
3.4 Device Management
muDeviceGet
MUresult muDeviceGet(MUdevice *device, int ordinal)
Description
- Returns a handle to a compute device.
- Returns in *device a device handle given an ordinal in the range [0, muDeviceGetCount()-1].
Parameters
device(MUdevice *): Returned device handleordinal(int): Device number to get handle for
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGetUuid, muDeviceGetLuid, muDeviceTotalMem, muDeviceGetExecAffinitySupport
muDeviceGetCount
MUresult muDeviceGetCount(int *count)
Description
- Returns the number of compute-capable devices.
- Returns in *count the number of devices with compute capability greater than or equal to 2.0 that are available for execution. If there is no such device, muDeviceGetCount() returns 0.
Parameters
count(int *): Returned number of compute-capable devices
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetName, muDeviceGetUuid, muDeviceGetLuid, muDeviceGet, muDeviceTotalMem, muDeviceGetExecAffinitySupport, musaGetDeviceCount
muDeviceGetName
MUresult muDeviceGetName(char *name, int len, MUdevice dev)
Description
- Returns an identifier string for the device.
- Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name. len specifies the maximum length of the string that may be returned.
Parameters
name(char *): Returned identifier string for the devicelen(int): Maximum length of string to store in namedev(MUdevice): Device to get identifier string for
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetUuid, muDeviceGetLuid, muDeviceGetCount, muDeviceGet, muDeviceTotalMem, muDeviceGetExecAffinitySupport, musaGetDeviceProperties
muDeviceGetUuid
MUresult muDeviceGetUuid(MUuuid *uuid, MUdevice dev)
Description
- Return an UUID for the device.
- Note there is a later version of this API, muDeviceGetUuid_v2. It will supplant this version in 12.0, which is retained for minor version compatibility.
- Returns 16-octets identifying the device dev in the structure pointed by the uuid.
Parameters
uuid(MUuuid *): Returned UUIDdev(MUdevice): Device to get identifier string for
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetUuid_v2 muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGetLuid, muDeviceGet, muDeviceTotalMem, muDeviceGetExecAffinitySupport, musaGetDeviceProperties
muDeviceGetUuid_v2
MUresult muDeviceGetUuid_v2(MUuuid *uuid, MUdevice dev)
Description
- Return an UUID for the device (11.4+)
- Returns 16-octets identifying the device dev in the structure pointed by the uuid. If the device is in MIG mode, returns its MIG UUID which uniquely identifies the subscribed MIG compute instance.
Parameters
uuid(MUuuid *): Returned UUIDdev(MUdevice): Device to get identifier string for
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGetLuid, muDeviceGet, muDeviceTotalMem, musaGetDeviceProperties
muDeviceTotalMem
MUresult muDeviceTotalMem(size_t *bytes, MUdevice dev)
Description
- Return an LUID and device node mask for the device.
- Return identifying information (luid and deviceNodeMask) to allow matching device with graphics APIs.
- Returns in *bytes the total amount of memory available on the device dev in bytes.
Parameters
bytes(size_t *): Returned memory available on device in bytesdev(MUdevice): Device handle
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- Additional exported symbol names in scope:
muDeviceTotalMem_v2. - This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGet, muDeviceTotalMem, muDeviceGetExecAffinitySupport, musaGetDeviceProperties
- muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGetUuid, muDeviceGet, muDeviceGetExecAffinitySupport, musaMemGetInfo
muDeviceGetTexture1DLinearMaxWidth
MUresult muDeviceGetTexture1DLinearMaxWidth(size_t *maxWidthInElements, MUarray_format format, unsigned numChannels, MUdevice dev)
Description
- Returns the maximum number of elements allocatable in a 1D linear texture for a given texture element size.
- Returns in maxWidthInElements the maximum number of texture elements allocatable in a 1D linear texture for given format and numChannels.
Parameters
maxWidthInElements(size_t *): Returned maximum number of texture elements allocatable for given format and numChannels.format(MUarray_format): Texture format.numChannels(unsigned): Number of channels per texture element.dev(MUdevice): Device handle.
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGetUuid, muDeviceGet, musaMemGetInfo, muDeviceTotalMem
muDeviceGetAttribute
MUresult muDeviceGetAttribute(int *pi, MUdevice_attribute attrib, MUdevice dev)
Description
- Returns information about the device.
- Returns in *pi the integer value of the attribute attrib on device dev. The supported attributes are: MU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK: Maximum number of threads per block; MU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X: Maximum x-dimension of a block MU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y: Maximum y-dimension of a block MU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z: Maximum z-dimension of a block MU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X: Maximum x-dimension of a grid MU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y: Maximum y-dimension of a grid MU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z: Maximum z-dimension of a grid MU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK: Maximum amount of shared memory available to a thread block in bytes MU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY: Memory available on device for constant variables in a MUSA C kernel in bytes MU_DEVICE_ATTRIBUTE_WARP_SIZE: Warp size in threads MU_DEVICE_ATTRIBUTE_MAX_PITCH: Maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through muMemAllocPitch() MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH: Maximum 1D texture width MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH: Maximum width for a 1D texture bound to linear memory MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH: Maximum mipmapped 1D texture width MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH: Maximum 2D texture width MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT: Maximum 2D texture height MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH: Maximum width for a 2D texture bound to linear memory MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT: Maximum height for a 2D texture bound to linear memory MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH: Maximum pitch in bytes for a 2D texture bound to linear memory MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH: Maximum mipmapped 2D texture width MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT: Maximum mipmapped 2D texture height MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH: Maximum 3D texture width MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT: Maximum 3D texture height MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH: Maximum 3D texture depth MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE: Alternate maximum 3D texture width, 0 if no alternate maximum 3D texture size is supported MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE: Alternate maximum 3D texture height, 0 if no alternate maximum 3D texture size is supported MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE: Alternate maximum 3D texture depth, 0 if no alternate maximum 3D texture size is supported MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH: Maximum cubemap texture width or height MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH: Maximum 1D layered texture width MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS: Maximum layers in a 1D layered texture MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH: Maximum 2D layered texture width MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT: Maximum 2D layered texture height MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS: Maximum layers in a 2D layered texture MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH: Maximum cubemap layered texture width or height MU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS: Maximum layers in a cubemap layered texture MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH: Maximum 1D surface width MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH: Maximum 2D surface width MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT: Maximum 2D surface height MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH: Maximum 3D surface width MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT: Maximum 3D surface height MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH: Maximum 3D surface depth MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH: Maximum 1D layered surface width MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS: Maximum layers in a 1D layered surface MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH: Maximum 2D layered surface width MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT: Maximum 2D layered surface height MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS: Maximum layers in a 2D layered surface MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH: Maximum cubemap surface width MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH: Maximum cubemap layered surface width MU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS: Maximum layers in a cubemap layered surface MU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK: Maximum number of 32-bit registers available to a thread block MU_DEVICE_ATTRIBUTE_CLOCK_RATE: The typical clock frequency in kilohertz MU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT: Alignment requirement; texture base addresses aligned to textureAlign bytes do not need an offset applied to texture fetches MU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT: Pitch alignment requirement for 2D texture references bound to pitched memory MU_DEVICE_ATTRIBUTE_GPU_OVERLAP: 1 if the device can concurrently copy memory between host and device while executing a kernel, or 0 if not MU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT: Number of multiprocessors on the device MU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT: 1 if there is a run time limit for kernels executed on the device, or 0 if not MU_DEVICE_ATTRIBUTE_INTEGRATED: 1 if the device is integrated with the memory subsystem, or 0 if not MU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY: 1 if the device can map host memory into the MUSA address space, or 0 if not MU_DEVICE_ATTRIBUTE_COMPUTE_MODE: Compute mode that device is currently in. Available modes are as follows: MU_COMPUTEMODE_DEFAULT: Default mode - Device is not restricted and can have multiple MUSA contexts present at a single time. MU_COMPUTEMODE_PROHIBITED: Compute-prohibited mode - Device is prohibited from creating new MUSA contexts. MU_COMPUTEMODE_EXCLUSIVE_PROCESS: Compute-exclusive-process mode - Device can have only one context used by a single process at a time. MU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS: 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. MU_DEVICE_ATTRIBUTE_ECC_ENABLED: 1 if error correction is enabled on the device, 0 if error correction is disabled or not supported by the device MU_DEVICE_ATTRIBUTE_PCI_BUS_ID: PCI bus identifier of the device MU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID: PCI device (also known as slot) identifier of the device MU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID: PCI domain identifier of the device MU_DEVICE_ATTRIBUTE_TCC_DRIVER: 1 if the device is using a TCC driver. TCC is only available on Tesla hardware running Windows Vista or later MU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE: Peak memory clock frequency in kilohertz MU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH: Global memory bus width in bits MU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE: Size of L2 cache in bytes. 0 if the device doesn't have L2 cache MU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR: Maximum resident threads per multiprocessor MU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING: 1 if the device shares a unified address space with the host, or 0 if not MU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR: Major compute capability version number MU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR: Minor compute capability version number MU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED: 1 if device supports caching globals in L1 cache, 0 if caching globals in L1 cache is not supported by the device MU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED: 1 if device supports caching locals in L1 cache, 0 if caching locals in L1 cache is not supported by the device MU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR: Maximum amount of shared memory available to a multiprocessor in bytes; this amount is shared by all thread blocks simultaneously resident on a multiprocessor MU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR: Maximum number of 32-bit registers available to a multiprocessor; this number is shared by all thread blocks simultaneously resident on a multiprocessor MU_DEVICE_ATTRIBUTE_MANAGED_MEMORY: 1 if device supports allocating managed memory on this system, 0 if allocating managed memory is not supported by the device on this system. MU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD: 1 if device is on a multi-GPU board, 0 if not. MU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID: Unique identifier for a group of devices associated with the same board. Devices on the same multi-GPU board will share the same identifier. MU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED: 1 if Link between the device and the host supports native atomic operations. MU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO: Ratio of single precision performance (in floating-point operations per second) to double precision performance. MU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS: Device supports coherently accessing pageable memory without calling musaHostRegister on it. MU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS: Device can coherently access managed memory concurrently with the CPU. MU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED: Device supports Compute Preemption. MU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM: Device can access host registered memory at the same virtual address as the CPU. MU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN: The maximum per block shared memory size supported on this device. This is the maximum value that can be opted into when using the muFuncSetAttribute() or muKernelSetAttribute() call. For more details see MU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES MU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES: Device accesses pageable memory via the host's page tables. MU_DEVICE_ATTRIBUTE_DIRECT_MANAGED_MEM_ACCESS_FROM_HOST: The host can directly access managed memory on the device without migration. MU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED: Device supports virtual memory management APIs like muMemAddressReserve, muMemCreate, muMemMap and related APIs MU_DEVICE_ATTRIBUTE_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR_SUPPORTED: Device supports exporting memory to a posix file descriptor with muMemExportToShareableHandle, if requested via muMemCreate MU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_HANDLE_SUPPORTED: Device supports exporting memory to a Win32 NT handle with muMemExportToShareableHandle, if requested via muMemCreate MU_DEVICE_ATTRIBUTE_HANDLE_TYPE_WIN32_KMT_HANDLE_SUPPORTED: Device supports exporting memory to a Win32 KMT handle with muMemExportToShareableHandle, if requested via muMemCreate MU_DEVICE_ATTRIBUTE_MAX_BLOCKS_PER_MULTIPROCESSOR: Maximum number of thread blocks that can reside on a multiprocessor MU_DEVICE_ATTRIBUTE_GENERIC_COMPRESSION_SUPPORTED: Device supports compressible memory allocation via muMemCreate MU_DEVICE_ATTRIBUTE_MAX_PERSISTING_L2_CACHE_SIZE: Maximum L2 persisting lines capacity setting in bytes MU_DEVICE_ATTRIBUTE_MAX_ACCESS_POLICY_WINDOW_SIZE: Maximum value of MUaccessPolicyWindow::num_bytes MU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_MUSA_VMM_SUPPORTED: Device supports specifying the GPUDirect RDMA flag with muMemCreate. MU_DEVICE_ATTRIBUTE_RESERVED_SHARED_MEMORY_PER_BLOCK: Amount of shared memory per block reserved by MUSA driver in bytes MU_DEVICE_ATTRIBUTE_SPARSE_MUSA_ARRAY_SUPPORTED: Device supports sparse MUSA arrays and sparse MUSA mipmapped arrays. MU_DEVICE_ATTRIBUTE_READ_ONLY_HOST_REGISTER_SUPPORTED: Device supports using the muMemHostRegister flag MU_MEMHOSTERGISTER_READ_ONLY to register memory that must be mapped as read-only to the GPU MU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED: Device supports using the muMemAllocAsync and muMemPool family of APIs MU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_SUPPORTED: Device supports GPUDirect RDMA APIs, like mthreads_p2p_get_pages (see https://docs.mthreads.com/musa/gpudirect-rdma for more information) MU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_FLUSH_WRITES_OPTIONS: The returned attribute shall be interpreted as a bitmask, where the individual bits are described by the MUflushGPUDirectRDMAWritesOptions enum MU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WRITES_ORDERING: GPUDirect RDMA writes to the device do not need to be flushed for consumers within the scope indicated by the returned attribute. See MUGPUDirectRDMAWritesOrdering for the numerical values returned here. MU_DEVICE_ATTRIBUTE_MEMPOOL_SUPPORTED_HANDLE_TYPES: Bitmask of handle types supported with mempool based IPC MU_DEVICE_ATTRIBUTE_DEFERRED_MAPPING_MUSA_ARRAY_SUPPORTED: Device supports deferred mapping MUSA arrays and MUSA mipmapped arrays. MU_DEVICE_ATTRIBUTE_NUMA_CONFIG: NUMA configuration of a device: value is of type MUdeviceNumaConfig enum MU_DEVICE_ATTRIBUTE_NUMA_ID: NUMA node ID of the GPU memory MU_DEVICE_ATTRIBUTE_MULTICAST_SUPPORTED: Device supports switch multicast and reduction operations. MU_DEVICE_ATTRIBUTE_GPU_PCI_DEVICE_ID: The combined 16-bit PCI device ID and 16-bit PCI vendor ID. MU_DEVICE_ATTRIBUTE_GPU_PCI_SUBSYSTEM_ID: The combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID. ID.
Parameters
pi(int *): Returned device attribute valueattrib(MUdevice_attribute): Device attribute to querydev(MUdevice): Device handle
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetCount, muDeviceGetName, muDeviceGetUuid, muDeviceGet, muDeviceTotalMem, muDeviceGetExecAffinitySupport, musaDeviceGetAttribute, musaGetDeviceProperties
muDeviceSetMemPool
MUresult muDeviceSetMemPool(MUdevice dev, MUmemoryPool pool)
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 MUatomicOperation in *operations, the corresponding result in *capabilities will be a bitmask indicating which of MUatomicOperationCapability the link supports natively.
- Returns MUSA_ERROR_INVALID_DEVICE if dev is not valid.
- Returns MUSA_ERROR_INVALID_VALUE if *capabilities or *operations is NULL, if count is 0, or if any of *operations is not valid.
- Returns in mtSciSyncAttrList, the properties of NvSciSync that this MUSA device, dev can support. The returned mtSciSyncAttrList can be used to create an NvSciSync object that matches this device's capabilities.
- If NvSciSyncAttrKey_RequiredPerm field in mtSciSyncAttrList is already set this API will return MUSA_ERROR_INVALID_VALUE.
- The applications should set mtSciSyncAttrList to a valid NvSciSyncAttrList failing which this API will return MUSA_ERROR_INVALID_HANDLE.
- The flags controls how applications intends to use the NvSciSync created from the mtSciSyncAttrList. The valid flags are: MUSA_MTSCISYNC_ATTR_SIGNAL, specifies that the applications intends to signal an NvSciSync on this MUSA device. MUSA_MTSCISYNC_ATTR_WAIT, specifies that the applications intends to wait on an NvSciSync on this MUSA device.
- At least one of these flags must be set, failing which the API returns MUSA_ERROR_INVALID_VALUE. 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: NvSciSyncAttrKey_RequiredPerm is set to NvSciSyncAccessPerm_SignalOnly if MUSA_MTSCISYNC_ATTR_SIGNAL is set in flags. NvSciSyncAccessPerm_WaitOnly if MUSA_MTSCISYNC_ATTR_WAIT is set in flags. NvSciSyncAccessPerm_WaitSignal if both MUSA_MTSCISYNC_ATTR_WAIT and MUSA_MTSCISYNC_ATTR_SIGNAL are set in flags. NvSciSyncAttrKey_PrimitiveInfo is set to NvSciSyncAttrValPrimitiveType_SysmemSemaphore on any valid device. NvSciSyncAttrValPrimitiveType_Syncpoint if device is a Tegra device. NvSciSyncAttrValPrimitiveType_SysmemSemaphorePayload64b if device is GA10X+. NvSciSyncAttrKey_GpuId is set to the same UUID that is returned for this device from muDeviceGetUuid.
- The memory pool must be local to the specified device. muMemAllocAsync 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
dev(MUdevice): Valid Musa Device to get NvSciSync attributes for.pool(MUmemoryPool)
Returns
- MUSA_SUCCESS, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_VALUE
- MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
- Use muMemAllocFromPoolAsync to specify asynchronous allocations from a device different than the one the stream runs on.
See also
- muDeviceGetAttribute, muDeviceGetP2PAtomicCapabilities, musaDeviceGeHostAtomicCapabilities
- muImportExternalSemaphore, muDestroyExternalSemaphore, muSignalExternalSemaphoresAsync, muWaitExternalSemaphoresAsync
- muDeviceGetDefaultMemPool, muDeviceGetMemPool, muMemPoolCreate, muMemPoolDestroy, muMemAllocFromPoolAsync
muDeviceGetMemPool
MUresult muDeviceGetMemPool(MUmemoryPool *pool, MUdevice dev)
Description
- Gets the current mempool for a device.
- Returns the last pool provided to muDeviceSetMemPool for this device or the device's default memory pool if muDeviceSetMemPool 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.
Parameters
pool(MUmemoryPool *)dev(MUdevice)
Returns
- MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE
See also
muDeviceGetDefaultMemPool
MUresult muDeviceGetDefaultMemPool(MUmemoryPool *pool_out, MUdevice dev)
Description
- Returns the default mempool of a device.
- The default mempool of a device contains device memory from that device.
Parameters
pool_out(MUmemoryPool *)dev(MUdevice)
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_NOT_SUPPORTED
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muMemAllocAsync, muMemPoolTrimTo, muMemPoolGetAttribute, muMemPoolSetAttribute, muMemPoolSetAccess, muDeviceGetMemPool, muMemPoolCreate
3.5 Device Management [DEPRECATED]
muDeviceGetProperties
MUresult muDeviceGetProperties(MUdevprop *prop, MUdevice dev)
Description
- Returns properties for a selected device.
- Deprecated
- This function was deprecated as of MUSA 5.0 and replaced by muDeviceGetAttribute().
- Returns in *prop the properties of device dev. The MUdevprop structure is defined as:
typedef struct MUdevprop_st {
int maxThreadsPerBlock;
int maxThreadsDim[3];
int maxGridSize[3];
int sharedMemPerBlock;
int totalConstantMemory;
int SIMDWidth;
int memPitch;
int regsPerBlock;
int clockRate;
int textureAlign;
} MUdevprop;
- where:
- maxThreadsPerBlock is the maximum number of threads per block; maxThreadsDim[3] is the maximum sizes of each dimension of a block; maxGridSize[3] is the maximum sizes of each dimension of a grid; sharedMemPerBlock is the total amount of shared memory available per block in bytes; totalConstantMemory is the total amount of constant memory available on the device in bytes; SIMDWidth is the warp size; memPitch is the maximum pitch allowed by the memory copy functions that involve memory regions allocated through muMemAllocPitch(); regsPerBlock is the total number of registers available per block; clockRate is the clock frequency in kilohertz; textureAlign is the alignment requirement; texture base addresses that are aligned to textureAlign bytes do not need an offset applied to texture fetches.
Parameters
prop(MUdevprop *): Returned properties of devicedev(MUdevice): Device to get properties for
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGetUuid, muDeviceGet, muDeviceTotalMem
muDeviceComputeCapability
MUresult muDeviceComputeCapability(int *major, int *minor, MUdevice dev)
Description
- Returns the compute capability of the device.
- Deprecated
- This function was deprecated as of MUSA 5.0 and its functionality superseded by muDeviceGetAttribute().
- Returns in *major and *minor the major and minor revision numbers that define the compute capability of the device dev.
Parameters
major(int *): Major revision numberminor(int *): Minor revision numberdev(MUdevice): Device handle
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_INVALID_DEVICE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDeviceGetAttribute, muDeviceGetCount, muDeviceGetName, muDeviceGetUuid, muDeviceGet, muDeviceTotalMem
3.6 Primary Context Management
muDevicePrimaryCtxRetain
MUresult muDevicePrimaryCtxRetain(MUcontext *pctx, MUdevice dev)
Description
- Retain the primary context on the GPU.
- Retains the primary context on the device. Once the user successfully retains the primary context, the primary context will be active and available to the user until the user releases it with muDevicePrimaryCtxRelease() or resets it with muDevicePrimaryCtxReset(). Unlike muCtxCreate() the newly retained context is not pushed onto the stack.
- Retaining the primary context for the first time will fail with MUSA_ERROR_UNKNOWN if the compute mode of the device is MU_COMPUTEMODE_PROHIBITED. The function muDeviceGetAttribute() can be used with MU_DEVICE_ATTRIBUTE_COMPUTE_MODE to determine the compute mode of the device. The mthreads-smi tool can be used to set the compute mode for devices. Documentation for mthreads-smi can be obtained by passing a -h option to it.
- Please note that the primary context always supports pinned allocations. Other flags can be specified by muDevicePrimaryCtxSetFlags().
Parameters
pctx(MUcontext *): Returned context handle of the new contextdev(MUdevice): Device for which primary context is requested
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_OUT_OF_MEMORY, MUSA_ERROR_UNKNOWN
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muDevicePrimaryCtxRelease, muDevicePrimaryCtxSetFlags, muCtxCreate, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize
muDevicePrimaryCtxRelease
MUresult muDevicePrimaryCtxRelease(MUdevice dev)
Description
- Release the primary context on the GPU.
- Releases the primary context interop on the device. A retained context should always be released once the user is done using it. The context is automatically reset once the last reference to it is released. This behavior is different when the primary context was retained by the MUSA runtime from MUSA 4.0 and earlier. In this case, the primary context remains always active.
- Releasing a primary context that has not been previously retained will fail with MUSA_ERROR_INVALID_CONTEXT.
- Please note that unlike muCtxDestroy() this method does not pop the context from stack in any circumstances.
Parameters
dev(MUdevice): Device which primary context is released
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_CONTEXT
Note
- Additional exported symbol names in scope:
muDevicePrimaryCtxRelease_v2. - This function may also return error codes from previous, asynchronous launches.
See also
- muDevicePrimaryCtxRetain, muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize
muDevicePrimaryCtxSetFlags
MUresult muDevicePrimaryCtxSetFlags(MUdevice dev, unsigned int flags)
Description
- Set flags for the primary context.
- Sets the flags for the primary context on the device overwriting perviously set ones.
- The three LSBs of the flags parameter can be used to control how the OS thread, which owns the MUSA context at the time of an API call, interacts with the OS scheduler when waiting for results from the GPU. Only one of the scheduling flags can be set when creating a context.
- MU_CTX_SCHED_SPIN: Instruct MUSA to actively spin when waiting for results from the GPU. This can decrease latency when waiting for the GPU, but may lower the performance of CPU threads if they are performing work in parallel with the MUSA thread. MU_CTX_SCHED_YIELD: Instruct MUSA to yield its thread when waiting for results from the GPU. This can increase latency when waiting for the GPU, but can increase the performance of CPU threads performing work in parallel with the GPU. MU_CTX_SCHED_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. MU_CTX_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. Deprecated: This flag was deprecated as of MUSA 4.0 and was replaced with MU_CTX_SCHED_BLOCKING_SYNC. MU_CTX_SCHED_AUTO: 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 GPU (MU_CTX_SCHED_YIELD), otherwise MUSA will not yield while waiting for results and actively spin on the processor (MU_CTX_SCHED_SPIN). Additionally, on Tegra devices, MU_CTX_SCHED_AUTO uses a heuristic based on the power profile of the platform and may choose MU_CTX_SCHED_BLOCKING_SYNC for low-powered devices. MU_CTX_LMEM_RESIZE_TO_MAX: 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. MU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if this context raises an exception during execution. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. The initial settings will be taken from the global settings at the time of context creation. The other settings that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. MU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if data is written to a certain pipe that is present in the OS space. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. It is important to note that the pipe name must be set with muCoredumpSetAttributeGlobal before creating the context if this flag is used. Setting this flag implies that MU_CTX_COREDUMP_ENABLE is set. The initial settings will be taken from the global settings at the time of context creation. The other settings that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. MU_CTX_SYNC_MEMOPS: 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
dev(MUdevice): Device for which the primary context flags are setflags(unsigned int): New flags for the device
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_VALUE
Note
- Additional exported symbol names in scope:
muDevicePrimaryCtxSetFlags_v2. - This function may also return error codes from previous, asynchronous launches.
See also
- muDevicePrimaryCtxRetain, muDevicePrimaryCtxGetState, muCtxCreate, muCtxGetFlags, muCtxSetFlags, musaSetDeviceFlags
muDevicePrimaryCtxGetState
MUresult muDevicePrimaryCtxGetState(MUdevice dev, unsigned int *flags, int *active)
Description
- Get the state of the primary context.
- Returns in *flags the flags for the primary context of dev, and in *active whether it is active. See muDevicePrimaryCtxSetFlags for flag values.
Parameters
dev(MUdevice): Device to get primary context flags forflags(unsigned int *): Pointer to store flagsactive(int *): Pointer to store context state; 0 = inactive, 1 = active
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
muDevicePrimaryCtxReset
MUresult muDevicePrimaryCtxReset(MUdevice dev)
Description
- Destroy all allocations and reset all state on the primary context.
- Explicitly destroys and cleans up all resources associated with the current device in the current process.
- Note that it is responsibility of the calling function to ensure that no other module in the process is using the device any more. For that reason it is recommended to use muDevicePrimaryCtxRelease() in most cases. However it is safe for other modules to call muDevicePrimaryCtxRelease() even after resetting the device. Resetting the primary context does not release it, an application that has retained the primary context should explicitly release its usage.
Parameters
dev(MUdevice): Device for which primary context is destroyed
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_PRIMARY_CONTEXT_ACTIVE
Note
- Additional exported symbol names in scope:
muDevicePrimaryCtxReset_v2. - This function may also return error codes from previous, asynchronous launches.
See also
- muDevicePrimaryCtxRetain, muDevicePrimaryCtxRelease, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize, musaDeviceReset
3.7 Context Management
muCtxCreate
MUresult muCtxCreate(MUcontext *pctx, unsigned int flags, MUdevice dev)
Description
- Create a MUSA context.
- The three LSBs of the flags parameter can be used to control how the OS thread, which owns the MUSA context at the time of an API call, interacts with the OS scheduler when waiting for results from the GPU. Only one of the scheduling flags can be set when creating a context.
- MU_CTX_SCHED_SPIN: Instruct MUSA to actively spin when waiting for results from the GPU. This can decrease latency when waiting for the GPU, but may lower the performance of CPU threads if they are performing work in parallel with the MUSA thread. MU_CTX_SCHED_YIELD: Instruct MUSA to yield its thread when waiting for results from the GPU. This can increase latency when waiting for the GPU, but can increase the performance of CPU threads performing work in parallel with the GPU. MU_CTX_SCHED_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. MU_CTX_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. Deprecated: This flag was deprecated as of MUSA 4.0 and was replaced with MU_CTX_SCHED_BLOCKING_SYNC. MU_CTX_SCHED_AUTO: 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 GPU (MU_CTX_SCHED_YIELD), otherwise MUSA will not yield while waiting for results and actively spin on the processor (MU_CTX_SCHED_SPIN). Additionally, on Tegra devices, MU_CTX_SCHED_AUTO uses a heuristic based on the power profile of the platform and may choose MU_CTX_SCHED_BLOCKING_SYNC for low-powered devices. MU_CTX_MAP_HOST: Instruct MUSA to support mapped pinned allocations. This flag must be set in order to allocate pinned host memory that is accessible to the GPU. MU_CTX_LMEM_RESIZE_TO_MAX: 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. Instead, the per-thread stack size can be controlled with muCtxSetLimit(). MU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if this context raises an exception during execution. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. The initial attributes will be taken from the global attributes at the time of context creation. The other attributes that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. MU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if data is written to a certain pipe that is present in the OS space. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. It is important to note that the pipe name must be set with muCoredumpSetAttributeGlobal before creating the context if this flag is used. Setting this flag implies that MU_CTX_COREDUMP_ENABLE is set. The initial attributes will be taken from the global attributes at the time of context creation. The other attributes that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. Setting this flag on any context creation is equivalent to setting the MU_COREDUMP_ENABLE_USER_TRIGGER attribute to true globally. MU_CTX_SYNC_MEMOPS: 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.
- Context creation will fail with MUSA_ERROR_UNKNOWN if the compute mode of the device is MU_COMPUTEMODE_PROHIBITED. The function muDeviceGetAttribute() can be used with MU_DEVICE_ATTRIBUTE_COMPUTE_MODE to determine the compute mode of the device. The mthreads-smi tool can be used to set the compute mode for * devices. Documentation for mthreads-smi can be obtained by passing a -h option to it.
Parameters
pctx(MUcontext *): Returned context handle of the new contextflags(unsigned int): Context creation flagsdev(MUdevice): Device to create context on
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_OUT_OF_MEMORY, MUSA_ERROR_UNKNOWN
Note
- Additional exported symbol names in scope:
muCtxCreate_v2. - In most cases it is recommended to use muDevicePrimaryCtxRetain.
- This function may also return error codes from previous, asynchronous launches.
See also
- muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCoredumpSetAttributeGlobal, muCoredumpSetAttribute, muCtxSynchronize
muCtxDestroy
MUresult muCtxDestroy(MUcontext ctx)
Description
- Create a MUSA context with execution affinity.
- Creates a new MUSA context with execution affinity and associates it with the calling thread. The paramsArray and flags parameter are described below. The context is created with a usage count of 1 and the caller of muCtxCreate() must call muCtxDestroy() when done using the context. If a context is already current to the thread, it is supplanted by the newly created context and may be restored by a subsequent call to muCtxPopCurrent().
- The type and the amount of execution resource the context can use is limited by paramsArray and numParams. The paramsArray is an array of MUexecAffinityParam and the numParams describes the size of the array. If two MUexecAffinityParam in the array have the same type, the latter execution affinity parameter overrides the former execution affinity parameter. The supported execution affinity types are: MU_EXEC_AFFINITY_TYPE_SM_COUNT limits the portion of SMs that the context can use. The portion of SMs is specified as the number of SMs via MUexecAffinitySmCount. This limit will be internally rounded up to the next hardware-supported amount. Hence, it is imperative to query the actual execution affinity of the context via muCtxGetExecAffinity after context creation. Currently, this attribute is only supported under Volta+ MPS.
- The three LSBs of the flags parameter can be used to control how the OS thread, which owns the MUSA context at the time of an API call, interacts with the OS scheduler when waiting for results from the GPU. Only one of the scheduling flags can be set when creating a context.
- MU_CTX_SCHED_SPIN: Instruct MUSA to actively spin when waiting for results from the GPU. This can decrease latency when waiting for the GPU, but may lower the performance of CPU threads if they are performing work in parallel with the MUSA thread. MU_CTX_SCHED_YIELD: Instruct MUSA to yield its thread when waiting for results from the GPU. This can increase latency when waiting for the GPU, but can increase the performance of CPU threads performing work in parallel with the GPU. MU_CTX_SCHED_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. MU_CTX_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. Deprecated: This flag was deprecated as of MUSA 4.0 and was replaced with MU_CTX_SCHED_BLOCKING_SYNC. MU_CTX_SCHED_AUTO: 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 GPU (MU_CTX_SCHED_YIELD), otherwise MUSA will not yield while waiting for results and actively spin on the processor (MU_CTX_SCHED_SPIN). Additionally, on Tegra devices, MU_CTX_SCHED_AUTO uses a heuristic based on the power profile of the platform and may choose MU_CTX_SCHED_BLOCKING_SYNC for low-powered devices. MU_CTX_MAP_HOST: Instruct MUSA to support mapped pinned allocations. This flag must be set in order to allocate pinned host memory that is accessible to the GPU. MU_CTX_LMEM_RESIZE_TO_MAX: 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. Instead, the per-thread stack size can be controlled with muCtxSetLimit(). MU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if this context raises an exception during execution. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. The initial attributes will be taken from the global attributes at the time of context creation. The other attributes that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. MU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if data is written to a certain pipe that is present in the OS space. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. It is important to note that the pipe name must be set with muCoredumpSetAttributeGlobal before creating the context if this flag is used. Setting this flag implies that MU_CTX_COREDUMP_ENABLE is set. The initial attributes will be taken from the global attributes at the time of context creation. The other attributes that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. Setting this flag on any context creation is equivalent to setting the MU_COREDUMP_ENABLE_USER_TRIGGER attribute to true globally.
- Context creation will fail with MUSA_ERROR_UNKNOWN if the compute mode of the device is MU_COMPUTEMODE_PROHIBITED. The function muDeviceGetAttribute() can be used with MU_DEVICE_ATTRIBUTE_COMPUTE_MODE to determine the compute mode of the device. The mthreads-smi tool can be used to set the compute mode for * devices. Documentation for mthreads-smi can be obtained by passing a -h option to it.
- Creates a new MUSA context and associates it with the calling thread. The flags parameter is described below. The context is created with a usage count of 1 and the caller of muCtxCreate() must call muCtxDestroy() when done using the context. If a context is already current to the thread, it is supplanted by the newly created context and may be restored by a subsequent call to muCtxPopCurrent().
- MUSA context can be created with execution affinity. The type and the amount of execution resource the context can use is limited by paramsArray and numExecAffinityParams in execAffinity. The paramsArray is an array of MUexecAffinityParam and the numExecAffinityParams describes the size of the paramsArray. If two MUexecAffinityParam in the array have the same type, the latter execution affinity parameter overrides the former execution affinity parameter. The supported execution affinity types are: MU_EXEC_AFFINITY_TYPE_SM_COUNT limits the portion of SMs that the context can use. The portion of SMs is specified as the number of SMs via MUexecAffinitySmCount. This limit will be internally rounded up to the next hardware-supported amount. Hence, it is imperative to query the actual execution affinity of the context via muCtxGetExecAffinity after context creation. Currently, this attribute is only supported under Volta+ MPS.
- MUSA context can be created in CIG(MUSA in Graphics) mode by setting cigParams. Data from graphics client is shared with MUSA via the sharedData in cigParams. Support for D3D12 graphics client can be determined using muDeviceGetAttribute() with MU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED. sharedData is a ID3D12CommandQueue handle. Either execAffinityParams or cigParams can be set to a non-null value. Setting both to a non-null value will result in an undefined behavior.
- MU_CTX_SCHED_SPIN: Instruct MUSA to actively spin when waiting for results from the GPU. This can decrease latency when waiting for the GPU, but may lower the performance of CPU threads if they are performing work in parallel with the MUSA thread. MU_CTX_SCHED_YIELD: Instruct MUSA to yield its thread when waiting for results from the GPU. This can increase latency when waiting for the GPU, but can increase the performance of CPU threads performing work in parallel with the GPU. MU_CTX_SCHED_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. MU_CTX_BLOCKING_SYNC: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the GPU to finish work. Deprecated: This flag was deprecated as of MUSA 4.0 and was replaced with MU_CTX_SCHED_BLOCKING_SYNC. MU_CTX_SCHED_AUTO: 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 GPU (MU_CTX_SCHED_YIELD), otherwise MUSA will not yield while waiting for results and actively spin on the processor (MU_CTX_SCHED_SPIN). Additionally, on Tegra devices, MU_CTX_SCHED_AUTO uses a heuristic based on the power profile of the platform and may choose MU_CTX_SCHED_BLOCKING_SYNC for low-powered devices. MU_CTX_MAP_HOST: Instruct MUSA to support mapped pinned allocations. This flag must be set in order to allocate pinned host memory that is accessible to the GPU. MU_CTX_LMEM_RESIZE_TO_MAX: 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. Instead, the per-thread stack size can be controlled with muCtxSetLimit(). MU_CTX_COREDUMP_ENABLE: If GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if this context raises an exception during execution. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. The initial attributes will be taken from the global attributes at the time of context creation. The other attributes that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. This flag is not supported when MUSA context is created in CIG(MUSA in Graphics) mode. MU_CTX_USER_COREDUMP_ENABLE: If user-triggered GPU coredumps have not been enabled globally with muCoredumpSetAttributeGlobal or environment variables, this flag can be set during context creation to instruct MUSA to create a coredump if data is written to a certain pipe that is present in the OS space. These environment variables are described in the MUSA-GDB user guide under the "GPU core dump support" section. It is important to note that the pipe name must be set with muCoredumpSetAttributeGlobal before creating the context if this flag is used. Setting this flag implies that MU_CTX_COREDUMP_ENABLE is set. The initial attributes will be taken from the global attributes at the time of context creation. The other attributes that control coredump output can be modified by calling muCoredumpSetAttribute from the created context after it becomes current. Setting this flag on any context creation is equivalent to setting the MU_COREDUMP_ENABLE_USER_TRIGGER attribute to true globally. This flag is not supported when MUSA context is created in CIG(MUSA in Graphics) mode. MU_CTX_SYNC_MEMOPS: 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.
- Context creation will fail with MUSA_ERROR_INVALID_VALUE if invalid parameter was passed by client to create the MUSA context.
- Destroys the MUSA context specified by ctx. The context ctx will be destroyed regardless of how many threads it is current to. It is the responsibility of the calling function to ensure that no API call issues using ctx while muCtxDestroy() is executing.
- Destroys and cleans up all resources associated with the context. It is the caller's responsibility to ensure that the context or its resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These resources include MUSA types MUmodule, MUfunction, MUstream, MUevent, MUarray, MUmipmappedArray, MUtexObject, MUsurfObject, MUtexref, MUsurfref, MUgraphicsResource, MUlinkState, MUexternalMemory and MUexternalSemaphore. These resources also include memory allocations by muMemAlloc(), muMemAllocHost(), muMemAllocManaged() and muMemAllocPitch().
- If ctx is current to the calling thread then ctx will also be popped from the current thread's context stack (as though muCtxPopCurrent() were called). If ctx is current to other threads, then ctx will remain current to those threads, and attempting to access ctx from those threads will result in the error MUSA_ERROR_CONTEXT_IS_DESTROYED.
Parameters
ctx(MUcontext): Context to destroy
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_OUT_OF_MEMORY, MUSA_ERROR_UNSUPPORTED_EXEC_AFFINITY, MUSA_ERROR_UNKNOWN
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_DEVICE, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_NOT_SUPPORTED, MUSA_ERROR_OUT_OF_MEMORY, MUSA_ERROR_UNKNOWN
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE
Note
- Additional exported symbol names in scope:
muCtxDestroy_v2. - This function may also return error codes from previous, asynchronous launches.
- muCtxDestroy() will not destroy memory allocations by muMemCreate(), muMemAllocAsync() and muMemAllocFromPoolAsync(). These memory allocations are not associated with any MUSA context and need to be destroyed explicitly.
See also
- muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize, muCoredumpSetAttributeGlobal, muCoredumpSetAttribute, MUexecAffinityParam
- muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCoredumpSetAttributeGlobal, muCoredumpSetAttribute, muCtxSynchronize
- muCtxCreate, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize
muCtxPushCurrent
MUresult muCtxPushCurrent(MUcontext ctx)
Description
- Pushes a context on the current CPU thread.
- Pushes the given context ctx onto the CPU thread's stack of current contexts. The specified context becomes the CPU thread's current context, so all MUSA functions that operate on the current context are affected.
- The previous current context may be made current again by calling muCtxDestroy() or muCtxPopCurrent().
Parameters
ctx(MUcontext): Context to push
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE
Note
- Additional exported symbol names in scope:
muCtxPushCurrent_v2. - This function may also return error codes from previous, asynchronous launches.
See also
- muCtxCreate, muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize
muCtxPopCurrent
MUresult muCtxPopCurrent(MUcontext *pctx)
Description
- Pops the current MUSA context from the current CPU thread.
- Pops the current MUSA context from the CPU thread and passes back the old context handle in *pctx. That context may then be made current to a different CPU thread by calling muCtxPushCurrent().
- If a context was current to the CPU thread before muCtxCreate() or muCtxPushCurrent() was called, this function makes that context current to the CPU thread again.
Parameters
pctx(MUcontext *): Returned popped context handle
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT
Note
- Additional exported symbol names in scope:
muCtxPopCurrent_v2. - This function may also return error codes from previous, asynchronous launches.
See also
- muCtxCreate, muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize
muCtxSetCurrent
MUresult muCtxSetCurrent(MUcontext ctx)
Description
- Binds the specified MUSA context to the calling CPU thread.
- Binds the specified MUSA context to the calling CPU thread. If ctx is NULL then the MUSA context previously bound to the calling CPU thread is unbound and MUSA_SUCCESS is returned.
- If there exists a MUSA context stack on the calling CPU thread, this will replace the top of that stack with ctx. If ctx is NULL then this will be equivalent to popping the top of the calling CPU thread's MUSA context stack (or a no-op if the calling CPU thread's MUSA context stack is empty).
Parameters
ctx(MUcontext): Context to bind to the calling CPU thread
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT
Note
- This function may also return error codes from previous, asynchronous launches.
See also
muCtxGetCurrent
MUresult muCtxGetCurrent(MUcontext *pctx)
Description
- Returns the MUSA context bound to the calling CPU thread.
- Returns in *pctx the MUSA context bound to the calling CPU thread. If no context is bound to the calling CPU thread then *pctx is set to NULL and MUSA_SUCCESS is returned.
Parameters
pctx(MUcontext *): Returned context handle
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED
Note
- This function may also return error codes from previous, asynchronous launches.
See also
muCtxGetDevice
MUresult muCtxGetDevice(MUdevice *device)
Description
- Returns the device handle for the current context.
- Returns in *device the handle of the current context's device.
Parameters
device(MUdevice *): Returned device handle for the current context
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muCtxCreate, muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, muCtxSynchronize, musaGetDevice
muCtxGetFlags
MUresult muCtxGetFlags(unsigned int *flags)
Description
- Returns the device handle for the specified context.
- Returns in *device the handle of the specified context's device. If the specified context is NULL, the API will return the current context's device.
- Returns in *flags the flags of the current context. See muCtxCreate for flag values.
Parameters
flags(unsigned int *): Pointer to store flags of current context
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muCtxGetCurrent, muCtxPopCurrent, muCtxPushCurrent
- muCtxCreate, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetCurrent, muCtxGetDevice, muCtxGetLimit, muCtxGetSharedMemConfig, muCtxGetStreamPriorityRange, muCtxSetFlags, musaGetDeviceFlags
muCtxSetFlags
MUresult muCtxSetFlags(unsigned int flags)
Description
- Sets the flags for the current context.
- Sets the flags for the current context overwriting previously set ones. See muDevicePrimaryCtxSetFlags for flag values.
Parameters
flags(unsigned int): Flags to set on the current context
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muCtxCreate, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetCurrent, muCtxGetDevice, muCtxGetLimit, muCtxGetSharedMemConfig, muCtxGetStreamPriorityRange, muCtxGetFlags, musaGetDeviceFlags, muDevicePrimaryCtxSetFlags,
muCtxGetId
MUresult muCtxGetId(MUcontext ctx, unsigned long long *ctxId)
Description
- Returns the unique Id associated with the context supplied.
- Returns in ctxId the unique Id which is associated with a given context. The Id is unique for the life of the program for this instance of MUSA. If context is supplied as NULL and there is one current, the Id of the current context is returned.
Parameters
ctx(MUcontext): Context for which to obtain the IdctxId(unsigned long long *): Pointer to store the Id of the context
Returns
- MUSA_SUCCESS, MUSA_ERROR_CONTEXT_IS_DESTROYED, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT, MUSA_ERROR_INVALID_VALUE
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muCtxCreate, muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPushCurrent
muCtxSynchronize
MUresult muCtxSynchronize(void)
Description
- Block for the current context's tasks to complete.
- Blocks until the current context has completed all preceding requested tasks. If the current context is the primary context, green contexts that have been created will also be synchronized. muCtxSynchronize() returns an error if one of the preceding tasks failed. If the context was created with the MU_CTX_SCHED_BLOCKING_SYNC flag, the CPU thread will block until the GPU context has finished its work.
Parameters
(unnamed)(void)
Returns
- MUSA_SUCCESS, MUSA_ERROR_DEINITIALIZED, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_INVALID_CONTEXT
Note
- This function may also return error codes from previous, asynchronous launches.
See also
- muCtxCreate, muCtxDestroy, muCtxGetApiVersion, muCtxGetCacheConfig, muCtxGetDevice, muCtxGetFlags, muCtxGetLimit, muCtxPopCurrent, muCtxPushCurrent, muCtxSetCacheConfig, muCtxSetLimit, musaDeviceSynchronize