Skip to main content

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

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 set
  • value (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 limit
  • limit (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

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 returned
  • greatestPriority (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

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 ordinal
  • pciBusId (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 format
  • len (int): Maximum length of string to store in name
  • device (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 handle
  • event (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

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 event
  • handle (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

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

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 pointer
  • handle (musaIpcMemHandle_t): musaIpcMemHandle to open
  • flags (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

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

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 callback
  • callbackFunc (musaAsyncCallback): The function to register as a callback
  • userData (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

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

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 device
  • device (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

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 value
  • attr (enum musaDeviceAttr): Device attribute to query
  • device (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

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

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

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 pool
  • location (struct musaMemLocation *): Memory location identifying the pool
  • type (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

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 pool
  • location (struct musaMemLocation *): Memory location identifying the pool
  • type (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 pool
  • type (enum musaMemAllocationType): Allocation type for which to set the pool
  • memPool (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

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 attribute
  • attr (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

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 match
  • prop (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

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

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

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

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

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

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

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 set
  • value (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 limit
  • limit (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

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

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

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

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

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 identifier
  • flags (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

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 identifier
  • flags (unsigned int): Flags for stream creation. See musaStreamCreateWithFlags for a list of valid flags that can be passed
  • priority (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

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 queried
  • priority (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

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 queried
  • flags (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

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 queried
  • streamId (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

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 queried
  • device (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

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 stream
  • src (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

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 wait
  • event (musaEvent_t): Event to wait on
  • flags (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

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 to
  • callback (musaStreamCallback_t): The function to call once preceding stream operations are complete
  • userData (void *): User specified data to be passed to the callback function
  • flags (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

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

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

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 operation
  • devPtr (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

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 capture
  • 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

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 query
  • pGraph (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 query
  • pCaptureStatus (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 query
  • captureStatus_out (enum musaStreamCaptureStatus *): Location to return the capture status of the stream; required
  • id_out (unsigned long long *): Optional location to return an id for the capture sequence, which is unique over the lifetime of the process
  • graph_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

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 query
  • captureStatus_out (enum musaStreamCaptureStatus *): Location to return the capture status of the stream; required
  • id_out (unsigned long long *): Optional location to return an id for the capture sequence, which is unique over the lifetime of the process
  • graph_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 update
  • dependencies (musaGraphNode_t *): The set of dependencies to add
  • numDependencies (size_t): The size of the dependencies array
  • flags (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

musaEventCreateWithFlags

musaError_t musaEventCreateWithFlags(musaEvent_t *event, unsigned int flags)

Description

  • Creates an event object with the specified flags.
  • Creates an event object for the current device with the specified flags. Valid flags include: musaEventDefault: Default event creation flag. musaEventBlockingSync: Specifies that event should use blocking synchronization. A host thread that uses musaEventSynchronize() to wait on an event created with this flag will block until the event actually completes. musaEventDisableTiming: Specifies that the created event does not need to record timing data. Events created with this flag specified and the musaEventBlockingSync flag not specified will provide the best performance when used with musaStreamWaitEvent() and musaEventQuery(). musaEventInterprocess: Specifies that the created event may be used as an interprocess event by musaIpcGetEventHandle(). musaEventInterprocess must be specified along with musaEventDisableTiming.

Parameters

  • event (musaEvent_t *): Newly created event
  • flags (unsigned int): Flags for new 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

musaEventRecord

musaError_t musaEventRecord(musaEvent_t event, musaStream_t stream)

Description

  • Records an event.
  • Captures in event the contents of stream at the time of this call. event and stream must be on the same MUSA context. Calls such as musaEventQuery() or musaStreamWaitEvent() will then examine or wait for completion of the work that was captured. Uses of stream after this call do not modify event. See note on default stream behavior for what is captured in the default case.
  • musaEventRecord() can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as musaStreamWaitEvent() use the most recently captured state at the time of the API call, and are not affected by later calls to musaEventRecord(). Before the first call to musaEventRecord(), an event represents an empty set of work, so for example musaEventQuery() would return musaSuccess.

Parameters

  • event (musaEvent_t): Event to record
  • stream (musaStream_t): Stream in which to record event

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

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 the event note for NULL event semantics.

See also

musaEventRecordWithFlags

musaError_t musaEventRecordWithFlags(musaEvent_t event, musaStream_t stream, unsigned int flags)

Description

  • Records an event.
  • Captures in event the contents of stream at the time of this call. event and stream must be on the same MUSA context. Calls such as musaEventQuery() or musaStreamWaitEvent() will then examine or wait for completion of the work that was captured. Uses of stream after this call do not modify event. See note on default stream behavior for what is captured in the default case.
  • musaEventRecordWithFlags() can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as musaStreamWaitEvent() use the most recently captured state at the time of the API call, and are not affected by later calls to musaEventRecordWithFlags(). Before the first call to musaEventRecordWithFlags(), an event represents an empty set of work, so for example musaEventQuery() would return musaSuccess.
  • flags include: musaEventRecordDefault: Default event creation flag. musaEventRecordExternal: Event is captured in the graph as an external event node when performing stream capture.

Parameters

  • event (musaEvent_t): Event to record
  • stream (musaStream_t): Stream in which to record event
  • flags (unsigned int): Parameters for the operation(See above)

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

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 the event note for NULL event semantics.

See also

musaEventQuery

musaError_t musaEventQuery(musaEvent_t event)

Description

  • Queries an event's status.
  • Queries the status of all work currently captured by event. See musaEventRecord() for details on what is captured by an event.
  • Returns musaSuccess if all captured work has been completed, or musaErrorNotReady if any captured work is incomplete.
  • For the purposes of Unified Memory, a return value of musaSuccess is equivalent to having called musaEventSynchronize().

Parameters

  • event (musaEvent_t): Event to query

Returns

  • musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

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 event note for NULL event semantics.

See also

musaEventSynchronize

musaError_t musaEventSynchronize(musaEvent_t event)

Description

  • Waits for an event to complete.
  • Waits until the completion of all work currently captured in event. See musaEventRecord() for details on what is captured by an event.
  • Waiting for an event that was created with the musaEventBlockingSync flag will cause the calling CPU thread to block until the event has been completed by the device. If the musaEventBlockingSync flag has not been set, then the CPU thread will busy-wait until the event has been completed by the device.

Parameters

  • event (musaEvent_t): Event to wait for

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

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 event note for NULL event semantics.

See also

musaEventDestroy

musaError_t musaEventDestroy(musaEvent_t event)

Description

  • Destroys an event object.
  • Destroys the event specified by event.
  • An event may be destroyed before it is complete (i.e., while musaEventQuery() would return musaErrorNotReady). In this case, the call does not block on completion of the event, and any associated resources will automatically be released asynchronously at completion.

Parameters

  • event (musaEvent_t): Event to destroy

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

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 event note for NULL event semantics.

See also

musaEventElapsedTime

musaError_t musaEventElapsedTime(float *ms, musaEvent_t start, musaEvent_t end)

Description

  • Computes the elapsed time between events.
  • Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds).
  • If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used the same stream handle). This happens because the musaEventRecord() operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two events. Any number of other different stream operations could execute in between the two measured events, thus altering the timing in a significant way.
  • If musaEventRecord() has not been called on either event, then musaErrorInvalidResourceHandle is returned. If musaEventRecord() has been called on both events but one or both of them has not yet been completed (that is, musaEventQuery() would return musaErrorNotReady on at least one of the events), musaErrorNotReady is returned. If either event was created with the musaEventDisableTiming flag, then this function will return musaErrorInvalidResourceHandle.

Parameters

  • ms (float *): Time between start and end in ms
  • start (musaEvent_t): Starting event
  • end (musaEvent_t): Ending event

Returns

  • musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure, 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 the event note for NULL event semantics.

See also

musaEventElapsedTime_v2

musaError_t musaEventElapsedTime_v2(float *ms, musaEvent_t start, musaEvent_t end)

Description

  • Computes the elapsed time between events.
  • Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). Note this API is not guaranteed to return the latest errors for pending work. As such this API is intended to serve as a elapsed time calculation only and polling for completion on the events to be compared should be done with musaEventQuery instead.
  • If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used the same stream handle). This happens because the musaEventRecord() operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two events. Any number of other different stream operations could execute in between the two measured events, thus altering the timing in a significant way.
  • If musaEventRecord() has not been called on either event, then musaErrorInvalidResourceHandle is returned. If musaEventRecord() has been called on both events but one or both of them has not yet been completed (that is, musaEventQuery() would return musaErrorNotReady on at least one of the events), musaErrorNotReady is returned. If either event was created with the musaEventDisableTiming flag, then this function will return musaErrorInvalidResourceHandle.

Parameters

  • ms (float *): Time between start and end in ms
  • start (musaEvent_t): Starting event
  • end (musaEvent_t): Ending event

Returns

  • musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure, 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 the event note for NULL event semantics.

See also

3.8 External Resource Interoperability

musaImportExternalMemory

musaError_t musaImportExternalMemory(musaExternalMemory_t *extMem_out, const struct musaExternalMemoryHandleDesc *memHandleDesc)

Description

  • Imports an external memory object.
  • Imports an externally allocated memory object and returns a handle to that in extMem_out.
  • The properties of the handle being imported must be described in memHandleDesc. The musaExternalMemoryHandleDesc structure is defined as follows:
typedef struct musaExternalMemoryHandleDesc_st {
musaExternalMemoryHandleTypetype;
union {
int fd;
struct {
void *handle;
const void *name;
} win32;
const void *mtSciBufObject;
} handle;
unsigned long long size;
unsigned int flags;
} musaExternalMemoryHandleDesc;
  • where musaExternalMemoryHandleDesc::type specifies the type of handle being imported. musaExternalMemoryHandleType is defined as:
typedef enum musaExternalMemoryHandleType_enum {
musaExternalMemoryHandleTypeOpaqueFd = 1,
musaExternalMemoryHandleTypeOpaqueWin32 = 2,
musaExternalMemoryHandleTypeOpaqueWin32Kmt = 3,
musaExternalMemoryHandleTypeD3D12Heap = 4,
musaExternalMemoryHandleTypeD3D12Resource = 5,
musaExternalMemoryHandleTypeD3D11Resource = 6,
musaExternalMemoryHandleTypeD3D11ResourceKmt = 7,
musaExternalMemoryHandleTypeMtSciBuf = 8;
} musaExternalMemoryHandleType;
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeOpaqueFd, then musaExternalMemoryHandleDesc::handle::fd must be a valid file descriptor referencing a memory object. Ownership of the file descriptor is transferred to the MUSA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeOpaqueWin32, then exactly one of musaExternalMemoryHandleDesc::handle::win32::handle and musaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If musaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that references a memory object. Ownership of this handle is not transferred to MUSA after the import operation, so the application must release the handle using the appropriate system call. If musaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a memory object.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeOpaqueWin32Kmt, then musaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and musaExternalMemoryHandleDesc::handle::win32::name must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying object, and thus will be invalid when all references to the memory object are destroyed.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeD3D12Heap, then exactly one of musaExternalMemoryHandleDesc::handle::win32::handle and musaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If musaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Heap object. This handle holds a reference to the underlying object. If musaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Heap object.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeD3D12Resource, then exactly one of musaExternalMemoryHandleDesc::handle::win32::handle and musaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If musaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Resource object. This handle holds a reference to the underlying object. If musaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Resource object.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeD3D11Resource,then exactly one of musaExternalMemoryHandleDesc::handle::win32::handle and musaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If musaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by IDXGIResource1::CreateSharedHandle when referring to a ID3D11Resource object. If musaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D11Resource object.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeD3D11ResourceKmt, then musaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and musaExternalMemoryHandleDesc::handle::win32::name must be NULL. The handle specified must be a valid shared KMT handle that is returned by IDXGIResource::GetSharedHandle when referring to a ID3D11Resource object.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeMtSciBuf, then musaExternalMemoryHandleDesc::handle::mtSciBufObject must be NON-NULL and reference a valid MtSciBuf object. If the MtSciBuf object imported into MUSA is also mapped by other drivers, then the application must use musaWaitExternalSemaphoresAsync or musaSignalExternalSemaphoresAsync as approprriate barriers to maintain coherence between MUSA and the other drivers. See musaExternalSemaphoreWaitSkipMtSciBufMemSync and musaExternalSemaphoreSignalSkipMtSciBufMemSync for memory synchronization.
  • The size of the memory object must be specified in musaExternalMemoryHandleDesc::size.
  • Specifying the flag musaExternalMemoryDedicated in musaExternalMemoryHandleDesc::flags indicates that the resource is a dedicated resource. The definition of what a dedicated resource is outside the scope of this extension. This flag must be set if musaExternalMemoryHandleDesc::type is one of the following: musaExternalMemoryHandleTypeD3D12Resource musaExternalMemoryHandleTypeD3D11Resource musaExternalMemoryHandleTypeD3D11ResourceKmt

Parameters

  • extMem_out (musaExternalMemory_t *): Returned handle to an external memory object
  • memHandleDesc (const struct musaExternalMemoryHandleDesc *): Memory import handle descriptor

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorOperatingSystem

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.
  • If the Vulkan memory imported into MUSA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs, please refer to "Synchronization and Cache Control" chapter from Vulkan specification.

See also

musaExternalMemoryGetMappedBuffer

musaError_t musaExternalMemoryGetMappedBuffer(void **devPtr, musaExternalMemory_t extMem, const struct musaExternalMemoryBufferDesc *bufferDesc)

Description

  • Maps a buffer onto an imported memory object.
  • Maps a buffer onto an imported memory object and returns a device pointer in devPtr.
  • The properties of the buffer being mapped must be described in bufferDesc. The musaExternalMemoryBufferDesc structure is defined as follows:
typedef struct musaExternalMemoryBufferDesc_st {
unsigned long long offset;
unsigned long long size;
unsigned int flags;
} musaExternalMemoryBufferDesc;
  • where musaExternalMemoryBufferDesc::offset is the offset in the memory object where the buffer's base address is. musaExternalMemoryBufferDesc::size is the size of the buffer. musaExternalMemoryBufferDesc::flags must be zero.
  • The offset and size have to be suitably aligned to match the requirements of the external API. Mapping two buffers whose ranges overlap may or may not result in the same virtual address being returned for the overlapped portion. In such cases, the application must ensure that all accesses to that region from the GPU are volatile. Otherwise writes made via one address are not guaranteed to be visible via the other address, even if they're issued by the same thread. It is recommended that applications map the combined range instead of mapping separate buffers and then apply the appropriate offsets to the returned pointer to derive the individual buffers.
  • The returned pointer devPtr must be freed using musaFree.

Parameters

  • devPtr (void **): Returned device pointer to buffer
  • extMem (musaExternalMemory_t): Handle to external memory object
  • bufferDesc (const struct musaExternalMemoryBufferDesc *): Buffer descriptor

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

musaExternalMemoryGetMappedMipmappedArray

musaError_t musaExternalMemoryGetMappedMipmappedArray(musaMipmappedArray_t *mipmap, musaExternalMemory_t extMem, const struct musaExternalMemoryMipmappedArrayDesc *mipmapDesc)

Description

  • Maps a MUSA mipmapped array onto an external memory object.
  • Maps a MUSA mipmapped array onto an external object and returns a handle to it in mipmap.
  • The properties of the MUSA mipmapped array being mapped must be described in mipmapDesc. The structure musaExternalMemoryMipmappedArrayDesc is defined as follows:
typedef struct musaExternalMemoryMipmappedArrayDesc_st {
unsigned long long offset;
musaChannelFormatDesc formatDesc;
musaExtent extent;
unsigned int flags;
unsigned int numLevels;
} musaExternalMemoryMipmappedArrayDesc;
  • where musaExternalMemoryMipmappedArrayDesc::offset is the offset in the memory object where the base level of the mipmap chain is. musaExternalMemoryMipmappedArrayDesc::formatDesc describes the format of the data. musaExternalMemoryMipmappedArrayDesc::extent specifies the dimensions of the base level of the mipmap chain. musaExternalMemoryMipmappedArrayDesc::flags are flags associated with MUSA mipmapped arrays. For further details, please refer to the documentation for musaMalloc3DArray. Note that if the mipmapped array is bound as a color target in the graphics API, then the flag musaArrayColorAttachment must be specified in musaExternalMemoryMipmappedArrayDesc::flags. musaExternalMemoryMipmappedArrayDesc::numLevels specifies the total number of levels in the mipmap chain.
  • The returned MUSA mipmapped array must be freed using musaFreeMipmappedArray.

Parameters

  • mipmap (musaMipmappedArray_t *): Returned MUSA mipmapped array
  • extMem (musaExternalMemory_t): Handle to external memory object
  • mipmapDesc (const struct musaExternalMemoryMipmappedArrayDesc *): MUSA array descriptor

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.
  • If musaExternalMemoryHandleDesc::type is musaExternalMemoryHandleTypeMtSciBuf, then musaExternalMemoryMipmappedArrayDesc::numLevels must not be greater than 1.

See also

musaDestroyExternalMemory

musaError_t musaDestroyExternalMemory(musaExternalMemory_t extMem)

Description

  • Destroys an external memory object.
  • Destroys the specified external memory object. Any existing buffers and MUSA mipmapped arrays mapped onto this object must no longer be used and must be explicitly freed using musaFree and musaFreeMipmappedArray respectively.

Parameters

  • extMem (musaExternalMemory_t): External memory object to be destroyed

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.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

musaImportExternalSemaphore

musaError_t musaImportExternalSemaphore(musaExternalSemaphore_t *extSem_out, const struct musaExternalSemaphoreHandleDesc *semHandleDesc)

Description

  • Imports an external semaphore.
  • Imports an externally allocated synchronization object and returns a handle to that in extSem_out.
  • The properties of the handle being imported must be described in semHandleDesc. The musaExternalSemaphoreHandleDesc is defined as follows:
typedef struct musaExternalSemaphoreHandleDesc_st {
musaExternalSemaphoreHandleTypetype;
union {
int fd;
struct {
void *handle;
const void *name;
} win32;
const void *MtSciSyncObj;
} handle;
unsigned int flags;
} musaExternalSemaphoreHandleDesc;
  • where musaExternalSemaphoreHandleDesc::type specifies the type of handle being imported. musaExternalSemaphoreHandleType is defined as:
typedef enum musaExternalSemaphoreHandleType_enum {
musaExternalSemaphoreHandleTypeOpaqueFd = 1,
musaExternalSemaphoreHandleTypeOpaqueWin32 = 2,
musaExternalSemaphoreHandleTypeOpaqueWin32Kmt = 3,
musaExternalSemaphoreHandleTypeD3D12Fence = 4,
musaExternalSemaphoreHandleTypeD3D11Fence = 5,
musaExternalSemaphoreHandleTypeMtSciSync = 6,
musaExternalSemaphoreHandleTypeKeyedMutex = 7,
musaExternalSemaphoreHandleTypeKeyedMutexKmt = 8,
musaExternalSemaphoreHandleTypeTimelineSemaphoreFd = 9,
musaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10;
} musaExternalSemaphoreHandleType;
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeOpaqueFd, then musaExternalSemaphoreHandleDesc::handle::fd must be a valid file descriptor referencing a synchronization object. Ownership of the file descriptor is transferred to the MUSA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeOpaqueWin32, then exactly one of musaExternalSemaphoreHandleDesc::handle::win32::handle and musaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If musaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that references a synchronization object. Ownership of this handle is not transferred to MUSA after the import operation, so the application must release the handle using the appropriate system call. If musaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeOpaqueWin32Kmt, then musaExternalSemaphoreHandleDesc::handle::win32::handle must be non-NULL and musaExternalSemaphoreHandleDesc::handle::win32::name must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying object, and thus will be invalid when all references to the synchronization object are destroyed.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeD3D12Fence, then exactly one of musaExternalSemaphoreHandleDesc::handle::win32::handle and musaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If musaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Fence object. This handle holds a reference to the underlying object. If musaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object that refers to a valid ID3D12Fence object.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeD3D11Fence, then exactly one of musaExternalSemaphoreHandleDesc::handle::win32::handle and musaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If musaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D11Fence::CreateSharedHandle. If musaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object that refers to a valid ID3D11Fence object.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeMtSciSync, then musaExternalSemaphoreHandleDesc::handle::mtSciSyncObj represents a valid MtSciSyncObj.
  • musaExternalSemaphoreHandleTypeKeyedMutex, then exactly one of musaExternalSemaphoreHandleDesc::handle::win32::handle and musaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If musaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it represent a valid shared NT handle that is returned by IDXGIResource1::CreateSharedHandle when referring to a IDXGIKeyedMutex object.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeKeyedMutexKmt, then musaExternalSemaphoreHandleDesc::handle::win32::handle must be non-NULL and musaExternalSemaphoreHandleDesc::handle::win32::name must be NULL. The handle specified must represent a valid KMT handle that is returned by IDXGIResource::GetSharedHandle when referring to a IDXGIKeyedMutex object.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeTimelineSemaphoreFd, then musaExternalSemaphoreHandleDesc::handle::fd must be a valid file descriptor referencing a synchronization object. Ownership of the file descriptor is transferred to the MUSA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior.
  • If musaExternalSemaphoreHandleDesc::type is musaExternalSemaphoreHandleTypeTimelineSemaphoreWin32, then exactly one of musaExternalSemaphoreHandleDesc::handle::win32::handle and musaExternalSemaphoreHandleDesc::handle::win32::name must not be NULL. If musaExternalSemaphoreHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that references a synchronization object. Ownership of this handle is not transferred to MUSA after the import operation, so the application must release the handle using the appropriate system call. If musaExternalSemaphoreHandleDesc::handle::win32::name is not NULL, then it must name a valid synchronization object.

Parameters

  • extSem_out (musaExternalSemaphore_t *): Returned handle to an external semaphore
  • semHandleDesc (const struct musaExternalSemaphoreHandleDesc *): Semaphore import handle descriptor

Returns

  • musaSuccess, musaErrorInvalidResourceHandle, musaErrorOperatingSystem

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

musaSignalExternalSemaphoresAsync

musaError_t musaSignalExternalSemaphoresAsync(const musaExternalSemaphore_t *extSemArray, const struct musaExternalSemaphoreSignalParams *paramsArray, unsigned int numExtSems, musaStream_t stream)

Description

  • Signals a set of external semaphore objects.
  • Enqueues a signal operation on a set of externally allocated semaphore object in the specified stream. The operations will be executed when all prior operations in the stream complete.
  • The exact semantics of signaling a semaphore depends on the type of the object.
  • If the semaphore object is any one of the following types: musaExternalSemaphoreHandleTypeOpaqueFd, musaExternalSemaphoreHandleTypeOpaqueWin32, musaExternalSemaphoreHandleTypeOpaqueWin32Kmt then signaling the semaphore will set it to the signaled state.
  • If the semaphore object is any one of the following types: musaExternalSemaphoreHandleTypeD3D12Fence, musaExternalSemaphoreHandleTypeD3D11Fence, musaExternalSemaphoreHandleTypeTimelineSemaphoreFd, musaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 then the semaphore will be set to the value specified in musaExternalSemaphoreSignalParams::params::fence::value.
  • If the semaphore object is of the type musaExternalSemaphoreHandleTypeMtSciSync this API sets musaExternalSemaphoreSignalParams::params::mtSciSync::fence to a value that can be used by subsequent waiters of the same MtSciSync object to order operations with those currently submitted in stream. Such an update will overwrite previous contents of musaExternalSemaphoreSignalParams::params::mtSciSync::fence. By default, signaling such an external semaphore object causes appropriate memory synchronization operations to be performed over all the external memory objects that are imported as musaExternalMemoryHandleTypeMtSciBuf. This ensures that any subsequent accesses made by other importers of the same set of MtSciBuf memory object(s) are coherent. These operations can be skipped by specifying the flag musaExternalSemaphoreSignalSkipMtSciBufMemSync, which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios where data coherency is required results in undefined behavior. Also, for semaphore object of the type musaExternalSemaphoreHandleTypeMtSciSync, if the MtSciSyncAttrList used to create the MtSciSyncObj had not set the flags in musaDeviceGetMtSciSyncAttributes to musaMtSciSyncAttrSignal, this API will return musaErrorNotSupported.
  • musaExternalSemaphoreSignalParams::params::mtSciSync::fence associated with semaphore object of the type musaExternalSemaphoreHandleTypeMtSciSync can be deterministic. For this the MtSciSyncAttrList used to create the semaphore object must have value of MtSciSyncAttrKey_RequireDeterministicFences key set to true. Deterministic fences allow users to enqueue a wait over the semaphore object even before corresponding signal is enqueued. For such a semaphore object, MUSA guarantees that each signal operation will increment the fence value by '1'. Users are expected to track count of signals enqueued on the semaphore object and insert waits accordingly. When such a semaphore object is signaled from multiple streams, due to concurrent stream execution, it is possible that the order in which the semaphore gets signaled is indeterministic. This could lead to waiters of the semaphore getting unblocked incorrectly. Users are expected to handle such situations, either by not using the same semaphore object with deterministic fence support enabled in different streams or by adding explicit dependency amongst such streams so that the semaphore is signaled in order.
  • If the semaphore object is any one of the following types: musaExternalSemaphoreHandleTypeKeyedMutex, musaExternalSemaphoreHandleTypeKeyedMutexKmt, then the keyed mutex will be released with the key specified in musaExternalSemaphoreSignalParams::params::keyedmutex::key.

Parameters

  • extSemArray (const musaExternalSemaphore_t *): Set of external semaphores to be signaled
  • paramsArray (const struct musaExternalSemaphoreSignalParams *): Array of semaphore parameters
  • numExtSems (unsigned int): Number of semaphores to signal
  • stream (musaStream_t): Stream to enqueue the signal operations in

Returns

  • musaSuccess, musaErrorInvalidResourceHandle

Note

  • Additional exported symbol names in scope: musaSignalExternalSemaphoresAsync_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

musaWaitExternalSemaphoresAsync

musaError_t musaWaitExternalSemaphoresAsync(const musaExternalSemaphore_t *extSemArray, const struct musaExternalSemaphoreWaitParams *paramsArray, unsigned int numExtSems, musaStream_t stream)

Description

  • Waits on a set of external semaphore objects.
  • Enqueues a wait operation on a set of externally allocated semaphore object in the specified stream. The operations will be executed when all prior operations in the stream complete.
  • The exact semantics of waiting on a semaphore depends on the type of the object.
  • If the semaphore object is any one of the following types: musaExternalSemaphoreHandleTypeOpaqueFd, musaExternalSemaphoreHandleTypeOpaqueWin32, musaExternalSemaphoreHandleTypeOpaqueWin32Kmt then waiting on the semaphore will wait until the semaphore reaches the signaled state. The semaphore will then be reset to the unsignaled state. Therefore for every signal operation, there can only be one wait operation.
  • If the semaphore object is any one of the following types: musaExternalSemaphoreHandleTypeD3D12Fence, musaExternalSemaphoreHandleTypeD3D11Fence, musaExternalSemaphoreHandleTypeTimelineSemaphoreFd, musaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 then waiting on the semaphore will wait until the value of the semaphore is greater than or equal to musaExternalSemaphoreWaitParams::params::fence::value.
  • If the semaphore object is of the type musaExternalSemaphoreHandleTypeMtSciSync then, waiting on the semaphore will wait until the musaExternalSemaphoreSignalParams::params::mtSciSync::fence is signaled by the signaler of the MtSciSyncObj that was associated with this semaphore object. By default, waiting on such an external semaphore object causes appropriate memory synchronization operations to be performed over all external memory objects that are imported as musaExternalMemoryHandleTypeMtSciBuf. This ensures that any subsequent accesses made by other importers of the same set of MtSciBuf memory object(s) are coherent. These operations can be skipped by specifying the flag musaExternalSemaphoreWaitSkipMtSciBufMemSync, which can be used as a performance optimization when data coherency is not required. But specifying this flag in scenarios where data coherency is required results in undefined behavior. Also, for semaphore object of the type musaExternalSemaphoreHandleTypeMtSciSync, if the MtSciSyncAttrList used to create the MtSciSyncObj had not set the flags in musaDeviceGetMtSciSyncAttributes to musaMtSciSyncAttrWait, this API will return musaErrorNotSupported.
  • If the semaphore object is any one of the following types: musaExternalSemaphoreHandleTypeKeyedMutex, musaExternalSemaphoreHandleTypeKeyedMutexKmt, then the keyed mutex will be acquired when it is released with the key specified in musaExternalSemaphoreSignalParams::params::keyedmutex::key or until the timeout specified by musaExternalSemaphoreSignalParams::params::keyedmutex::timeoutMs has lapsed. The timeout interval can either be a finite value specified in milliseconds or an infinite value. In case an infinite value is specified the timeout never elapses. The windows INFINITE macro must be used to specify infinite timeout

Parameters

  • extSemArray (const musaExternalSemaphore_t *): External semaphores to be waited on
  • paramsArray (const struct musaExternalSemaphoreWaitParams *): Array of semaphore parameters
  • numExtSems (unsigned int): Number of semaphores to wait on
  • stream (musaStream_t): Stream to enqueue the wait operations in

Returns

  • musaSuccess, musaErrorInvalidResourceHandle musaErrorTimeout

Note

  • Additional exported symbol names in scope: musaWaitExternalSemaphoresAsync_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

musaDestroyExternalSemaphore

musaError_t musaDestroyExternalSemaphore(musaExternalSemaphore_t extSem)

Description

  • Destroys an external semaphore.
  • Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits must have completed before the semaphore is destroyed.

Parameters

  • extSem (musaExternalSemaphore_t): External semaphore to be destroyed

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.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

3.9 Execution Control

musaLaunchKernel

musaError_t musaLaunchKernel(const void *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, musaStream_t stream)

Description

  • Launches a device function.
  • The function invokes kernel func on gridDim (gridDim.x gridDim.y gridDim.z) grid of blocks. Each block contains blockDim (blockDim.x blockDim.y blockDim.z) threads.
  • If the kernel has N parameters the args should point to array of N pointers. Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied.
  • For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N>
  • sharedMem sets the amount of dynamic shared memory that will be available to each thread block.
  • stream specifies a stream the invocation is associated to.

Parameters

  • func (const void *): Device function symbol
  • gridDim (dim3): Grid dimentions
  • blockDim (dim3): Block dimentions
  • args (void **): Arguments
  • sharedMem (size_t): Shared memory
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorSharedObjectInitFailed, 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 the default-stream note for NULL stream semantics.
  • This API operates on a musaKernel_t handle.

See also

musaLaunchKernelExC

musaError_t musaLaunchKernelExC(const musaLaunchConfig_t *config, const void *func, void **args)

Description

  • Launches a MUSA function with launch-time configuration.
  • Note that the functionally equivalent variadic template musaLaunchKernelEx is available for C++11 and newer.
  • Invokes the kernel func on config->gridDim (config->gridDim.x config->gridDim.y config->gridDim.z) grid of blocks. Each block contains config->blockDim (config->blockDim.x config->blockDim.y config->blockDim.z) threads.
  • config->dynamicSmemBytes sets the amount of dynamic shared memory that will be available to each thread block.
  • config->stream specifies a stream the invocation is associated to.
  • Configuration beyond grid and block dimensions, dynamic shared memory size, and stream can be provided with the following two fields of config:
  • config->attrs is an array of config->numAttrs contiguous musaLaunchAttribute elements. The value of this pointer is not considered if config->numAttrs is zero. However, in that case, it is recommended to set the pointer to NULL. config->numAttrs is the number of attributes populating the first config->numAttrs positions of the config->attrs array.
  • If the kernel has N parameters the args should point to array of N pointers. Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied.
  • N.B. This function is so named to avoid unintentionally invoking the templated version, musaLaunchKernelEx, for kernels taking a single void** or void* parameter.

Parameters

  • config (const musaLaunchConfig_t *): Launch configuration
  • func (const void *): Kernel to launch
  • args (void **): Array of pointers to kernel parameters

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorSharedObjectInitFailed, 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 the default-stream note for NULL stream semantics.
  • This API operates on a musaKernel_t handle.

See also

  • musaLaunchKernelEx(const musaLaunchConfig_t *config, void (*kernel)(ExpTypes...), ActTypes &&... args) "musaLaunchKernelEx (C++ API)", muLaunchKernelEx

musaLaunchCooperativeKernel

musaError_t musaLaunchCooperativeKernel(const void *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, musaStream_t stream)

Description

  • Launches a device function where thread blocks can cooperate and synchronize as they execute.
  • The function invokes kernel func on gridDim (gridDim.x gridDim.y gridDim.z) grid of blocks. Each block contains blockDim (blockDim.x blockDim.y blockDim.z) threads.
  • The device on which this kernel is invoked must have a non-zero value for the device attribute musaDevAttrCooperativeLaunch.
  • The total number of blocks launched cannot exceed the maximum number of blocks per multiprocessor as returned by musaOccupancyMaxActiveBlocksPerMultiprocessor (or musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors as specified by the device attribute musaDevAttrMultiProcessorCount.
  • The kernel cannot make use of MUSA dynamic parallelism.
  • If the kernel has N parameters the args should point to array of N pointers. Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied.
  • For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N>
  • sharedMem sets the amount of dynamic shared memory that will be available to each thread block.
  • stream specifies a stream the invocation is associated to.

Parameters

  • func (const void *): Device function symbol
  • gridDim (dim3): Grid dimentions
  • blockDim (dim3): Block dimentions
  • args (void **): Arguments
  • sharedMem (size_t): Shared memory
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorCooperativeLaunchTooLarge, musaErrorSharedObjectInitFailed

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.
  • This API operates on a musaKernel_t handle.

See also

musaLaunchCooperativeKernelMultiDevice

musaError_t musaLaunchCooperativeKernelMultiDevice(struct musaLaunchParams *launchParamsList, unsigned int numDevices, unsigned int flags)

Description

  • Launches device functions on multiple devices where thread blocks can cooperate and synchronize as they execute.
  • DeprecatedThis function is deprecated as of MUSA 11.3.
  • Invokes kernels as specified in the launchParamsList array where each element of the array specifies all the parameters required to perform a single kernel launch. These kernels can cooperate and synchronize as they execute. The size of the array is specified by numDevices.
  • No two kernels can be launched on the same device. All the devices targeted by this multi-device launch must be identical. All devices must have a non-zero value for the device attribute musaDevAttrCooperativeMultiDeviceLaunch.
  • The same kernel must be launched on all devices. Note that any device or constant variables are independently instantiated on every device. It is the application's responsiblity to ensure these variables are initialized and used appropriately.
  • The size of the grids as specified in blocks, the size of the blocks themselves and the amount of shared memory used by each thread block must also match across all launched kernels.
  • The streams used to launch these kernels must have been created via either musaStreamCreate or musaStreamCreateWithPriority or musaStreamCreateWithPriority. The NULL stream or musaStreamLegacy or musaStreamPerThread cannot be used.
  • The total number of blocks launched per kernel cannot exceed the maximum number of blocks per multiprocessor as returned by musaOccupancyMaxActiveBlocksPerMultiprocessor (or musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors as specified by the device attribute musaDevAttrMultiProcessorCount. Since the total number of blocks launched per device has to match across all devices, the maximum number of blocks that can be launched per device will be limited by the device with the least number of multiprocessors.
  • The kernel cannot make use of MUSA dynamic parallelism.
  • The musaLaunchParams structure is defined as:
struct musaLaunchParams {
void *func;
dim3 gridDim;
dim3 blockDim;
void **args;
size_t sharedMem;
musaStream_t stream;
};
  • ; where: musaLaunchParams::func specifies the kernel to be launched. This same functions must be launched on all devices. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N> musaLaunchParams::gridDim specifies the width, height and depth of the grid in blocks. This must match across all kernels launched. musaLaunchParams::blockDim is the width, height and depth of each thread block. This must match across all kernels launched. musaLaunchParams::args specifies the arguments to the kernel. If the kernel has N parameters then musaLaunchParams::args should point to array of N pointers. Each pointer, from musaLaunchParams::args[0] to musaLaunchParams::args[N - 1], point to the region of memory from which the actual parameter will be copied. musaLaunchParams::sharedMem is the dynamic shared-memory size per thread block in bytes. This must match across all kernels launched. musaLaunchParams::stream is the handle to the stream to perform the launch in. This cannot be the NULL stream or musaStreamLegacy or musaStreamPerThread.
  • By default, the kernel won't begin execution on any GPU until all prior work in all the specified streams has completed. This behavior can be overridden by specifying the flag musaCooperativeLaunchMultiDeviceNoPreSync. When this flag is specified, each kernel will only wait for prior work in the stream corresponding to that GPU to complete before it begins execution.
  • Similarly, by default, any subsequent work pushed in any of the specified streams will not begin execution until the kernels on all GPUs have completed. This behavior can be overridden by specifying the flag musaCooperativeLaunchMultiDeviceNoPostSync. When this flag is specified, any subsequent work pushed in any of the specified streams will only wait for the kernel launched on the GPU corresponding to that stream to complete before it begins execution.

Parameters

  • launchParamsList (struct musaLaunchParams *): List of launch parameters, one per device
  • numDevices (unsigned int): Size of the launchParamsList array
  • flags (unsigned int): Flags to control launch behavior

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorCooperativeLaunchTooLarge, musaErrorSharedObjectInitFailed

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

musaFuncSetCacheConfig

musaError_t musaFuncSetCacheConfig(const void *func, enum musaFuncCache cacheConfig)

Description

  • Sets the preferred cache configuration for a device function.
  • On devices where the L1 cache and shared memory use the same hardware resources, this sets through cacheConfig the preferred cache configuration for the function specified via func. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute func.
  • func is a device function symbol and must be declared as a global function. If the specified function does not exist, then musaErrorInvalidDeviceFunction is returned. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N>
  • 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

  • func (const void *): Device function symbol
  • cacheConfig (enum musaFuncCache): Requested cache configuration

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction

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 string-based API is deprecated; use the newer typed API instead.
  • This API does not accept a musaKernel_t casted as void*. If cache config modification is required for a musaKernel_t (or a global function), it can be replaced with a call to musaFuncSetAttributes with the attribute musaFuncAttributePreferredSharedMemoryCarveout to specify a more granular L1 cache and shared memory split configuration.

See also

musaFuncGetAttributes

musaError_t musaFuncGetAttributes(struct musaFuncAttributes *attr, const void *func)

Description

  • Find out attributes for a given function.
  • This function obtains the attributes of a function specified via func. func is a device function symbol and must be declared as a global function. The fetched attributes are placed in attr. If the specified function does not exist, then it is assumed to be a musaKernel_t and used as is. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N>
  • Note that some function attributes such as maxThreadsPerBlock may vary based on the device that is currently being used.

Parameters

  • attr (struct musaFuncAttributes *): Return pointer to function's attributes
  • func (const void *): Device function symbol

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction

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 string-based API is deprecated; use the newer typed API instead.
  • This API operates on a musaKernel_t handle.

See also

musaFuncSetAttribute

musaError_t musaFuncSetAttribute(const void *func, enum musaFuncAttribute attr, int value)

Description

  • Set attributes for a given function.
  • This function sets the attributes of a function specified via func. The parameter func must be a pointer to a function that executes on the device. The parameter specified by func must be declared as a global function. The enumeration defined by attr is set to the value defined by value. If the specified function does not exist, then it is assumed to be a musaKernel_t and used as is. If the specified attribute cannot be written, or if the value is incorrect, then musaErrorInvalidValue is returned.
  • Valid values for attr are: musaFuncAttributeMaxDynamicSharedMemorySize - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute sharedSizeBytes cannot exceed the device attribute musaDevAttrMaxSharedMemoryPerBlockOptin. The maximal size of requestable dynamic shared memory may differ by GPU architecture. musaFuncAttributePreferredSharedMemoryCarveout - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See musaDevAttrMaxSharedMemoryPerMultiprocessor. This is only a hint, and the driver can choose a different ratio if required to execute the function. musaFuncAttributeRequiredClusterWidth: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterHeight: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterDepth: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeNonPortableClusterSizeAllowed: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. musaFuncAttributeClusterSchedulingPolicyPreference: The block scheduling policy of a function. The value type is musaClusterSchedulingPolicy.

Parameters

  • func (const void *): Function to get attributes of
  • attr (enum musaFuncAttribute): Attribute to set
  • value (int): Value to set

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction, 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.
  • This API operates on a musaKernel_t handle.

musaFuncGetName

musaError_t musaFuncGetName(const char **name, const void *func)

Description

  • Returns the function name for a device entry function pointer.
  • Returns in **name the function name associated with the symbol func . The function name is returned as a null-terminated string. This API may return a mangled name if the function is not declared as having C linkage. If **name is NULL, musaErrorInvalidValue is returned. If func is not a device entry function, then it is assumed to be a musaKernel_t and used as is.

Parameters

  • name (const char **): The returned name of the function
  • func (const void *): The function pointer to retrieve name for

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction

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 operates on a musaKernel_t handle.

musaFuncGetParamCount

musaError_t musaFuncGetParamCount(const void *func, size_t *paramCount)

Description

  • Returns the number of parameters used by the function.
  • Queries the number of kernel parameters used by func and returns it in paramCount

Parameters

  • func (const void *): The function to query
  • paramCount (size_t *): Returns the number of parameters used by the function

Returns

  • MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE

Note

  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

musaFuncGetParamInfo

musaError_t musaFuncGetParamInfo(const void *func, size_t paramIndex, size_t *paramOffset, size_t *paramSize)

Description

  • Returns the offset and size of a kernel parameter in the device-side parameter layout.
  • Queries the kernel parameter at paramIndex in func's list of parameters and returns parameter information via paramOffset and paramSize. paramOffset returns the offset of the parameter in the device-side parameter layout. paramSize returns the size in bytes of the parameter. This information can be used to update kernel node parameters from the device via musaGraphKernelNodeSetParam() and musaGraphKernelNodeUpdatesApply(). paramIndex must be less than the number of parameters that func takes.

Parameters

  • func (const void *): The function to query
  • paramIndex (size_t): The parameter index to query
  • paramOffset (size_t *): The offset into the device-side parameter layout at which the parameter resides
  • paramSize (size_t *): The size of the parameter in the device-side parameter layout

Returns

  • MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE

Note

  • This function may also return error codes from previous, asynchronous launches.
  • This API operates on a musaKernel_t handle.

musaLaunchHostFunc

musaError_t musaLaunchHostFunc(musaStream_t stream, musaHostFn_t fn, void *userData)

Description

  • Converts a double argument to be executed on a device.
  • Converts the double value of d to an internal float representation if the device does not support double arithmetic. If the device does natively support doubles, then this function does nothing.
  • DeprecatedThis function is deprecated as of MUSA 7.5
  • Converts the double value of d from a potentially internal float representation if the device does not support double arithmetic. If the device does natively support doubles, then this function does nothing.
  • Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work added after it.
  • The host function must not make any MUSA API calls. Attempting to use a MUSA API may result in musaErrorNotPermitted, but this is not required. The host function must not perform any synchronization that may depend on outstanding MUSA work not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined order and may be serialized.
  • For the purposes of Unified Memory, execution makes a number of guarantees: The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use memory attached to the stream it was enqueued in. The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately prior to the function. It thus synchronizes streams which have been "joined" prior to the function. Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added to another stream, if the work has been ordered behind the function call with an event. Completion of the function does not cause a stream to become active except as described above. The stream will remain idle if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end of the stream.
  • Note that, in constrast to muStreamAddCallback, the function will not be called in the event of an error in the MUSA context.

Parameters

  • stream (musaStream_t)
  • fn (musaHostFn_t): The function to call once preceding stream operations are complete
  • userData (void *): User-specified data to be passed to the function

Returns

  • musaSuccess
  • musaSuccess, musaErrorInvalidResourceHandle, 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 the default-stream note for NULL stream semantics.

See also

3.10 Execution Control [DEPRECATED]

musaFuncSetSharedMemConfig

musaError_t musaFuncSetSharedMemConfig(const void *func, enum musaSharedMemConfig config)

Description

  • Sets the shared memory configuration for a device function.
  • Deprecated
  • On devices with configurable shared memory banks, this function will force all subsequent launches of the specified device function to have the given shared memory bank size configuration. On any given launch of the function, the shared memory configuration of the device will be temporarily changed if needed to suit the function's preferred configuration. Changes in shared memory configuration between subsequent launches of functions, may introduce a device side synchronization point.
  • Any per-function setting of shared memory bank size set via musaFuncSetSharedMemConfig will override the device wide setting set by musaDeviceSetSharedMemConfig.
  • 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.
  • For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N>
  • The supported bank configurations are: musaSharedMemBankSizeDefault: use the device's shared memory configuration when launching this function. musaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively when launching this function. musaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively when launching this function.

Parameters

  • func (const void *): Device function symbol
  • config (enum musaSharedMemConfig): Requested shared memory configuration

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction, 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.
  • This string-based API is deprecated; use the newer typed API instead.

See also

3.11 Occupancy

musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags

musaError_t musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSMemSize, unsigned int flags)

Description

  • Returns occupancy for a device function with the specified flags.
  • Returns in *numBlocks the maximum number of active blocks per streaming multiprocessor for the device function.
  • The flags parameter controls how special cases are handled. Valid flags include:
  • musaOccupancyDefault: keeps the default behavior as musaOccupancyMaxActiveBlocksPerMultiprocessor musaOccupancyDisableCachingOverride: This flag suppresses the default behavior on platform where global caching affects occupancy. On such platforms, if caching is enabled, but per-block SM resource usage would result in zero occupancy, the occupancy calculator will calculate the occupancy as if caching is disabled. Setting this flag makes the occupancy calculator to return 0 in such cases. More information can be found about this feature in the "Unified L1/Texture Cache" section of the Maxwell tuning guide.

Parameters

  • numBlocks (int *): Returned occupancy
  • func (const void *): Kernel function for which occupancy is calculated
  • blockSize (int): Block size the kernel is intended to be launched with
  • dynamicSMemSize (size_t): Per-block dynamic shared memory usage intended, in bytes
  • flags (unsigned int): Requested behavior for the occupancy calculator

Returns

  • musaSuccess, musaErrorInvalidDevice, musaErrorInvalidDeviceFunction, musaErrorInvalidValue, 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.
  • This API operates on a musaKernel_t handle.

See also

  • musaOccupancyMaxActiveBlocksPerMultiprocessor, musaOccupancyMaxPotentialBlockSize (C++ API), musaOccupancyMaxPotentialBlockSizeWithFlags (C++ API), musaOccupancyMaxPotentialBlockSizeVariableSMem (C++ API), musaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags (C++ API), musaOccupancyAvailableDynamicSMemPerBlock (C++ API), muOccupancyMaxActiveBlocksPerMultiprocessorWithFlags

3.12 Memory Management

musaMallocManaged

musaError_t musaMallocManaged(void **devPtr, size_t size, unsigned int flags)

Description

  • Allocates memory that will be automatically managed by the Unified Memory system.
  • Allocates size bytes of managed memory on the device and returns in *devPtr a pointer to the allocated memory. If the device doesn't support allocating managed memory, musaErrorNotSupported is returned. Support for managed memory can be queried using the device attribute musaDevAttrManagedMemory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. If size is 0, musaMallocManaged returns musaErrorInvalidValue. The pointer is valid on the CPU and on all GPUs in the system that support managed memory. All accesses to this pointer must obey the Unified Memory programming model.
  • flags specifies the default stream association for this allocation. flags must be one of musaMemAttachGlobal or musaMemAttachHost. The default value for flags is musaMemAttachGlobal. If musaMemAttachGlobal is specified, then this memory is accessible from any stream on any device. If musaMemAttachHost is specified, then the allocation should not be accessed from devices that have a zero value for the device attribute musaDevAttrConcurrentManagedAccess; an explicit call to musaStreamAttachMemAsync will be required to enable access on such devices.
  • If the association is later changed via musaStreamAttachMemAsync to a single stream, the default association, as specifed during musaMallocManaged, is restored when that stream is destroyed. 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.
  • Memory allocated with musaMallocManaged should be released with musaFree.
  • Device memory oversubscription is possible for GPUs that have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Managed memory on such GPUs may be evicted from device memory to host memory at any time by the Unified Memory driver in order to make room for other allocations.
  • In a system where all GPUs have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess, managed memory may not be populated when this API returns and instead may be populated on access. In such systems, managed memory can migrate to any processor's memory at any time. The Unified Memory driver will employ heuristics to maintain data locality and prevent excessive page faults to the extent possible. The application can also guide the driver about memory usage patterns via musaMemAdvise. The application can also explicitly migrate memory to a desired processor's memory via musaMemPrefetchAsync.
  • In a multi-GPU system where all of the GPUs have a zero value for the device attribute musaDevAttrConcurrentManagedAccess and all the GPUs have peer-to-peer support with each other, the physical storage for managed memory is created on the GPU which is active at the time musaMallocManaged is called. All other GPUs will reference the data at reduced bandwidth via peer mappings over the PCIe bus. The Unified Memory driver does not migrate memory among such GPUs.
  • In a multi-GPU system where not all GPUs have peer-to-peer support with each other and where the value of the device attribute musaDevAttrConcurrentManagedAccess is zero for at least one of those GPUs, the location chosen for physical storage of managed memory is system-dependent. On Linux, the location chosen will be device memory as long as the current set of active contexts are on devices that either have peer-to-peer support with each other or have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. If there is an active context on a GPU that does not have a non-zero value for that device attribute and it does not have peer-to-peer support with the other devices that have active contexts on them, then the location for physical storage will be 'zero-copy' or host memory. Note that this means that managed memory that is located in device memory is migrated to host memory if a new context is created on a GPU that doesn't have a non-zero value for the device attribute and does not support peer-to-peer with at least one of the other devices that has an active context. This in turn implies that context creation may fail if there is insufficient host memory to migrate all managed allocations. On Windows, the physical storage is always created in 'zero-copy' or host memory. All GPUs will reference the data at reduced bandwidth over the PCIe bus. In these circumstances, use of the environment variable MUSA_VISIBLE_DEVICES is recommended to restrict MUSA to only use those GPUs that have peer-to-peer support. Alternatively, users can also set MUSA_MANAGED_FORCE_DEVICE_ALLOC to a non-zero value to force the driver to always use device memory for physical storage. When this environment variable is set to a non-zero value, all devices used in that process that support managed memory have to be peer-to-peer compatible with each other. The error musaErrorInvalidDevice will be returned if a device that supports managed memory is used and it is not peer-to-peer compatible with any of the other managed memory supporting devices that were previously used in that process, even if musaDeviceReset has been called on those devices. These environment variables are described in the MUSA programming guide under the "MUSA environment variables" section.

Parameters

  • devPtr (void **): Pointer to allocated device memory
  • size (size_t): Requested allocation size in bytes
  • flags (unsigned int): Must be either musaMemAttachGlobal or musaMemAttachHost (defaults to musaMemAttachGlobal)

Returns

  • musaSuccess, musaErrorMemoryAllocation, musaErrorNotSupported, 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

musaMalloc

musaError_t musaMalloc(void **devPtr, size_t size)

Description

  • Allocate memory on the device.
  • Allocates size bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. musaMalloc() returns musaErrorMemoryAllocation in case of failure.
  • The device version of musaFree cannot be used with a *devPtr allocated using the host API, and vice versa.

Parameters

  • devPtr (void **): Pointer to allocated device memory
  • size (size_t): Requested allocation size in bytes

Returns

  • musaSuccess, 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

musaMallocHost

musaError_t musaMallocHost(void **ptr, size_t size)

Description

  • Allocates page-locked memory on the host.
  • Allocates size bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as musaMemcpy*(). Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc().
  • On systems where pageableMemoryAccessUsesHostPageTables is true, musaMallocHost may not page-lock the allocated memory.
  • Page-locking excessive amounts of memory with musaMallocHost() may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device.

Parameters

  • ptr (void **): Pointer to allocated host memory
  • size (size_t): Requested allocation size in bytes

Returns

  • musaSuccess, 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

musaMallocPitch

musaError_t musaMallocPitch(void **devPtr, size_t *pitch, size_t width, size_t height)

Description

  • Allocates pitched memory on the device.
  • Allocates at least width (in bytes) * height bytes of linear memory on the device and returns in devPtr a pointer to the allocated memory. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The pitch returned in pitch by musaMallocPitch() is the width in bytes of the allocation. The intended usage of pitch is as a separate parameter of the allocation, used to compute addresses within the 2D array. Given the row and column of an array element of type T, the address is computed as: TpElement=(T)((char*)BaseAddress+Row*pitch)+Column;
  • For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations using musaMallocPitch(). Due to pitch alignment restrictions in the hardware, this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or MUSA arrays).

Parameters

  • devPtr (void **): Pointer to allocated pitched device memory
  • pitch (size_t *): Pitch for allocation
  • width (size_t): Requested pitched allocation width (in bytes)
  • height (size_t): Requested pitched allocation height

Returns

  • musaSuccess, 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

musaMallocArray

musaError_t musaMallocArray(musaArray_t *array, const struct musaChannelFormatDesc *desc, size_t width, size_t height, unsigned int flags)

Description

  • Allocate an array on the device.
  • Allocates a MUSA array according to the musaChannelFormatDesc structure desc and returns a handle to the new MUSA array in *array.
  • The musaChannelFormatDesc is defined as:
struct musaChannelFormatDesc {
int x, y, z, w;
enum musaChannelFormatKind f;
};
  • ; where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat.
  • The flags parameter enables different options to be specified that affect the allocation, as follows. musaArrayDefault: This flag's value is defined to be 0 and provides default array allocation musaArraySurfaceLoadStore: Allocates an array that can be read from or written to using a surface reference musaArrayTextureGather: This flag indicates that texture gather operations will be performed on the array. musaArraySparse: Allocates a MUSA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate. musaArrayDeferredMapping: Allocates a MUSA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate.
  • width and height must meet certain size requirements. See musaMalloc3DArray() for more details.

Parameters

  • array (musaArray_t *): Pointer to allocated array in device memory
  • desc (const struct musaChannelFormatDesc *): Requested channel format
  • width (size_t): Requested array allocation width
  • height (size_t): Requested array allocation height
  • flags (unsigned int): Requested properties of allocated array

Returns

  • musaSuccess, 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

musaFree

musaError_t musaFree(void *devPtr)

Description

  • Frees memory on the device.
  • Frees the memory space pointed to by devPtr, which must have been returned by a previous call to one of the following memory allocation APIs - musaMalloc(), musaMallocPitch(), musaMallocManaged(), musaMallocAsync(), musaMallocFromPoolAsync().
  • Note - This API will not perform any implicit synchronization when the pointer was allocated with musaMallocAsync or musaMallocFromPoolAsync. Callers must ensure that all accesses to these pointer have completed before invoking musaFree. For best performance and memory reuse, users should use musaFreeAsync to free memory allocated via the stream ordered memory allocator. For all other pointers, this API may perform implicit synchronization.
  • If musaFree(devPtr) has already been called before, an error is returned. If devPtr is 0, no operation is performed. musaFree() returns musaErrorValue in case of failure.
  • The device version of musaFree cannot be used with a *devPtr allocated using the host API, and vice versa.

Parameters

  • devPtr (void *): Device pointer to memory to free

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

musaFreeHost

musaError_t musaFreeHost(void *ptr)

Description

  • Frees page-locked memory.
  • Frees the memory space pointed to by hostPtr, which must have been returned by a previous call to musaMallocHost() or musaHostAlloc().

Parameters

  • ptr (void *): Pointer to memory to free

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

musaFreeArray

musaError_t musaFreeArray(musaArray_t array)

Description

  • Frees an array on the device.
  • Frees the MUSA array array, which must have been returned by a previous call to musaMallocArray(). If devPtr is 0, no operation is performed.

Parameters

  • array (musaArray_t): Pointer to array to free

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

musaFreeMipmappedArray

musaError_t musaFreeMipmappedArray(musaMipmappedArray_t mipmappedArray)

Description

  • Frees a mipmapped array on the device.
  • Frees the MUSA mipmapped array mipmappedArray, which must have been returned by a previous call to musaMallocMipmappedArray(). If devPtr is 0, no operation is performed.

Parameters

  • mipmappedArray (musaMipmappedArray_t): Pointer to mipmapped array to free

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

musaHostAlloc

musaError_t musaHostAlloc(void **pHost, size_t size, unsigned int flags)

Description

  • Allocates page-locked memory on the host.
  • Allocates size bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as musaMemcpy(). Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). Allocating excessive amounts of pinned memory may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device.
  • The flags parameter enables different options to be specified that affect the allocation, as follows. musaHostAllocDefault: This flag's value is defined to be 0 and causes musaHostAlloc() to emulate musaMallocHost(). musaHostAllocPortable: The memory returned by this call will be considered as pinned memory by all MUSA contexts, not just the one that performed the allocation. musaHostAllocMapped: Maps the allocation into the MUSA address space. The device pointer to the memory may be obtained by calling musaHostGetDevicePointer(). musaHostAllocWriteCombined: Allocates the memory as write-combined (WC). WC memory can be transferred across the PCI Express bus more quickly on some system configurations, but cannot be read efficiently by most CPUs. WC memory is a good option for buffers that will be written by the CPU and read by the device via mapped pinned memory or host->device transfers.
  • All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or write-combined with no restrictions.
  • In order for the musaHostAllocMapped flag to have any effect, the MUSA context must support the musaDeviceMapHost flag, which can be checked via musaGetDeviceFlags(). The musaDeviceMapHost flag is implicitly set for contexts created via the runtime API.
  • The musaHostAllocMapped flag may be specified on MUSA contexts for devices that do not support mapped pinned memory. The failure is deferred to musaHostGetDevicePointer() because the memory may be mapped into other MUSA contexts via the musaHostAllocPortable flag.
  • Memory allocated by this function must be freed with musaFreeHost().

Parameters

  • pHost (void **): Device pointer to allocated memory
  • size (size_t): Requested allocation size in bytes
  • flags (unsigned int): Requested properties of allocated memory

Returns

  • musaSuccess, 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

musaHostRegister

musaError_t musaHostRegister(void *ptr, size_t size, unsigned int flags)

Description

  • Registers an existing host memory range for use by MUSA.
  • Page-locks the memory range specified by ptr and size and maps it for the device(s) as specified by flags. This memory range also is added to the same tracking mechanism as musaHostAlloc() to automatically accelerate calls to functions such as musaMemcpy(). Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory that has not been registered. Page-locking excessive amounts of memory may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to register staging areas for data exchange between host and device.
  • On systems where pageableMemoryAccessUsesHostPageTables is true, musaHostRegister will not page-lock the memory range specified by ptr but only populate unpopulated pages.
  • musaHostRegister is supported only on I/O coherent devices that have a non-zero value for the device attribute musaDevAttrHostRegisterSupported.
  • The flags parameter enables different options to be specified that affect the allocation, as follows.
  • musaHostRegisterDefault: On a system with unified virtual addressing, the memory will be both mapped and portable. On a system with no unified virtual addressing, the memory will be neither mapped nor portable. musaHostRegisterPortable: The memory returned by this call will be considered as pinned memory by all MUSA contexts, not just the one that performed the allocation. musaHostRegisterMapped: Maps the allocation into the MUSA address space. The device pointer to the memory may be obtained by calling musaHostGetDevicePointer(). musaHostRegisterIoMemory: The passed memory pointer is treated as pointing to some memory-mapped I/O space, e.g. belonging to a third-party PCIe device, and it will marked as non cache-coherent and contiguous. musaHostRegisterReadOnly: The passed memory pointer is treated as pointing to memory that is considered read-only by the device. On platforms without musaDevAttrPageableMemoryAccessUsesHostPageTables, this flag is required in order to register memory mapped to the CPU as read-only. Support for the use of this flag can be queried from the device attribute musaDevAttrHostRegisterReadOnlySupported. Using this flag with a current context associated with a device that does not have this attribute set will cause musaHostRegister to error with musaErrorNotSupported.
  • All of these flags are orthogonal to one another: a developer may page-lock memory that is portable or mapped with no restrictions.
  • The MUSA context must have been created with the musaMapHost flag in order for the musaHostRegisterMapped flag to have any effect.
  • The musaHostRegisterMapped flag may be specified on MUSA contexts for devices that do not support mapped pinned memory. The failure is deferred to musaHostGetDevicePointer() because the memory may be mapped into other MUSA contexts via the musaHostRegisterPortable flag.
  • For devices that have a non-zero value for the device attribute musaDevAttrCanUseHostPointerForRegisteredMem, the memory can also be accessed from the device using the host pointer ptr. The device pointer returned by musaHostGetDevicePointer() may or may not match the original host pointer ptr and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will match the original pointer ptr. If any device visible to the application has a zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will not match the original host pointer ptr, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that such devices should access the memory using only of the two pointers and not both.
  • The memory page-locked by this function must be unregistered with musaHostUnregister().

Parameters

  • ptr (void *): Host pointer to memory to page-lock
  • size (size_t): Size in bytes of the address range to page-lock in bytes
  • flags (unsigned int): Flags for allocation request

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorHostMemoryAlreadyRegistered, 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

musaHostUnregister

musaError_t musaHostUnregister(void *ptr)

Description

  • Unregisters a memory range that was registered with musaHostRegister.
  • Unmaps the memory range whose base address is specified by ptr, and makes it pageable again.
  • The base address must be the same one specified to musaHostRegister().

Parameters

  • ptr (void *): Host pointer to memory to unregister

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorHostMemoryNotRegistered

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

musaHostGetDevicePointer

musaError_t musaHostGetDevicePointer(void **pDevice, void *pHost, unsigned int flags)

Description

  • Passes back device pointer of mapped host memory allocated by musaHostAlloc or registered by musaHostRegister.
  • Passes back the device pointer corresponding to the mapped, pinned host buffer allocated by musaHostAlloc() or registered by musaHostRegister().
  • musaHostGetDevicePointer() will fail if the musaDeviceMapHost flag was not specified before deferred context creation occurred, or if called on a device that does not support mapped, pinned memory.
  • For devices that have a non-zero value for the device attribute musaDevAttrCanUseHostPointerForRegisteredMem, the memory can also be accessed from the device using the host pointer pHost. The device pointer returned by musaHostGetDevicePointer() may or may not match the original host pointer pHost and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will match the original pointer pHost. If any device visible to the application has a zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will not match the original host pointer pHost, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that such devices should access the memory using only of the two pointers and not both.
  • flags provides for future releases. For now, it must be set to 0.

Parameters

  • pDevice (void **): Returned device pointer for mapped memory
  • pHost (void *): Requested host pointer mapping
  • flags (unsigned int): Flags for extensions (must be 0 for now)

Returns

  • musaSuccess, 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

musaHostGetFlags

musaError_t musaHostGetFlags(unsigned int *pFlags, void *pHost)

Description

  • Passes back flags used to allocate pinned host memory allocated by musaHostAlloc.
  • musaHostGetFlags() will fail if the input pointer does not reside in an address range allocated by musaHostAlloc().

Parameters

  • pFlags (unsigned int *): Returned flags word
  • pHost (void *): Host pointer

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

musaMalloc3D

musaError_t musaMalloc3D(struct musaPitchedPtr *pitchedDevPtr, struct musaExtent extent)

Description

  • Allocates logical 1D, 2D, or 3D memory objects on the device.
  • Allocates at least width * height * depth bytes of linear memory on the device and returns a musaPitchedPtr in which ptr is a pointer to the allocated memory. The function may pad the allocation to ensure hardware alignment requirements are met. The pitch returned in the pitch field of pitchedDevPtr is the width in bytes of the allocation.
  • The returned musaPitchedPtr contains additional fields xsize and ysize, the logical width and height of the allocation, which are equivalent to the width and height extent parameters provided by the programmer during allocation.
  • For allocations of 2D and 3D objects, it is highly recommended that programmers perform allocations using musaMalloc3D() or musaMallocPitch(). Due to alignment restrictions in the hardware, this is especially true if the application will be performing memory copies involving 2D or 3D objects (whether linear memory or MUSA arrays).

Parameters

  • pitchedDevPtr (struct musaPitchedPtr *): Pointer to allocated pitched device memory
  • extent (struct musaExtent): Requested allocation size (width field in bytes)

Returns

  • musaSuccess, 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

musaMalloc3DArray

musaError_t musaMalloc3DArray(musaArray_t *array, const struct musaChannelFormatDesc *desc, struct musaExtent extent, unsigned int flags)

Description

  • Allocate an array on the device.
  • Allocates a MUSA array according to the musaChannelFormatDesc structure desc and returns a handle to the new MUSA array in *array.
  • The musaChannelFormatDesc is defined as:
struct musaChannelFormatDesc {
int x, y, z, w;
enum musaChannelFormatKind f;
};
  • ; where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat.
  • musaMalloc3DArray() can allocate the following:
  • A 1D array is allocated if the height and depth extents are both zero. A 2D array is allocated if only the depth extent is zero. A 3D array is allocated if all three extents are non-zero. A 1D layered MUSA array is allocated if only the height extent is zero and the musaArrayLayered flag is set. Each layer is a 1D array. The number of layers is determined by the depth extent. A 2D layered MUSA array is allocated if all three extents are non-zero and the musaArrayLayered flag is set. Each layer is a 2D array. The number of layers is determined by the depth extent. A cubemap MUSA array is allocated if all three extents are non-zero and the musaArrayCubemap flag is set. Width must be equal to height, and depth must be six. A cubemap is a special type of 2D layered MUSA array, where the six layers represent the six faces of a cube. The order of the six layers in memory is the same as that listed in musaGraphicsCubeFace. A cubemap layered MUSA array is allocated if all three extents are non-zero, and both, musaArrayCubemap and musaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered MUSA array is a special type of 2D layered MUSA array that consists of a collection of cubemaps. The first six layers represent the first cubemap, the next six layers form the second cubemap, and so on.
  • The flags parameter enables different options to be specified that affect the allocation, as follows. musaArrayDefault: This flag's value is defined to be 0 and provides default array allocation musaArrayLayered: Allocates a layered MUSA array, with the depth extent indicating the number of layers musaArrayCubemap: Allocates a cubemap MUSA array. Width must be equal to height, and depth must be six. If the musaArrayLayered flag is also set, depth must be a multiple of six. musaArraySurfaceLoadStore: Allocates a MUSA array that could be read from or written to using a surface reference. musaArrayTextureGather: This flag indicates that texture gather operations will be performed on the MUSA array. Texture gather can only be performed on 2D MUSA arrays. musaArraySparse: Allocates a MUSA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. This flag can only be used for creating 2D, 3D or 2D layered sparse MUSA arrays. The physical backing memory must be allocated via muMemCreate. musaArrayDeferredMapping: Allocates a MUSA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate.
  • The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements.
  • Note that 2D MUSA arrays have different size requirements if the musaArrayTextureGather flag is set. In that case, the valid range for (width, height, depth) is ((1,maxTexture2DGather[0]), (1,maxTexture2DGather[1]), 0).
  • MUSA array type Valid extents that must always be met {(width range in elements), (height range), (depth range)} Valid extents with musaArraySurfaceLoadStore set {(width range in elements), (height range), (depth range)} 1D { (1,maxTexture1D), 0, 0 } { (1,maxSurface1D), 0, 0 } 2D { (1,maxTexture2D[0]), (1,maxTexture2D[1]), 0 } { (1,maxSurface2D[0]), (1,maxSurface2D[1]), 0 } 3D { (1,maxTexture3D[0]), (1,maxTexture3D[1]), (1,maxTexture3D[2]) } OR { (1,maxTexture3DAlt[0]), (1,maxTexture3DAlt[1]), (1,maxTexture3DAlt[2]) } { (1,maxSurface3D[0]), (1,maxSurface3D[1]), (1,maxSurface3D[2]) } 1D Layered { (1,maxTexture1DLayered[0]), 0, (1,maxTexture1DLayered[1]) } { (1,maxSurface1DLayered[0]), 0, (1,maxSurface1DLayered[1]) } 2D Layered { (1,maxTexture2DLayered[0]), (1,maxTexture2DLayered[1]), (1,maxTexture2DLayered[2]) } { (1,maxSurface2DLayered[0]), (1,maxSurface2DLayered[1]), (1,maxSurface2DLayered[2]) } Cubemap { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } Cubemap Layered { (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[1]) } { (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[1]) }

Parameters

  • array (musaArray_t *): Pointer to allocated array in device memory
  • desc (const struct musaChannelFormatDesc *): Requested channel format
  • extent (struct musaExtent): Requested allocation size (width field in elements)
  • flags (unsigned int): Flags for extensions

Returns

  • musaSuccess, 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

musaMallocMipmappedArray

musaError_t musaMallocMipmappedArray(musaMipmappedArray_t *mipmappedArray, const struct musaChannelFormatDesc *desc, struct musaExtent extent, unsigned int numLevels, unsigned int flags)

Description

  • Allocate a mipmapped array on the device.
  • Allocates a MUSA mipmapped array according to the musaChannelFormatDesc structure desc and returns a handle to the new MUSA mipmapped array in *mipmappedArray. numLevels specifies the number of mipmap levels to be allocated. This value is clamped to the range [1, 1 + floor(log2(max(width, height, depth)))].
  • The musaChannelFormatDesc is defined as:
struct musaChannelFormatDesc {
int x, y, z, w;
enum musaChannelFormatKind f;
};
  • ; where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat.
  • musaMallocMipmappedArray() can allocate the following:
  • A 1D mipmapped array is allocated if the height and depth extents are both zero. A 2D mipmapped array is allocated if only the depth extent is zero. A 3D mipmapped array is allocated if all three extents are non-zero. A 1D layered MUSA mipmapped array is allocated if only the height extent is zero and the musaArrayLayered flag is set. Each layer is a 1D mipmapped array. The number of layers is determined by the depth extent. A 2D layered MUSA mipmapped array is allocated if all three extents are non-zero and the musaArrayLayered flag is set. Each layer is a 2D mipmapped array. The number of layers is determined by the depth extent. A cubemap MUSA mipmapped array is allocated if all three extents are non-zero and the musaArrayCubemap flag is set. Width must be equal to height, and depth must be six. The order of the six layers in memory is the same as that listed in musaGraphicsCubeFace. A cubemap layered MUSA mipmapped array is allocated if all three extents are non-zero, and both, musaArrayCubemap and musaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered MUSA mipmapped array is a special type of 2D layered MUSA mipmapped array that consists of a collection of cubemap mipmapped arrays. The first six layers represent the first cubemap mipmapped array, the next six layers form the second cubemap mipmapped array, and so on.
  • The flags parameter enables different options to be specified that affect the allocation, as follows. musaArrayDefault: This flag's value is defined to be 0 and provides default mipmapped array allocation musaArrayLayered: Allocates a layered MUSA mipmapped array, with the depth extent indicating the number of layers musaArrayCubemap: Allocates a cubemap MUSA mipmapped array. Width must be equal to height, and depth must be six. If the musaArrayLayered flag is also set, depth must be a multiple of six. musaArraySurfaceLoadStore: This flag indicates that individual mipmap levels of the MUSA mipmapped array will be read from or written to using a surface reference. musaArrayTextureGather: This flag indicates that texture gather operations will be performed on the MUSA array. Texture gather can only be performed on 2D MUSA mipmapped arrays, and the gather operations are performed only on the most detailed mipmap level. musaArraySparse: Allocates a MUSA mipmapped array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. This flag can only be used for creating 2D, 3D or 2D layered sparse MUSA mipmapped arrays. The physical backing memory must be allocated via muMemCreate. musaArrayDeferredMapping: Allocates a MUSA mipmapped array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate.
  • The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements.
  • MUSA array type Valid extents that must always be met {(width range in elements), (height range), (depth range)} Valid extents with musaArraySurfaceLoadStore set {(width range in elements), (height range), (depth range)} 1D { (1,maxTexture1DMipmap), 0, 0 } { (1,maxSurface1D), 0, 0 } 2D { (1,maxTexture2DMipmap[0]), (1,maxTexture2DMipmap[1]), 0 } { (1,maxSurface2D[0]), (1,maxSurface2D[1]), 0 } 3D { (1,maxTexture3D[0]), (1,maxTexture3D[1]), (1,maxTexture3D[2]) } OR { (1,maxTexture3DAlt[0]), (1,maxTexture3DAlt[1]), (1,maxTexture3DAlt[2]) } { (1,maxSurface3D[0]), (1,maxSurface3D[1]), (1,maxSurface3D[2]) } 1D Layered { (1,maxTexture1DLayered[0]), 0, (1,maxTexture1DLayered[1]) } { (1,maxSurface1DLayered[0]), 0, (1,maxSurface1DLayered[1]) } 2D Layered { (1,maxTexture2DLayered[0]), (1,maxTexture2DLayered[1]), (1,maxTexture2DLayered[2]) } { (1,maxSurface2DLayered[0]), (1,maxSurface2DLayered[1]), (1,maxSurface2DLayered[2]) } Cubemap { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } Cubemap Layered { (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[1]) } { (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[1]) }

Parameters

  • mipmappedArray (musaMipmappedArray_t *): Pointer to allocated mipmapped array in device memory
  • desc (const struct musaChannelFormatDesc *): Requested channel format
  • extent (struct musaExtent): Requested allocation size (width field in elements)
  • numLevels (unsigned int): Number of mipmap levels to allocate
  • flags (unsigned int): Flags for extensions

Returns

  • musaSuccess, 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

musaGetMipmappedArrayLevel

musaError_t musaGetMipmappedArrayLevel(musaArray_t *levelArray, musaMipmappedArray_const_t mipmappedArray, unsigned int level)

Description

  • Gets a mipmap level of a MUSA mipmapped array.
  • Returns in *levelArray a MUSA array that represents a single mipmap level of the MUSA mipmapped array mipmappedArray.
  • If level is greater than the maximum number of levels in this mipmapped array, musaErrorInvalidValue is returned.
  • If mipmappedArray is NULL, musaErrorInvalidResourceHandle is returned.

Parameters

  • levelArray (musaArray_t *): Returned mipmap level MUSA array
  • mipmappedArray (musaMipmappedArray_const_t): MUSA mipmapped array
  • level (unsigned int): Mipmap level

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

musaMemcpy3D

musaError_t musaMemcpy3D(const struct musaMemcpy3DParms *p)

Description

  • Copies data between 3D objects.
struct musaExtent {
size_t width;
size_t height;
size_t depth;
};
  • ;
struct musaExtent make_musaExtent(size_t w, size_t h, size_t d);
struct musaPos {
size_t x;
size_t y;
size_t z;
}
  • ;
struct musaPosmake_musaPos(size_t x, size_t y, size_t z);
struct musaMemcpy3DParms {
musaArray_t srcArray;
struct musaPossrcPos;
struct musaPitchedPtrsrcPtr;
musaArray_t dstArray;
struct musaPosdstPos;
struct musaPitchedPtrdstPtr;
struct musaExtent extent;
enum musaMemcpyKindkind;
}
  • ;
  • musaMemcpy3D() copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a MUSA array. The source, destination, extent, and kind of copy performed is specified by the musaMemcpy3DParms
struct which should be initialized to zero before use: musaMemcpy3DParmsmyParms= {
0;
}
  • ;
  • The struct passed to musaMemcpy3D() must specify one of srcArray or srcPtr and one of dstArray or dstPtr. Passing more than one non-zero source or destination will cause musaMemcpy3D() to return an error.
  • The srcPos and dstPos fields are optional offsets into the source and destination objects and are defined in units of each object's elements. The element for a host or device pointer is assumed to be unsigned char.
  • The extent field defines the dimensions of the transferred area in elements. If a MUSA array is participating in the copy, the extent is defined in terms of that array's elements. If no MUSA array is participating in the copy then the extents are defined in elements of unsigned char.
  • The kind field defines the direction of the copy. It must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. For musaMemcpyHostToHost or musaMemcpyHostToDevice or musaMemcpyDeviceToHost passed as kind and musaArray type passed as source or destination, if the kind implies musaArray type to be present on the host, musaMemcpy3D() will disregard that implication and silently correct the kind based on the fact that musaArray type can only be present on the device.
  • If the source and destination are both arrays, musaMemcpy3D() will return an error if they do not have the same element size.
  • The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result.
  • The source object must entirely contain the region defined by srcPos and extent. The destination object must entirely contain the region defined by dstPos and extent.
  • musaMemcpy3D() returns an error if the pitch of srcPtr or dstPtr exceeds the maximum allowed. The pitch of a musaPitchedPtr allocated with musaMalloc3D() will always be valid.

Parameters

  • p (const struct musaMemcpy3DParms *): 3D memory copy parameters

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for synchronization behavior.

See also

musaMemcpy3DPeer

musaError_t musaMemcpy3DPeer(const struct musaMemcpy3DPeerParms *p)

Description

  • Copies memory between devices.
  • Perform a 3D memory copy according to the parameters specified in p. See the definition of the musaMemcpy3DPeerParms structure for documentation of its parameters.
  • Note that this function is synchronous with respect to the host only if the source or destination of the transfer is host memory. Note also that this copy is serialized with respect to all pending and future asynchronous work in to the current device, the copy's source device, and the copy's destination device (use musaMemcpy3DPeerAsync to avoid this synchronization).

Parameters

  • p (const struct musaMemcpy3DPeerParms *): Parameters for the memory copy

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice, musaErrorInvalidPitchValue

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 API synchronization behavior notes for synchronization behavior.

See also

musaMemcpy3DAsync

musaError_t musaMemcpy3DAsync(const struct musaMemcpy3DParms *p, musaStream_t stream)

Description

  • Copies data between 3D objects.
struct musaExtent {
size_t width;
size_t height;
size_t depth;
};
  • ;
struct musaExtent make_musaExtent(size_t w, size_t h, size_t d);
struct musaPos {
size_t x;
size_t y;
size_t z;
}
  • ;
struct musaPosmake_musaPos(size_t x, size_t y, size_t z);
struct musaMemcpy3DParms {
musaArray_t srcArray;
struct musaPossrcPos;
struct musaPitchedPtrsrcPtr;
musaArray_t dstArray;
struct musaPosdstPos;
struct musaPitchedPtrdstPtr;
struct musaExtent extent;
enum musaMemcpyKindkind;
}
  • ;
  • musaMemcpy3DAsync() copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a MUSA array. The source, destination, extent, and kind of copy performed is specified by the musaMemcpy3DParms
struct which should be initialized to zero before use: musaMemcpy3DParmsmyParms= {
0;
}
  • ;
  • The struct passed to musaMemcpy3DAsync() must specify one of srcArray or srcPtr and one of dstArray or dstPtr. Passing more than one non-zero source or destination will cause musaMemcpy3DAsync() to return an error.
  • The srcPos and dstPos fields are optional offsets into the source and destination objects and are defined in units of each object's elements. The element for a host or device pointer is assumed to be unsigned char. For MUSA arrays, positions must be in the range [0, 2048) for any dimension.
  • The extent field defines the dimensions of the transferred area in elements. If a MUSA array is participating in the copy, the extent is defined in terms of that array's elements. If no MUSA array is participating in the copy then the extents are defined in elements of unsigned char.
  • The kind field defines the direction of the copy. It must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. For musaMemcpyHostToHost or musaMemcpyHostToDevice or musaMemcpyDeviceToHost passed as kind and musaArray type passed as source or destination, if the kind implies musaArray type to be present on the host, musaMemcpy3DAsync() will disregard that implication and silently correct the kind based on the fact that musaArray type can only be present on the device.
  • If the source and destination are both arrays, musaMemcpy3DAsync() will return an error if they do not have the same element size.
  • The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result.
  • The source object must lie entirely within the region defined by srcPos and extent. The destination object must lie entirely within the region defined by dstPos and extent.
  • musaMemcpy3DAsync() returns an error if the pitch of srcPtr or dstPtr exceeds the maximum allowed. The pitch of a musaPitchedPtr allocated with musaMalloc3D() will always be valid.
  • musaMemcpy3DAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.
  • The device version of this function only handles device to device copies and cannot be given local or shared pointers.

Parameters

  • p (const struct musaMemcpy3DParms *): 3D memory copy parameters
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemcpy3DPeerAsync

musaError_t musaMemcpy3DPeerAsync(const struct musaMemcpy3DPeerParms *p, musaStream_t stream)

Description

  • Copies memory between devices asynchronously.
  • Perform a 3D memory copy according to the parameters specified in p. See the definition of the musaMemcpy3DPeerParms structure for documentation of its parameters.

Parameters

  • p (const struct musaMemcpy3DPeerParms *): Parameters for the memory copy
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice, musaErrorInvalidPitchValue

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 API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemGetInfo

musaError_t musaMemGetInfo(size_t *free, size_t *total)

Description

  • Gets free and total device memory.
  • Returns in *total the total amount of memory available to the the current context. Returns in *free the amount of memory on the device that is free according to the OS. MUSA is not guaranteed to be able to allocate all of the memory that the OS reports as free. In a multi-tenet situation, free estimate returned is prone to race condition where a new allocation/free done by a different process or a different thread in the same process between the time when free memory was estimated and reported, will result in deviation in free value reported and actual free memory.
  • The integrated GPU on Tegra shares memory with CPU and other component of the SoC. The free and total values returned by the API excludes the SWAP memory space maintained by the OS on some platforms. The OS may move some of the memory pages into swap area as the GPU or CPU allocate or access memory. See Tegra app note on how to calculate total and free memory on Tegra.

Parameters

  • free (size_t *): Returned free memory in bytes
  • total (size_t *): Returned total memory in bytes

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure

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

musaArrayGetInfo

musaError_t musaArrayGetInfo(struct musaChannelFormatDesc *desc, struct musaExtent *extent, unsigned int *flags, musaArray_t array)

Description

  • Gets info about the specified musaArray.
  • Returns in *desc, *extent and *flags respectively, the type, shape and flags of array.
  • Any of *desc, *extent and *flags may be specified as NULL.

Parameters

  • desc (struct musaChannelFormatDesc *): Returned array type
  • extent (struct musaExtent *): Returned array shape. 2D arrays will have depth of zero
  • flags (unsigned int *): Returned array flags
  • array (musaArray_t): The musaArray to get info for

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

musaMemcpy

musaError_t musaMemcpy(void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Description

  • Returns the layout properties of a sparse MUSA array.
  • Returns the layout properties of a sparse MUSA array in sparseProperties. If the MUSA array is not allocated with flag musaArraySparse musaErrorInvalidValue will be returned.
  • If the returned value in musaArraySparseProperties::flags contains musaArraySparsePropertiesSingleMipTail, then musaArraySparseProperties::miptailSize represents the total size of the array. Otherwise, it will be zero. Also, the returned value in musaArraySparseProperties::miptailFirstLevel is always zero. Note that the array must have been allocated using musaMallocArray or musaMalloc3DArray. For MUSA arrays obtained using musaMipmappedArrayGetLevel, musaErrorInvalidValue will be returned. Instead, musaMipmappedArrayGetSparseProperties must be used to obtain the sparse properties of the entire MUSA mipmapped array to which array belongs to.
  • Returns the sparse array layout properties in sparseProperties. If the MUSA mipmapped array is not allocated with flag musaArraySparse musaErrorInvalidValue will be returned.
  • For non-layered MUSA mipmapped arrays, musaArraySparseProperties::miptailSize returns the size of the mip tail region. The mip tail region includes all mip levels whose width, height or depth is less than that of the tile. For layered MUSA mipmapped arrays, if musaArraySparseProperties::flags contains musaArraySparsePropertiesSingleMipTail, then musaArraySparseProperties::miptailSize specifies the size of the mip tail of all layers combined. Otherwise, musaArraySparseProperties::miptailSize specifies mip tail size per layer. The returned value of musaArraySparseProperties::miptailFirstLevel is valid only if musaArraySparseProperties::miptailSize is non-zero.
  • Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Calling musaMemcpy() with dst and src pointers that do not match the direction of the copy results in an undefined behavior.

Parameters

  • dst (void *): Destination memory address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess musaErrorInvalidValue
  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

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

musaMemcpyPeer

musaError_t musaMemcpyPeer(void *dst, int dstDevice, const void *src, int srcDevice, size_t count)

Description

  • Copies memory between two devices.
  • Copies memory from one device to memory on another device. dst is the base device pointer of the destination memory and dstDevice is the destination device. src is the base device pointer of the source memory and srcDevice is the source device. count specifies the number of bytes to copy.
  • Note that this function is asynchronous with respect to the host, but serialized with respect all pending and future asynchronous work in to the current device, srcDevice, and dstDevice (use musaMemcpyPeerAsync to avoid this synchronization).

Parameters

  • dst (void *): Destination device pointer
  • dstDevice (int): Destination device
  • src (const void *): Source device pointer
  • srcDevice (int): Source device
  • count (size_t): Size of memory copy in bytes

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 the API synchronization behavior notes for synchronization behavior.

See also

musaMemcpy2D

musaError_t musaMemcpy2D(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind)

Description

  • Copies data between host and device.
  • Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dpitch and spitch are the widths in memory in bytes of the 2D arrays pointed to by dst and src, including any padding added to the end of each row. The memory areas may not overlap. width must not exceed either dpitch or spitch. Calling musaMemcpy2D() with dst and src pointers that do not match the direction of the copy results in an undefined behavior. musaMemcpy2D() returns an error if dpitch or spitch exceeds the maximum allowed.

Parameters

  • dst (void *): Destination memory address
  • dpitch (size_t): Pitch of destination memory
  • src (const void *): Source memory address
  • spitch (size_t): Pitch of source memory
  • width (size_t): Width of matrix transfer (columns in bytes)
  • height (size_t): Height of matrix transfer (rows)
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for memcpy-specific synchronization semantics.

See also

musaMemcpy2DToArray

musaError_t musaMemcpy2DToArray(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind)

Description

  • Copies data between host and device.
  • Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array dst. width must not exceed spitch. musaMemcpy2DToArray() returns an error if spitch exceeds the maximum allowed.

Parameters

  • dst (musaArray_t): Destination memory address
  • wOffset (size_t): Destination starting X offset (columns in bytes)
  • hOffset (size_t): Destination starting Y offset (rows)
  • src (const void *): Source memory address
  • spitch (size_t): Pitch of source memory
  • width (size_t): Width of matrix transfer (columns in bytes)
  • height (size_t): Height of matrix transfer (rows)
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for synchronization behavior.

See also

musaMemcpy2DFromArray

musaError_t musaMemcpy2DFromArray(void *dst, size_t dpitch, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, enum musaMemcpyKind kind)

Description

  • Copies data between host and device.
  • Copies a matrix (height rows of width bytes each) from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array src. width must not exceed dpitch. musaMemcpy2DFromArray() returns an error if dpitch exceeds the maximum allowed.

Parameters

  • dst (void *): Destination memory address
  • dpitch (size_t): Pitch of destination memory
  • src (musaArray_const_t): Source memory address
  • wOffset (size_t): Source starting X offset (columns in bytes)
  • hOffset (size_t): Source starting Y offset (rows)
  • width (size_t): Width of matrix transfer (columns in bytes)
  • height (size_t): Height of matrix transfer (rows)
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for synchronization behavior.

See also

musaMemcpy2DArrayToArray

musaError_t musaMemcpy2DArrayToArray(musaArray_t dst, size_t wOffsetDst, size_t hOffsetDst, musaArray_const_t src, size_t wOffsetSrc, size_t hOffsetSrc, size_t width, size_t height, enum musaMemcpyKind kind)

Description

  • Copies data between host and device.
  • Copies a matrix (height rows of width bytes each) from the MUSA array src starting at hOffsetSrc rows and wOffsetSrc bytes from the upper left corner to the MUSA array dst starting at hOffsetDst rows and wOffsetDst bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. wOffsetDst + width must not exceed the width of the MUSA array dst. wOffsetSrc + width must not exceed the width of the MUSA array src.

Parameters

  • dst (musaArray_t): Destination memory address
  • wOffsetDst (size_t): Destination starting X offset (columns in bytes)
  • hOffsetDst (size_t): Destination starting Y offset (rows)
  • src (musaArray_const_t): Source memory address
  • wOffsetSrc (size_t): Source starting X offset (columns in bytes)
  • hOffsetSrc (size_t): Source starting Y offset (rows)
  • width (size_t): Width of matrix transfer (columns in bytes)
  • height (size_t): Height of matrix transfer (rows)
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for synchronization behavior.

See also

musaMemcpyToSymbol

musaError_t musaMemcpyToSymbol(const void *symbol, const void *src, size_t count, size_t offset, enum musaMemcpyKind kind)

Description

  • Copies data to the given symbol on the device.
  • Copies count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyHostToDevice, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.

Parameters

  • symbol (const void *): Device symbol address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • offset (size_t): Offset from start of symbol in bytes
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

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 API synchronization behavior notes for synchronization behavior.
  • This string-based API is deprecated.

See also

musaMemcpyFromSymbol

musaError_t musaMemcpyFromSymbol(void *dst, const void *symbol, size_t count, size_t offset, enum musaMemcpyKind kind)

Description

  • Copies data from the given symbol on the device.
  • Copies count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.

Parameters

  • dst (void *): Destination memory address
  • symbol (const void *): Device symbol address
  • count (size_t): Size in bytes to copy
  • offset (size_t): Offset from start of symbol in bytes
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

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 API synchronization behavior notes for synchronization behavior.
  • This string-based API is deprecated.

See also

musaMemcpyAsync

musaError_t musaMemcpyAsync(void *dst, const void *src, size_t count, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data between host and device.
  • Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • The memory areas may not overlap. Calling musaMemcpyAsync() with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
  • musaMemcpyAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and the stream is non-zero, the copy may overlap with operations in other streams.
  • The device version of this function only handles device to device copies and cannot be given local or shared pointers.

Parameters

  • dst (void *): Destination memory address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemcpyPeerAsync

musaError_t musaMemcpyPeerAsync(void *dst, int dstDevice, const void *src, int srcDevice, size_t count, musaStream_t stream)

Description

  • Copies memory between two devices asynchronously.
  • Copies memory from one device to memory on another device. dst is the base device pointer of the destination memory and dstDevice is the destination device. src is the base device pointer of the source memory and srcDevice is the source device. count specifies the number of bytes to copy.
  • Note that this function is asynchronous with respect to the host and all work on other devices.

Parameters

  • dst (void *): Destination device pointer
  • dstDevice (int): Destination device
  • src (const void *): Source device pointer
  • srcDevice (int): Source device
  • count (size_t): Size of memory copy in bytes
  • stream (musaStream_t): Stream identifier

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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemcpyBatchAsync

musaError_t musaMemcpyBatchAsync(void **dsts, void **srcs, size_t *sizes, size_t count, struct musaMemcpyAttributes *attrs, size_t *attrsIdxs, size_t numAttrs, size_t *failIdx, musaStream_t stream)

Description

  • Performs a batch of memory copies asynchronously.
  • Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed to execute in any specific order. This API only supports pointer-to-pointer copies. For copies involving MUSA arrays, please see musaMemcpy3DBatchAsync.
  • Performs memory copies from source buffers specified in srcs to destination buffers specified in dsts. The size of each copy is specified in sizes. All three arrays must be of the same length as specified by count. Since there are no ordering guarantees for copies within a batch, specifying any dependent copies within a batch will result in undefined behavior.
  • Every copy in the batch has to be associated with a set of attributes specified in the attrs array. Each entry in this array can apply to more than one copy. This can be done by specifying in the attrsIdxs array, the index of the first copy that the corresponding entry in the attrs array applies to. Both attrs and attrsIdxs must be of the same length as specified by numAttrs. For example, if a batch has 10 copies listed in dst/src/sizes, the first 6 of which have one set of attributes and the remaining 4 another, then numAttrs will be 2, attrsIdxs will be {0, 6} and attrs will contains the two sets of attributes. Note that the first entry in attrsIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than count. Furthermore, numAttrs must be lesser than or equal to count.
  • The musaMemcpyAttributes::srcAccessOrder indicates the source access ordering to be observed for copies associated with the attribute. If the source access order is set to musaMemcpySrcAccessOrderStream, then the source will be accessed in stream order. If the source access order is set to musaMemcpySrcAccessOrderDuringApiCall then it indicates that access to the source pointer can be out of stream order and all accesses must be complete before the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to synchronize the stream after the API call. If the source access order is set to musaMemcpySrcAccessOrderAny then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the API call returns. This flag is suited for host pointers allocated outside MUSA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain platforms. Each memcpy operation in the batch must have a valid musaMemcpyAttributes corresponding to it including the appropriate srcAccessOrder setting, otherwise the API will return musaErrorInvalidValue.
  • The musaMemcpyAttributes::srcLocHint and musaMemcpyAttributes::dstLocHint allows applications to specify hint locations for operands of a copy when the operand doesn't have a fixed location. That is, these hints are only applicable for managed memory pointers on devices where musaDevAttrConcurrentManagedAccess is true or system-allocated pageable memory on devices where musaDevAttrPageableMemoryAccess is true. For other cases, these hints are ignored.
  • The musaMemcpyAttributes::flags field can be used to specify certain flags for copies. Setting the musaMemcpyFlagPreferOverlapWithCompute flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint and can be ignored depending on the platform and other parameters of the copy.
  • If any error is encountered while parsing the batch, the index within the batch where the error was encountered will be returned in failIdx.

Parameters

  • dsts (void **): Array of destination pointers.
  • srcs (void **): Array of memcpy source pointers.
  • sizes (size_t *): Array of sizes for memcpy operations.
  • count (size_t): Size of dsts, srcs and sizes arrays
  • attrs (struct musaMemcpyAttributes *): Array of memcpy attributes.
  • attrsIdxs (size_t *): Array of indices to specify which copies each entry in the attrs array applies to. The attributes specified in attrs[k] will be applied to copies starting from attrsIdxs[k] through attrsIdxs[k+1] - 1. Also attrs[numAttrs-1] will apply to copies starting from attrsIdxs[numAttrs-1] through count - 1.
  • numAttrs (size_t): Size of attrs and attrsIdxs arrays.
  • failIdx (size_t *): Pointer to a location to return the index of the copy where a failure was encountered. The value will be SIZE_MAX if the error doesn't pertain to any specific copy.
  • stream (musaStream_t)

Returns

  • musaSuccess musaErrorInvalidValue

Note

  • This function may also return error codes from previous, asynchronous launches.
  • See the API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for asynchronous host/device behavior.

musaMemcpy3DBatchAsync

musaError_t musaMemcpy3DBatchAsync(size_t numOps, struct musaMemcpy3DBatchOp *opList, size_t *failIdx, unsigned long long flags, musaStream_t stream)

Description

  • Performs a batch of 3D memory copies asynchronously.
  • Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed to execute in any specific order. Note that this means specifying any dependent copies within a batch will result in undefined behavior.
  • Performs memory copies as specified in the opList array. The length of this array is specified in numOps. Each entry in this array describes a copy operation. This includes among other things, the source and destination operands for the copy as specified in musaMemcpy3DBatchOp::src and musaMemcpy3DBatchOp::dst respectively. The source and destination operands of a copy can either be a pointer or a MUSA array. The width, height and depth of a copy is specified in musaMemcpy3DBatchOp::extent. The width, height and depth of a copy are specified in elements and must not be zero. For pointer-to-pointer copies, the element size is considered to be 1. For pointer to MUSA array or vice versa copies, the element size is determined by the MUSA array. For MUSA array to MUSA array copies, the element size of the two MUSA arrays must match.
  • For a given operand, if musaMemcpy3DOperand::type is specified as musaMemcpyOperandTypePointer, then musaMemcpy3DOperand::op::ptr will be used. The musaMemcpy3DOperand::op::ptr::ptr field must contain the pointer where the copy should begin. The musaMemcpy3DOperand::op::ptr::rowLength field specifies the length of each row in elements and must either be zero or be greater than or equal to the width of the copy specified in musaMemcpy3DBatchOp::extent::width. The musaMemcpy3DOperand::op::ptr::layerHeight field specifies the height of each layer and must either be zero or be greater than or equal to the height of the copy specified in musaMemcpy3DBatchOp::extent::height. When either of these values is zero, that aspect of the operand is considered to be tightly packed according to the copy extent. For managed memory pointers on devices where musaDevAttrConcurrentManagedAccess is true or system-allocated pageable memory on devices where musaDevAttrPageableMemoryAccess is true, the musaMemcpy3DOperand::op::ptr::locHint field can be used to hint the location of the operand.
  • If an operand's type is specified as musaMemcpyOperandTypeArray, then musaMemcpy3DOperand::op::array will be used. The musaMemcpy3DOperand::op::array::array field specifies the MUSA array and musaMemcpy3DOperand::op::array::offset specifies the 3D offset into that array where the copy begins.
  • The musaMemcpyAttributes::srcAccessOrder indicates the source access ordering to be observed for copies associated with the attribute. If the source access order is set to musaMemcpySrcAccessOrderStream, then the source will be accessed in stream order. If the source access order is set to musaMemcpySrcAccessOrderDuringApiCall then it indicates that access to the source pointer can be out of stream order and all accesses must be complete before the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to synchronize the stream after the API call. If the source access order is set to musaMemcpySrcAccessOrderAny then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the API call returns. This flag is suited for host pointers allocated outside MUSA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain platforms. Each memcopy operation in opList must have a valid srcAccessOrder setting, otherwise this API will return musaErrorInvalidValue.
  • The musaMemcpyAttributes::flags field can be used to specify certain flags for copies. Setting the musaMemcpyFlagPreferOverlapWithCompute flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint and can be ignored depending on the platform and other parameters of the copy.
  • If any error is encountered while parsing the batch, the index within the batch where the error was encountered will be returned in failIdx.

Parameters

  • numOps (size_t): Total number of memcpy operations.
  • opList (struct musaMemcpy3DBatchOp *): Array of size numOps containing the actual memcpy operations.
  • failIdx (size_t *): Pointer to a location to return the index of the copy where a failure was encountered. The value will be SIZE_MAX if the error doesn't pertain to any specific copy.
  • flags (unsigned long long): Flags for future use, must be zero now.
  • stream (musaStream_t)

Returns

  • musaSuccess musaErrorInvalidValue

Note

  • This function may also return error codes from previous, asynchronous launches.
  • See the API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for asynchronous host/device behavior.

musaMemcpy2DAsync

musaError_t musaMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data between host and device.
  • Performs asynchronous memory copy operation with the specified attributes.
  • Performs asynchronous memory copy operation where dst and src are the destination and source pointers respectively. size specifies the number of bytes to copy. attr specifies the attributes for the copy and hStream specifies the stream to enqueue the operation in.
  • For more information regarding the attributes, please refer to musaMemcpyAttributes and it's usage desciption in::musaMemcpyBatchAsync
  • For more information regarding the operation, please refer to musaMemcpy3DBatchOp and it's usage desciption in::musaMemcpy3DBatchAsync
  • Calling musaMemcpy2DAsync() with dst and src pointers that do not match the direction of the copy results in an undefined behavior. musaMemcpy2DAsync() returns an error if dpitch or spitch is greater than the maximum allowed.
  • musaMemcpy2DAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.
  • The device version of this function only handles device to device copies and cannot be given local or shared pointers.

Parameters

  • dst (void *): Destination memory address
  • dpitch (size_t): Pitch of destination memory
  • src (const void *): Source memory address
  • spitch (size_t): Pitch of source memory
  • width (size_t): Width of matrix transfer (columns in bytes)
  • height (size_t): Height of matrix transfer (rows)
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue
  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

Note

  • This function may also return error codes from previous, asynchronous launches.
  • See the API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for asynchronous host/device behavior.
  • 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

musaMemcpy2DToArrayAsync

musaError_t musaMemcpy2DToArrayAsync(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data between host and device.
  • Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array dst. width must not exceed spitch. musaMemcpy2DToArrayAsync() returns an error if spitch exceeds the maximum allowed.
  • musaMemcpy2DToArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.

Parameters

  • dst (musaArray_t): Destination memory address
  • wOffset (size_t): Destination starting X offset (columns in bytes)
  • hOffset (size_t): Destination starting Y offset (rows)
  • src (const void *): Source memory address
  • spitch (size_t): Pitch of source memory
  • width (size_t): Width of matrix transfer (columns in bytes)
  • height (size_t): Height of matrix transfer (rows)
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemcpy2DFromArrayAsync

musaError_t musaMemcpy2DFromArrayAsync(void *dst, size_t dpitch, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data between host and device.
  • Copies a matrix (height rows of width bytes each) from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array src. width must not exceed dpitch. musaMemcpy2DFromArrayAsync() returns an error if dpitch exceeds the maximum allowed.
  • musaMemcpy2DFromArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.

Parameters

  • dst (void *): Destination memory address
  • dpitch (size_t): Pitch of destination memory
  • src (musaArray_const_t): Source memory address
  • wOffset (size_t): Source starting X offset (columns in bytes)
  • hOffset (size_t): Source starting Y offset (rows)
  • width (size_t): Width of matrix transfer (columns in bytes)
  • height (size_t): Height of matrix transfer (rows)
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for memcpy-specific synchronization semantics.
  • See the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemcpyToSymbolAsync

musaError_t musaMemcpyToSymbolAsync(const void *symbol, const void *src, size_t count, size_t offset, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data to the given symbol on the device.
  • Copies count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyHostToDevice, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • musaMemcpyToSymbolAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice and stream is non-zero, the copy may overlap with operations in other streams.

Parameters

  • symbol (const void *): Device symbol address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • offset (size_t): Offset from start of symbol in bytes
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

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 API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.
  • This string-based API is deprecated.

See also

musaMemcpyFromSymbolAsync

musaError_t musaMemcpyFromSymbolAsync(void *dst, const void *symbol, size_t count, size_t offset, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data from the given symbol on the device.
  • Copies count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • musaMemcpyFromSymbolAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.

Parameters

  • dst (void *): Destination memory address
  • symbol (const void *): Device symbol address
  • count (size_t): Size in bytes to copy
  • offset (size_t): Offset from start of symbol in bytes
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

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 API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.
  • This string-based API is deprecated.

See also

musaMemset

musaError_t musaMemset(void *devPtr, int value, size_t count)

Description

  • Initializes or sets device memory to a value.
  • Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value.
  • Note that this function is asynchronous with respect to the host unless devPtr refers to pinned host memory.

Parameters

  • devPtr (void *): Pointer to device memory
  • value (int): Value to set for each byte of specified memory
  • count (size_t): Size in bytes to set

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 the API synchronization behavior notes for memset-specific synchronization semantics.

See also

musaMemset2D

musaError_t musaMemset2D(void *devPtr, size_t pitch, int value, size_t width, size_t height)

Description

  • Initializes or sets device memory to a value.
  • Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. pitch is the width in bytes of the 2D array pointed to by dstPtr, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by musaMallocPitch().
  • Note that this function is asynchronous with respect to the host unless devPtr refers to pinned host memory.

Parameters

  • devPtr (void *): Pointer to 2D device memory
  • pitch (size_t): Pitch in bytes of 2D device memory(Unused if height is 1)
  • value (int): Value to set for each byte of specified memory
  • width (size_t): Width of matrix set (columns in bytes)
  • height (size_t): Height of matrix set (rows)

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 the API synchronization behavior notes for memset-specific synchronization semantics.

See also

musaMemset3D

musaError_t musaMemset3D(struct musaPitchedPtr pitchedDevPtr, int value, struct musaExtent extent)

Description

  • Initializes or sets device memory to a value.
  • Initializes each element of a 3D array to the specified value value. The object to initialize is defined by pitchedDevPtr. The pitch field of pitchedDevPtr is the width in memory in bytes of the 3D array pointed to by pitchedDevPtr, including any padding added to the end of each row. The xsize field specifies the logical width of each row in bytes, while the ysize field specifies the height of each 2D slice in rows. The pitch field of pitchedDevPtr is ignored when height and depth are both equal to 1.
  • The extents of the initialized region are specified as a width in bytes, a height in rows, and a depth in slices.
  • Extents with width greater than or equal to the xsize of pitchedDevPtr may perform significantly faster than extents narrower than the xsize. Secondarily, extents with height equal to the ysize of pitchedDevPtr will perform faster than when the height is shorter than the ysize.
  • This function performs fastest when the pitchedDevPtr has been allocated by musaMalloc3D().
  • Note that this function is asynchronous with respect to the host unless pitchedDevPtr refers to pinned host memory.

Parameters

  • pitchedDevPtr (struct musaPitchedPtr): Pointer to pitched device memory
  • value (int): Value to set for each byte of specified memory
  • extent (struct musaExtent): Size parameters for where to set device memory (width field in bytes)

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 the API synchronization behavior notes for memset-specific synchronization semantics.

See also

musaMemsetAsync

musaError_t musaMemsetAsync(void *devPtr, int value, size_t count, musaStream_t stream)

Description

  • Initializes or sets device memory to a value.
  • Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value.
  • musaMemsetAsync() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams.
  • The device version of this function only handles device to device copies and cannot be given local or shared pointers.

Parameters

  • devPtr (void *): Pointer to device memory
  • value (int): Value to set for each byte of specified memory
  • count (size_t): Size in bytes to set
  • stream (musaStream_t): 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 the API synchronization behavior notes for memset-specific synchronization semantics.
  • See the default-stream note for NULL stream semantics.

See also

musaMemset2DAsync

musaError_t musaMemset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, musaStream_t stream)

Description

  • Initializes or sets device memory to a value.
  • Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. pitch is the width in bytes of the 2D array pointed to by dstPtr, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by musaMallocPitch().
  • musaMemset2DAsync() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams.
  • The device version of this function only handles device to device copies and cannot be given local or shared pointers.

Parameters

  • devPtr (void *): Pointer to 2D device memory
  • pitch (size_t): Pitch in bytes of 2D device memory(Unused if height is 1)
  • value (int): Value to set for each byte of specified memory
  • width (size_t): Width of matrix set (columns in bytes)
  • height (size_t): Height of matrix set (rows)
  • stream (musaStream_t): 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 the API synchronization behavior notes for memset-specific synchronization semantics.
  • See the default-stream note for NULL stream semantics.

See also

musaMemset3DAsync

musaError_t musaMemset3DAsync(struct musaPitchedPtr pitchedDevPtr, int value, struct musaExtent extent, musaStream_t stream)

Description

  • Initializes or sets device memory to a value.
  • Initializes each element of a 3D array to the specified value value. The object to initialize is defined by pitchedDevPtr. The pitch field of pitchedDevPtr is the width in memory in bytes of the 3D array pointed to by pitchedDevPtr, including any padding added to the end of each row. The xsize field specifies the logical width of each row in bytes, while the ysize field specifies the height of each 2D slice in rows. The pitch field of pitchedDevPtr is ignored when height and depth are both equal to 1.
  • The extents of the initialized region are specified as a width in bytes, a height in rows, and a depth in slices.
  • Extents with width greater than or equal to the xsize of pitchedDevPtr may perform significantly faster than extents narrower than the xsize. Secondarily, extents with height equal to the ysize of pitchedDevPtr will perform faster than when the height is shorter than the ysize.
  • This function performs fastest when the pitchedDevPtr has been allocated by musaMalloc3D().
  • musaMemset3DAsync() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams.
  • The device version of this function only handles device to device copies and cannot be given local or shared pointers.

Parameters

  • pitchedDevPtr (struct musaPitchedPtr): Pointer to pitched device memory
  • value (int): Value to set for each byte of specified memory
  • extent (struct musaExtent): Size parameters for where to set device memory (width field in bytes)
  • stream (musaStream_t): 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 the API synchronization behavior notes for memset-specific synchronization semantics.
  • See the default-stream note for NULL stream semantics.

See also

musaGetSymbolAddress

musaError_t musaGetSymbolAddress(void **devPtr, const void *symbol)

Description

  • Finds the address associated with a MUSA symbol.
  • Returns in *devPtr the address of symbol symbol on the device. symbol is a variable that resides in global or constant memory space. If symbol cannot be found, or if symbol is not declared in the global or constant memory space, *devPtr is unchanged and the error musaErrorInvalidSymbol is returned.

Parameters

  • devPtr (void **): Return device pointer associated with symbol
  • symbol (const void *): Device symbol address

Returns

  • musaSuccess, musaErrorInvalidSymbol, musaErrorNoKernelImageForDevice

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 string-based API is deprecated.

See also

musaGetSymbolSize

musaError_t musaGetSymbolSize(size_t *size, const void *symbol)

Description

  • Finds the size of the object associated with a MUSA symbol.
  • Returns in *size the size of symbol symbol. symbol is a variable that resides in global or constant memory space. If symbol cannot be found, or if symbol is not declared in global or constant memory space, *size is unchanged and the error musaErrorInvalidSymbol is returned.

Parameters

  • size (size_t *): Size of object associated with symbol
  • symbol (const void *): Device symbol address

Returns

  • musaSuccess, musaErrorInvalidSymbol, musaErrorNoKernelImageForDevice

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 string-based API is deprecated.

See also

musaMemPrefetchAsync

musaError_t musaMemPrefetchAsync(const void *devPtr, size_t count, int dstDevice, musaStream_t stream)

Description

  • Prefetches memory to the specified destination device.
  • Prefetches memory to the specified destination device. devPtr is the base device pointer of the memory to be prefetched and dstDevice is the destination device. count specifies the number of bytes to copy. stream is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables, or it may also refer to system-allocated memory on systems with non-zero musaDevAttrPageableMemoryAccess.
  • Passing in musaCpuDeviceId for dstDevice will prefetch the data to host memory. If dstDevice is a GPU, then the device attribute musaDevAttrConcurrentManagedAccess must be non-zero. Additionally, stream must be associated with a device that has a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess.
  • The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the prefetch operation is enqueued in the stream.
  • If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other musaMallocManaged allocations to host memory in order to make room. Device memory allocated using musaMalloc or musaMallocArray will not be evicted.
  • By default, any mappings to the previous location of the migrated pages are removed and mappings for the new location are only setup on dstDevice. The exact behavior however also depends on the settings applied to this memory range via musaMemAdvise as described below:
  • If musaMemAdviseSetReadMostly was set on any subset of this memory range, then that subset will create a read-only copy of the pages on dstDevice.
  • If musaMemAdviseSetPreferredLocation was called on any subset of this memory range, then the pages will be migrated to dstDevice even if dstDevice is not the preferred location of any pages in the memory range.
  • If musaMemAdviseSetAccessedBy was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared.
  • Note that this API is not required for functionality and only serves to improve performance by allowing the application to migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed even when the data is actively being migrated.
  • Note that this function is asynchronous with respect to the host and all work on other devices.

Parameters

  • devPtr (const void *): Pointer to be prefetched
  • count (size_t): Size in bytes
  • dstDevice (int): Destination device to prefetch to
  • stream (musaStream_t): Stream to enqueue prefetch operation

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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemPrefetchAsync_v2

musaError_t musaMemPrefetchAsync_v2(const void *devPtr, size_t count, struct musaMemLocation location, unsigned int flags, musaStream_t stream)

Description

  • Prefetches memory to the specified destination location.
  • Prefetches memory to the specified destination location. devPtr is the base device pointer of the memory to be prefetched and location specifies the destination location. count specifies the number of bytes to copy. stream is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables, or it may also refer to system-allocated memory on systems with non-zero musaDevAttrPageableMemoryAccess.
  • Specifying musaMemLocationTypeDevice for musaMemLocation::type will prefetch memory to GPU specified by device ordinal musaMemLocation::id which must have non-zero value for the device attribute concurrentManagedAccess. Additionally, stream must be associated with a device that has a non-zero value for the device attribute concurrentManagedAccess. Specifying musaMemLocationTypeHost as musaMemLocation::type will prefetch data to host memory. Applications can request prefetching memory to a specific host NUMA node by specifying musaMemLocationTypeHostNuma for musaMemLocation::type and a valid host NUMA node id in musaMemLocation::id Users can also request prefetching memory to the host NUMA node closest to the current thread's CPU by specifying musaMemLocationTypeHostNumaCurrent for musaMemLocation::type. Note when musaMemLocation::type is etiher musaMemLocationTypeHost OR musaMemLocationTypeHostNumaCurrent, musaMemLocation::id will be ignored.
  • The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the prefetch operation is enqueued in the stream.
  • If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other musaMallocManaged allocations to host memory in order to make room. Device memory allocated using musaMalloc or musaMallocArray will not be evicted.
  • By default, any mappings to the previous location of the migrated pages are removed and mappings for the new location are only setup on the destination location. The exact behavior however also depends on the settings applied to this memory range via muMemAdvise as described below:
  • If musaMemAdviseSetReadMostly was set on any subset of this memory range, then that subset will create a read-only copy of the pages on destination location. If however the destination location is a host NUMA node, then any pages of that subset that are already in another host NUMA node will be transferred to the destination.
  • If musaMemAdviseSetPreferredLocation was called on any subset of this memory range, then the pages will be migrated to location even if location is not the preferred location of any pages in the memory range.
  • If musaMemAdviseSetAccessedBy was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared.
  • Note that this API is not required for functionality and only serves to improve performance by allowing the application to migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed even when the data is actively being migrated.
  • Note that this function is asynchronous with respect to the host and all work on other devices.

Parameters

  • devPtr (const void *): Pointer to be prefetched
  • count (size_t): Size in bytes
  • location (struct musaMemLocation): location to prefetch to
  • flags (unsigned int): flags for future use, must be zero now.
  • stream (musaStream_t): Stream to enqueue prefetch operation

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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemAdvise

musaError_t musaMemAdvise(const void *devPtr, size_t count, enum musaMemoryAdvise advice, int device)

Description

  • Performs a batch of memory prefetches asynchronously.
  • Performs a batch of memory prefetches. The batch as a whole executes in stream order but operations within a batch are not guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess otherwise the API will return an error.
  • The semantics of the individual prefetch operations are as described in musaMemPrefetchAsync.
  • Performs memory prefetch on address ranges specified in dptrs and sizes. Both arrays must be of the same length as specified by count. Each memory range specified must refer to managed memory allocated via musaMallocManaged or declared via managed variables or it may also refer to system-allocated memory when all devices have a non-zero value for musaDevAttrPageableMemoryAccess. The prefetch location for every operation in the batch is specified in the prefetchLocs array. Each entry in this array can apply to more than one operation. This can be done by specifying in the prefetchLocIdxs array, the index of the first prefetch operation that the corresponding entry in the prefetchLocs array applies to. Both prefetchLocs and prefetchLocIdxs must be of the same length as specified by numPrefetchLocs. For example, if a batch has 10 prefetches listed in dptrs/sizes, the first 4 of which are to be prefetched to one location and the remaining 6 are to be prefetched to another, then numPrefetchLocs will be 2, prefetchLocIdxs will be {0, 4} and prefetchLocs will contain the two locations. Note the first entry in prefetchLocIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than count. Furthermore, numPrefetchLocs must be lesser than or equal to count.
  • Performs a batch of memory discards. The batch as a whole executes in stream order but operations within a batch are not guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess otherwise the API will return an error.
  • Discarding a memory range informs the driver that the contents of that range are no longer useful. Discarding memory ranges allows the driver to optimize certain data migrations and can also help reduce memory pressure. This operation can be undone on any part of the range by either writing to it or prefetching it via musaMemPrefetchAsync or musaMemPrefetchBatchAsync. Reading from a discarded range, without a subsequent write or prefetch to that part of the range, will return an indeterminate value. Note that any reads, writes or prefetches to any part of the memory range that occur simultaneously with the discard operation result in undefined behavior.
  • Performs memory discard on address ranges specified in dptrs and sizes. Both arrays must be of the same length as specified by count. Each memory range specified must refer to managed memory allocated via musaMallocManaged or declared via managed variables or it may also refer to system-allocated memory when all devices have a non-zero value for musaDevAttrPageableMemoryAccess.
  • Performs a batch of memory discards followed by prefetches. The batch as a whole executes in stream order but operations within a batch are not guaranteed to execute in any specific order. All devices in the system must have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess otherwise the API will return an error.
  • Calling musaMemDiscardAndPrefetchBatchAsync is semantically equivalent to calling musaMemDiscardBatchAsync followed by musaMemPrefetchBatchAsync, but is more optimal. For more details on what discarding and prefetching imply, please refer to musaMemDiscardBatchAsync and musaMemPrefetchBatchAsync respectively. Note that any reads, writes or prefetches to any part of the memory range that occur simultaneously with this combined discard+prefetch operation result in undefined behavior.
  • Performs memory discard and prefetch on address ranges specified in dptrs and sizes. Both arrays must be of the same length as specified by count. Each memory range specified must refer to managed memory allocated via musaMallocManaged or declared via managed variables or it may also refer to system-allocated memory when all devices have a non-zero value for musaDevAttrPageableMemoryAccess. Every operation in the batch has to be associated with a valid location to prefetch the address range to and specified in the prefetchLocs array. Each entry in this array can apply to more than one operation. This can be done by specifying in the prefetchLocIdxs array, the index of the first operation that the corresponding entry in the prefetchLocs array applies to. Both prefetchLocs and prefetchLocIdxs must be of the same length as specified by numPrefetchLocs. For example, if a batch has 10 operations listed in dptrs/sizes, the first 6 of which are to be prefetched to one location and the remaining 4 are to be prefetched to another, then numPrefetchLocs will be 2, prefetchLocIdxs will be {0, 6} and prefetchLocs will contain the two set of locations. Note the first entry in prefetchLocIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than count. Furthermore, numPrefetchLocs must be lesser than or equal to count.
  • Advise the Unified Memory subsystem about the usage pattern for the memory range starting at devPtr with a size of count bytes. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables. The memory range could also refer to system-allocated pageable memory provided it represents a valid, host-accessible region of memory and all additional constraints imposed by advice as outlined below are also satisfied. Specifying an invalid system-allocated pageable memory range results in an error being returned.
  • The advice parameter can take the following values: musaMemAdviseSetReadMostly: This implies that the data is mostly going to be read from and only occasionally written to. Any read accesses from any processor to this region will create a read-only copy of at least the accessed pages in that processor's memory. Additionally, if musaMemPrefetchAsync is called on this region, it will create a read-only copy of the data on the destination processor. If any processor writes to this region, all copies of the corresponding page will be invalidated except for the one where the write occurred. The device argument is ignored for this advice. Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU that has a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Also, if a context is created on a device that does not have the device attribute musaDevAttrConcurrentManagedAccess set, then read-duplication will not occur until all such contexts are destroyed. If the memory region refers to valid system-allocated pageable memory, then the accessing device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess for a read-only copy to be created on that device. Note however that if the accessing device also has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then setting this advice will not create a read-only copy when that device accesses this memory region. musaMemAdviceUnsetReadMostly: Undoes the effect of musaMemAdviceReadMostly and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location chosen is arbitrary. musaMemAdviseSetPreferredLocation: This advice sets the preferred location for the data to be the memory belonging to device. Passing in musaCpuDeviceId for device sets the preferred location as host memory. If device is a GPU, then it must have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand, if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done using musaMemPrefetchAsync. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue to thrash indefinitely. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice, unless read accesses from device will not result in a read-only copy being created on that device as outlined in description for the advice musaMemAdviseSetReadMostly. If the memory region refers to valid system-allocated pageable memory, then device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. musaMemAdviseUnsetPreferredLocation: Undoes the effect of musaMemAdviseSetPreferredLocation and changes the preferred location to none. musaMemAdviseSetAccessedBy: This advice implies that the data will be accessed by device. Passing in musaCpuDeviceId for device will set the advice for the CPU. If device is a GPU, then the device attribute musaDevAttrConcurrentManagedAccess must be non-zero. This advice does not cause data migration and has no impact on the location of the data per se. Instead, it causes the data to always be mapped in the specified processor's page tables, as long as the location of the data permits a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically cannot access device memory directly. Any GPU that had the musaMemAdviceSetAccessedBy flag set for this data will now have its mapping updated to point to the page in host memory. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice. Additionally, if the preferred location of this memory region or any subset of it is also device, then the policies associated with musaMemAdviseSetPreferredLocation will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, then device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if device has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect. musaMemAdviseUnsetAccessedBy: Undoes the effect of musaMemAdviseSetAccessedBy. Any mappings to the data from device may be removed at any time causing accesses to result in non-fatal page faults. If the memory region refers to valid system-allocated pageable memory, then device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if device has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect.

Parameters

  • devPtr (const void *): Pointer to memory to set the advice for
  • count (size_t): Size in bytes of the memory range
  • advice (enum musaMemoryAdvise): Advice to be applied for the specified memory range
  • device (int): Device to apply the advice 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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemAdvise_v2

musaError_t musaMemAdvise_v2(const void *devPtr, size_t count, enum musaMemoryAdvise advice, struct musaMemLocation location)

Description

  • Advise about the usage of a given memory range.
  • Advise the Unified Memory subsystem about the usage pattern for the memory range starting at devPtr with a size of count bytes. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables. The memory range could also refer to system-allocated pageable memory provided it represents a valid, host-accessible region of memory and all additional constraints imposed by advice as outlined below are also satisfied. Specifying an invalid system-allocated pageable memory range results in an error being returned.
  • The advice parameter can take the following values: musaMemAdviseSetReadMostly: This implies that the data is mostly going to be read from and only occasionally written to. Any read accesses from any processor to this region will create a read-only copy of at least the accessed pages in that processor's memory. Additionally, if musaMemPrefetchAsync or musaMemPrefetchAsync_v2 is called on this region, it will create a read-only copy of the data on the destination processor. If the target location for musaMemPrefetchAsync_v2 is a host NUMA node and a read-only copy already exists on another host NUMA node, that copy will be migrated to the targeted host NUMA node. If any processor writes to this region, all copies of the corresponding page will be invalidated except for the one where the write occurred. If the writing processor is the CPU and the preferred location of the page is a host NUMA node, then the page will also be migrated to that host NUMA node. The location argument is ignored for this advice. Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU that has a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Also, if a context is created on a device that does not have the device attribute musaDevAttrConcurrentManagedAccess set, then read-duplication will not occur until all such contexts are destroyed. If the memory region refers to valid system-allocated pageable memory, then the accessing device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess for a read-only copy to be created on that device. Note however that if the accessing device also has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then setting this advice will not create a read-only copy when that device accesses this memory region. musaMemAdviceUnsetReadMostly: Undoes the effect of musaMemAdviseSetReadMostly and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location chosen is arbitrary. Note: The location argument is ignored for this advice. musaMemAdviseSetPreferredLocation: This advice sets the preferred location for the data to be the memory belonging to location. When musaMemLocation::type is musaMemLocationTypeHost, musaMemLocation::id is ignored and the preferred location is set to be host memory. To set the preferred location to a specific host NUMA node, applications must set musaMemLocation::type to musaMemLocationTypeHostNuma and musaMemLocation::id must specify the NUMA ID of the host NUMA node. If musaMemLocation::type is set to musaMemLocationTypeHostNumaCurrent, musaMemLocation::id will be ignored and the host NUMA node closest to the calling thread's CPU will be used as the preferred location. If musaMemLocation::type is a musaMemLocationTypeDevice, then musaMemLocation::id must be a valid device ordinal and the device must have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand, if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done using musaMemPrefetchAsync. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue to thrash indefinitely. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice, unless read accesses from location will not result in a read-only copy being created on that procesor as outlined in description for the advice musaMemAdviseSetReadMostly. If the memory region refers to valid system-allocated pageable memory, and musaMemLocation::type is musaMemLocationTypeDevice then musaMemLocation::id must be a valid device that has a non-zero alue for the device attribute musaDevAttrPageableMemoryAccess. musaMemAdviseUnsetPreferredLocation: Undoes the effect of musaMemAdviseSetPreferredLocation and changes the preferred location to none. The location argument is ignored for this advice. musaMemAdviseSetAccessedBy: This advice implies that the data will be accessed by processor location. The musaMemLocation::type must be either musaMemLocationTypeDevice with musaMemLocation::id representing a valid device ordinal or musaMemLocationTypeHost and musaMemLocation::id will be ignored. All other location types are invalid. If musaMemLocation::id is a GPU, then the device attribute musaDevAttrConcurrentManagedAccess must be non-zero. This advice does not cause data migration and has no impact on the location of the data per se. Instead, it causes the data to always be mapped in the specified processor's page tables, as long as the location of the data permits a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically cannot access device memory directly. Any GPU that had the musaMemAdviseSetAccessedBy flag set for this data will now have its mapping updated to point to the page in host memory. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice. Additionally, if the preferred location of this memory region or any subset of it is also location, then the policies associated with MU_MEM_ADVISE_SET_PREFERRED_LOCATION will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, and musaMemLocation::type is musaMemLocationTypeDevice then device in musaMemLocation::id must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if musaMemLocation::id has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect. MU_MEM_ADVISE_UNSET_ACCESSED_BY: Undoes the effect of musaMemAdviseSetAccessedBy. Any mappings to the data from location may be removed at any time causing accesses to result in non-fatal page faults. If the memory region refers to valid system-allocated pageable memory, and musaMemLocation::type is musaMemLocationTypeDevice then device in musaMemLocation::id must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if musaMemLocation::id has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect.

Parameters

  • devPtr (const void *): Pointer to memory to set the advice for
  • count (size_t): Size in bytes of the memory range
  • advice (enum musaMemoryAdvise): Advice to be applied for the specified memory range
  • location (struct musaMemLocation): location to apply the advice 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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemRangeGetAttribute

musaError_t musaMemRangeGetAttribute(void *data, size_t dataSize, enum musaMemRangeAttribute attribute, const void *devPtr, size_t count)

Description

  • Query an attribute of a given memory range.
  • Query an attribute about the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables.
  • The attribute parameter can take the following values: musaMemRangeAttributeReadMostly: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be 1 if all pages in the given memory range have read-duplication enabled, or 0 otherwise. musaMemRangeAttributePreferredLocation: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be a GPU device id if all pages in the memory range have that GPU as their preferred location, or it will be musaCpuDeviceId if all pages in the memory range have the CPU as their preferred location, or it will be musaInvalidDeviceId if either all the pages don't have the same preferred location or some of the pages don't have a preferred location at all. Note that the actual location of the pages in the memory range at the time of the query may be different from the preferred location. musaMemRangeAttributeAccessedBy: If this attribute is specified, data will be interpreted as an array of 32-bit integers, and dataSize must be a non-zero multiple of 4. The result returned will be a list of device ids that had musaMemAdviceSetAccessedBy set for that entire memory range. If any device does not have that advice set for the entire memory range, that device will not be included. If data is larger than the number of devices that have that advice set for that memory range, musaInvalidDeviceId will be returned in all the extra space provided. For ex., if dataSize is 12 (i.e. data has 3 elements) and only device 0 has the advice set, then the result returned will be { 0, musaInvalidDeviceId, musaInvalidDeviceId }. If data is smaller than the number of devices that have that advice set, then only as many devices will be returned as can fit in the array. There is no guarantee on which specific devices will be returned, however. musaMemRangeAttributeLastPrefetchLocation: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be the last location to which all pages in the memory range were prefetched explicitly via musaMemPrefetchAsync. This will either be a GPU id or musaCpuDeviceId depending on whether the last location for prefetch was a GPU or the CPU respectively. If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same location, musaInvalidDeviceId will be returned. Note that this simply returns the last location that the applicaton requested to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or even begun. musaMemRangeAttributePreferredLocationType: If this attribute is specified, data will be interpreted as a musaMemLocationType, and dataSize must be sizeof(musaMemLocationType). The musaMemLocationType returned will be musaMemLocationTypeDevice if all pages in the memory range have the same GPU as their preferred location, or musaMemLocationType will be musaMemLocationTypeHost if all pages in the memory range have the CPU as their preferred location, or or it will be musaMemLocationTypeHostNuma if all the pages in the memory range have the same host NUMA node ID as their preferred location or it will be musaMemLocationTypeInvalid if either all the pages don't have the same preferred location or some of the pages don't have a preferred location at all. Note that the actual location type of the pages in the memory range at the time of the query may be different from the preferred location type. musaMemRangeAttributePreferredLocationId: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the musaMemRangeAttributePreferredLocationType query for the same address range returns musaMemLocationTypeDevice, it will be a valid device ordinal or if it returns musaMemLocationTypeHostNuma, it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored. musaMemRangeAttributeLastPrefetchLocationType: If this attribute is specified, data will be interpreted as a musaMemLocationType, and dataSize must be sizeof(musaMemLocationType). The result returned will be the last location type to which all pages in the memory range were prefetched explicitly via muMemPrefetchAsync. The musaMemLocationType returned will be musaMemLocationTypeDevice if the last prefetch location was the GPU or musaMemLocationTypeHost if it was the CPU or musaMemLocationTypeHostNuma if the last prefetch location was a specific host NUMA node. If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same location, MUmemLocationType will be musaMemLocationTypeInvalid. Note that this simply returns the last location type that the application requested to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or even begun. musaMemRangeAttributeLastPrefetchLocationId: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the musaMemRangeAttributeLastPrefetchLocationType query for the same address range returns musaMemLocationTypeDevice, it will be a valid device ordinal or if it returns musaMemLocationTypeHostNuma, it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored.

Parameters

  • data (void *): A pointers to a memory location where the result of each attribute query will be written to.
  • dataSize (size_t): Array containing the size of data
  • attribute (enum musaMemRangeAttribute): The attribute to query
  • devPtr (const void *): Start of the range to query
  • count (size_t): Size of the range to query

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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemRangeGetAttributes

musaError_t musaMemRangeGetAttributes(void **data, size_t *dataSizes, enum musaMemRangeAttribute *attributes, size_t numAttributes, const void *devPtr, size_t count)

Description

  • Query attributes of a given memory range.
  • Query attributes of the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables. The attributes array will be interpreted to have numAttributes entries. The dataSizes array will also be interpreted to have numAttributes entries. The results of the query will be stored in data.
  • The list of supported attributes are given below. Please refer to musaMemRangeGetAttribute for attribute descriptions and restrictions.
  • musaMemRangeAttributeReadMostly musaMemRangeAttributePreferredLocation musaMemRangeAttributeAccessedBy musaMemRangeAttributeLastPrefetchLocation musaMemRangeAttributePreferredLocationType musaMemRangeAttributePreferredLocationId musaMemRangeAttributeLastPrefetchLocationType musaMemRangeAttributeLastPrefetchLocationId

Parameters

  • data (void **): A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written to.
  • dataSizes (size_t *): Array containing the sizes of each result
  • attributes (enum musaMemRangeAttribute *): An array of attributes to query (numAttributes and the number of attributes in this array should match)
  • numAttributes (size_t): Number of attributes to query
  • devPtr (const void *): Start of the range to query
  • count (size_t): Size of the range to query

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

musaMemoryTransfer

musaError_t musaMemoryTransfer(void *dst, const void *src, size_t count)

Description

  • Copies memory from Device to Device by transfer engine.
  • Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst.

Parameters

  • dst (void *): Destination device memory address
  • src (const void *): Source device memory address
  • count (size_t): Size in bytes to copy

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

musaMemoryTransferAsync

musaError_t musaMemoryTransferAsync(void *dst, const void *src, size_t count, musaStream_t stream)

Description

  • Copies memory from Device to Device by transfer engine asynchronously.
  • Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst.
  • The memory areas may not overlap.
  • musaMemoryTransferAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument.
  • The device version of this function cannot be given local or shared pointers.

Parameters

  • dst (void *): Destination device memory address
  • src (const void *): Source device memory address
  • count (size_t): Size in bytes to copy
  • stream (musaStream_t): 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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

3.13 Memory Management [DEPRECATED]

musaMemcpyToArray

musaError_t musaMemcpyToArray(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum musaMemcpyKind kind)

Description

  • Copies data between host and device.
  • Deprecated
  • Copies count bytes from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.

Parameters

  • dst (musaArray_t): Destination memory address
  • wOffset (size_t): Destination starting X offset (columns in bytes)
  • hOffset (size_t): Destination starting Y offset (rows)
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for synchronization behavior.

See also

musaMemcpyFromArray

musaError_t musaMemcpyFromArray(void *dst, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum musaMemcpyKind kind)

Description

  • Copies data between host and device.
  • Deprecated
  • Copies count bytes from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.

Parameters

  • dst (void *): Destination memory address
  • src (musaArray_const_t): Source memory address
  • wOffset (size_t): Source starting X offset (columns in bytes)
  • hOffset (size_t): Source starting Y offset (rows)
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for synchronization behavior.

See also

musaMemcpyToArrayAsync

musaError_t musaMemcpyToArrayAsync(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data between host and device.
  • Deprecated
  • Copies count bytes from the MUSA array src starting at hOffsetSrc rows and wOffsetSrc bytes from the upper left corner to the MUSA array dst starting at hOffsetDst rows and wOffsetDst bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • Copies count bytes from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • musaMemcpyToArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.

Parameters

  • dst (musaArray_t): Destination memory address
  • wOffset (size_t): Destination starting X offset (columns in bytes)
  • hOffset (size_t): Destination starting Y offset (rows)
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemcpyFromArrayAsync

musaError_t musaMemcpyFromArrayAsync(void *dst, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum musaMemcpyKind kind, musaStream_t stream)

Description

  • Copies data between host and device.
  • Deprecated
  • Copies count bytes from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • musaMemcpyFromArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.

Parameters

  • dst (void *): Destination memory address
  • src (musaArray_const_t): Source memory address
  • wOffset (size_t): Source starting X offset (columns in bytes)
  • hOffset (size_t): Source starting Y offset (rows)
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer
  • stream (musaStream_t): Stream identifier

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

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 API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

3.14 Stream Ordered Memory Allocator

musaMallocAsync

musaError_t musaMallocAsync(void **devPtr, size_t size, musaStream_t hStream)

Description

  • Allocates memory with stream ordered semantics.
  • Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in *dptr. The allocation must not be accessed until the the allocation operation completes. The allocation comes from the memory pool associated with the stream's device.

Parameters

  • devPtr (void **): Returned device pointer
  • size (size_t): Number of bytes to allocate
  • hStream (musaStream_t): The stream establishing the stream ordering contract and the memory pool to allocate from

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorNotSupported, musaErrorOutOfMemory

Note

  • The default memory pool of a device contains device memory from that device.
  • Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize, and MUSA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream runs.
  • During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters.
  • 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

musaFreeAsync

musaError_t musaFreeAsync(void *devPtr, musaStream_t hStream)

Description

  • Frees memory with stream ordered semantics.
  • Inserts a free operation into hStream. The allocation must not be accessed after stream execution reaches the free. After this API returns, accessing the memory from any subsequent work launched on the GPU or querying its pointer attributes results in undefined behavior.

Parameters

  • devPtr (void *)
  • hStream (musaStream_t): The stream establishing the stream ordering promise

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

Note

  • During stream capture, this function results in the creation of a free node and must therefore be passed the address of a graph allocation.
  • 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

musaMemPoolTrimTo

musaError_t musaMemPoolTrimTo(musaMemPool_t memPool, size_t minBytesToKeep)

Description

  • Tries to release memory back to the OS.
  • Releases memory back to the OS until the pool contains fewer than minBytesToKeep reserved bytes, or there is no more memory that the allocator can safely release. The allocator cannot release OS allocations that back outstanding asynchronous allocations. The OS allocations may happen at different granularity from the user allocations.

Parameters

  • memPool (musaMemPool_t)
  • minBytesToKeep (size_t): If the pool has less than minBytesToKeep reserved, the TrimTo operation is a no-op. Otherwise the pool will be guaranteed to have at least minBytesToKeep bytes reserved after the operation.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • : Allocations that have not been freed count as outstanding.
  • : Allocations that have been asynchronously freed but whose completion has not been observed on the host (eg. by a synchronize) can count as outstanding.
  • No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.

See also

musaMemPoolSetAttribute

musaError_t musaMemPoolSetAttribute(musaMemPool_t memPool, enum musaMemPoolAttr attr, void *value)

Description

  • Sets attributes of a memory pool.
  • Supported attributes are: musaMemPoolAttrReleaseThreshold: (value type = muuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS. When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory back to the OS on the next call to stream, event or context synchronize. (default 0) musaMemPoolReuseFollowEventDependencies: (value type = int) Allow musaMallocAsync to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on the free action exists. Musa events and null stream interactions can create the required stream ordered dependencies. (default enabled) musaMemPoolReuseAllowOpportunistic: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default enabled) musaMemPoolReuseAllowInternalDependencies: (value type = int) Allow musaMallocAsync to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released by musaFreeAsync (default enabled). musaMemPoolAttrReservedMemHigh: (value type = muuint64_t) Reset the high watermark that tracks the amount of backing memory that was allocated for the memory pool. It is illegal to set this attribute to a non-zero value. musaMemPoolAttrUsedMemHigh: (value type = muuint64_t) Reset the high watermark that tracks the amount of used memory that was allocated for the memory pool. It is illegal to set this attribute to a non-zero value.

Parameters

  • memPool (musaMemPool_t)
  • attr (enum musaMemPoolAttr): The attribute to modify
  • value (void *): Pointer to the value to assign

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.

See also

musaMemPoolGetAttribute

musaError_t musaMemPoolGetAttribute(musaMemPool_t memPool, enum musaMemPoolAttr attr, void *value)

Description

  • Gets attributes of a memory pool.
  • Supported attributes are: musaMemPoolAttrReleaseThreshold: (value type = muuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS. When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory back to the OS on the next call to stream, event or context synchronize. (default 0) musaMemPoolReuseFollowEventDependencies: (value type = int) Allow musaMallocAsync to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on the free action exists. Musa events and null stream interactions can create the required stream ordered dependencies. (default enabled) musaMemPoolReuseAllowOpportunistic: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default enabled) musaMemPoolReuseAllowInternalDependencies: (value type = int) Allow musaMallocAsync to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released by musaFreeAsync (default enabled). musaMemPoolAttrReservedMemCurrent: (value type = muuint64_t) Amount of backing memory currently allocated for the mempool. musaMemPoolAttrReservedMemHigh: (value type = muuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset. musaMemPoolAttrUsedMemCurrent: (value type = muuint64_t) Amount of memory from the pool that is currently in use by the application. musaMemPoolAttrUsedMemHigh: (value type = muuint64_t) High watermark of the amount of memory from the pool that was in use by the application since the last time it was reset.

Parameters

  • memPool (musaMemPool_t)
  • attr (enum musaMemPoolAttr): The attribute to get
  • value (void *): Retrieved value

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • No MUSA API may be called from a stream callback; a not-permitted error may be returned as a diagnostic.

See also

musaMemPoolSetAccess

musaError_t musaMemPoolSetAccess(musaMemPool_t memPool, const struct musaMemAccessDesc *descList, size_t count)

Description

  • Controls visibility of pools between devices.

Parameters

  • memPool (musaMemPool_t)
  • descList (const struct musaMemAccessDesc *)
  • count (size_t): Number of descriptors in the map array.

Returns

  • musaSuccess, musaErrorInvalidValue

See also

musaMemPoolGetAccess

musaError_t musaMemPoolGetAccess(enum musaMemAccessFlags *flags, musaMemPool_t memPool, struct musaMemLocation *location)

Description

  • Returns the accessibility of a pool from a device.
  • Returns the accessibility of the pool's memory from the specified location.

Parameters

  • flags (enum musaMemAccessFlags *): the accessibility of the pool from the specified location
  • memPool (musaMemPool_t): the pool being queried
  • location (struct musaMemLocation *): the location accessing the pool

Returns

  • Return type: musaError_t.

See also

musaMemPoolCreate

musaError_t musaMemPoolCreate(musaMemPool_t *memPool, const struct musaMemPoolProps *poolProps)

Description

  • Creates a memory pool.
  • Creates a MUSA memory pool and returns the handle in pool. The poolProps determines the properties of the pool such as the backing device and IPC capabilities.
  • To create a memory pool targeting a specific host NUMA node, applications must set musaMemPoolProps::musaMemLocation::type to musaMemLocationTypeHostNuma and musaMemPoolProps::musaMemLocation::id must specify the NUMA ID of the host memory node. Specifying musaMemLocationTypeHostNumaCurrent or musaMemLocationTypeHost as the musaMemPoolProps::musaMemLocation::type will result in musaErrorInvalidValue. By default, the pool's memory will be accessible from the device it is allocated on. In the case of pools created with musaMemLocationTypeHostNuma, their default accessibility will be from the host CPU. Applications can control the maximum size of the pool by specifying a non-zero value for musaMemPoolProps::maxSize. If set to 0, the maximum size of the pool will default to a system dependent value.
  • Applications that intend to use MU_MEM_HANDLE_TYPE_FABRIC based memory sharing must ensure: (1) mthreads-caps-imex-channels character device is created by the driver and is listed under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application.
  • When exporter and importer MUSA processes have been granted access to the same IMEX channel, they can securely share memory.
  • The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each user.
  • These channel files exist in /dev/mthreads-caps-imex-channels/channel* and can be created using standard OS native calls like mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command: mknod /dev/mthreads-caps-imex-channels/channel0 c <major number> 0

Parameters

  • memPool (musaMemPool_t *)
  • poolProps (const struct musaMemPoolProps *)

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

Note

  • Specifying musaMemHandleTypeNone creates a memory pool that will not support IPC.

See also

musaMemPoolDestroy

musaError_t musaMemPoolDestroy(musaMemPool_t memPool)

Description

  • Destroys the specified memory pool.
  • If any pointers obtained from this pool haven't been freed or the pool has free operations that haven't completed when musaMemPoolDestroy is invoked, the function will return immediately and the resources associated with the pool will be released automatically once there are no more outstanding allocations.
  • Destroying the current mempool of a device sets the default mempool of that device as the current mempool for that device.

Parameters

  • memPool (musaMemPool_t)

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • A device's default memory pool cannot be destroyed.

See also

musaMallocFromPoolAsync

musaError_t musaMallocFromPoolAsync(void **ptr, size_t size, musaMemPool_t memPool, musaStream_t stream)

Description

  • Allocates memory from a specified pool with stream ordered semantics.
  • Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in *dptr. The allocation must not be accessed until the the allocation operation completes. The allocation comes from the specified memory pool.

Parameters

  • ptr (void **): Returned device pointer
  • size (size_t)
  • memPool (musaMemPool_t): The pool to allocate from
  • stream (musaStream_t): The stream establishing the stream ordering semantic

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorNotSupported, musaErrorOutOfMemory

Note

  • The specified memory pool may be from a device different than that of the specified hStream. Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize, and MUSA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream runs. The specified memory pool may be from a device different than that of the specified hStream. Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize, and MUSA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream runs.
  • During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters.

See also

musaMemPoolExportToShareableHandle

musaError_t musaMemPoolExportToShareableHandle(void *shareableHandle, musaMemPool_t memPool, enum musaMemAllocationHandleType handleType, unsigned int flags)

Description

  • Exports a memory pool to the requested handle type.
  • Given an IPC capable mempool, create an OS handle to share the pool with another process. A recipient process can convert the shareable handle into a mempool with musaMemPoolImportFromShareableHandle. Individual pointers can then be shared with the musaMemPoolExportPointer and musaMemPoolImportPointer APIs. The implementation of what the shareable handle is and how it can be transferred is defined by the requested handle type.

Parameters

  • shareableHandle (void *)
  • memPool (musaMemPool_t)
  • handleType (enum musaMemAllocationHandleType): the type of handle to create
  • flags (unsigned int): must be 0

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory

Note

  • : To create an IPC capable mempool, create a mempool with a MUmemAllocationHandleType other than musaMemHandleTypeNone.

See also

musaMemPoolImportFromShareableHandle

musaError_t musaMemPoolImportFromShareableHandle(musaMemPool_t *memPool, void *shareableHandle, enum musaMemAllocationHandleType handleType, unsigned int flags)

Description

  • imports a memory pool from a shared handle.
  • Specific allocations can be imported from the imported pool with musaMemPoolImportPointer.

Parameters

  • memPool (musaMemPool_t *)
  • shareableHandle (void *)
  • handleType (enum musaMemAllocationHandleType): The type of handle being imported
  • flags (unsigned int): must be 0

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory

Note

  • Imported memory pools do not support creating new allocations. As such imported memory pools may not be used in musaDeviceSetMemPool or musaMallocFromPoolAsync calls.

See also

musaMemPoolExportPointer

musaError_t musaMemPoolExportPointer(struct musaMemPoolPtrExportData *exportData, void *ptr)

Description

  • Export data to share a memory pool allocation between processes.
  • Constructs shareData_out for sharing a specific allocation from an already shared memory pool. The recipient process can import the allocation with the musaMemPoolImportPointer api. The data is not a handle and may be shared through any IPC mechanism.

Parameters

  • exportData (struct musaMemPoolPtrExportData *)
  • ptr (void *): pointer to memory being exported

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory

See also

musaMemPoolImportPointer

musaError_t musaMemPoolImportPointer(void **ptr, musaMemPool_t memPool, struct musaMemPoolPtrExportData *exportData)

Description

  • Import a memory pool allocation from another process.
  • Returns in ptr_out a pointer to the imported memory. The imported memory must not be accessed before the allocation operation completes in the exporting process. The imported memory must be freed from all importing processes before being freed in the exporting process. The pointer may be freed with musaFree or musaFreeAsync. If musaFreeAsync is used, the free must be completed on the importing process before the free operation on the exporting process.

Parameters

  • ptr (void **)
  • memPool (musaMemPool_t)
  • exportData (struct musaMemPoolPtrExportData *)

Returns

  • MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_OUT_OF_MEMORY

Note

  • The musaFreeAsync api may be used in the exporting process before the musaFreeAsync operation completes in its stream as long as the musaFreeAsync in the exporting process specifies a stream with a stream dependency on the importing process's musaFreeAsync.

See also

3.15 Unified Addressing

musaPointerGetAttributes

musaError_t musaPointerGetAttributes(struct musaPointerAttributes *attributes, const void *ptr)

Description

  • Returns attributes about a specified pointer.
  • Returns in *attributes the attributes of the pointer ptr. If pointer was not allocated in, mapped by or registered with context supporting unified addressing musaErrorInvalidValue is returned.
  • musaPointerAttributes::type identifies type of memory. It can be musaMemoryTypeUnregistered for unregistered host memory, musaMemoryTypeHost for registered host memory, musaMemoryTypeDevice for device memory or musaMemoryTypeManaged for managed memory. device is the device against which ptr was allocated. If ptr has memory type musaMemoryTypeDevice then this identifies the device on which the memory referred to by ptr physically resides. If ptr has memory type musaMemoryTypeHost then this identifies the device which was current when the allocation was made (and if that device is deinitialized then this allocation will vanish with that device's state). devicePointer is the device pointer alias through which the memory referred to by ptr may be accessed on the current device. If the memory referred to by ptr cannot be accessed directly by the current device then this is NULL. hostPointer is the host pointer alias through which the memory referred to by ptr may be accessed on the host. If the memory referred to by ptr cannot be accessed directly by the host then this is NULL.

Parameters

  • attributes (struct musaPointerAttributes *): Attributes for the specified pointer
  • ptr (const void *): Pointer to get attributes for

Returns

  • musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue

Note

  • In MUSA 11.0 forward passing host pointer will return musaMemoryTypeUnregistered in musaPointerAttributes::type and call will return musaSuccess.
  • 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.16 Peer Device Memory Access

musaDeviceCanAccessPeer

musaError_t musaDeviceCanAccessPeer(int *canAccessPeer, int device, int peerDevice)

Description

  • Queries if a device may directly access a peer device's memory.
  • Returns in *canAccessPeer a value of 1 if device device is capable of directly accessing memory from peerDevice and 0 otherwise. If direct access of peerDevice from device is possible, then access may be enabled by calling musaDeviceEnablePeerAccess().

Parameters

  • canAccessPeer (int *): Returned access capability
  • device (int): Device from which allocations on peerDevice are to be directly accessed.
  • peerDevice (int): Device on which the allocations to be directly accessed by device reside.

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

musaDeviceEnablePeerAccess

musaError_t musaDeviceEnablePeerAccess(int peerDevice, unsigned int flags)

Description

  • Enables direct access to memory allocations on a peer device.
  • On success, all allocations from peerDevice will immediately be accessible by the current device. They will remain accessible until access is explicitly disabled using musaDeviceDisablePeerAccess() or either device is reset using musaDeviceReset().
  • Note that access granted by this call is unidirectional and that in order to access memory on the current device from peerDevice, a separate symmetric call to musaDeviceEnablePeerAccess() is required.
  • Note that there are both device-wide and system-wide limitations per system configuration, as noted in the MUSA Programming Guide under the section "Peer-to-Peer Memory Access".
  • Returns musaErrorInvalidDevice if musaDeviceCanAccessPeer() indicates that the current device cannot directly access memory from peerDevice.
  • Returns musaErrorPeerAccessAlreadyEnabled if direct access of peerDevice from the current device has already been enabled.
  • Returns musaErrorInvalidValue if flags is not 0.

Parameters

  • peerDevice (int): Peer device to enable direct access to from the current device
  • flags (unsigned int): Reserved for future use and must be set to 0

Returns

  • musaSuccess, musaErrorInvalidDevice, musaErrorPeerAccessAlreadyEnabled, 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

musaDeviceDisablePeerAccess

musaError_t musaDeviceDisablePeerAccess(int peerDevice)

Description

  • Disables direct access to memory allocations on a peer device.
  • Returns musaErrorPeerAccessNotEnabled if direct access to memory on peerDevice has not yet been enabled from the current device.

Parameters

  • peerDevice (int): Peer device to disable direct access to

Returns

  • musaSuccess, musaErrorPeerAccessNotEnabled, 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

3.17 Graphics Interoperability

musaGraphicsUnregisterResource

musaError_t musaGraphicsUnregisterResource(musaGraphicsResource_t resource)

Description

  • Unregisters a graphics resource for access by MUSA.
  • Unregisters the graphics resource resource so it is not accessible by MUSA unless registered again.
  • If resource is invalid then musaErrorInvalidResourceHandle is returned.

Parameters

  • resource (musaGraphicsResource_t): Resource to unregister

Returns

  • musaSuccess, musaErrorInvalidResourceHandle, 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.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

  • musaGraphicsD3D9RegisterResource, musaGraphicsD3D10RegisterResource, musaGraphicsD3D11RegisterResource, musaGraphicsGLRegisterBuffer, musaGraphicsGLRegisterImage, muGraphicsUnregisterResource

musaGraphicsResourceSetMapFlags

musaError_t musaGraphicsResourceSetMapFlags(musaGraphicsResource_t resource, unsigned int flags)

Description

  • Set usage flags for mapping a graphics resource.
  • Set flags for mapping the graphics resource resource.
  • Changes to flags will take effect the next time resource is mapped. The flags argument may be any of the following: musaGraphicsMapFlagsNone: Specifies no hints about how resource will be used. It is therefore assumed that MUSA may read from or write to resource. musaGraphicsMapFlagsReadOnly: Specifies that MUSA will not write to resource. musaGraphicsMapFlagsWriteDiscard: Specifies MUSA will not read from resource and will write over the entire contents of resource, so none of the data previously stored in resource will be preserved.
  • If resource is presently mapped for access by MUSA then musaErrorUnknown is returned. If flags is not one of the above values then musaErrorInvalidValue is returned.

Parameters

  • resource (musaGraphicsResource_t): Registered resource to set flags for
  • flags (unsigned int): Parameters for resource mapping

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, 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

musaGraphicsMapResources

musaError_t musaGraphicsMapResources(int count, musaGraphicsResource_t *resources, musaStream_t stream)

Description

  • Map graphics resources for access by MUSA.
  • Maps the count graphics resources in resources for access by MUSA.
  • The resources in resources may be accessed by MUSA until they are unmapped. The graphics API from which resources were registered should not access any resources while they are mapped by MUSA. If an application does so, the results are undefined.
  • This function provides the synchronization guarantee that any graphics calls issued before musaGraphicsMapResources() will complete before any subsequent MUSA work issued in stream begins.
  • If resources contains any duplicate entries then musaErrorInvalidResourceHandle is returned. If any of resources are presently mapped for access by MUSA then musaErrorUnknown is returned.

Parameters

  • count (int): Number of resources to map
  • resources (musaGraphicsResource_t *): Resources to map for MUSA
  • stream (musaStream_t): Stream for synchronization

Returns

  • musaSuccess, musaErrorInvalidResourceHandle, 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 the default-stream note for NULL stream semantics.

See also

musaGraphicsUnmapResources

musaError_t musaGraphicsUnmapResources(int count, musaGraphicsResource_t *resources, musaStream_t stream)

Description

  • Unmap graphics resources.
  • Unmaps the count graphics resources in resources.
  • Once unmapped, the resources in resources may not be accessed by MUSA until they are mapped again.
  • This function provides the synchronization guarantee that any MUSA work issued in stream before musaGraphicsUnmapResources() will complete before any subsequently issued graphics work begins.
  • If resources contains any duplicate entries then musaErrorInvalidResourceHandle is returned. If any of resources are not presently mapped for access by MUSA then musaErrorUnknown is returned.

Parameters

  • count (int): Number of resources to unmap
  • resources (musaGraphicsResource_t *): Resources to unmap
  • stream (musaStream_t): Stream for synchronization

Returns

  • musaSuccess, musaErrorInvalidResourceHandle, 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 the default-stream note for NULL stream semantics.

See also

musaGraphicsResourceGetMappedPointer

musaError_t musaGraphicsResourceGetMappedPointer(void **devPtr, size_t *size, musaGraphicsResource_t resource)

Description

  • Get an device pointer through which to access a mapped graphics resource.
  • Returns in *devPtr a pointer through which the mapped graphics resource resource may be accessed. Returns in *size the size of the memory in bytes which may be accessed from that pointer. The value set in devPtr may change every time that resource is mapped.
  • If resource is not a buffer then it cannot be accessed via a pointer and musaErrorUnknown is returned. If resource is not mapped then musaErrorUnknown is returned. devPtr - Returned pointer through which resource may be accessed size - Returned size of the buffer accessible starting at *devPtr resource - Mapped resource to access musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown 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. musaGraphicsMapResources, musaGraphicsSubResourceGetMappedArray, muGraphicsResourceGetMappedPointer

Parameters

  • devPtr (void **): Returned pointer through which resource may be accessed
  • size (size_t *): Returned size of the buffer accessible starting at *devPtr
  • resource (musaGraphicsResource_t): Mapped resource to access

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, 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

musaGraphicsSubResourceGetMappedArray

musaError_t musaGraphicsSubResourceGetMappedArray(musaArray_t *array, musaGraphicsResource_t resource, unsigned int arrayIndex, unsigned int mipLevel)

Description

  • Get an array through which to access a subresource of a mapped graphics resource.
  • Returns in *array an array through which the subresource of the mapped graphics resource resource which corresponds to array index arrayIndex and mipmap level mipLevel may be accessed. The value set in array may change every time that resource is mapped.
  • If resource is not a texture then it cannot be accessed via an array and musaErrorUnknown is returned. If arrayIndex is not a valid array index for resource then musaErrorInvalidValue is returned. If mipLevel is not a valid mipmap level for resource then musaErrorInvalidValue is returned. If resource is not mapped then musaErrorUnknown is returned.

Parameters

  • array (musaArray_t *): Returned array through which a subresource of resource may be accessed
  • resource (musaGraphicsResource_t): Mapped resource to access
  • arrayIndex (unsigned int): Array index for array textures or cubemap face index as defined by musaGraphicsCubeFace for cubemap textures for the subresource to access
  • mipLevel (unsigned int): Mipmap level for the subresource to access

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, 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

musaGraphicsResourceGetMappedMipmappedArray

musaError_t musaGraphicsResourceGetMappedMipmappedArray(musaMipmappedArray_t *mipmappedArray, musaGraphicsResource_t resource)

Description

  • Get a mipmapped array through which to access a mapped graphics resource.
  • Returns in *mipmappedArray a mipmapped array through which the mapped graphics resource resource may be accessed. The value set in mipmappedArray may change every time that resource is mapped.
  • If resource is not a texture then it cannot be accessed via an array and musaErrorUnknown is returned. If resource is not mapped then musaErrorUnknown is returned.

Parameters

  • mipmappedArray (musaMipmappedArray_t *): Returned mipmapped array through which resource may be accessed
  • resource (musaGraphicsResource_t): Mapped resource to access

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, 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

3.18 Texture Reference Management [DEPRECATED]

musaBindTexture

musaError_t musaBindTexture(size_t *offset, const struct textureReference *texref, const void *devPtr, const struct musaChannelFormatDesc *desc, size_t size)

Description

  • Binds a memory area to a texture.
  • Deprecated
  • Binds size bytes of the memory area pointed to by devPtr to the texture reference texref. desc describes how the memory is interpreted when fetching values from the texture. Any memory previously bound to texref is unbound.
  • Since the hardware enforces an alignment requirement on texture base addresses, musaBindTexture() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function. If the device memory pointer was returned from musaMalloc(), the offset is guaranteed to be 0 and NULL may be passed as the offset parameter.
  • The total number of elements (or texels) in the linear address range cannot exceed musaDeviceProp::maxTexture1DLinear[0]. The number of elements is computed as (size / elementSize), where elementSize is determined from desc.

Parameters

  • offset (size_t *): Offset in bytes
  • texref (const struct textureReference *): Texture to bind
  • devPtr (const void *): Memory area on device
  • desc (const struct musaChannelFormatDesc *): Channel format
  • size (size_t): Size of the memory area pointed to by devPtr

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

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

musaBindTexture2D

musaError_t musaBindTexture2D(size_t *offset, const struct textureReference *texref, const void *devPtr, const struct musaChannelFormatDesc *desc, size_t width, size_t height, size_t pitch)

Description

  • Binds a 2D memory area to a texture.
  • Deprecated
  • Binds the 2D memory area pointed to by devPtr to the texture reference texref. The size of the area is constrained by width in texel units, height in texel units, and pitch in byte units. desc describes how the memory is interpreted when fetching values from the texture. Any memory previously bound to texref is unbound.
  • Since the hardware enforces an alignment requirement on texture base addresses, musaBindTexture2D() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex2D() function. If the device memory pointer was returned from musaMalloc(), the offset is guaranteed to be 0 and NULL may be passed as the offset parameter.
  • width and height, which are specified in elements (or texels), cannot exceed musaDeviceProp::maxTexture2DLinear[0] and musaDeviceProp::maxTexture2DLinear[1] respectively. pitch, which is specified in bytes, cannot exceed musaDeviceProp::maxTexture2DLinear[2].
  • The driver returns musaErrorInvalidValue if pitch is not a multiple of musaDeviceProp::texturePitchAlignment.

Parameters

  • offset (size_t *): Offset in bytes
  • texref (const struct textureReference *): Texture reference to bind
  • devPtr (const void *): 2D memory area on device
  • desc (const struct musaChannelFormatDesc *): Channel format
  • width (size_t): Width in texel units
  • height (size_t): Height in texel units
  • pitch (size_t): Pitch in bytes

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

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

musaBindTextureToArray

musaError_t musaBindTextureToArray(const struct textureReference *texref, musaArray_const_t array, const struct musaChannelFormatDesc *desc)

Description

  • Binds an array to a texture.
  • Deprecated
  • Binds the MUSA array array to the texture reference texref. desc describes how the memory is interpreted when fetching values from the texture. Any MUSA array previously bound to texref is unbound.

Parameters

  • texref (const struct textureReference *): Texture to bind
  • array (musaArray_const_t): Memory array on device
  • desc (const struct musaChannelFormatDesc *): Channel format

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

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

musaBindTextureToMipmappedArray

musaError_t musaBindTextureToMipmappedArray(const struct textureReference *texref, musaMipmappedArray_const_t mipmappedArray, const struct musaChannelFormatDesc *desc)

Description

  • Binds a mipmapped array to a texture.
  • Deprecated
  • Binds the MUSA mipmapped array mipmappedArray to the texture reference texref. desc describes how the memory is interpreted when fetching values from the texture. Any MUSA mipmapped array previously bound to texref is unbound.

Parameters

  • texref (const struct textureReference *): Texture to bind
  • mipmappedArray (musaMipmappedArray_const_t): Memory mipmapped array on device
  • desc (const struct musaChannelFormatDesc *): Channel format

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

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

musaUnbindTexture

musaError_t musaUnbindTexture(const struct textureReference *texref)

Description

  • Unbinds a texture.
  • Deprecated
  • Unbinds the texture bound to texref. If texref is not currently bound, no operation is performed.

Parameters

  • texref (const struct textureReference *): Texture to unbind

Returns

  • musaSuccess, musaErrorInvalidTexture

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

musaGetTextureAlignmentOffset

musaError_t musaGetTextureAlignmentOffset(size_t *offset, const struct textureReference *texref)

Description

  • Get the alignment offset of a texture.
  • Deprecated
  • Returns in *offset the offset that was returned when texture reference texref was bound.

Parameters

  • offset (size_t *): Offset of texture reference in bytes
  • texref (const struct textureReference *): Texture to get offset of

Returns

  • musaSuccess, musaErrorInvalidTexture, musaErrorInvalidTextureBinding

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

musaGetTextureReference

musaError_t musaGetTextureReference(const struct textureReference **texref, const void *symbol)

Description

  • Get the texture reference associated with a symbol.
  • Deprecated
  • Returns in *texref the structure associated to the texture reference defined by symbol symbol.

Parameters

  • texref (const struct textureReference **): Texture reference associated with symbol
  • symbol (const void *): Texture to get reference for

Returns

  • musaSuccess, musaErrorInvalidTexture

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 string-based API has been deprecated since 5.0.

See also

3.19 Surface Reference Management [DEPRECATED]

musaBindSurfaceToArray

musaError_t musaBindSurfaceToArray(const struct surfaceReference *surfref, musaArray_const_t array, const struct musaChannelFormatDesc *desc)

Description

  • Binds an array to a surface.
  • Deprecated
  • Binds the MUSA array array to the surface reference surfref. desc describes how the memory is interpreted when fetching values from the surface. Any MUSA array previously bound to surfref is unbound.

Parameters

  • surfref (const struct surfaceReference *): Surface to bind
  • array (musaArray_const_t): Memory array on device
  • desc (const struct musaChannelFormatDesc *): Channel format

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidSurface

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

musaGetSurfaceReference

musaError_t musaGetSurfaceReference(const struct surfaceReference **surfref, const void *symbol)

Description

  • Get the surface reference associated with a symbol.
  • Deprecated
  • Returns in *surfref the structure associated to the surface reference defined by symbol symbol.

Parameters

  • surfref (const struct surfaceReference **): Surface reference associated with symbol
  • symbol (const void *): Surface to get reference for

Returns

  • musaSuccess, musaErrorInvalidSurface

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 string-based API has been deprecated since 5.0.

See also

3.20 Texture Object Management

musaGetChannelDesc

musaError_t musaGetChannelDesc(struct musaChannelFormatDesc *desc, musaArray_const_t array)

Description

  • Get the channel descriptor of an array.
  • Returns in *desc the channel descriptor of the MUSA array array.

Parameters

  • desc (struct musaChannelFormatDesc *): Channel format
  • array (musaArray_const_t): Memory array on device

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

musaCreateChannelDesc

struct musaChannelFormatDesc musaCreateChannelDesc(int x, int y, int z, int w, enum musaChannelFormatKind f)

Description

  • Returns a channel descriptor using the specified format.
  • Returns a channel descriptor with format f and number of bits of each component x, y, z, and w. The musaChannelFormatDesc is defined as:
struct musaChannelFormatDesc {
int x, y, z, w;
enum musaChannelFormatKind f;
};
  • ;
  • where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat.

Parameters

  • x (int): X component
  • y (int): Y component
  • z (int): Z component
  • w (int): W component
  • f (enum musaChannelFormatKind): Channel format

Returns

  • Channel descriptor with format f

See also

musaCreateTextureObject

musaError_t musaCreateTextureObject(musaTextureObject_t *pTexObject, const struct musaResourceDesc *pResDesc, const struct musaTextureDesc *pTexDesc, const struct musaResourceViewDesc *pResViewDesc)

Description

  • Creates a texture object.
  • Creates a texture object and returns it in pTexObject. pResDesc describes the data to texture from. pTexDesc describes how the data should be sampled. pResViewDesc is an optional argument that specifies an alternate format for the data described by pResDesc, and also describes the subresource region to restrict access to when texturing. pResViewDesc can only be specified if the type of resource is a MUSA array or a MUSA mipmapped array not in a block compressed format.
  • Texture objects are only supported on devices of compute capability 3.0 or higher. Additionally, a texture object is an opaque value, and, as such, should only be accessed through MUSA API calls.
  • The musaResourceDesc structure is defined as:
struct musaResourceDesc {
enum musaResourceType resType;
union {
struct {
musaArray_t array;
} array;
struct {
musaMipmappedArray_t mipmap;
} mipmap;
struct {
void *devPtr;
struct musaChannelFormatDesc desc;
size_t sizeInBytes;
} linear;
struct {
void *devPtr;
struct musaChannelFormatDesc desc;
size_t width;
size_t height;
size_t pitchInBytes;
} pitch2D;
} res;
};
  • ; where: musaResourceDesc::resType specifies the type of resource to texture from. MUresourceType is defined as:
enum musaResourceType {
musaResourceTypeArray = 0x00,
musaResourceTypeMipmappedArray = 0x01,
musaResourceTypeLinear = 0x02,
musaResourceTypePitch2D = 0x03;
};
  • ;
  • The musaResourceViewDesc struct is defined as
struct musaResourceViewDesc {
enum musaResourceViewFormat format;
size_t width;
size_t height;
size_t depth;
unsigned int firstMipmapLevel;
unsigned int lastMipmapLevel;
unsigned int firstLayer;
unsigned int lastLayer;
};
  • ; where: musaResourceViewDesc::format specifies how the data contained in the MUSA array or MUSA mipmapped array should be interpreted. Note that this can incur a change in size of the texture data. If the resource view format is a block compressed format, then the underlying MUSA array or MUSA mipmapped array has to have a 32-bit unsigned integer format with 2 or 4 channels, depending on the block compressed format. For ex., BC1 and BC4 require the underlying MUSA array to have a 32-bit unsigned int with 2 channels. The other BC formats require the underlying resource to have the same 32-bit unsigned int format but with 4 channels. musaResourceViewDesc::width specifies the new width of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original width of the resource. For non block compressed formats, this value has to be equal to that of the original resource. musaResourceViewDesc::height specifies the new height of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original height of the resource. For non block compressed formats, this value has to be equal to that of the original resource. musaResourceViewDesc::depth specifies the new depth of the texture data. This value has to be equal to that of the original resource. musaResourceViewDesc::firstMipmapLevel specifies the most detailed mipmap level. This will be the new mipmap level zero. For non-mipmapped resources, this value has to be zero.musaTextureDesc::minMipmapLevelClamp and musaTextureDesc::maxMipmapLevelClamp will be relative to this value. For ex., if the firstMipmapLevel is set to 2, and a minMipmapLevelClamp of 1.2 is specified, then the actual minimum mipmap level clamp will be 3.2. musaResourceViewDesc::lastMipmapLevel specifies the least detailed mipmap level. For non-mipmapped resources, this value has to be zero. musaResourceViewDesc::firstLayer specifies the first layer index for layered textures. This will be the new layer zero. For non-layered resources, this value has to be zero. musaResourceViewDesc::lastLayer specifies the last layer index for layered textures. For non-layered resources, this value has to be zero.

Parameters

  • pTexObject (musaTextureObject_t *): Texture object to create
  • pResDesc (const struct musaResourceDesc *): Resource descriptor
  • pTexDesc (const struct musaTextureDesc *): Texture descriptor
  • pResViewDesc (const struct musaResourceViewDesc *): Resource view descriptor

Returns

  • musaSuccess, 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

musaDestroyTextureObject

musaError_t musaDestroyTextureObject(musaTextureObject_t texObject)

Description

  • Destroys a texture object.
  • Destroys the texture object specified by texObject.

Parameters

  • texObject (musaTextureObject_t): Texture object to destroy

Returns

  • musaSuccess, 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.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

musaGetTextureObjectResourceDesc

musaError_t musaGetTextureObjectResourceDesc(struct musaResourceDesc *pResDesc, musaTextureObject_t texObject)

Description

  • Returns a texture object's resource descriptor.
  • Returns the resource descriptor for the texture object specified by texObject.

Parameters

  • pResDesc (struct musaResourceDesc *): Resource descriptor
  • texObject (musaTextureObject_t): Texture object

Returns

  • musaSuccess, 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

musaGetTextureObjectTextureDesc

musaError_t musaGetTextureObjectTextureDesc(struct musaTextureDesc *pTexDesc, musaTextureObject_t texObject)

Description

  • Returns a texture object's texture descriptor.
  • Returns the texture descriptor for the texture object specified by texObject.

Parameters

  • pTexDesc (struct musaTextureDesc *): Texture descriptor
  • texObject (musaTextureObject_t): Texture object

Returns

  • musaSuccess, 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

musaGetTextureObjectResourceViewDesc

musaError_t musaGetTextureObjectResourceViewDesc(struct musaResourceViewDesc *pResViewDesc, musaTextureObject_t texObject)

Description

  • Returns a texture object's resource view descriptor.
  • Returns the resource view descriptor for the texture object specified by texObject. If no resource view was specified, musaErrorInvalidValue is returned.

Parameters

  • pResViewDesc (struct musaResourceViewDesc *): Resource view descriptor
  • texObject (musaTextureObject_t): Texture object

Returns

  • musaSuccess, 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

3.21 Surface Object Management

musaCreateSurfaceObject

musaError_t musaCreateSurfaceObject(musaSurfaceObject_t *pSurfObject, const struct musaResourceDesc *pResDesc)

Description

  • Creates a surface object.
  • Creates a surface object and returns it in pSurfObject. pResDesc describes the data to perform surface load/stores on. musaResourceDesc::resType must be musaResourceTypeArray and musaResourceDesc::res::array::array must be set to a valid MUSA array handle.
  • Surface objects are only supported on devices of compute capability 3.0 or higher. Additionally, a surface object is an opaque value, and, as such, should only be accessed through MUSA API calls.

Parameters

  • pSurfObject (musaSurfaceObject_t *): Surface object to create
  • pResDesc (const struct musaResourceDesc *): Resource descriptor

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidChannelDescriptor, musaErrorInvalidResourceHandle

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

musaDestroySurfaceObject

musaError_t musaDestroySurfaceObject(musaSurfaceObject_t surfObject)

Description

  • Destroys a surface object.
  • Destroys the surface object specified by surfObject.

Parameters

  • surfObject (musaSurfaceObject_t): Surface object to destroy

Returns

  • musaSuccess, 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.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

musaGetSurfaceObjectResourceDesc

musaError_t musaGetSurfaceObjectResourceDesc(struct musaResourceDesc *pResDesc, musaSurfaceObject_t surfObject)

Description

  • Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject.

Parameters

  • pResDesc (struct musaResourceDesc *): Resource descriptor
  • surfObject (musaSurfaceObject_t): Surface object

Returns

  • musaSuccess, 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

3.22 Version Management

musaDriverGetVersion

musaError_t musaDriverGetVersion(int *driverVersion)

Description

  • Returns the latest version of MUSA supported by the driver.
  • Returns in *driverVersion the latest 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. If no driver is installed, then 0 is returned as the driver version.
  • This function automatically returns musaErrorInvalidValue if driverVersion is NULL.

Parameters

  • driverVersion (int *): Returns the MUSA driver version.

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

musaRuntimeGetVersion

musaError_t musaRuntimeGetVersion(int *runtimeVersion)

Description

  • Returns the MUSA Runtime version.
  • Returns in *runtimeVersion the version number of the current MUSA Runtime instance. The version is returned as (1000 major + 10 minor). For example, MUSA 9.2 would be represented by 9020.
  • As of MUSA 12.0, this function no longer initializes MUSA. The purpose of this API is solely to return a compile-time constant stating the MUSA Toolkit version in the above format.
  • This function automatically returns musaErrorInvalidValue if the runtimeVersion argument is NULL.

Parameters

  • runtimeVersion (int *): Returns the MUSA Runtime version.

Returns

  • musaSuccess, 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

3.23 Graph Management

Information

  • This module is experimental in MUSA SDK 5.2.0 and is provided for reference only.

musaGraphCreate

musaError_t musaGraphCreate(musaGraph_t *pGraph, unsigned int flags)

Description

  • Creates a graph.
  • Creates an empty graph, which is returned via pGraph.

Parameters

  • pGraph (musaGraph_t *): Returns newly created graph
  • flags (unsigned int): Graph creation flags, must be 0

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddKernelNode

musaError_t musaGraphAddKernelNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaKernelNodeParams *pNodeParams)

Description

  • Creates a kernel execution node and adds it to a graph.
  • Creates a new kernel execution node and adds it to graph with numDependencies dependencies specified via pDependencies and arguments specified in pNodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • The musaKernelNodeParams structure is defined as:
struct musaKernelNodeParams {
void *func;
dim3 gridDim;
dim3 blockDim;
unsigned int sharedMemBytes;
void **kernelParams;
void **extra;
};
  • ;
  • When the graph is launched, the node will invoke kernel func on a (gridDim.x x gridDim.y x gridDim.z) grid of blocks. Each block contains (blockDim.x x blockDim.y x blockDim.z) threads.
  • sharedMem sets the amount of dynamic shared memory that will be available to each thread block.
  • Kernel parameters to func can be specified in one of two ways:
    1. Kernel parameters can be specified via kernelParams. If the kernel has N parameters, then kernelParams needs to be an array of N pointers. Each pointer, from kernelParams[0] to kernelParams[N-1], points to the region of memory from which the actual parameter will be copied. The number of kernel parameters and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image.
    1. Kernel parameters can also be packaged by the application into a single buffer that is passed in via extra. This places the burden on the application of knowing each kernel parameter's size and alignment/padding within the buffer. The extra parameter exists to allow this function to take additional less commonly used arguments. extra specifies a list of names of extra settings and their corresponding values. Each extra setting name is immediately followed by the corresponding value. The list must be terminated with either NULL or MU_LAUNCH_PARAM_END.
  • MU_LAUNCH_PARAM_END, which indicates the end of the extra array; MU_LAUNCH_PARAM_BUFFER_POINTER, which specifies that the next value in extra will be a pointer to a buffer containing all the kernel parameters for launching kernel func; MU_LAUNCH_PARAM_BUFFER_SIZE, which specifies that the next value in extra will be a pointer to a size_t containing the size of the buffer specified with MU_LAUNCH_PARAM_BUFFER_POINTER;
  • The error musaErrorInvalidValue will be returned if kernel parameters are specified with both kernelParams and extra (i.e. both kernelParams and extra are non-NULL).
  • The kernelParams or extra array, as well as the argument values it points to, are copied during this call.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pNodeParams (const struct musaKernelNodeParams *): Parameters for the GPU execution node

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Kernels launched using graphs 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.
  • 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.
  • Graph objects are not thread-safe.
  • This API operates on a musaKernel_t handle.

See also

musaGraphKernelNodeGetParams

musaError_t musaGraphKernelNodeGetParams(musaGraphNode_t node, struct musaKernelNodeParams *pNodeParams)

Description

  • Returns a kernel node's parameters.
  • Returns the parameters of kernel node node in pNodeParams. The kernelParams or extra array returned in pNodeParams, as well as the argument values it points to, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use musaGraphKernelNodeSetParams to update the parameters of this node.
  • The params will contain either kernelParams or extra, according to which of these was most recently set on the node.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaKernelNodeParams *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphKernelNodeSetParams

musaError_t musaGraphKernelNodeSetParams(musaGraphNode_t node, const struct musaKernelNodeParams *pNodeParams)

Description

  • Sets a kernel node's parameters.
  • Sets the parameters of kernel node node to pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaKernelNodeParams *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorMemoryAllocation

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.
  • This API operates on a musaKernel_t handle.

See also

musaGraphKernelNodeCopyAttributes

musaError_t musaGraphKernelNodeCopyAttributes(musaGraphNode_t hSrc, musaGraphNode_t hDst)

Description

  • Copies attributes from source node to destination node.
  • Copies attributes from source node src to destination node dst. Both node must have the same context.

Parameters

  • hSrc (musaGraphNode_t)
  • hDst (musaGraphNode_t)

Returns

  • musaSuccess, musaErrorInvalidContext

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • This function may also return error codes from previous, asynchronous launches.

See also

  • musaAccessPolicyWindow

musaGraphKernelNodeGetAttribute

musaError_t musaGraphKernelNodeGetAttribute(musaGraphNode_t hNode, enum musaKernelNodeAttrID attr, union musaKernelNodeAttrValue *value_out)

Description

  • Queries node attribute.
  • Queries attribute attr from node hNode and stores it in corresponding member of value_out.

Parameters

  • hNode (musaGraphNode_t)
  • attr (enum musaKernelNodeAttrID)
  • value_out (union musaKernelNodeAttrValue *)

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • This function may also return error codes from previous, asynchronous launches.

See also

  • musaAccessPolicyWindow

musaGraphKernelNodeSetAttribute

musaError_t musaGraphKernelNodeSetAttribute(musaGraphNode_t hNode, enum musaKernelNodeAttrID attr, const union musaKernelNodeAttrValue *value)

Description

  • Sets node attribute.
  • Sets attribute attr on node hNode from corresponding attribute of value.

Parameters

  • hNode (musaGraphNode_t)
  • attr (enum musaKernelNodeAttrID)
  • value (const union musaKernelNodeAttrValue *)

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • This function may also return error codes from previous, asynchronous launches.

See also

  • musaAccessPolicyWindow

musaGraphAddMemcpyNode

musaError_t musaGraphAddMemcpyNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemcpy3DParms *pCopyParams)

Description

  • Creates a memcpy node and adds it to a graph.
  • Creates a new memcpy node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will perform the memcpy described by pCopyParams. See musaMemcpy3D() for a description of the structure and its restrictions.
  • Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pCopyParams (const struct musaMemcpy3DParms *): Parameters for the memory copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemcpyNodeToSymbol

musaError_t musaGraphAddMemcpyNodeToSymbol(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const void *symbol, const void *src, size_t count, size_t offset, enum musaMemcpyKind kind)

Description

  • Creates a memcpy node to copy to a symbol on the device and adds it to a graph.
  • Creates a new memcpy node to copy to symbol and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyHostToDevice, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • symbol (const void *): Device symbol address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • offset (size_t): Offset from start of symbol in bytes
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemcpyNodeFromSymbol

musaError_t musaGraphAddMemcpyNodeFromSymbol(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, void *dst, const void *symbol, size_t count, size_t offset, enum musaMemcpyKind kind)

Description

  • Creates a memcpy node to copy from a symbol on the device and adds it to a graph.
  • Creates a new memcpy node to copy from symbol and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will copy count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing.
  • Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • dst (void *): Destination memory address
  • symbol (const void *): Device symbol address
  • count (size_t): Size in bytes to copy
  • offset (size_t): Offset from start of symbol in bytes
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemcpyNode1D

musaError_t musaGraphAddMemcpyNode1D(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Description

  • Creates a 1D memcpy node and adds it to a graph.
  • Creates a new 1D memcpy node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
  • Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • dst (void *): Destination memory address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemcpyNodeGetParams

musaError_t musaGraphMemcpyNodeGetParams(musaGraphNode_t node, struct musaMemcpy3DParms *pNodeParams)

Description

  • Returns a memcpy node's parameters.
  • Returns the parameters of memcpy node node in pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaMemcpy3DParms *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemcpyNodeSetParams

musaError_t musaGraphMemcpyNodeSetParams(musaGraphNode_t node, const struct musaMemcpy3DParms *pNodeParams)

Description

  • Sets a memcpy node's parameters.
  • Sets the parameters of memcpy node node to pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaMemcpy3DParms *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemcpyNodeSetParams1D

musaError_t musaGraphMemcpyNodeSetParams1D(musaGraphNode_t node, void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Description

  • Sets a memcpy node's parameters to perform a 1-dimensional copy.
  • Sets the parameters of memcpy node node to the copy described by the provided parameters.
  • When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • dst (void *): Destination memory address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemsetNode

musaError_t musaGraphAddMemsetNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemsetParams *pMemsetParams)

Description

  • Creates a memset node and adds it to a graph.
  • Creates a new memset node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • The element size must be 1, 2, or 4 bytes. When the graph is launched, the node will perform the memset described by pMemsetParams.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pMemsetParams (const struct musaMemsetParams *): Parameters for the memory set

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemsetNodeGetParams

musaError_t musaGraphMemsetNodeGetParams(musaGraphNode_t node, struct musaMemsetParams *pNodeParams)

Description

  • Returns a memset node's parameters.
  • Returns the parameters of memset node node in pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaMemsetParams *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemsetNodeSetParams

musaError_t musaGraphMemsetNodeSetParams(musaGraphNode_t node, const struct musaMemsetParams *pNodeParams)

Description

  • Sets a memset node's parameters.
  • Sets the parameters of memset node node to pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaMemsetParams *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddHostNode

musaError_t musaGraphAddHostNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaHostNodeParams *pNodeParams)

Description

  • Creates a host execution node and adds it to a graph.
  • Creates a new CPU execution node and adds it to graph with numDependencies dependencies specified via pDependencies and arguments specified in pNodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will invoke the specified CPU function. Host nodes are not supported under MPS with pre-Volta GPUs.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pNodeParams (const struct musaHostNodeParams *): Parameters for the host node

Returns

  • musaSuccess, musaErrorNotSupported, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphHostNodeGetParams

musaError_t musaGraphHostNodeGetParams(musaGraphNode_t node, struct musaHostNodeParams *pNodeParams)

Description

  • Returns a host node's parameters.
  • Returns the parameters of host node node in pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaHostNodeParams *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphHostNodeSetParams

musaError_t musaGraphHostNodeSetParams(musaGraphNode_t node, const struct musaHostNodeParams *pNodeParams)

Description

  • Sets a host node's parameters.
  • Sets the parameters of host node node to nodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaHostNodeParams *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddChildGraphNode

musaError_t musaGraphAddChildGraphNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, musaGraph_t childGraph)

Description

  • Creates a child graph node and adds it to a graph.
  • Creates a new node which executes an embedded graph, and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • If hGraph contains allocation or free nodes, this call will return an error.
  • The node executes an embedded child graph. The child graph is cloned in this call.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • childGraph (musaGraph_t): The graph to clone into this node

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphChildGraphNodeGetGraph

musaError_t musaGraphChildGraphNodeGetGraph(musaGraphNode_t node, musaGraph_t *pGraph)

Description

  • Gets a handle to the embedded graph of a child graph node.
  • Gets a handle to the embedded graph in a child graph node. This call does not clone the graph. Changes to the graph will be reflected in the node, and the node retains ownership of the graph.
  • Allocation and free nodes cannot be added to the returned graph. Attempting to do so will return an error.

Parameters

  • node (musaGraphNode_t): Node to get the embedded graph for
  • pGraph (musaGraph_t *): Location to store a handle to the graph

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddEmptyNode

musaError_t musaGraphAddEmptyNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies)

Description

  • Creates an empty node and adds it to a graph.
  • Creates a new node which performs no operation, and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • An empty node performs no operation during execution, but can be used for transitive ordering. For example, a phased execution graph with 2 groups of n nodes with a barrier between them can be represented using an empty node and 2*n dependency edges, rather than no empty node and n^2 dependency edges.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddEventRecordNode

musaError_t musaGraphAddEventRecordNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, musaEvent_t event)

Description

  • Creates an event record node and adds it to a graph.
  • Creates a new event record node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
  • Each launch of the graph will record event to capture execution of the node's dependencies.
  • These nodes may not be used in loops or conditionals.

Parameters

  • pGraphNode (musaGraphNode_t *)
  • graph (musaGraph_t)
  • pDependencies (const musaGraphNode_t *)
  • numDependencies (size_t): Number of dependencies
  • event (musaEvent_t): Event for the node

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphEventRecordNodeGetEvent

musaError_t musaGraphEventRecordNodeGetEvent(musaGraphNode_t node, musaEvent_t *event_out)

Description

  • Returns the event associated with an event record node.
  • Returns the event of event record node hNode in event_out.

Parameters

  • node (musaGraphNode_t)
  • event_out (musaEvent_t *): Pointer to return the event

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphEventRecordNodeSetEvent

musaError_t musaGraphEventRecordNodeSetEvent(musaGraphNode_t node, musaEvent_t event)

Description

  • Sets an event record node's event.
  • Sets the event of event record node hNode to event.

Parameters

  • node (musaGraphNode_t)
  • event (musaEvent_t): Event to use

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddEventWaitNode

musaError_t musaGraphAddEventWaitNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, musaEvent_t event)

Description

  • Creates an event wait node and adds it to a graph.
  • Creates a new event wait node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode.
  • The graph node will wait for all work captured in event. See muEventRecord() 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 context or device than the launch stream.
  • These nodes may not be used in loops or conditionals.

Parameters

  • pGraphNode (musaGraphNode_t *)
  • graph (musaGraph_t)
  • pDependencies (const musaGraphNode_t *)
  • numDependencies (size_t): Number of dependencies
  • event (musaEvent_t): Event for the node

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphEventWaitNodeGetEvent

musaError_t musaGraphEventWaitNodeGetEvent(musaGraphNode_t node, musaEvent_t *event_out)

Description

  • Returns the event associated with an event wait node.
  • Returns the event of event wait node hNode in event_out.

Parameters

  • node (musaGraphNode_t)
  • event_out (musaEvent_t *): Pointer to return the event

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphEventWaitNodeSetEvent

musaError_t musaGraphEventWaitNodeSetEvent(musaGraphNode_t node, musaEvent_t event)

Description

  • Sets an event wait node's event.
  • Sets the event of event wait node hNode to event.

Parameters

  • node (musaGraphNode_t)
  • event (musaEvent_t): Event to use

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddExternalSemaphoresSignalNode

musaError_t musaGraphAddExternalSemaphoresSignalNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaExternalSemaphoreSignalNodeParams *nodeParams)

Description

  • Creates an external semaphore signal node and adds it to a graph.
  • Creates a new external semaphore signal node and adds it to graph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • Performs a signal operation on a set of externally allocated semaphore objects when the node is launched. The operation(s) will occur after all of the node's dependencies have completed.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • nodeParams (const struct musaExternalSemaphoreSignalNodeParams *): Parameters for the node

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExternalSemaphoresSignalNodeGetParams

musaError_t musaGraphExternalSemaphoresSignalNodeGetParams(musaGraphNode_t hNode, struct musaExternalSemaphoreSignalNodeParams *params_out)

Description

  • Returns an external semaphore signal node's parameters.
  • Returns the parameters of an external semaphore signal node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use musaGraphExternalSemaphoresSignalNodeSetParams to update the parameters of this node.

Parameters

  • hNode (musaGraphNode_t): Node to get the parameters for
  • params_out (struct musaExternalSemaphoreSignalNodeParams *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExternalSemaphoresSignalNodeSetParams

musaError_t musaGraphExternalSemaphoresSignalNodeSetParams(musaGraphNode_t hNode, const struct musaExternalSemaphoreSignalNodeParams *nodeParams)

Description

  • Sets an external semaphore signal node's parameters.
  • Sets the parameters of an external semaphore signal node hNode to nodeParams.

Parameters

  • hNode (musaGraphNode_t): Node to set the parameters for
  • nodeParams (const struct musaExternalSemaphoreSignalNodeParams *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddExternalSemaphoresWaitNode

musaError_t musaGraphAddExternalSemaphoresWaitNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaExternalSemaphoreWaitNodeParams *nodeParams)

Description

  • Creates an external semaphore wait node and adds it to a graph.
  • Creates a new external semaphore wait node and adds it to graph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • Performs a wait operation on a set of externally allocated semaphore objects when the node is launched. The node's dependencies will not be launched until the wait operation has completed.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • nodeParams (const struct musaExternalSemaphoreWaitNodeParams *): Parameters for the node

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExternalSemaphoresWaitNodeGetParams

musaError_t musaGraphExternalSemaphoresWaitNodeGetParams(musaGraphNode_t hNode, struct musaExternalSemaphoreWaitNodeParams *params_out)

Description

  • Returns an external semaphore wait node's parameters.
  • Returns the parameters of an external semaphore wait node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use musaGraphExternalSemaphoresSignalNodeSetParams to update the parameters of this node.

Parameters

  • hNode (musaGraphNode_t): Node to get the parameters for
  • params_out (struct musaExternalSemaphoreWaitNodeParams *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExternalSemaphoresWaitNodeSetParams

musaError_t musaGraphExternalSemaphoresWaitNodeSetParams(musaGraphNode_t hNode, const struct musaExternalSemaphoreWaitNodeParams *nodeParams)

Description

  • Sets an external semaphore wait node's parameters.
  • Sets the parameters of an external semaphore wait node hNode to nodeParams.

Parameters

  • hNode (musaGraphNode_t): Node to set the parameters for
  • nodeParams (const struct musaExternalSemaphoreWaitNodeParams *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemAllocNode

musaError_t musaGraphAddMemAllocNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, struct musaMemAllocNodeParams *nodeParams)

Description

  • Creates an allocation node and adds it to a graph.
  • Creates a new allocation node and adds it to graph with numDependencies dependencies specified via pDependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • If the allocation is freed in the same graph, by creating a free node using musaGraphAddMemFreeNode, the allocation can be accessed by nodes ordered after the allocation node but before the free node. These allocations cannot be freed outside the owning graph, and they can only be freed once in the owning graph.
  • If the allocation is not freed in the same graph, then it can be accessed not only by nodes in the graph which are ordered after the allocation node, but also by stream operations ordered after the graph's execution but before the allocation is freed.
  • Allocations which are not freed in the same graph can be freed by: passing the allocation to musaMemFreeAsync or musaMemFree; launching a graph with a free node for that allocation; or specifying musaGraphInstantiateFlagAutoFreeOnLaunch during instantiation, which makes each launch behave as though it called musaMemFreeAsync for every unfreed allocation.
  • It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer be added to the owning graph.
  • The following restrictions apply to graphs which contain allocation and/or memory free nodes: Nodes and edges of the graph cannot be deleted. The graph cannot be used in a child node. Only one instantiation of the graph may exist at any point in time. The graph cannot be cloned.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • nodeParams (struct musaMemAllocNodeParams *): Parameters for the node

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorNotSupported, musaErrorInvalidValue, musaErrorOutOfMemory

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • This function may also return error codes from previous, asynchronous launches.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemFreeNode

musaError_t musaGraphAddMemFreeNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, void *dptr)

Description

  • Creates a memory free node and adds it to a graph.
  • Creates a new memory free node and adds it to graph with numDependencies dependencies specified via pDependencies and address specified in dptr. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • The following restrictions apply to graphs which contain allocation and/or memory free nodes: Nodes and edges of the graph cannot be deleted. The graph cannot be used in a child node. Only one instantiation of the graph may exist at any point in time. The graph cannot be cloned.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • dptr (void *): Address of memory to free

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorNotSupported, musaErrorInvalidValue, musaErrorOutOfMemory

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • This function may also return error codes from previous, asynchronous launches.
  • Graph objects are not thread-safe.

See also

musaDeviceGraphMemTrim

musaError_t musaDeviceGraphMemTrim(int device)

Description

  • Free unused memory that was cached on the specified device for use with graphs back to the OS.
  • Blocks which are not in use by a graph that is either currently executing or scheduled to execute are freed back to the operating system.

Parameters

  • device (int): The device for which cached memory should be freed.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaDeviceGetGraphMemAttribute

musaError_t musaDeviceGetGraphMemAttribute(int device, enum musaGraphMemAttributeType attr, void *value)

Description

  • Query asynchronous allocation attributes related to graphs.
  • Valid attributes are:
  • musaGraphMemAttrUsedMemCurrent: Amount of memory, in bytes, currently associated with graphs musaGraphMemAttrUsedMemHigh: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be reset to zero. musaGraphMemAttrReservedMemCurrent: Amount of memory, in bytes, currently allocated for use by the MUSA graphs asynchronous allocator. musaGraphMemAttrReservedMemHigh: High watermark of memory, in bytes, currently allocated for use by the MUSA graphs asynchronous allocator.

Parameters

  • device (int): Specifies the scope of the query
  • attr (enum musaGraphMemAttributeType): attribute to get
  • value (void *): retrieved value

Returns

  • musaSuccess, musaErrorInvalidDevice

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaDeviceSetGraphMemAttribute

musaError_t musaDeviceSetGraphMemAttribute(int device, enum musaGraphMemAttributeType attr, void *value)

Description

  • Set asynchronous allocation attributes related to graphs.
  • Valid attributes are:
  • musaGraphMemAttrUsedMemHigh: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be reset to zero. musaGraphMemAttrReservedMemHigh: High watermark of memory, in bytes, currently allocated for use by the MUSA graphs asynchronous allocator.

Parameters

  • device (int): Specifies the scope of the query
  • attr (enum musaGraphMemAttributeType): attribute to get
  • value (void *): pointer to value to set

Returns

  • musaSuccess, musaErrorInvalidDevice

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphClone

musaError_t musaGraphClone(musaGraph_t *pGraphClone, musaGraph_t originalGraph)

Description

  • Clones a graph.
  • This function creates a copy of originalGraph and returns it in pGraphClone. All parameters are copied into the cloned graph. The original graph may be modified after this call without affecting the clone.
  • Child graph nodes in the original graph are recursively copied into the clone.

Parameters

  • pGraphClone (musaGraph_t *): Returns newly created cloned graph
  • originalGraph (musaGraph_t): Graph to clone

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeFindInClone

musaError_t musaGraphNodeFindInClone(musaGraphNode_t *pNode, musaGraphNode_t originalNode, musaGraph_t clonedGraph)

Description

  • Finds a cloned version of a node.
  • This function returns the node in clonedGraph corresponding to originalNode in the original graph.
  • clonedGraph must have been cloned from originalGraph via musaGraphClone. originalNode must have been in originalGraph at the time of the call to musaGraphClone, and the corresponding cloned node in clonedGraph must not have been removed. The cloned node is then returned via pClonedNode.

Parameters

  • pNode (musaGraphNode_t *): Returns handle to the cloned node
  • originalNode (musaGraphNode_t): Handle to the original node
  • clonedGraph (musaGraph_t): Cloned graph to query

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeGetType

musaError_t musaGraphNodeGetType(musaGraphNode_t node, enum musaGraphNodeType *pType)

Description

  • Returns a node's type.
  • Returns the node type of node in pType.

Parameters

  • node (musaGraphNode_t): Node to query
  • pType (enum musaGraphNodeType *): Pointer to return the node type

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeGetContainingGraph

musaError_t musaGraphNodeGetContainingGraph(musaGraphNode_t hNode, musaGraph_t *phGraph)

Description

  • Returns the graph that contains a given graph node.
  • Returns the graph that contains hNode in *phGraph. If hNode is in a child graph, the child graph it is in is returned.

Parameters

  • hNode (musaGraphNode_t): Node to query
  • phGraph (musaGraph_t *): Pointer to return the containing graph

Returns

  • musaSuccess musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

See also

musaGraphNodeGetLocalId

musaError_t musaGraphNodeGetLocalId(musaGraphNode_t hNode, unsigned int *nodeId)

Description

  • Returns the node id of a given graph node.
  • Returns the node id of hNode in *nodeId. The nodeId matches that referenced by musaGraphDebugDotPrint. The local nodeId and graphId together can uniquely identify the node.

Parameters

  • hNode (musaGraphNode_t): Node to query
  • nodeId (unsigned int *): Pointer to return the nodeId

Returns

  • musaSuccess musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

See also

musaGraphNodeGetToolsId

musaError_t musaGraphNodeGetToolsId(musaGraphNode_t hNode, unsigned long long *toolsNodeId)

Description

  • Returns an id used by tools to identify a given node.

Parameters

  • hNode (musaGraphNode_t): Node to query
  • toolsNodeId (unsigned long long *)

Returns

  • MUSA_SUCCESS musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

See also

musaGraphGetId

musaError_t musaGraphGetId(musaGraph_t hGraph, unsigned int *graphID)

Description

  • Returns the id of a given graph.
  • Returns the id of hGraph in *graphId. The value in *graphId matches that referenced by musaGraphDebugDotPrint.

Parameters

  • hGraph (musaGraph_t): Graph to query
  • graphID (unsigned int *)

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

See also

musaGraphExecGetId

musaError_t musaGraphExecGetId(musaGraphExec_t hGraphExec, unsigned int *graphID)

Description

  • Returns the id of a given graph exec.
  • Returns the id of hGraphExec in *graphId. The value in *graphId matches that referenced by musaGraphDebugDotPrint.

Parameters

  • hGraphExec (musaGraphExec_t): Graph to query
  • graphID (unsigned int *)

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

See also

musaGraphGetNodes

musaError_t musaGraphGetNodes(musaGraph_t graph, musaGraphNode_t *nodes, size_t *numNodes)

Description

  • Returns a graph's nodes.
  • Returns a list of graph's nodes. nodes may be NULL, in which case this function will return the number of nodes in numNodes. Otherwise, numNodes entries will be filled in. If numNodes is higher than the actual number of nodes, the remaining entries in nodes will be set to NULL, and the number of nodes actually obtained will be returned in numNodes.

Parameters

  • graph (musaGraph_t): Graph to query
  • nodes (musaGraphNode_t *): Pointer to return the nodes
  • numNodes (size_t *): See description

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphGetRootNodes

musaError_t musaGraphGetRootNodes(musaGraph_t graph, musaGraphNode_t *pRootNodes, size_t *pNumRootNodes)

Description

  • Returns a graph's root nodes.
  • Returns a list of graph's root nodes. pRootNodes may be NULL, in which case this function will return the number of root nodes in pNumRootNodes. Otherwise, pNumRootNodes entries will be filled in. If pNumRootNodes is higher than the actual number of root nodes, the remaining entries in pRootNodes will be set to NULL, and the number of nodes actually obtained will be returned in pNumRootNodes.

Parameters

  • graph (musaGraph_t): Graph to query
  • pRootNodes (musaGraphNode_t *): Pointer to return the root nodes
  • pNumRootNodes (size_t *): See description

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphGetEdges

musaError_t musaGraphGetEdges(musaGraph_t graph, musaGraphNode_t *from, musaGraphNode_t *to, size_t *numEdges)

Description

  • Returns a graph's dependency edges.
  • Returns a list of graph's dependency edges. Edges are returned via corresponding indices in from and to; that is, the node in to[i] has a dependency on the node in from[i]. from and to may both be NULL, in which case this function only returns the number of edges in numEdges. Otherwise, numEdges entries will be filled in. If numEdges is higher than the actual number of edges, the remaining entries in from and to will be set to NULL, and the number of edges actually returned will be written to numEdges.

Parameters

  • graph (musaGraph_t): Graph to get the edges from
  • from (musaGraphNode_t *): Location to return edge endpoints
  • to (musaGraphNode_t *): Location to return edge endpoints
  • numEdges (size_t *): See description

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphGetEdges_v2

musaError_t musaGraphGetEdges_v2(musaGraph_t graph, musaGraphNode_t *from, musaGraphNode_t *to, musaGraphEdgeData *edgeData, size_t *numEdges)

Description

  • Returns a graph's dependency edges (12.3+)
  • Returns a list of graph's dependency edges. Edges are returned via corresponding indices in from, to and edgeData; that is, the node in to[i] has a dependency on the node in from[i] with data edgeData[i]. from and to may both be NULL, in which case this function only returns the number of edges in numEdges. Otherwise, numEdges entries will be filled in. If numEdges is higher than the actual number of edges, the remaining entries in from and to will be set to NULL, and the number of edges actually returned will be written to numEdges. edgeData may alone be NULL, in which case the edges must all have default (zeroed) edge data. Attempting a losst query via NULL edgeData will result in musaErrorLossyQuery. If edgeData is non-NULL then from and to must be as well.

Parameters

  • graph (musaGraph_t): Graph to get the edges from
  • from (musaGraphNode_t *): Location to return edge endpoints
  • to (musaGraphNode_t *): Location to return edge endpoints
  • edgeData (musaGraphEdgeData *): Optional location to return edge data
  • numEdges (size_t *): See description

Returns

  • musaSuccess, musaErrorLossyQuery, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeGetDependencies

musaError_t musaGraphNodeGetDependencies(musaGraphNode_t node, musaGraphNode_t *pDependencies, size_t *pNumDependencies)

Description

  • Returns a node's dependencies.
  • Returns a list of node's dependencies. pDependencies may be NULL, in which case this function will return the number of dependencies in pNumDependencies. Otherwise, pNumDependencies entries will be filled in. If pNumDependencies is higher than the actual number of dependencies, the remaining entries in pDependencies will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependencies.

Parameters

  • node (musaGraphNode_t): Node to query
  • pDependencies (musaGraphNode_t *): Pointer to return the dependencies
  • pNumDependencies (size_t *): See description

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeGetDependentNodes

musaError_t musaGraphNodeGetDependentNodes(musaGraphNode_t node, musaGraphNode_t *pDependentNodes, size_t *pNumDependentNodes)

Description

  • Returns a node's dependent nodes.
  • Returns a list of node's dependent nodes. pDependentNodes may be NULL, in which case this function will return the number of dependent nodes in pNumDependentNodes. Otherwise, pNumDependentNodes entries will be filled in. If pNumDependentNodes is higher than the actual number of dependent nodes, the remaining entries in pDependentNodes will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependentNodes.

Parameters

  • node (musaGraphNode_t): Node to query
  • pDependentNodes (musaGraphNode_t *): Pointer to return the dependent nodes
  • pNumDependentNodes (size_t *): See description

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeGetDependentNodes_v2

musaError_t musaGraphNodeGetDependentNodes_v2(musaGraphNode_t node, musaGraphNode_t *pDependentNodes, musaGraphEdgeData *edgeData, size_t *pNumDependentNodes)

Description

  • Returns a node's dependent nodes (12.3+)
  • Returns a list of node's dependent nodes. pDependentNodes may be NULL, in which case this function will return the number of dependent nodes in pNumDependentNodes. Otherwise, pNumDependentNodes entries will be filled in. If pNumDependentNodes is higher than the actual number of dependent nodes, the remaining entries in pDependentNodes will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependentNodes.
  • Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return musaErrorLossyQuery. If edgeData is non-NULL, then pDependentNodes must be as well.

Parameters

  • node (musaGraphNode_t): Node to query
  • pDependentNodes (musaGraphNode_t *): Pointer to return the dependent nodes
  • edgeData (musaGraphEdgeData *): Optional pointer to return edge data for dependent nodes
  • pNumDependentNodes (size_t *): See description

Returns

  • musaSuccess, musaErrorLossyQuery, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddDependencies

musaError_t musaGraphAddDependencies(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, size_t numDependencies)

Description

  • Adds dependency edges to a graph.
  • The number of dependencies to be added is defined by numDependencies Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph.
  • If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying an existing dependency will return an error.

Parameters

  • graph (musaGraph_t): Graph to which dependencies are added
  • from (const musaGraphNode_t *): Array of nodes that provide the dependencies
  • to (const musaGraphNode_t *): Array of dependent nodes
  • numDependencies (size_t): Number of dependencies to be added

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddDependencies_v2

musaError_t musaGraphAddDependencies_v2(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, const musaGraphEdgeData *edgeData, size_t numDependencies)

Description

  • Adds dependency edges to a graph. (12.3+)
  • The number of dependencies to be added is defined by numDependencies Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph.
  • If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying an existing dependency will return an error.

Parameters

  • graph (musaGraph_t): Graph to which dependencies are added
  • from (const musaGraphNode_t *): Array of nodes that provide the dependencies
  • to (const musaGraphNode_t *): Array of dependent nodes
  • edgeData (const musaGraphEdgeData *): Optional array of edge data. If NULL, default (zeroed) edge data is assumed.
  • numDependencies (size_t): Number of dependencies to be added

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphRemoveDependencies

musaError_t musaGraphRemoveDependencies(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, size_t numDependencies)

Description

  • Removes dependency edges from a graph.
  • The number of pDependencies to be removed is defined by numDependencies. Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph.
  • If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying a non-existing dependency will return an error.

Parameters

  • graph (musaGraph_t): Graph from which to remove dependencies
  • from (const musaGraphNode_t *): Array of nodes that provide the dependencies
  • to (const musaGraphNode_t *): Array of dependent nodes
  • numDependencies (size_t): Number of dependencies to be removed

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphRemoveDependencies_v2

musaError_t musaGraphRemoveDependencies_v2(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, const musaGraphEdgeData *edgeData, size_t numDependencies)

Description

  • Removes dependency edges from a graph. (12.3+)
  • The number of pDependencies to be removed is defined by numDependencies. Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph.
  • If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying an edge that does not exist in the graph, with data matching edgeData, results in an error. edgeData is nullable, which is equivalent to passing default (zeroed) data for each edge.

Parameters

  • graph (musaGraph_t): Graph from which to remove dependencies
  • from (const musaGraphNode_t *): Array of nodes that provide the dependencies
  • to (const musaGraphNode_t *): Array of dependent nodes
  • edgeData (const musaGraphEdgeData *): Optional array of edge data. If NULL, edge data is assumed to be default (zeroed).
  • numDependencies (size_t): Number of dependencies to be removed

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphDestroyNode

musaError_t musaGraphDestroyNode(musaGraphNode_t node)

Description

  • Remove a node from the graph.
  • Removes node from its graph. This operation also severs any dependencies of other nodes on node and vice versa.
  • Dependencies cannot be removed from graphs which contain allocation or free nodes. Any attempt to do so will return an error.

Parameters

  • node (musaGraphNode_t): Node to remove

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

musaGraphInstantiate

musaError_t musaGraphInstantiate(musaGraphExec_t *pGraphExec, musaGraph_t graph, unsigned long long flags)

Description

  • Creates an executable graph from a graph.
  • Instantiates graph as an executable graph. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec.
  • The flags parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are:
  • musaGraphInstantiateFlagAutoFreeOnLaunch, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. musaGraphInstantiateFlagDeviceLaunch, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag cannot be used in conjunction with musaGraphInstantiateFlagAutoFreeOnLaunch. musaGraphInstantiateFlagUseNodePriority, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture.
  • If graph contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with musaGraphExecDestroy will result in an error. The same also applies if graph contains any device-updatable kernel nodes.
  • Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:
  • The graph's nodes must reside on a single device. The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. Kernel nodes: Use of MUSA Dynamic Parallelism is not permitted. Cooperative launches are permitted as long as MPS is not in use. Memcpy nodes: Only copies involving device memory and/or pinned device-mapped host memory are permitted. Copies involving MUSA arrays are not permitted. Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph.
  • If graph is not instantiated for launch on the device but contains kernels which call device-side musaGraphLaunch() from multiple devices, this will result in an error.

Parameters

  • pGraphExec (musaGraphExec_t *): Returns instantiated graph
  • graph (musaGraph_t): Graph to instantiate
  • flags (unsigned long long): Flags to control instantiation. See MUgraphInstantiate_flags.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphInstantiateWithFlags

musaError_t musaGraphInstantiateWithFlags(musaGraphExec_t *pGraphExec, musaGraph_t graph, unsigned long long flags)

Description

  • Creates an executable graph from a graph.
  • Instantiates graph as an executable graph. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec.
  • The flags parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are:
  • musaGraphInstantiateFlagAutoFreeOnLaunch, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. musaGraphInstantiateFlagDeviceLaunch, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with musaGraphInstantiateFlagAutoFreeOnLaunch. musaGraphInstantiateFlagUseNodePriority, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture.
  • If graph contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with musaGraphExecDestroy will result in an error. The same also applies if graph contains any device-updatable kernel nodes.
  • If graph contains kernels which call device-side musaGraphLaunch() from multiple devices, this will result in an error.
  • Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:
  • The graph's nodes must reside on a single device. The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. Kernel nodes: Use of MUSA Dynamic Parallelism is not permitted. Cooperative launches are permitted as long as MPS is not in use. Memcpy nodes: Only copies involving device memory and/or pinned device-mapped host memory are permitted. Copies involving MUSA arrays are not permitted. Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph.

Parameters

  • pGraphExec (musaGraphExec_t *): Returns instantiated graph
  • graph (musaGraph_t): Graph to instantiate
  • flags (unsigned long long): Flags to control instantiation. See MUgraphInstantiate_flags.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphInstantiateWithParams

musaError_t musaGraphInstantiateWithParams(musaGraphExec_t *pGraphExec, musaGraph_t graph, musaGraphInstantiateParams *instantiateParams)

Description

  • Creates an executable graph from a graph.
  • Instantiates graph as an executable graph according to the instantiateParams structure. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec.
  • instantiateParams controls the behavior of instantiation and subsequent graph launches, as well as returning more detailed information in the event of an error. musaGraphInstantiateParams is defined as:
typedef struct {
unsigned long long flags;
musaStream_t uploadStream;
musaGraphNode_terrNode_out;
musaGraphInstantiateResultresult_out;
} musaGraphInstantiateParams;
  • The flags field controls the behavior of instantiation and subsequent graph launches. Valid flags are:
  • musaGraphInstantiateFlagAutoFreeOnLaunch, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. musaGraphInstantiateFlagUpload, which will perform an upload of the graph into uploadStream once the graph has been instantiated. musaGraphInstantiateFlagDeviceLaunch, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with musaGraphInstantiateFlagAutoFreeOnLaunch. musaGraphInstantiateFlagUseNodePriority, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture.
  • If graph contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with musaGraphExecDestroy will result in an error. The same also applies if graph contains any device-updatable kernel nodes.
  • If graph contains kernels which call device-side musaGraphLaunch() from multiple devices, this will result in an error.
  • Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs:
  • The graph's nodes must reside on a single device. The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. Kernel nodes: Use of MUSA Dynamic Parallelism is not permitted. Cooperative launches are permitted as long as MPS is not in use. Memcpy nodes: Only copies involving device memory and/or pinned device-mapped host memory are permitted. Copies involving MUSA arrays are not permitted. Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph.
  • In the event of an error, the result_out and errNode_out fields will contain more information about the nature of the error. Possible error reporting includes:
  • musaGraphInstantiateError, if passed an invalid value or if an unexpected error occurred which is described by the return value of the function. errNode_out will be set to NULL. musaGraphInstantiateInvalidStructure, if the graph structure is invalid. errNode_out will be set to one of the offending nodes. musaGraphInstantiateNodeOperationNotSupported, if the graph is instantiated for device launch but contains a node of an unsupported node type, or a node which performs unsupported operations, such as use of MUSA dynamic parallelism within a kernel node. errNode_out will be set to this node. musaGraphInstantiateMultipleDevicesNotSupported, if the graph is instantiated for device launch but a node’s device differs from that of another node. This error can also be returned if a graph is not instantiated for device launch and it contains kernels which call device-side musaGraphLaunch() from multiple devices. errNode_out will be set to this node.
  • If instantiation is successful, result_out will be set to musaGraphInstantiateSuccess, and hErrNode_out will be set to NULL.

Parameters

  • pGraphExec (musaGraphExec_t *): Returns instantiated graph
  • graph (musaGraph_t): Graph to instantiate
  • instantiateParams (musaGraphInstantiateParams *): Instantiation parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecGetFlags

musaError_t musaGraphExecGetFlags(musaGraphExec_t graphExec, unsigned long long *flags)

Description

  • Query the instantiation flags of an executable graph.
  • Returns the flags that were passed to instantiation for the given executable graph. musaGraphInstantiateFlagUpload will not be returned by this API as it does not affect the resulting executable graph.

Parameters

  • graphExec (musaGraphExec_t): The executable graph to query
  • flags (unsigned long long *): Returns the instantiation flags

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecKernelNodeSetParams

musaError_t musaGraphExecKernelNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaKernelNodeParams *pNodeParams)

Description

  • Sets the parameters for a kernel node in the given graphExec.
  • Sets the parameters of a kernel node in an executable graph hGraphExec. The node is identified by the corresponding node node in the non-executable graph, from which the executable graph was instantiated.
  • node must not have been removed from the original graph. All nodeParams fields may change, but the following restrictions apply to func updates:
  • The owning device of the function cannot change. A node whose function originally did not use MUSA dynamic parallelism cannot be updated to a function which uses CDP A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side update calls. If hGraphExec was not instantiated for device launch, a node whose function originally did not use device-side musaGraphLaunch() cannot be updated to a function which uses device-side musaGraphLaunch() unless the node resides on the same device as nodes which contained such calls at instantiate-time. If no such calls were present at instantiation, these updates cannot be performed at all.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.
  • If node is a device-updatable kernel node, the next upload/launch of hGraphExec will overwrite any previous device-side updates. Additionally, applying host updates to a device-updatable kernel node while it is being updated from the device will result in undefined behavior.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): kernel node from the graph from which graphExec was instantiated
  • pNodeParams (const struct musaKernelNodeParams *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.
  • This API operates on a musaKernel_t handle.

See also

musaGraphExecMemcpyNodeSetParams

musaError_t musaGraphExecMemcpyNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemcpy3DParms *pNodeParams)

Description

  • Sets the parameters for a memcpy node in the given graphExec.
  • Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored.
  • The source and destination memory in pNodeParams must be allocated from the same contexts as the original source and destination memory. Both the instantiation-time memory operands and the memory operands in pNodeParams must be 1-dimensional. Zero-length operations are not supported.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.
  • Returns musaErrorInvalidValue if the memory operands' mappings changed or either the original or new memory operands are multidimensional.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Memcpy node from the graph which was used to instantiate graphExec
  • pNodeParams (const struct musaMemcpy3DParms *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecMemcpyNodeSetParams1D

musaError_t musaGraphExecMemcpyNodeSetParams1D(musaGraphExec_t hGraphExec, musaGraphNode_t node, void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Description

  • Sets the parameters for a memcpy node in the given graphExec to perform a 1-dimensional copy.
  • Updates the work represented by node in hGraphExec as though node had contained the given params at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored.
  • src and dst must be allocated from the same contexts as the original source and destination memory. The instantiation-time memory operands must be 1-dimensional. Zero-length operations are not supported.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.
  • Returns musaErrorInvalidValue if the memory operands' mappings changed or the original memory operands are multidimensional.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Memcpy node from the graph which was used to instantiate graphExec
  • dst (void *): Destination memory address
  • src (const void *): Source memory address
  • count (size_t): Size in bytes to copy
  • kind (enum musaMemcpyKind): Type of transfer

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecEventWaitNodeSetEvent

musaError_t musaGraphExecEventWaitNodeSetEvent(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, musaEvent_t event)

Description

  • No description is available.

Parameters

  • hGraphExec (musaGraphExec_t)
  • hNode (musaGraphNode_t)
  • event (musaEvent_t)

Returns

  • Return type: musaError_t.

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

musaGraphExecMemsetNodeSetParams

musaError_t musaGraphExecMemsetNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemsetParams *pNodeParams)

Description

  • Sets the parameters for a memset node in the given graphExec.
  • Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored.
  • Zero sized operations are not supported.
  • The new destination pointer in pNodeParams must be to the same kind of allocation as the original destination pointer and have the same context association and device mapping as the original destination pointer.
  • Both the value and pointer address may be updated. Changing other aspects of the memset (width, height, element size or pitch) may cause the update to be rejected. Specifically, for 2d memsets, all dimension changes are rejected. For 1d memsets, changes in height are explicitly rejected and other changes are oportunistically allowed if the resulting work maps onto the work resources already allocated for the node.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Memset node from the graph which was used to instantiate graphExec
  • pNodeParams (const struct musaMemsetParams *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecHostNodeSetParams

musaError_t musaGraphExecHostNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaHostNodeParams *pNodeParams)

Description

  • Sets the parameters for a host node in the given graphExec.
  • Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Host node from the graph which was used to instantiate graphExec
  • pNodeParams (const struct musaHostNodeParams *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecEventRecordNodeSetEvent

musaError_t musaGraphExecEventRecordNodeSetEvent(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, musaEvent_t event)

Description

  • Sets the event for an event record node in the given graphExec.
  • Sets the event of an event record node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • hNode (musaGraphNode_t): Event record node from the graph from which graphExec was instantiated
  • event (musaEvent_t): Updated event to use

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecExternalSemaphoresSignalNodeSetParams

musaError_t musaGraphExecExternalSemaphoresSignalNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, const struct musaExternalSemaphoreSignalNodeParams *nodeParams)

Description

  • Sets the event for an event wait node in the given graphExec.
  • Sets the event of an event wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
  • Sets the parameters of an external semaphore signal node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
  • hNode must not have been removed from the original graph.
  • Changing nodeParams->numExtSems is not supported.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • hNode (musaGraphNode_t): semaphore signal node from the graph from which graphExec was instantiated
  • nodeParams (const struct musaExternalSemaphoreSignalNodeParams *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecExternalSemaphoresWaitNodeSetParams

musaError_t musaGraphExecExternalSemaphoresWaitNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, const struct musaExternalSemaphoreWaitNodeParams *nodeParams)

Description

  • Sets the parameters for an external semaphore wait node in the given graphExec.
  • Sets the parameters of an external semaphore wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
  • hNode must not have been removed from the original graph.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.
  • Changing nodeParams->numExtSems is not supported.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • hNode (musaGraphNode_t): semaphore wait node from the graph from which graphExec was instantiated
  • nodeParams (const struct musaExternalSemaphoreWaitNodeParams *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeSetEnabled

musaError_t musaGraphNodeSetEnabled(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, unsigned int isEnabled)

Description

  • Enables or disables the specified node in the given graphExec.
  • Sets hNode to be either enabled or disabled. Disabled nodes are functionally equivalent to empty nodes until they are reenabled. Existing node parameters are not affected by disabling/enabling the node.
  • The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
  • hNode must not have been removed from the original graph.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • hNode (musaGraphNode_t): Node from the graph from which graphExec was instantiated
  • isEnabled (unsigned int): Node is enabled if != 0, otherwise the node is disabled

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Currently only kernel, memset and memcpy nodes are supported.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeGetEnabled

musaError_t musaGraphNodeGetEnabled(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, unsigned int *isEnabled)

Description

  • Query whether a node in the given graphExec is enabled.
  • Sets isEnabled to 1 if hNode is enabled, or 0 if hNode is disabled.
  • The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated.
  • hNode must not have been removed from the original graph.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • hNode (musaGraphNode_t): Node from the graph from which graphExec was instantiated
  • isEnabled (unsigned int *): Location to return the enabled status of the node

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Currently only kernel, memset and memcpy nodes are supported.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecUpdate

musaError_t musaGraphExecUpdate(musaGraphExec_t hGraphExec, musaGraph_t hGraph, musaGraphExecUpdateResultInfo *resultInfo)

Description

  • Check whether an executable graph can be updated with a graph and perform the update if possible.
  • Updates the node parameters in the instantiated graph specified by hGraphExec with the node parameters in a topologically identical graph specified by hGraph.
  • Limitations:
  • Kernel nodes: The owning context of the function cannot change. A node whose function originally did not use MUSA dynamic parallelism cannot be updated to a function which uses CDP. A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side update calls. A cooperative node cannot be updated to a non-cooperative node, and vice-versa. If the graph was instantiated with musaGraphInstantiateFlagUseNodePriority, the priority attribute cannot change. Equality is checked on the originally requested priority values, before they are clamped to the device's supported range. If hGraphExec was not instantiated for device launch, a node whose function originally did not use device-side musaGraphLaunch() cannot be updated to a function which uses device-side musaGraphLaunch() unless the node resides on the same device as nodes which contained such calls at instantiate-time. If no such calls were present at instantiation, these updates cannot be performed at all. Neither hGraph nor hGraphExec may contain device-updatable kernel nodes. Memset and memcpy nodes: The MUSA device(s) to which the operand(s) was allocated/mapped cannot change. The source/destination memory must be allocated from the same contexts as the original source/destination memory. For 2d memsets, only address and assinged value may be updated. For 1d memsets, updating dimensions is also allowed, but may fail if the resulting operation doesn't map onto the work resources already allocated for the node. Additional memcpy node restrictions: Changing either the source or destination memory type(i.e. MU_MEMORYTYPE_DEVICE, MU_MEMORYTYPE_ARRAY, etc.) is not supported. Conditional nodes: Changing node parameters is not supported. Changeing parameters of nodes within the conditional body graph is subject to the rules above. Conditional handle flags and default values are updated as part of the graph update.
  • Note: The API may add further restrictions in future releases. The return code should always be checked.
  • musaGraphExecUpdate sets the result member of resultInfo to musaGraphExecUpdateErrorTopologyChanged under the following conditions: The count of nodes directly in hGraphExec and hGraph differ, in which case resultInfo->errorNode is set to NULL. hGraph has more exit nodes than hGraph, in which case resultInfo->errorNode is set to one of the exit nodes in hGraph. A node in hGraph has a different number of dependencies than the node from hGraphExec it is paired with, in which case resultInfo->errorNode is set to the node from hGraph. A node in hGraph has a dependency that does not match with the corresponding dependency of the paired node from hGraphExec. resultInfo->errorNode will be set to the node from hGraph. resultInfo->errorFromNode will be set to the mismatched dependency. The dependencies are paired based on edge order and a dependency does not match when the nodes are already paired based on other edges examined in the graph.
  • musaGraphExecUpdate sets the result member of resultInfo to: musaGraphExecUpdateError if passed an invalid value. musaGraphExecUpdateErrorTopologyChanged if the graph topology changed musaGraphExecUpdateErrorNodeTypeChanged if the type of a node changed, in which case hErrorNode_out is set to the node from hGraph. musaGraphExecUpdateErrorFunctionChanged if the function of a kernel node changed (MUSA driver < 11.2) musaGraphExecUpdateErrorUnsupportedFunctionChange if the func field of a kernel changed in an unsupported way(see note above), in which case hErrorNode_out is set to the node from hGraph musaGraphExecUpdateErrorParametersChanged if any parameters to a node changed in a way that is not supported, in which case hErrorNode_out is set to the node from hGraph musaGraphExecUpdateErrorAttributesChanged if any attributes of a node changed in a way that is not supported, in which case hErrorNode_out is set to the node from hGraph musaGraphExecUpdateErrorNotSupported if something about a node is unsupported, like the node's type or configuration, in which case hErrorNode_out is set to the node from hGraph
  • If the update fails for a reason not listed above, the result member of resultInfo will be set to musaGraphExecUpdateError. If the update succeeds, the result member will be set to musaGraphExecUpdateSuccess.
  • musaGraphExecUpdate returns musaSuccess when the updated was performed successfully. It returns musaErrorGraphExecUpdateFailure if the graph update was not performed because it included changes which violated constraints specific to instantiated graph update.

Parameters

  • hGraphExec (musaGraphExec_t): The instantiated graph to be updated
  • hGraph (musaGraph_t): The graph containing the updated parameters
  • resultInfo (musaGraphExecUpdateResultInfo *): the error info structure

Returns

  • musaSuccess, musaErrorGraphExecUpdateFailure

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphUpload

musaError_t musaGraphUpload(musaGraphExec_t graphExec, musaStream_t stream)

Description

  • Uploads an executable graph in a stream.
  • Uploads hGraphExec to the device in hStream without executing it. Uploads of the same hGraphExec will be serialized. Each upload is ordered behind both any previous work in hStream and any previous launches of hGraphExec. Uses memory cached by stream to back the allocations owned by graphExec.

Parameters

  • graphExec (musaGraphExec_t)
  • stream (musaStream_t)

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.

See also

musaGraphLaunch

musaError_t musaGraphLaunch(musaGraphExec_t graphExec, musaStream_t stream)

Description

  • Launches an executable graph in a stream.
  • Executes graphExec in stream. Only one instance of graphExec may be executing at a time. Each launch is ordered behind both any previous work in stream and any previous launches of graphExec. To execute a graph concurrently, it must be instantiated multiple times into multiple executable graphs.
  • If any allocations created by graphExec remain unfreed (from a previous launch) and graphExec was not instantiated with musaGraphInstantiateFlagAutoFreeOnLaunch, the launch will fail with musaErrorInvalidValue.

Parameters

  • graphExec (musaGraphExec_t): Executable graph to launch
  • stream (musaStream_t): Stream in which to launch the graph

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecDestroy

musaError_t musaGraphExecDestroy(musaGraphExec_t graphExec)

Description

  • Destroys an executable graph.
  • Destroys the executable graph specified by graphExec.

Parameters

  • graphExec (musaGraphExec_t): Executable graph to destroy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

musaGraphDestroy

musaError_t musaGraphDestroy(musaGraph_t graph)

Description

  • Destroys a graph.
  • Destroys the graph specified by graph, as well as all of its nodes.

Parameters

  • graph (musaGraph_t): Graph to destroy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.
  • Destroying the target object while work is still pending results in undefined behavior.

See also

musaGraphDebugDotPrint

musaError_t musaGraphDebugDotPrint(musaGraph_t graph, const char *path, unsigned int flags)

Description

  • Write a DOT file describing graph structure.
  • Using the provided graph, write to path a DOT formatted description of the graph. By default this includes the graph topology, node types, node id, kernel names and memcpy direction. flags can be specified to write more detailed information about each node type such as parameter values, kernel attributes, node and function handles.

Parameters

  • graph (musaGraph_t): The graph to create a DOT file from
  • path (const char *): The path to write the DOT file to
  • flags (unsigned int): Flags from musaGraphDebugDotFlags for specifying which additional node information to write

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorOperatingSystem

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.

musaUserObjectCreate

musaError_t musaUserObjectCreate(musaUserObject_t *object_out, void *ptr, musaHostFn_t destroy, unsigned int initialRefcount, unsigned int flags)

Description

  • Create a user object.
  • Create a user object with the specified destructor callback and initial reference count. The initial references are owned by the caller.
  • Destructor callbacks cannot make MUSA API calls and should avoid blocking behavior, as they are executed by a shared internal thread. Another thread may be signaled to perform such actions, if it does not block forward progress of tasks scheduled through MUSA.
  • See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects.

Parameters

  • object_out (musaUserObject_t *): Location to return the user object handle
  • ptr (void *): The pointer to pass to the destroy function
  • destroy (musaHostFn_t): Callback to free the user object when it is no longer in use
  • initialRefcount (unsigned int): The initial refcount to create the object with, typically 1. The initial references are owned by the calling thread.
  • flags (unsigned int): Currently it is required to pass musaUserObjectNoDestructorSync, which is the only defined flag. This indicates that the destroy callback cannot be waited on by any MUSA API. Users requiring synchronization of the callback should signal its completion manually.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.

See also

musaUserObjectRetain

musaError_t musaUserObjectRetain(musaUserObject_t object, unsigned int count)

Description

  • Retain a reference to a user object.
  • Retains new references to a user object. The new references are owned by the caller.
  • See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects.

Parameters

  • object (musaUserObject_t): The object to retain
  • count (unsigned int): The number of references to retain, typically 1. Must be nonzero and not larger than INT_MAX.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.

See also

musaUserObjectRelease

musaError_t musaUserObjectRelease(musaUserObject_t object, unsigned int count)

Description

  • Release a reference to a user object.
  • Releases user object references owned by the caller. The object's destructor is invoked if the reference count reaches zero.
  • It is undefined behavior to release references not owned by the caller, or to use a user object handle after all references are released.
  • See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects.

Parameters

  • object (musaUserObject_t): The object to release
  • count (unsigned int): The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.

See also

musaGraphRetainUserObject

musaError_t musaGraphRetainUserObject(musaGraph_t graph, musaUserObject_t object, unsigned int count, unsigned int flags)

Description

  • Retain a reference to a user object from a graph.
  • Creates or moves user object references that will be owned by a MUSA graph.
  • See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects.

Parameters

  • graph (musaGraph_t): The graph to associate the reference with
  • object (musaUserObject_t): The user object to retain a reference for
  • count (unsigned int): The number of references to add to the graph, typically 1. Must be nonzero and not larger than INT_MAX.
  • flags (unsigned int): The optional flag musaGraphUserObjectMove transfers references from the calling thread, rather than create new references. Pass 0 to create new references.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.

See also

musaGraphReleaseUserObject

musaError_t musaGraphReleaseUserObject(musaGraph_t graph, musaUserObject_t object, unsigned int count)

Description

  • Release a user object reference from a graph.
  • Releases user object references owned by a graph.
  • See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects.

Parameters

  • graph (musaGraph_t): The graph that will release the reference
  • object (musaUserObject_t): The user object to release a reference for
  • count (unsigned int): The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX.

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.

See also

musaGraphAddNode

musaError_t musaGraphAddNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, struct musaGraphNodeParams *nodeParams)

Description

  • Adds a node of arbitrary type to a graph.
  • Creates a new node in graph described by nodeParams with numDependencies dependencies specified via pDependencies. numDependencies may be 0. pDependencies may be null if numDependencies is 0. pDependencies may not have any duplicate entries.
  • nodeParams is a tagged union. The node type should be specified in the type field, and type-specific parameters in the corresponding union member. All unused bytes - that is, reserved0 and all bytes past the utilized union member - must be set to zero. It is recommended to use brace initialization or memset to ensure all bytes are initialized.
  • Note that for some node types, nodeParams may contain "out parameters" which are modified during the call, such as nodeParams->alloc.dptr.
  • A handle to the new node will be returned in phGraphNode.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • nodeParams (struct musaGraphNodeParams *): Specification of the node

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemAtomicNode

musaError_t musaGraphAddMemAtomicNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemAtomicParms *pMemAtomicParams)

Description

  • Creates a memory atomic node and adds it to a graph.
  • Creates a new memory atomic node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will perform the memory atomic operation described by pMemAtomicParams. See musaMemoryAtomicAsync() for a description of the structure.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pMemAtomicParams (const struct musaMemAtomicParms *): Parameters for the memory atomic

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemAtomicValueNode

musaError_t musaGraphAddMemAtomicValueNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemAtomicValueParms *pMemAtomicValueParams)

Description

  • Creates a memory atomic value node and adds it to a graph.
  • Creates a new memory atomic value node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will perform the memory atomic value operation described by pMemAtomicValueParams. See musaMemoryAtomicValueAsync() for a description of the structure.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pMemAtomicValueParams (const struct musaMemAtomicValueParms *): Parameters for the memory atomic value

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemWaitWriteNode

musaError_t musaGraphAddMemWaitWriteNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemWaitWriteParms *pMemWaitWriteParams)

Description

  • Creates a memory wait / write value node and adds it to a graph.
  • Creates a new memory wait / write value node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will perform the memory wait / write value described by pMemWaitWriteParams.
struct __device_builtin__musaMemWaitWriteParms {
void *addr;
size_t value;
unsigned int flags;
musaStreamBatchMemOpTypeoperation;
};
  • ;
  • See musaStreamBatchMemOpType for the full set of supported operations, and muStreamWaitValue64() and muStreamWriteValue64() for details of specific operations.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pMemWaitWriteParams (const struct musaMemWaitWriteParms *): Parameters for the memory atomic value

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddMemTransferNode

musaError_t musaGraphAddMemTransferNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemTransferParms *pMemTransferParams)

Description

  • Creates a memory transfer node and adds it to a graph.
  • Creates a new memory transfer node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode.
  • When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst by transfer engine.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • numDependencies (size_t): Number of dependencies
  • pMemTransferParams (const struct musaMemTransferParms *): Parameters for the memory transfer

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemAtomicNodeGetParams

musaError_t musaGraphMemAtomicNodeGetParams(musaGraphNode_t node, struct musaMemAtomicParms *pNodeParams)

Description

  • Returns a memory atomic node's parameters.
  • Returns the parameters of memory atomic node node in pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaMemAtomicParms *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemAtomicNodeSetParams

musaError_t musaGraphMemAtomicNodeSetParams(musaGraphNode_t node, const struct musaMemAtomicParms *pNodeParams)

Description

  • Sets a memory atomic node's parameters.
  • Sets the parameters of memory atomic node node to pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaMemAtomicParms *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemAtomicValueNodeGetParams

musaError_t musaGraphMemAtomicValueNodeGetParams(musaGraphNode_t node, struct musaMemAtomicValueParms *pNodeParams)

Description

  • Returns a memory atomic value node's parameters.
  • Returns the parameters of memory atomic value node node in pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaMemAtomicValueParms *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemAtomicValueNodeSetParams

musaError_t musaGraphMemAtomicValueNodeSetParams(musaGraphNode_t node, const struct musaMemAtomicValueParms *pNodeParams)

Description

  • Sets a memory atomic value node's parameters.
  • Sets the parameters of memory atomic value node node to pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaMemAtomicValueParms *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemWaitWriteNodeGetParams

musaError_t musaGraphMemWaitWriteNodeGetParams(musaGraphNode_t node, struct musaMemWaitWriteParms *pNodeParams)

Description

  • Returns a memory wait / write value node's parameters.
  • Returns the parameters of memory wait / write value node node in pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaMemWaitWriteParms *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemWaitWriteNodeSetParams

musaError_t musaGraphMemWaitWriteNodeSetParams(musaGraphNode_t node, const struct musaMemWaitWriteParms *pNodeParams)

Description

  • Sets a memory wait / write value node's parameters.
  • Sets the parameters of memory wait / write value node node to pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaMemWaitWriteParms *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemTransferNodeGetParams

musaError_t musaGraphMemTransferNodeGetParams(musaGraphNode_t node, struct musaMemTransferParms *pNodeParams)

Description

  • Returns a memory transfer node's parameters.
  • Returns the parameters of memory transfer node node in pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • pNodeParams (struct musaMemTransferParms *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphMemTransferNodeSetParams

musaError_t musaGraphMemTransferNodeSetParams(musaGraphNode_t node, const struct musaMemTransferParms *pNodeParams)

Description

  • Sets a memory transfer node's parameters.
  • Sets the parameters of memory transfer node node to pNodeParams.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • pNodeParams (const struct musaMemTransferParms *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecMemAtomicNodeSetParams

musaError_t musaGraphExecMemAtomicNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemAtomicParms *pNodeParams)

Description

  • Sets the parameters for a memory atomic node in the given graphExec.
  • Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored.
  • The source and destination memory in pNodeParams must be allocated from the same contexts as the original source and destination memory. Zero-length operations are not supported.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Memory atomic node from the graph which was used to instantiate graphExec
  • pNodeParams (const struct musaMemAtomicParms *): The updated parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecMemAtomicValueNodeSetParams

musaError_t musaGraphExecMemAtomicValueNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemAtomicValueParms *pNodeParams)

Description

  • Sets the parameters for a memory atomic value node in the given graphExec.
  • Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored.
  • The destination memory in pNodeParams must be allocated from the same contexts as the original destination memory.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Memory atomic value node from the graph which was used to instantiate graphExec
  • pNodeParams (const struct musaMemAtomicValueParms *): The updated parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecMemWaitWriteNodeSetParams

musaError_t musaGraphExecMemWaitWriteNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemWaitWriteParms *pNodeParams)

Description

  • Sets the parameters for a memory wait / write value node in the given graphExec.
  • Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored.
  • The destination memory in pNodeParams must be allocated from the same contexts as the original destination memory.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Memory wait / write value node from the graph which was used to instantiate graphExec
  • pNodeParams (const struct musaMemWaitWriteParms *): The updated parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecMemTransferNodeSetParams

musaError_t musaGraphExecMemTransferNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemTransferParms *pNodeParams)

Description

  • Sets the parameters for a memory transfer node in the given graphExec.
  • Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored.
  • The source and destination memory in pNodeParams must be allocated from the same contexts as the original source and destination memory. Zero-length operations are not supported.
  • The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call.
  • Returns musaErrorInvalidValue if the memory operands' mappings changed or either the original or new memory operands are multidimensional.

Parameters

  • hGraphExec (musaGraphExec_t): The executable graph in which to set the specified node
  • node (musaGraphNode_t): Memory transfer node from the graph which was used to instantiate graphExec
  • pNodeParams (const struct musaMemTransferParms *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphAddNode_v2

musaError_t musaGraphAddNode_v2(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, const musaGraphEdgeData *dependencyData, size_t numDependencies, struct musaGraphNodeParams *nodeParams)

Description

  • Adds a node of arbitrary type to a graph (12.3+)
  • Creates a new node in graph described by nodeParams with numDependencies dependencies specified via pDependencies. numDependencies may be 0. pDependencies may be null if numDependencies is 0. pDependencies may not have any duplicate entries.
  • nodeParams is a tagged union. The node type should be specified in the type field, and type-specific parameters in the corresponding union member. All unused bytes - that is, reserved0 and all bytes past the utilized union member - must be set to zero. It is recommended to use brace initialization or memset to ensure all bytes are initialized.
  • Note that for some node types, nodeParams may contain "out parameters" which are modified during the call, such as nodeParams->alloc.dptr.
  • A handle to the new node will be returned in phGraphNode.

Parameters

  • pGraphNode (musaGraphNode_t *): Returns newly created node
  • graph (musaGraph_t): Graph to which to add the node
  • pDependencies (const musaGraphNode_t *): Dependencies of the node
  • dependencyData (const musaGraphEdgeData *): Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies.
  • numDependencies (size_t): Number of dependencies
  • nodeParams (struct musaGraphNodeParams *): Specification of the node

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeSetParams

musaError_t musaGraphNodeSetParams(musaGraphNode_t node, struct musaGraphNodeParams *nodeParams)

Description

  • Update's a graph node's parameters.
  • Sets the parameters of graph node node to nodeParams. The node type specified by nodeParams->type must match the type of node. nodeParams must be fully initialized and all unused bytes (reserved, padding) zeroed.
  • Modifying parameters is not supported for node types musaGraphNodeTypeMemAlloc and musaGraphNodeTypeMemFree.

Parameters

  • node (musaGraphNode_t): Node to set the parameters for
  • nodeParams (struct musaGraphNodeParams *): Parameters to copy

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphNodeGetParams

musaError_t musaGraphNodeGetParams(musaGraphNode_t node, struct musaGraphNodeParams *nodeParams)

Description

  • Returns a graph node's parameters.
  • Returns the parameters of graph node node in *nodeParams.
  • Any pointers returned in *nodeParams point to driver-owned memory associated with the node. This memory remains valid until the node is destroyed. Any memory pointed to from *nodeParams must not be modified.
  • The returned parameters are a description of the node, but may not be identical to the struct provided at creation and may not be suitable for direct creation of identical nodes. This is because parameters may be partially unspecified and filled in by the driver at creation, may reference non-copyable handles, or may describe ownership semantics or other parameters that govern behavior of node creation but are not part of the final functional descriptor.

Parameters

  • node (musaGraphNode_t): Node to get the parameters for
  • nodeParams (struct musaGraphNodeParams *): Pointer to return the parameters

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphExecNodeSetParams

musaError_t musaGraphExecNodeSetParams(musaGraphExec_t graphExec, musaGraphNode_t node, struct musaGraphNodeParams *nodeParams)

Description

  • Update's a graph node's parameters in an instantiated graph.
  • Sets the parameters of a node in an executable graph graphExec. The node is identified by the corresponding node node in the non-executable graph from which the executable graph was instantiated. node must not have been removed from the original graph.
  • The modifications only affect future launches of graphExec. Already enqueued or running launches of graphExec are not affected by this call. node is also not modified by this call.
  • Allowed changes to parameters on executable graphs are as follows: Node type Allowed changes kernel See musaGraphExecKernelNodeSetParams memcpy Addresses for 1-dimensional copies if allocated in same context; see musaGraphExecMemcpyNodeSetParams memset Addresses for 1-dimensional memsets if allocated in same context; see musaGraphExecMemsetNodeSetParams host Unrestricted child graph Topology must match and restrictions apply recursively; see musaGraphExecUpdate event wait Unrestricted event record Unrestricted external semaphore signal Number of semaphore operations cannot change external semaphore wait Number of semaphore operations cannot change memory allocation API unsupported memory free API unsupported

Parameters

  • graphExec (musaGraphExec_t): The executable graph in which to update the specified node
  • node (musaGraphNode_t): Corresponding node from the graph from which graphExec was instantiated
  • nodeParams (struct musaGraphNodeParams *): Updated Parameters to set

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • 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.
  • Graph objects are not thread-safe.

See also

musaGraphConditionalHandleCreate

musaError_t musaGraphConditionalHandleCreate(musaGraphConditionalHandle *pHandle_out, musaGraph_t graph, unsigned int defaultLaunchValue, unsigned int flags)

Description

  • Create a conditional handle.
  • Creates a conditional handle associated with hGraph.
  • The conditional handle must be associated with a conditional node in this graph or one of its children.
  • Handles not associated with a conditional node may cause graph instantiation to fail.

Parameters

  • pHandle_out (musaGraphConditionalHandle *): Pointer used to return the handle to the caller.
  • graph (musaGraph_t)
  • defaultLaunchValue (unsigned int): Optional initial value for the conditional variable. Applied at the beginning of each graph execution if musaGraphCondAssignDefault is set in flags.
  • flags (unsigned int): Currently must be musaGraphCondAssignDefault or 0.

Returns

  • MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_NOT_SUPPORTED

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • This function may also return error codes from previous, asynchronous launches.
  • Graph objects are not thread-safe.

See also

3.24 Driver Entry Point Access

musaGetDriverEntryPoint

musaError_t musaGetDriverEntryPoint(const char *symbol, void **funcPtr, unsigned long long flags, enum musaDriverEntryPointQueryResult *driverStatus)

Description

  • Returns the requested driver API function pointer.
  • Returns in **funcPtr the address of the MUSA driver function for the requested flags.
  • For a requested driver symbol, if the MUSA version in which the driver symbol was introduced is less than or equal to the MUSA runtime version, the API will return the function pointer to the corresponding versioned driver function.
  • The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example, musaTypedefs.h consists of function pointer typedefs for driver APIs defined in musa.h.
  • The API will return musaSuccess and set the returned funcPtr if the requested driver function is valid and supported on the platform.
  • The API will return musaSuccess and set the returned funcPtr to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the MUSA runtime version or if the driver symbol is invalid.
  • It will also set the optional driverStatus to one of the values in musaDriverEntryPointQueryResult with the following meanings: musaDriverEntryPointSuccess - The requested symbol was succesfully found based on input arguments and pfn is valid musaDriverEntryPointSymbolNotFound - The requested symbol was not found musaDriverEntryPointVersionNotSufficent - The requested symbol was found but is not supported by the current runtime version (MUSART_VERSION)
  • The requested flags can be: musaEnableDefault: This is the default mode. This is equivalent to musaEnablePerThreadDefaultStream if the code is compiled with default-stream per-thread compilation flag or the macro MUSA_API_PER_THREAD_DEFAULT_STREAM is defined; musaEnableLegacyStream otherwise. musaEnableLegacyStream: This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions. musaEnablePerThreadDefaultStream: This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function.

Parameters

  • symbol (const char *): The base name of the driver API function to look for. As an example, for the driver API muMemAlloc_v2, symbol would be muMemAlloc. Note that the API will use the MUSA runtime version to return the address to the most recent ABI compatible driver symbol, muMemAlloc or muMemAlloc_v2.
  • funcPtr (void **): Location to return the function pointer to the requested driver function
  • flags (unsigned long long): Flags to specify search options.
  • driverStatus (enum musaDriverEntryPointQueryResult *): Optional location to store the status of finding the symbol from the driver. See musaDriverEntryPointQueryResult for possible values.

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

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 the API version mixing note in the toolkit documentation.

See also

musaGetDriverEntryPointByVersion

musaError_t musaGetDriverEntryPointByVersion(const char *symbol, void **funcPtr, unsigned int musaVersion, unsigned long long flags, enum musaDriverEntryPointQueryResult *driverStatus)

Description

  • Returns the requested driver API function pointer by MUSA version.
  • Returns in **funcPtr the address of the MUSA driver function for the requested flags and MUSA driver version.
  • The MUSA version is specified as (1000 * major + 10 * minor), so MUSA 11.2 should be specified as 11020. For a requested driver symbol, if the specified MUSA version is greater than or equal to the MUSA version in which the driver symbol was introduced, this API will return the function pointer to the corresponding versioned function.
  • The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example, musaTypedefs.h consists of function pointer typedefs for driver APIs defined in musa.h.
  • For the case where the MUSA version requested is greater than the MUSA Toolkit installed, there may not be an appropriate function pointer typedef in the corresponding header file and may need a custom typedef to match the driver function signature returned. This can be done by getting the typedefs from a later toolkit or creating appropriately matching custom function typedefs.
  • The API will return musaSuccess and set the returned funcPtr if the requested driver function is valid and supported on the platform.
  • The API will return musaSuccess and set the returned funcPtr to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the requested version or if the driver symbol is invalid.
  • It will also set the optional driverStatus to one of the values in musaDriverEntryPointQueryResult with the following meanings: musaDriverEntryPointSuccess - The requested symbol was succesfully found based on input arguments and pfn is valid musaDriverEntryPointSymbolNotFound - The requested symbol was not found musaDriverEntryPointVersionNotSufficent - The requested symbol was found but is not supported by the specified version musaVersion
  • The requested flags can be: musaEnableDefault: This is the default mode. This is equivalent to musaEnablePerThreadDefaultStream if the code is compiled with default-stream per-thread compilation flag or the macro MUSA_API_PER_THREAD_DEFAULT_STREAM is defined; musaEnableLegacyStream otherwise. musaEnableLegacyStream: This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions. musaEnablePerThreadDefaultStream: This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function.

Parameters

  • symbol (const char *): The base name of the driver API function to look for. As an example, for the driver API muMemAlloc_v2, symbol would be muMemAlloc.
  • funcPtr (void **): Location to return the function pointer to the requested driver function
  • musaVersion (unsigned int): The MUSA version to look for the requested driver symbol
  • flags (unsigned long long): Flags to specify search options.
  • driverStatus (enum musaDriverEntryPointQueryResult *): Optional location to store the status of finding the symbol from the driver. See musaDriverEntryPointQueryResult for possible values.

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

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 the API version mixing note in the toolkit documentation.

See also

3.25 Library Management

musaLibraryLoadData

musaError_t musaLibraryLoadData(musaLibrary_t *library, const void *code, enum musaJitOption *jitOptions, void **jitOptionsValues, unsigned int numJitOptions, enum musaLibraryOption *libraryOptions, void **libraryOptionValues, unsigned int numLibraryOptions)

Description

  • Load a library with specified code and options.
  • Takes a pointer code and loads the corresponding library library based on the application defined library loading mode: If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with musaLibraryUnload(). If the environment variables are set to LAZY, library is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch.
  • These environment variables are described in the MUSA programming guide under the "MUSA environment variables" section.
  • The code may be a mubin or fatbin as output by mtcc, or a NULL-terminated MTX, either as output by mtcc or hand-written. A fatbin should also contain relocatable code when doing separate compilation. Please also see the documentation for nvrtc (https://docs.mthreads.com/musa/nvrtc/index.html), nvjitlink (https://docs.mthreads.com/musa/nvjitlink/index.html), and nvfatbin (https://docs.mthreads.com/musa/nvfatbin/index.html) for more information on generating loadable code at runtime.
  • Options are passed as an array via jitOptions and any corresponding parameters are passed in jitOptionsValues. The number of total JIT options is supplied via numJitOptions. Any outputs will be returned via jitOptionsValues.
  • Library load options are passed as an array via libraryOptions and any corresponding parameters are passed in libraryOptionValues. The number of total library load options is supplied via numLibraryOptions.

Parameters

  • library (musaLibrary_t *): Returned library
  • code (const void *): Code to load
  • jitOptions (enum musaJitOption *): Options for JIT
  • jitOptionsValues (void **): Option values for JIT
  • numJitOptions (unsigned int): Number of options
  • libraryOptions (enum musaLibraryOption *): Options for loading
  • libraryOptionValues (void **): Option values for loading
  • numLibraryOptions (unsigned int): Number of options for loading

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorMusartUnloading, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorSharedObjectSymbolNotFound, musaErrorSharedObjectInitFailed, musaErrorJitCompilerNotFound

See also

musaLibraryLoadFromFile

musaError_t musaLibraryLoadFromFile(musaLibrary_t *library, const char *fileName, enum musaJitOption *jitOptions, void **jitOptionsValues, unsigned int numJitOptions, enum musaLibraryOption *libraryOptions, void **libraryOptionValues, unsigned int numLibraryOptions)

Description

  • Load a library with specified file and options.
  • Takes a pointer code and loads the corresponding library library based on the application defined library loading mode: If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with musaLibraryUnload(). If the environment variables are set to LAZY, library is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch.
  • These environment variables are described in the MUSA programming guide under the "MUSA environment variables" section.
  • The file should be a mubin file as output by mtcc, or a MTX file either as output by mtcc or handwritten, or a fatbin file as output by mtcc. A fatbin should also contain relocatable code when doing separate compilation. Please also see the documentation for nvrtc (https://docs.mthreads.com/musa/nvrtc/index.html), nvjitlink (https://docs.mthreads.com/musa/nvjitlink/index.html), and nvfatbin (https://docs.mthreads.com/musa/nvfatbin/index.html) for more information on generating loadable code at runtime.
  • Options are passed as an array via jitOptions and any corresponding parameters are passed in jitOptionsValues. The number of total options is supplied via numJitOptions. Any outputs will be returned via jitOptionsValues.
  • Library load options are passed as an array via libraryOptions and any corresponding parameters are passed in libraryOptionValues. The number of total library load options is supplied via numLibraryOptions.

Parameters

  • library (musaLibrary_t *): Returned library
  • fileName (const char *): File to load from
  • jitOptions (enum musaJitOption *): Options for JIT
  • jitOptionsValues (void **): Option values for JIT
  • numJitOptions (unsigned int): Number of options
  • libraryOptions (enum musaLibraryOption *): Options for loading
  • libraryOptionValues (void **): Option values for loading
  • numLibraryOptions (unsigned int): Number of options for loading

Returns

  • musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorMusartUnloading, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorSharedObjectSymbolNotFound, musaErrorSharedObjectInitFailed, musaErrorJitCompilerNotFound

See also

musaLibraryUnload

musaError_t musaLibraryUnload(musaLibrary_t library)

Description

  • Unloads a library.
  • Unloads the library specified with library

Parameters

  • library (musaLibrary_t): Library to unload

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue

See also

musaLibraryGetKernel

musaError_t musaLibraryGetKernel(musaKernel_t *pKernel, musaLibrary_t library, const char *name)

Description

  • Returns a kernel handle.
  • Returns in pKernel the handle of the kernel with name name located in library library. If kernel handle is not found, the call returns musaErrorSymbolNotFound.

Parameters

  • pKernel (musaKernel_t *): Returned kernel handle
  • library (musaLibrary_t): Library to retrieve kernel from
  • name (const char *): Name of kernel to retrieve

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound

See also

musaLibraryGetGlobal

musaError_t musaLibraryGetGlobal(void **dptr, size_t *bytes, musaLibrary_t library, const char *name)

Description

  • Returns a global device pointer.
  • Returns in *dptr and *bytes the base pointer and size of the global with name name for the requested library library and the current device. If no global for the requested name name exists, the call returns musaErrorSymbolNotFound. One of the parameters dptr or bytes (not both) can be NULL in which case it is ignored. The returned dptr cannot be passed to the Symbol APIs such as musaMemcpyToSymbol, musaMemcpyFromSymbol, musaGetSymbolAddress, or musaGetSymbolSize.

Parameters

  • dptr (void **): Returned global device pointer for the requested library
  • bytes (size_t *): Returned global size in bytes
  • library (musaLibrary_t): Library to retrieve global from
  • name (const char *): Name of global to retrieve

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound musaErrorDeviceUninitialized, musaErrorContextIsDestroyed

See also

musaLibraryGetManaged

musaError_t musaLibraryGetManaged(void **dptr, size_t *bytes, musaLibrary_t library, const char *name)

Description

  • Returns a pointer to managed memory.
  • Returns in *dptr and *bytes the base pointer and size of the managed memory with name name for the requested library library. If no managed memory with the requested name name exists, the call returns musaErrorSymbolNotFound. One of the parameters dptr or bytes (not both) can be NULL in which case it is ignored. Note that managed memory for library library is shared across devices and is registered when the library is loaded. The returned dptr cannot be passed to the Symbol APIs such as musaMemcpyToSymbol, musaMemcpyFromSymbol, musaGetSymbolAddress, or musaGetSymbolSize.

Parameters

  • dptr (void **): Returned pointer to the managed memory
  • bytes (size_t *): Returned memory size in bytes
  • library (musaLibrary_t): Library to retrieve managed memory from
  • name (const char *): Name of managed memory to retrieve

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound

See also

musaLibraryGetUnifiedFunction

musaError_t musaLibraryGetUnifiedFunction(void **fptr, musaLibrary_t library, const char *symbol)

Description

  • Returns a pointer to a unified function.
  • Returns in *fptr the function pointer to a unified function denoted by symbol. If no unified function with name symbol exists, the call returns musaErrorSymbolNotFound. If there is no device with attribute musaDeviceProp::unifiedFunctionPointers present in the system, the call may return musaErrorSymbolNotFound.

Parameters

  • fptr (void **): Returned pointer to a unified function
  • library (musaLibrary_t): Library to retrieve function pointer memory from
  • symbol (const char *): Name of function pointer to retrieve

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound

See also

musaLibraryGetKernelCount

musaError_t musaLibraryGetKernelCount(unsigned int *count, musaLibrary_t lib)

Description

  • Returns the number of kernels within a library.
  • Returns in count the number of kernels in lib.

Parameters

  • count (unsigned int *): Number of kernels found within the library
  • lib (musaLibrary_t): Library to query

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also

musaLibraryEnumerateKernels

musaError_t musaLibraryEnumerateKernels(musaKernel_t *kernels, unsigned int numKernels, musaLibrary_t lib)

Description

  • Retrieve the kernel handles within a library.
  • Returns in kernels a maximum number of numKernels kernel handles within lib. The returned kernel handle becomes invalid when the library is unloaded.

Parameters

  • kernels (musaKernel_t *): Buffer where the kernel handles are returned to
  • numKernels (unsigned int): Maximum number of kernel handles may be returned to the buffer
  • lib (musaLibrary_t): Library to query from

Returns

  • musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also

musaKernelSetAttributeForDevice

musaError_t musaKernelSetAttributeForDevice(musaKernel_t kernel, enum musaFuncAttribute attr, int value, int device)

Description

  • Sets information about a kernel.
  • This call sets the value of a specified attribute attr on the kernel kernel for the requested device device to an integer value specified by value. This function returns musaSuccess if the new value of the attribute could be successfully set. If the set fails, this call will return an error. Not all attributes can have values set. Attempting to set a value on a read-only attribute will result in an error (musaErrorInvalidValue)
  • Note that attributes set using musaFuncSetAttribute() will override the attribute set by this API irrespective of whether the call to musaFuncSetAttribute() is made before or after this API call. Because of this and the stricter locking requirements mentioned below it is suggested that this call be used during the initialization path and not on each thread accessing kernel such as on kernel launches or on the critical path.
  • Valid values for attr are: musaFuncAttributeMaxDynamicSharedMemorySize - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute sharedSizeBytes cannot exceed the device attribute musaDevAttrMaxSharedMemoryPerBlockOptin. The maximal size of requestable dynamic shared memory may differ by GPU architecture. musaFuncAttributePreferredSharedMemoryCarveout - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See musaDevAttrMaxSharedMemoryPerMultiprocessor. This is only a hint, and the driver can choose a different ratio if required to execute the function. musaFuncAttributeRequiredClusterWidth: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterHeight: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterDepth: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeNonPortableClusterSizeAllowed: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. musaFuncAttributeClusterSchedulingPolicyPreference: The block scheduling policy of a function. The value type is musaClusterSchedulingPolicy.

Parameters

  • kernel (musaKernel_t): Kernel to set attribute of
  • attr (enum musaFuncAttribute): Attribute requested
  • value (int): Value to set
  • device (int): Device to set attribute of

Returns

  • musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidValue

Note

  • The API has stricter locking requirements in comparison to its legacy counterpart musaFuncSetAttribute() due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously, the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency.

See also

3.26 Error Log Management

Information

  • This module is experimental in MUSA SDK 5.2.0 and is provided for reference only.

musaLogsRegisterCallback

musaError_t musaLogsRegisterCallback(musaLogsCallback_t callbackFunc, void *userData, musaLogsCallbackHandle *callback_out)

Description

  • Register a callback function to receive error log messages.

Parameters

  • callbackFunc (musaLogsCallback_t): The function to register as a callback
  • userData (void *): A generic pointer to user data. This is passed into the callback function.
  • callback_out (musaLogsCallbackHandle *): Optional location to store the callback handle after it is registered

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

musaLogsUnregisterCallback

musaError_t musaLogsUnregisterCallback(musaLogsCallbackHandle callback)

Description

  • Unregister a log message callback.

Parameters

  • callback (musaLogsCallbackHandle): The callback instance to unregister from receiving log messages

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

musaLogsCurrent

musaError_t musaLogsCurrent(musaLogIterator *iterator_out, unsigned int flags)

Description

  • Sets log iterator to point to the end of log buffer, where the next message would be written.

Parameters

  • iterator_out (musaLogIterator *): Location to store an iterator to the current tail of the logs
  • flags (unsigned int): Reserved for future use, must be 0

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.

musaLogsDumpToFile

musaError_t musaLogsDumpToFile(musaLogIterator *iterator, const char *pathToFile, unsigned int flags)

Description

  • Dump accumulated driver logs into a file.
  • Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps all driver logs starting from iterator into pathToFile provided.

Parameters

  • iterator (musaLogIterator *): Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
  • pathToFile (const char *): Path to output file for dumping logs
  • flags (unsigned int): Reserved for future use, must be 0

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.
  • iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
  • The driver reserves limited memory for storing logs. The oldest logs may be overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk.

musaLogsDumpToMemory

musaError_t musaLogsDumpToMemory(musaLogIterator *iterator, char *buffer, size_t *size, unsigned int flags)

Description

  • Dump accumulated driver logs into a buffer.
  • Logs generated by the driver are stored in an internal buffer and can be copied out using this API. This API dumps driver logs from iterator into buffer up to the size specified in *size. The driver will always null terminate the buffer but there will not be a null character between log entries, only a newline \n. The driver will then return the actual number of bytes written in *size, excluding the null terminator. If there are no messages to dump, *size will be set to 0 and the function will return MUSA_SUCCESS. If the provided buffer is not large enough to hold any messages, *size will be set to 0 and the function will return MUSA_ERROR_INVALID_VALUE.

Parameters

  • iterator (musaLogIterator *): Optional auto-advancing iterator specifying the starting log to read. NULL value dumps all logs.
  • buffer (char *): Pointer to dump logs
  • size (size_t *): See description
  • flags (unsigned int): Reserved for future use, must be 0

Returns

  • musaSuccess, musaErrorInvalidValue

Note

  • This API is provided for reference only in MUSA SDK 5.2.0.
  • Experimental in the current MUSA SDK 5.2.0 delivery scope.
  • iterator is auto-advancing. Dumping logs will update the value of iterator to receive the next generated log.
  • The driver reserves limited memory for storing logs. The maximum size of the buffer is 25600 bytes. The oldest logs may be overwritten and become unrecoverable. An indication will appear in the destination outupt if the logs have been truncated. Call dump after each failed API to mitigate this risk.
  • If the provided value in *size is not large enough to hold all buffered messages, a message will be added at the head of the buffer indicating this. The driver then computes the number of messages it is able to store in buffer and writes it out. The final message in buffer will always be the most recent log message as of when the API is called.

3.27 Interactions with the MUSA Driver API

musaGetFuncBySymbol

musaError_t MUSARTAPI_CDECL musaGetFuncBySymbol(musaFunction_t *functionPtr, const void *symbolPtr)

Description

  • Get pointer to device entry function that matches entry function symbolPtr.
  • Returns in functionPtr the device entry function corresponding to the symbol symbolPtr.

Parameters

  • functionPtr (musaFunction_t *): Returns the device entry function
  • symbolPtr (const void *): Pointer to device entry function to search for

Returns

  • musaSuccess

3.28 Memory Atomic Management

musaMemoryAtomicAsync

musaError_t musaMemoryAtomicAsync(void *dst, const void *src, size_t elementCount, enum musaAtomicType operation, musaStream_t stream)

Description

  • Memory atomic from Device to Device.
  • Perform memory atomic operation from device memory to device memory. dst and src are base pointers of the destination and source, respectively. elementCount specifies the number of elements to perform memory atomic.

Parameters

  • dst (void *): Destination device pointer
  • src (const void *): Source device pointer
  • elementCount (size_t): Size of memory atomic in elements
  • operation (enum musaAtomicType): Specifies which atomic operation to perform, include element size.
  • stream (musaStream_t): 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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

musaMemoryAtomicValueAsync

musaError_t musaMemoryAtomicValueAsync(void *dst, size_t value, enum musaAtomicValueType operation, musaStream_t stream)

Description

  • Memory atomic value.
  • Perform memory atomic value operation to device memory range of 64-bit values.

Parameters

  • dst (void *): Destination device pointer
  • value (size_t): data value for the atomic operation
  • operation (enum musaAtomicValueType): Specifies which atomic operation to perform.
  • stream (musaStream_t): 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 the API synchronization behavior notes for asynchronous host/device behavior.
  • See the default-stream note for NULL stream semantics.

See also

4. Data Types Index

This section lists public enum, typedef, and macro names for the Runtime API. Full structure records are listed under Data Structures.

CategoryName
define__annotate__
define__builtin_align__
define__cluster_dims__
define__constant__
define__device_builtin__
define__device_builtin_surface_type__
define__device_builtin_texture_type__
define__grid_constant__
define__HOST_CONFIG_H__
define__HOST_DEFINES_H__
define__inline__
define__managed__
define__mt_pure__
define__MUSA_ARCH_HAS_FEATURE__
define__musa_builtin_vector_align8
define__MUSA_DEPRECATED
define__MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS__
define__MUSART_API_PTDS
define__MUSART_API_PTSZ
define__MUSART_API_VERSION
define__musart_builtin__
define__shared__
define__specialization_static
define__UNDEF_MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_TYPES_H__
define__UNDEF_MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS_DRIVER_TYPES_H__
define__UNDEF_MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS_HOST_CONFIG_H__
define__UNDEF_MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS_HOST_DEFINES_H__
define__UNDEF_MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS_MUSA_RUNTIME_API_H__
define__UNDEF_MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS_MUSA_RUNTIME_H__
define__UNDEF_MUSA_INCLUDE_COMPILER_INTERNAL_HEADERS_VECTOR_TYPES_H__
define__VECTOR_FUNCTIONS_DECL__
defineEXCLUDE_FROM_RTC
defineMU_UUID_HAS_BEEN_DEFINED
defineMUSA_IPC_HANDLE_SIZE
definemusaArrayColorAttachment
definemusaArrayCubemap
definemusaArrayDefault
definemusaArrayDeferredMapping
definemusaArrayLayered
definemusaArraySparse
definemusaArraySparsePropertiesSingleMipTail
definemusaArraySurfaceLoadStore
definemusaArrayTextureGather
definemusaCooperativeLaunchMultiDeviceNoPostSync
definemusaCooperativeLaunchMultiDeviceNoPreSync
definemusaCpuDeviceId
definemusaDeviceBlockingSync
definemusaDeviceLmemResizeToMax
definemusaDeviceMapHost
definemusaDeviceMask
definemusaDeviceScheduleAuto
definemusaDeviceScheduleBlockingSync
definemusaDeviceScheduleMask
definemusaDeviceScheduleSpin
definemusaDeviceScheduleYield
definemusaDeviceSyncMemops
definemusaEventBlockingSync
definemusaEventDefault
definemusaEventDisableTiming
definemusaEventInterprocess
definemusaEventRecordDefault
definemusaEventRecordExternal
definemusaEventWaitDefault
definemusaEventWaitExternal
definemusaExternalMemoryDedicated
definemusaExternalSemaphoreSignalSkipMtSciBufMemSync
definemusaExternalSemaphoreWaitSkipMtSciBufMemSync
definemusaGetDeviceProperties
definemusaGraphKernelNodePortDefault
definemusaGraphKernelNodePortLaunchCompletion
definemusaGraphKernelNodePortProgrammatic
definemusaHostAllocDefault
definemusaHostAllocMapped
definemusaHostAllocPortable
definemusaHostAllocWriteCombined
definemusaHostRegisterDefault
definemusaHostRegisterIoMemory
definemusaHostRegisterMapped
definemusaHostRegisterPortable
definemusaHostRegisterReadOnly
definemusaInitDeviceFlagsAreValid
definemusaInvalidDeviceId
definemusaIpcMemLazyBidirInterleavePeerAccess
definemusaIpcMemLazyEnablePeerAccess
definemusaIpcMemLazyHalfInterleavePeerAccess
definemusaIpcMemLazyHeteroBidirInterleavePeerAccess
definemusaIpcMemLazyHeteroInterleavePeerAccess
definemusaIpcMemLazyPciePeerAccess
definemusaIpcMemLazyPolicyMax
definemusaIpcMemLazyUnidirInterleavePeerAccess
definemusaKernelNodeAttributeAccessPolicyWindow
definemusaKernelNodeAttributeClusterDimension
definemusaKernelNodeAttributeClusterSchedulingPolicyPreference
definemusaKernelNodeAttributeCooperative
definemusaKernelNodeAttributeDeviceUpdatableKernelNode
definemusaKernelNodeAttributeMemSyncDomain
definemusaKernelNodeAttributeMemSyncDomainMap
definemusaKernelNodeAttributePreferredSharedMemoryCarveout
definemusaKernelNodeAttributePriority
definemusaKernelNodeAttrID
definemusaKernelNodeAttrValue
definemusaMemAttachGlobal
definemusaMemAttachHost
definemusaMemAttachSingle
definemusaMemPoolCreateUsageHwDecompress
definemusaMtSciSyncAttrSignal
definemusaMtSciSyncAttrWait
definemusaOccupancyDefault
definemusaOccupancyDisableCachingOverride
definemusaPeerAccessBidirInterleaved
definemusaPeerAccessDefault
definemusaPeerAccessHalfBidirInterleaved
definemusaPeerAccessHeteroBidirInterleaved
definemusaPeerAccessHeteroInterleaved
definemusaPeerAccessPcieOnly
definemusaPeerAccessPolicyMax
definemusaPeerAccessUnidirInterleaved
defineMUSART_CB
defineMUSART_DEVICE
defineMUSART_VERSION
definemusaSignalExternalSemaphoresAsync
definemusaStreamAttributeAccessPolicyWindow
definemusaStreamAttributeMemSyncDomain
definemusaStreamAttributeMemSyncDomainMap
definemusaStreamAttributePriority
definemusaStreamAttributeSynchronizationPolicy
definemusaStreamAttrID
definemusaStreamAttrValue
definemusaStreamDefault
definemusaStreamGetCaptureInfo
definemusaStreamLegacy
definemusaStreamNonBlocking
definemusaStreamPerThread
definemusaSurfaceType1D
definemusaSurfaceType1DLayered
definemusaSurfaceType2D
definemusaSurfaceType2DLayered
definemusaSurfaceType3D
definemusaSurfaceTypeCubemap
definemusaSurfaceTypeCubemapLayered
definemusaTextureType1D
definemusaTextureType1DLayered
definemusaTextureType2D
definemusaTextureType2DLayered
definemusaTextureType3D
definemusaTextureTypeCubemap
definemusaTextureTypeCubemapLayered
definemusaWaitExternalSemaphoresAsync
defineRESOURCE_ABI_BYTES
enumlibraryPropertyType
enummusaAccessProperty
enummusaAtomicOperation
enummusaAtomicOperationCapability
enummusaAtomicType
enummusaAtomicValueType
enummusaCGScope
enummusaChannelFormatKind
enummusaClusterSchedulingPolicy
enummusaComputeMode
enummusaDataType
enummusaDeviceAttr
enummusaDeviceNumaConfig
enummusaDeviceP2PAttr
enummusaDevResourceType
enummusaDevSmResourceGroup_flags
enummusaDevSmResourceSplitByCount_flags
enummusaDevWorkqueueConfigScope
enummusaDriverEntryPointQueryResult
enummusaError
enummusaExternalMemoryHandleType
enummusaExternalSemaphoreHandleType
enummusaFlushGPUDirectRDMAWritesOptions
enummusaFlushGPUDirectRDMAWritesScope
enummusaFlushGPUDirectRDMAWritesTarget
enummusaFuncAttribute
enummusaFuncCache
enummusaGetDriverEntryPointFlags
enummusaGPUDirectRDMAWritesOrdering
enummusaGraphChildGraphNodeOwnership
enummusaGraphConditionalHandleFlags
enummusaGraphConditionalNodeType
enummusaGraphDebugDotFlags
enummusaGraphDependencyType
enummusaGraphExecUpdateResult
enummusaGraphicsCubeFace
enummusaGraphicsMapFlags
enummusaGraphicsRegisterFlags
enummusaGraphInstantiateFlags
enummusaGraphInstantiateResult
enummusaGraphKernelNodeField
enummusaGraphMemAttributeType
enummusaGraphNodeType
enummusaHostTaskSyncMode
enummusaJit_CacheMode
enummusaJit_Fallback
enummusaJitOption
enummusaKernelFunctionType
enummusaLaunchAttributeID
enummusaLaunchAttributePortableClusterMode
enummusaLaunchMemSyncDomain
enummusaLibraryOption
enummusaLimit
enummusaLogLevel
enummusaMemAccessFlags
enummusaMemAllocationHandleType
enummusaMemAllocationType
enummusaMemcpy3DOperandType
enummusaMemcpyFlags
enummusaMemcpyKind
enummusaMemcpySrcAccessOrder
enummusaMemLocationType
enummusaMemoryAdvise
enummusaMemoryType
enummusaMemPoolAttr
enummusaMemRangeAttribute
enummusaResourceType
enummusaResourceViewFormat
enummusaRoundMode
enummusaSharedCarveout
enummusaSharedMemConfig
enummusaSharedMemoryMode
enummusaStreamBatchMemOpType
enummusaStreamCaptureMode
enummusaStreamCaptureStatus
enummusaStreamUpdateCaptureDependenciesFlags
enummusaSurfaceBoundaryMode
enummusaSurfaceFormatMode
enummusaSynchronizationPolicy
enummusaTextureAddressMode
enummusaTextureFilterMode
enummusaTextureReadMode
enummusaUserObjectFlags
enummusaUserObjectRetainFlags
typedefchar2
typedefchar4
typedefdouble2
typedefdouble4
typedeffloat2
typedeffloat4
typedefint2
typedefint4
typedeflibraryPropertyType_t
typedeflong2
typedeflong4
typedeflonglong2
typedeflonglong4
typedefmusaArray_const_t
typedefmusaArray_t
typedefmusaAsyncCallback
typedefmusaAsyncCallbackHandle_t
typedefmusaAsyncNotificationInfo_t
typedefmusaDataType_t
typedefmusaDevResourceDesc_t
typedefmusaError_t
typedefmusaEvent_t
typedefmusaExecutionContext_t
typedefmusaExternalMemory_t
typedefmusaExternalSemaphore_t
typedefmusaFunction_t
typedefmusaGraph_t
typedefmusaGraphConditionalHandle
typedefmusaGraphDeviceNode_t
typedefmusaGraphExec_t
typedefmusaGraphicsResource_t
typedefmusaGraphNode_t
typedefmusaHostFn_t
typedefmusaKernel_t
typedefmusaLibrary_t
typedefmusaLogIterator
typedefmusaLogsCallback_t
typedefmusaLogsCallbackHandle
typedefmusaMemPool_t
typedefmusaMipmappedArray_const_t
typedefmusaMipmappedArray_t
typedefmusaStream_t
typedefmusaStreamCallback_t
typedefmusaSurfaceObject_t
typedefmusaTextureObject_t
typedefmusaUserObject_t
typedefshort2
typedefshort4
typedefuchar2
typedefuchar4
typedefuint2
typedefuint4
typedefulong2
typedefulong4
typedefulonglong2
typedefulonglong4
typedefushort2
typedefushort4

5. Data Structures

This section lists public structures and unions for the Runtime API.

CategoryName
Structschar1
Structschar3
Structsdim3
Structsdouble1
Structsdouble3
Structsfloat1
Structsfloat3
Structsint1
Structsint3
Structslong1
Structslong3
Structslonglong1
Structslonglong3
StructsmusaAccessPolicyWindow
StructsmusaArrayMemoryRequirements
StructsmusaArraySparseProperties
StructsmusaChannelFormatDesc
StructsmusaChildGraphNodeParams
StructsmusaConditionalNodeParams
StructsmusaDeviceProp
StructsmusaDevResource
StructsmusaDevSmResource
StructsmusaDevSmResourceGroupParams
StructsmusaDevWorkqueueConfigResource
StructsmusaDevWorkqueueResource
StructsmusaEventRecordNodeParams
StructsmusaEventWaitNodeParams
StructsmusaExtent
StructsmusaExternalMemoryBufferDesc
StructsmusaExternalMemoryHandleDesc
StructsmusaExternalMemoryMipmappedArrayDesc
StructsmusaExternalSemaphoreHandleDesc
StructsmusaExternalSemaphoreSignalNodeParams
StructsmusaExternalSemaphoreSignalNodeParamsV2
StructsmusaExternalSemaphoreSignalParams
StructsmusaExternalSemaphoreSignalParams_v1
StructsmusaExternalSemaphoreWaitNodeParams
StructsmusaExternalSemaphoreWaitNodeParamsV2
StructsmusaExternalSemaphoreWaitParams
StructsmusaExternalSemaphoreWaitParams_v1
StructsmusaFuncAttributes
StructsmusaGraphEdgeData
StructsmusaGraphExecUpdateResultInfo
StructsmusaGraphInstantiateParams
StructsmusaGraphKernelNodeUpdate
StructsmusaGraphNodeParams
StructsmusaHostNodeParams
StructsmusaHostNodeParamsV2
StructsmusaIpcEventHandle_t
StructsmusaIpcMemHandle_t
StructsmusaKernelNodeParams
StructsmusaKernelNodeParamsV2
StructsmusaLaunchAttribute
StructsmusaLaunchConfig_t
StructsmusaLaunchMemSyncDomainMap
StructsmusaLaunchParams
StructsmusalibraryHostUniversalFunctionAndDataTable
StructsmusaMemAccessDesc
StructsmusaMemAllocNodeParams
StructsmusaMemAllocNodeParamsV2
StructsmusaMemAtomicParms
StructsmusaMemAtomicValueParms
StructsmusaMemcpy3DBatchOp
StructsmusaMemcpy3DOperand
StructsmusaMemcpy3DParms
StructsmusaMemcpy3DPeerParms
StructsmusaMemcpyAttributes
StructsmusaMemcpyNodeParams
StructsmusaMemFabricHandle_t
StructsmusaMemFreeNodeParams
StructsmusaMemLocation
StructsmusaMemPoolProps
StructsmusaMemPoolPtrExportData
StructsmusaMemsetParams
StructsmusaMemsetParamsV2
StructsmusaMemTransferParms
StructsmusaMemWaitWriteParms
StructsmusaOffset3D
StructsmusaPitchedPtr
StructsmusaPointerAttributes
StructsmusaPos
StructsmusaResourceDesc
StructsmusaResourceViewDesc
StructsmusaTextureDesc
StructsMUuuid_st
Structsshort1
Structsshort3
StructssurfaceReference
StructstextureReference
Structsuchar1
Structsuchar3
Structsuint1
Structsuint3
Structsulong1
Structsulong3
Structsulonglong1
Structsulonglong3
Structsushort1
Structsushort3
UnionsmusaLaunchAttributeValue

6. Data Fields

This section groups public fields by Runtime API structure or union. Expand a structure to view its fields.

char1 (1 field)
FieldTypeDescription
xsigned char
char3 (3 fields)
FieldTypeDescription
xsigned char
ysigned char
zsigned char
dim3 (3 fields)
FieldTypeDescription
xunsigned int
yunsigned int
zunsigned int
double1 (1 field)
FieldTypeDescription
xdouble
double3 (3 fields)
FieldTypeDescription
xdouble
ydouble
zdouble
float1 (1 field)
FieldTypeDescription
xfloat
float3 (3 fields)
FieldTypeDescription
xfloat
yfloat
zfloat
int1 (1 field)
FieldTypeDescription
xint
int3 (3 fields)
FieldTypeDescription
xint
yint
zint
long1 (1 field)
FieldTypeDescription
xlong int
long3 (3 fields)
FieldTypeDescription
xlong int
ylong int
zlong int
longlong1 (1 field)
FieldTypeDescription
xlong long int
longlong3 (3 fields)
FieldTypeDescription
xlong long int
ylong long int
zlong long int
musaAccessPolicyWindow (5 fields)
FieldTypeDescription
base_ptrvoid *Starting address of the access policy window. MUSA driver may align it.
hitPropenum musaAccessPropertyMUaccessProperty set for hit.
hitRatiofloathitRatio specifies percentage of lines assigned hitProp, rest are assigned missProp.
missPropenum musaAccessPropertyMUaccessProperty set for miss. Must be either NORMAL or STREAMING.
num_bytessize_tSize in bytes of the window policy. MUSA driver may restrict the maximum size and alignment.
musaArrayMemoryRequirements (3 fields)
FieldTypeDescription
alignmentsize_tAlignment necessary for mapping the array.
reservedunsigned int
sizesize_tTotal size of the array.
musaArraySparseProperties (8 fields)
FieldTypeDescription
depthunsigned intTile depth in elements
flagsunsigned intFlags will either be zero or musaArraySparsePropertiesSingleMipTail
heightunsigned intTile height in elements
miptailFirstLevelunsigned intFirst mip level at which the mip tail begins
miptailSizeunsigned long longTotal size of the mip tail.
reservedunsigned int
tileExtentstruct musaArraySparseProperties::@0
widthunsigned intTile width in elements
musaChannelFormatDesc (5 fields)
FieldTypeDescription
fenum musaChannelFormatKindChannel format kind
wintw
xintx
yinty
zintz
musaChildGraphNodeParams (2 fields)
FieldTypeDescription
graphmusaGraph_tThe child graph to clone into the node for node creation, or a handle to the graph owned by the node for node query. The graph must not contain conditional nodes. Graphs containing memory allocation or memory free nodes must set the ownership to be moved to the parent.
ownershipenum musaGraphChildGraphNodeOwnershipThe ownership relationship of the child graph node.
musaConditionalNodeParams (5 fields)
FieldTypeDescription
ctxmusaExecutionContext_tMUSA Execution Context
handlemusaGraphConditionalHandleConditional node handle. Handles must be created in advance of creating the node using musaGraphConditionalHandleCreate.
phGraph_outmusaGraph_t *MUSA-owned array populated with conditional node child graphs during creation of the node. Valid for the lifetime of the conditional node. The contents of the graph(s) are subject to the following constraints: These graphs may be populated using graph node creation APIs or musaStreamBeginCaptureToGraph. musaGraphCondTypeIf: phGraph_out[0] is executed when the condition is non-zero. If size == 2, phGraph_out[1] will be executed when the condition is zero. musaGraphCondTypeWhile: phGraph_out[0] is executed as long as the condition is non-zero. musaGraphCondTypeSwitch: phGraph_out[n] is executed when the condition is equal to n. If the condition >= size, no body graph is executed.
sizeunsigned intSize of graph output array. Allowed values are 1 for musaGraphCondTypeWhile, 1 or 2 for musaGraphCondTypeWhile, or any value greater than zero for musaGraphCondTypeSwitch.
typeenum musaGraphConditionalNodeTypeType of conditional node.
musaDeviceProp (101 fields)
FieldTypeDescription
accessPolicyMaxWindowSizeintThe maximum value of musaAccessPolicyWindow::num_bytes.
asyncEngineCountintNumber of asynchronous engines
canMapHostMemoryintDevice can map host memory with musaHostAlloc/musaHostGetDevicePointer
canUseHostPointerForRegisteredMemintDevice can access host registered memory at the same virtual address as the CPU
clockRateintDeprecated, Clock frequency in kilohertz
clusterLaunchintIndicates device supports cluster launch
computeModeintDeprecated, Compute mode (See musaComputeMode)
computePreemptionSupportedintDevice supports Compute Preemption
concurrentKernelsintDevice can possibly execute multiple kernels concurrently
concurrentManagedAccessintDevice can coherently access managed memory concurrently with the CPU
cooperativeLaunchintDevice supports launching cooperative kernels via musaLaunchCooperativeKernel
cooperativeMultiDeviceLaunchintDeprecated, musaLaunchCooperativeKernelMultiDevice is deprecated.
deferredMappingMusaArraySupportedint1 if the device supports deferred mapping MUSA arrays and MUSA mipmapped arrays
deviceNumaConfigintNUMA configuration of a device: value is of type musaDeviceNumaConfig enum
deviceNumaIdintNUMA node ID of the GPU memory
deviceOverlapintDevice can concurrently copy memory and execute a kernel. Deprecated. Use instead asyncEngineCount.
directManagedMemAccessFromHostintHost can directly access managed memory on the device without migration.
ECCEnabledintDevice has ECC support enabled
globalL1CacheSupportedintDevice supports caching globals in L1
gpuDirectRDMAFlushWritesOptionsunsigned intBitmask to be interpreted according to the musaFlushGPUDirectRDMAWritesOptions enum
gpuDirectRDMASupportedint1 if the device supports GPUDirect RDMA APIs, 0 otherwise
gpuDirectRDMAWritesOrderingintSee the musaGPUDirectRDMAWritesOrdering enum for numerical values
gpuPciDeviceIDunsigned intThe combined 16-bit PCI device ID and 16-bit PCI vendor ID
gpuPciSubsystemIDunsigned intThe combined 16-bit PCI subsystem ID and 16-bit PCI subsystem vendor ID
hostNativeAtomicSupportedintLink between the device and the host supports native atomic operations
hostNumaIdintNUMA ID of the host node closest to the device or -1 when system does not support NUMA
hostNumaMultinodeIpcSupportedint1 if the device supports HostNuma location IPC between nodes in a multi-node system.
hostRegisterReadOnlySupportedintDevice supports using the musaHostRegister flag musaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU
hostRegisterSupportedintDevice supports host memory registration via musaHostRegister.
integratedintDevice is integrated as opposed to discrete
ipcEventSupportedintDevice supports IPC Events.
isMultiGpuBoardintDevice is on a multi-GPU board
kernelExecTimeoutEnabledintDeprecated, Specified whether there is a run time limit on kernels
l2CacheSizeintSize of L2 cache in bytes
localL1CacheSupportedintDevice supports caching locals in L1
luidchar8-byte locally unique identifier. Value is undefined on TCC and non-Windows platforms
luidDeviceNodeMaskunsigned intLUID device node mask. Value is undefined on TCC and non-Windows platforms
majorintMajor compute capability
managedMemoryintDevice supports allocating managed memory on this system
maxBlocksPerMultiProcessorintMaximum number of resident blocks per multiprocessor
maxGridSizeintMaximum size of each dimension of a grid
maxSurface1DintMaximum 1D surface size
maxSurface1DLayeredintMaximum 1D layered surface dimensions
maxSurface2DintMaximum 2D surface dimensions
maxSurface2DLayeredintMaximum 2D layered surface dimensions
maxSurface3DintMaximum 3D surface dimensions
maxSurfaceCubemapintMaximum Cubemap surface dimensions
maxSurfaceCubemapLayeredintMaximum Cubemap layered surface dimensions
maxTexture1DintMaximum 1D texture size
maxTexture1DLayeredintMaximum 1D layered texture dimensions
maxTexture1DLinearintDeprecated, do not use. Use musaDeviceGetTexture1DLinearMaxWidth() or muDeviceGetTexture1DLinearMaxWidth() instead.
maxTexture1DMipmapintMaximum 1D mipmapped texture size
maxTexture2DintMaximum 2D texture dimensions
maxTexture2DGatherintMaximum 2D texture dimensions if texture gather operations have to be performed
maxTexture2DLayeredintMaximum 2D layered texture dimensions
maxTexture2DLinearintMaximum dimensions (width, height, pitch) for 2D textures bound to pitched memory
maxTexture2DMipmapintMaximum 2D mipmapped texture dimensions
maxTexture3DintMaximum 3D texture dimensions
maxTexture3DAltintMaximum alternate 3D texture dimensions
maxTextureCubemapintMaximum Cubemap texture dimensions
maxTextureCubemapLayeredintMaximum Cubemap layered texture dimensions
maxThreadsDimintMaximum size of each dimension of a block
maxThreadsPerBlockintMaximum number of threads per block
maxThreadsPerMultiProcessorintMaximum resident threads per multiprocessor
memoryBusWidthintGlobal memory bus width in bits
memoryClockRateintDeprecated, Peak memory clock frequency in kilohertz
memoryPoolsSupportedint1 if the device supports using the musaMallocAsync and musaMemPool family of APIs, 0 otherwise
memoryPoolSupportedHandleTypesunsigned intBitmask of handle types supported with mempool-based IPC
memPitchsize_tMaximum pitch in bytes allowed by memory copies
minorintMinor compute capability
mpsEnabledintIndicates if contexts created on this device will be shared via MPS
multiGpuBoardGroupIDintUnique identifier for a group of devices on the same multi-GPU board
multiProcessorCountintNumber of multiprocessors on device
namecharASCII string identifying device
pageableMemoryAccessintDevice supports coherently accessing pageable memory without calling musaHostRegister on it
pageableMemoryAccessUsesHostPageTablesintDevice accesses pageable memory via the host's page tables
pciBusIDintPCI bus ID of the device
pciDeviceIDintPCI device ID of the device
pciDomainIDintPCI domain ID of the device
persistingL2CacheMaxSizeintDevice's maximum l2 persisting lines capacity setting in bytes
regsPerBlockint32-bit registers available per block
regsPerMultiprocessorint32-bit registers available per multiprocessor
reservedintReserved for future use
reservedSharedMemPerBlocksize_tShared memory reserved by MUSA driver per block in bytes
sharedMemPerBlocksize_tShared memory available per block in bytes
sharedMemPerBlockOptinsize_tPer device maximum shared memory per block usable by special opt in
sharedMemPerMultiprocessorsize_tShared memory available per multiprocessor in bytes
singleToDoublePrecisionPerfRatiointDeprecated, Ratio of single precision performance (in floating-point operations per second) to double precision performance
sparseMusaArraySupportedint1 if the device supports sparse MUSA arrays and sparse MUSA mipmapped arrays, 0 otherwise
streamPrioritiesSupportedintDevice supports stream priorities
surfaceAlignmentsize_tAlignment requirements for surfaces
tccDriverint1 if device is a Tesla device using TCC driver, 0 otherwise
textureAlignmentsize_tAlignment requirement for textures
texturePitchAlignmentsize_tPitch alignment requirement for texture references bound to pitched memory
timelineSemaphoreInteropSupportedintExternal timeline semaphore interop is supported on the device
totalConstMemsize_tConstant memory available on device in bytes
totalGlobalMemsize_tGlobal memory available on device in bytes
unifiedAddressingintDevice shares a unified address space with the host
unifiedFunctionPointersintIndicates device supports unified pointers
uuidmusaUUID_t16-byte unique identifier
warpSizeintWarp size in threads
musaDevResource (8 fields)
FieldTypeDescription
@23union musaDevResource::@22
_internal_paddingunsigned char
_oversizeunsigned char
nextResourcestruct musaDevResource_st *
smstruct musaDevSmResourceResource corresponding to musaDevResourceTypeSm type.
typeenum musaDevResourceTypeType of resource, dictates which union field was last set
wqstruct musaDevWorkqueueResourceResource corresponding to musaDevResourceTypeWorkqueue type.
wqConfigstruct musaDevWorkqueueConfigResourceResource corresponding to musaDevResourceTypeWorkqueueConfig type.
musaDevSmResource (4 fields)
FieldTypeDescription
flagsunsigned intThe flags set on this SM resource. For available flags see musaDevSmResourceGroup_flags.
minSmPartitionSizeunsigned intThe minimum number of streaming multiprocessors required to partition this resource.
smCoscheduledAlignmentunsigned intThe number of streaming multiprocessors in this resource that are guaranteed to be co-scheduled on the same GPU processing cluster. smCount will be a multiple of this value, unless the backfill flag is set.
smCountunsigned intThe amount of streaming multiprocessors available in this resource.
musaDevSmResourceGroupParams (5 fields)
FieldTypeDescription
coscheduledSmCountunsigned intThe amount of co-scheduled SMs grouped together for locality purposes.
flagsunsigned intCombination of musaDevSmResourceGroup_flags values to indicate this this group is created.
preferredCoscheduledSmCountunsigned intWhen possible, combine co-scheduled groups together into larger groups of this size.
reservedunsigned intReserved for future use - ensure this is is zero initialized.
smCountunsigned intThe amount of SMs available in this resource.
musaDevWorkqueueConfigResource (3 fields)
FieldTypeDescription
deviceintThe device on which the workqueue resources are available
sharingScopeenum musaDevWorkqueueConfigScopeThe sharing scope for the workqueue resources
wqConcurrencyLimitunsigned intThe expected maximum number of concurrent stream-ordered workloads
musaDevWorkqueueResource (1 field)
FieldTypeDescription
reservedunsigned charReserved for future use
musaEventRecordNodeParams (1 field)
FieldTypeDescription
eventmusaEvent_tThe event to record when the node executes
musaEventWaitNodeParams (1 field)
FieldTypeDescription
eventmusaEvent_tThe event to wait on from the node
musaExtent (3 fields)
FieldTypeDescription
depthsize_tDepth in elements
heightsize_tHeight in elements
widthsize_tWidth in elements when referring to array memory, in bytes when referring to linear memory
musaExternalMemoryBufferDesc (4 fields)
FieldTypeDescription
flagsunsigned intFlags reserved for future use. Must be zero.
offsetunsigned long longOffset into the memory object where the buffer's base is
reservedunsigned intMust be zero
sizeunsigned long longSize of the buffer
musaExternalMemoryHandleDesc (10 fields)
FieldTypeDescription
fdintFile descriptor referencing the memory object. Valid when type is musaExternalMemoryHandleTypeOpaqueFd
flagsunsigned intFlags must either be zero or musaExternalMemoryDedicated
handlevoid *Valid NT handle. Must be NULL if 'name' is non-NULL
handleunion musaExternalMemoryHandleDesc::@10
mtSciBufObjectconst void *A handle representing MtSciBuf Object. Valid when type is musaExternalMemoryHandleTypeMtSciBuf
nameconst void *Name of a valid memory object. Must be NULL if 'handle' is non-NULL.
reservedunsigned intMust be zero
sizeunsigned long longSize of the memory allocation
typeenum musaExternalMemoryHandleTypeType of the handle
win32struct musaExternalMemoryHandleDesc::@10::@11Win32 handle referencing the semaphore object. Valid when type is one of the following:
musaExternalMemoryMipmappedArrayDesc (6 fields)
FieldTypeDescription
extentstruct musaExtentDimensions of base level of the mipmap chain
flagsunsigned intFlags associated with MUSA mipmapped arrays. See musaMallocMipmappedArray
formatDescstruct musaChannelFormatDescFormat of base level of the mipmap chain
numLevelsunsigned intTotal number of levels in the mipmap chain
offsetunsigned long longOffset into the memory object where the base level of the mipmap chain is.
reservedunsigned intMust be zero
musaExternalSemaphoreHandleDesc (9 fields)
FieldTypeDescription
fdintFile descriptor referencing the semaphore object. Valid when type is one of the following:
flagsunsigned intFlags reserved for the future. Must be zero.
handlevoid *Valid NT handle. Must be NULL if 'name' is non-NULL
handleunion musaExternalSemaphoreHandleDesc::@12
mtSciSyncObjconst void *Valid MtSciSyncObj. Must be non NULL
nameconst void *Name of a valid synchronization primitive. Must be NULL if 'handle' is non-NULL.
reservedunsigned intMust be zero
typeenum musaExternalSemaphoreHandleTypeType of the handle
win32struct musaExternalSemaphoreHandleDesc::@12::@13Win32 handle referencing the semaphore object. Valid when type is one of the following:
musaExternalSemaphoreSignalNodeParams (3 fields)
FieldTypeDescription
extSemArraymusaExternalSemaphore_t *Array of external semaphore handles.
numExtSemsunsigned intNumber of handles and parameters supplied in extSemArray and paramsArray.
paramsArrayconst struct musaExternalSemaphoreSignalParams *Array of external semaphore signal parameters.
musaExternalSemaphoreSignalNodeParamsV2 (3 fields)
FieldTypeDescription
extSemArraymusaExternalSemaphore_t *Array of external semaphore handles.
numExtSemsunsigned intNumber of handles and parameters supplied in extSemArray and paramsArray.
paramsArrayconst struct musaExternalSemaphoreSignalParams *Array of external semaphore signal parameters.
musaExternalSemaphoreSignalParams (10 fields)
FieldTypeDescription
fencestruct musaExternalSemaphoreSignalParams::@24::@25Parameters for fence objects
fencevoid *Pointer to MtSciSyncFence. Valid if musaExternalSemaphoreHandleType is of type musaExternalSemaphoreHandleTypeMtSciSync.
flagsunsigned intOnly when musaExternalSemaphoreSignalParams is used to signal a musaExternalSemaphore_t of type musaExternalSemaphoreHandleTypeMtSciSync, the valid flag is musaExternalSemaphoreSignalSkipMtSciBufMemSync: which indicates that while signaling the musaExternalSemaphore_t, no memory synchronization operations should be performed for any external memory object imported as musaExternalMemoryHandleTypeMtSciBuf. For all other types of musaExternalSemaphore_t, flags must be zero.
keyunsigned long long
keyedMutexstruct musaExternalSemaphoreSignalParams::@24::@27Parameters for keyed mutex objects
mtSciSyncunion musaExternalSemaphoreSignalParams::@24::@26
paramsstruct musaExternalSemaphoreSignalParams::@24
reservedunsigned long long
reservedunsigned int
valueunsigned long longValue of fence to be signaled
musaExternalSemaphoreSignalParams_v1 (9 fields)
FieldTypeDescription
fencestruct musaExternalSemaphoreSignalParams_v1::@14::@15Parameters for fence objects
fencevoid *Pointer to MtSciSyncFence. Valid if musaExternalSemaphoreHandleType is of type musaExternalSemaphoreHandleTypeMtSciSync.
flagsunsigned intOnly when musaExternalSemaphoreSignalParams is used to signal a musaExternalSemaphore_t of type musaExternalSemaphoreHandleTypeMtSciSync, the valid flag is musaExternalSemaphoreSignalSkipMtSciBufMemSync: which indicates that while signaling the musaExternalSemaphore_t, no memory synchronization operations should be performed for any external memory object imported as musaExternalMemoryHandleTypeMtSciBuf. For all other types of musaExternalSemaphore_t, flags must be zero.
keyunsigned long long
keyedMutexstruct musaExternalSemaphoreSignalParams_v1::@14::@17Parameters for keyed mutex objects
mtSciSyncunion musaExternalSemaphoreSignalParams_v1::@14::@16
paramsstruct musaExternalSemaphoreSignalParams_v1::@14
reservedunsigned long long
valueunsigned long longValue of fence to be signaled
musaExternalSemaphoreWaitNodeParams (3 fields)
FieldTypeDescription
extSemArraymusaExternalSemaphore_t *Array of external semaphore handles.
numExtSemsunsigned intNumber of handles and parameters supplied in extSemArray and paramsArray.
paramsArrayconst struct musaExternalSemaphoreWaitParams *Array of external semaphore wait parameters.
musaExternalSemaphoreWaitNodeParamsV2 (3 fields)
FieldTypeDescription
extSemArraymusaExternalSemaphore_t *Array of external semaphore handles.
numExtSemsunsigned intNumber of handles and parameters supplied in extSemArray and paramsArray.
paramsArrayconst struct musaExternalSemaphoreWaitParams *Array of external semaphore wait parameters.
musaExternalSemaphoreWaitParams (11 fields)
FieldTypeDescription
fencestruct musaExternalSemaphoreWaitParams::@28::@29Parameters for fence objects
fencevoid *Pointer to MtSciSyncFence. Valid if musaExternalSemaphoreHandleType is of type musaExternalSemaphoreHandleTypeMtSciSync.
flagsunsigned intOnly when musaExternalSemaphoreSignalParams is used to signal a musaExternalSemaphore_t of type musaExternalSemaphoreHandleTypeMtSciSync, the valid flag is musaExternalSemaphoreSignalSkipMtSciBufMemSync: which indicates that while waiting for the musaExternalSemaphore_t, no memory synchronization operations should be performed for any external memory object imported as musaExternalMemoryHandleTypeMtSciBuf. For all other types of musaExternalSemaphore_t, flags must be zero.
keyunsigned long longValue of key to acquire the mutex with
keyedMutexstruct musaExternalSemaphoreWaitParams::@28::@31Parameters for keyed mutex objects
mtSciSyncunion musaExternalSemaphoreWaitParams::@28::@30
paramsstruct musaExternalSemaphoreWaitParams::@28
reservedunsigned long long
reservedunsigned int
timeoutMsunsigned intTimeout in milliseconds to wait to acquire the mutex
valueunsigned long longValue of fence to be waited on
musaExternalSemaphoreWaitParams_v1 (11 fields)
FieldTypeDescription
fencestruct musaExternalSemaphoreWaitParams_v1::@18::@19Parameters for fence objects
fencevoid *Pointer to MtSciSyncFence. Valid if musaExternalSemaphoreHandleType is of type musaExternalSemaphoreHandleTypeMtSciSync.
flagsunsigned intOnly when musaExternalSemaphoreSignalParams is used to signal a musaExternalSemaphore_t of type musaExternalSemaphoreHandleTypeMtSciSync, the valid flag is musaExternalSemaphoreSignalSkipMtSciBufMemSync: which indicates that while waiting for the musaExternalSemaphore_t, no memory synchronization operations should be performed for any external memory object imported as musaExternalMemoryHandleTypeMtSciBuf. For all other types of musaExternalSemaphore_t, flags must be zero.
keyunsigned long longValue of key to acquire the mutex with
keyedMutexstruct musaExternalSemaphoreWaitParams_v1::@18::@21Parameters for keyed mutex objects
mtSciSyncunion musaExternalSemaphoreWaitParams_v1::@18::@20
paramsstruct musaExternalSemaphoreWaitParams_v1::@18
reservedunsigned long long
reservedunsigned int
timeoutMsunsigned intTimeout in milliseconds to wait to acquire the mutex
valueunsigned long longValue of fence to be waited on
musaFuncAttributes (18 fields)
FieldTypeDescription
binaryVersionintThe binary architecture version for which the function was compiled. This value is the major binary version * 10 + the minor binary version, so a binary version 1.3 function would return the value 13.
cacheModeCAintThe attribute to indicate whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set.
clusterDimMustBeSetintIf this attribute is set, the kernel must launch with a valid cluster dimension specified.
clusterSchedulingPolicyPreferenceintThe block scheduling policy of a function. See musaFuncSetAttribute
constSizeBytessize_tThe size in bytes of user-allocated constant memory required by this function.
localSizeBytessize_tThe size in bytes of local memory used by each thread of this function.
maxDynamicSharedSizeBytesintThe maximum size in bytes of dynamic shared memory per block for this function. Any launch must have a dynamic shared memory size smaller than this value.
maxThreadsPerBlockintThe maximum number of threads per block, beyond which a launch of the function would fail. This number depends on both the function and the device on which the function is currently loaded.
nonPortableClusterSizeAllowedintWhether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. A non-portable cluster size may only function on the specific SKUs the program is tested on. The launch might fail if the program is run on a different hardware platform. MUSA API provides musaOccupancyMaxActiveClusters to assist with checking whether the desired size can be launched on the current device. Portable Cluster Size A portable cluster size is guaranteed to be functional on all compute capabilities higher than the target compute capability. The portable cluster size for sm_90 is 8 blocks per cluster. This value may increase for future compute capabilities. The specific hardware unit may support higher cluster sizes that’s not guaranteed to be portable. See musaFuncSetAttribute
numRegsintThe number of registers used by each thread of this function.
preferredShmemCarveoutintOn devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the maximum shared memory. Refer to musaDevAttrMaxSharedMemoryPerMultiprocessor. This is only a hint, and the driver can choose a different ratio if required to execute the function. See musaFuncSetAttribute
ptxVersionintThe PTX virtual architecture version for which the function was compiled. This value is the major PTX version * 10 + the minor PTX version, so a PTX version 1.3 function would return the value 13.
requiredClusterDepthint
requiredClusterHeightint
requiredClusterWidthintThe required cluster width/height/depth in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions is otherwise checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime should return musaErrorNotPermitted. See musaFuncSetAttribute
reservedintReserved for future use.
reserved0int
sharedSizeBytessize_tThe size in bytes of statically-allocated shared memory per block required by this function. This does not include dynamically-allocated shared memory requested by the user at runtime.
musaGraphEdgeData (4 fields)
FieldTypeDescription
from_portunsigned charThis indicates when the dependency is triggered from the upstream node on the edge. The meaning is specfic to the node type. A value of 0 in all cases means full completion of the upstream node, with memory visibility to the downstream node or portion thereof (indicated by to_port). Only kernel nodes define non-zero ports. A kernel node can use the following output port types: musaGraphKernelNodePortDefault, musaGraphKernelNodePortProgrammatic, or musaGraphKernelNodePortLaunchCompletion.
reservedunsigned charThese bytes are unused and must be zeroed. This ensures compatibility if additional fields are added in the future.
to_portunsigned charThis indicates what portion of the downstream node is dependent on the upstream node or portion thereof (indicated by from_port). The meaning is specific to the node type. A value of 0 in all cases means the entirety of the downstream node is dependent on the upstream work. Currently no node types define non-zero ports. Accordingly, this field must be set to zero.
typeunsigned charThis should be populated with a value from musaGraphDependencyType. (It is typed as char due to compiler-specific layout of bitfields.) See musaGraphDependencyType.
musaGraphExecUpdateResultInfo (3 fields)
FieldTypeDescription
errorFromNodemusaGraphNode_tThe from node of error edge when the topologies do not match. Otherwise NULL.
errorNodemusaGraphNode_tThe "to node" of the error edge when the topologies do not match. The error node when the error is associated with a specific node. NULL when the error is generic.
resultenum musaGraphExecUpdateResultGives more specific detail when a musa graph update fails.
musaGraphInstantiateParams (4 fields)
FieldTypeDescription
errNode_outmusaGraphNode_tThe node which caused instantiation to fail, if any
flagsunsigned long longInstantiation flags
result_outmusaGraphInstantiateResultWhether instantiation was successful. If it failed, the reason why
uploadStreammusaStream_tUpload stream
musaGraphKernelNodeUpdate (9 fields)
FieldTypeDescription
fieldenum musaGraphKernelNodeFieldWhich type of update to apply. Determines how updateData is interpreted
gridDimdim3Grid dimensions
isEnabledunsigned intNode enable/disable data. Nonzero if the node should be enabled, 0 if it should be disabled
nodemusaGraphDeviceNode_tNode to update
offsetsize_tOffset into the parameter buffer at which to apply the update
paramstruct musaGraphKernelNodeUpdate::@36::@37Kernel parameter data
pValueconst void *Kernel parameter data to write in
sizesize_tNumber of bytes to update
updateDataunion musaGraphKernelNodeUpdate::@36Update data to apply. Which field is used depends on field's value
musaGraphNodeParams (17 fields)
FieldTypeDescription
@35union musaGraphNodeParams::@34
allocstruct musaMemAllocNodeParamsV2Memory allocation node parameters.
conditionalstruct musaConditionalNodeParamsConditional node parameters.
eventRecordstruct musaEventRecordNodeParamsEvent record node parameters.
eventWaitstruct musaEventWaitNodeParamsEvent wait node parameters.
extSemSignalstruct musaExternalSemaphoreSignalNodeParamsV2External semaphore signal node parameters.
extSemWaitstruct musaExternalSemaphoreWaitNodeParamsV2External semaphore wait node parameters.
freestruct musaMemFreeNodeParamsMemory free node parameters.
graphstruct musaChildGraphNodeParamsChild graph node parameters.
hoststruct musaHostNodeParamsV2Host node parameters.
kernelstruct musaKernelNodeParamsV2Kernel node parameters.
memcpystruct musaMemcpyNodeParamsMemcpy node parameters.
memsetstruct musaMemsetParamsV2Memset node parameters.
reserved0intReserved. Must be zero.
reserved1long longPadding. Unused bytes must be zero.
reserved2long longReserved bytes. Must be zero.
typeenum musaGraphNodeTypeType of the node
musaHostNodeParams (2 fields)
FieldTypeDescription
fnmusaHostFn_tThe function to call when the node executes
userDatavoid *Argument to pass to the function
musaHostNodeParamsV2 (3 fields)
FieldTypeDescription
fnmusaHostFn_tThe function to call when the node executes
syncModeunsigned intThe synchronization mode to use for the host task
userDatavoid *Argument to pass to the function
musaIpcEventHandle_t (1 field)
FieldTypeDescription
reservedchar
musaIpcMemHandle_t (1 field)
FieldTypeDescription
reservedchar
musaKernelNodeParams (6 fields)
FieldTypeDescription
blockDimdim3Block dimensions
extravoid **Pointer to kernel arguments in the "extra" format
funcvoid *Kernel to launch
gridDimdim3Grid dimensions
kernelParamsvoid **Array of pointers to individual kernel arguments
sharedMemBytesunsigned intDynamic shared-memory size per thread block in bytes
musaKernelNodeParamsV2 (11 fields)
FieldTypeDescription
@33union musaKernelNodeParamsV2::@32
blockDimdim3Block dimensions
ctxmusaExecutionContext_tContext in which to run the kernel. If NULL will try to use the current context.
cuFuncmusaFunction_tfunctionType = musaKernelFucntionTypeFunction
extravoid **Pointer to kernel arguments in the "extra" format
funcvoid *functionType = musaKernelFucntionTypeDevice
functionTypeenum musaKernelFunctionTypeType of handle passed in the func/kern/cuFunc union above
gridDimdim3Grid dimensions
kernmusaKernel_tfunctionType = musaKernelFucntionTypeKernel
kernelParamsvoid **Array of pointers to individual kernel arguments
sharedMemBytesunsigned intDynamic shared-memory size per thread block in bytes
musaLaunchAttribute (3 fields)
FieldTypeDescription
idmusaLaunchAttributeIDAttribute to set
padchar
valmusaLaunchAttributeValueValue of the attribute
musaLaunchAttributeValue (26 fields)
FieldTypeDescription
accessPolicyWindowstruct musaAccessPolicyWindowValue of launch attribute musaLaunchAttributeAccessPolicyWindow.
clusterDimstruct musaLaunchAttributeValue::@38Value of launch attribute musaLaunchAttributeClusterDimension that represents the desired cluster dimensions for the kernel. Opaque type with the following fields:
clusterSchedulingPolicyPreferenceenum musaClusterSchedulingPolicyValue of launch attribute musaLaunchAttributeClusterSchedulingPolicyPreference. Cluster scheduling policy preference for the kernel.
cooperativeintValue of launch attribute musaLaunchAttributeCooperative. Nonzero indicates a cooperative kernel (see musaLaunchCooperativeKernel).
deviceUpdatableint
deviceUpdatableKernelNodestruct musaLaunchAttributeValue::@42Value of launch attribute musaLaunchAttributeDeviceUpdatableKernelNode with the following fields:
devNodemusaGraphDeviceNode_t
eventmusaEvent_t
flagsint
launchCompletionEventstruct musaLaunchAttributeValue::@41Value of launch attribute musaLaunchAttributeLaunchCompletionEvent with the following fields:
memSyncDomainmusaLaunchMemSyncDomainValue of launch attribute musaLaunchAttributeMemSyncDomain. See musaLaunchMemSyncDomain.
memSyncDomainMapmusaLaunchMemSyncDomainMapValue of launch attribute musaLaunchAttributeMemSyncDomainMap. See musaLaunchMemSyncDomainMap.
mtlinkUtilCentricSchedulingunsigned intValue of launch attribute musaLaunchAttributeMtlinkUtilCentricScheduling.
padchar
portableClusterSizeModemusaLaunchAttributePortableClusterModeValue of launch attribute musaLaunchAttributePortableClusterSizeMode
preferredClusterDimstruct musaLaunchAttributeValue::@40Value of launch attribute musaLaunchAttributePreferredClusterDimension that represents the desired preferred cluster dimensions for the kernel. Opaque type with the following fields:
priorityintValue of launch attribute musaLaunchAttributePriority. Execution priority of the kernel.
programmaticEventstruct musaLaunchAttributeValue::@39Value of launch attribute musaLaunchAttributeProgrammaticEvent with the following fields:
programmaticStreamSerializationAllowedintValue of launch attribute musaLaunchAttributeProgrammaticStreamSerialization.
sharedMemCarveoutunsigned intValue of launch attribute musaLaunchAttributePreferredSharedMemoryCarveout.
sharedMemoryModemusaSharedMemoryModeValue of launch attribute musaLaunchAttributeSharedMemoryMode. See musaSharedMemoryMode for acceptable values.
syncPolicyenum musaSynchronizationPolicyValue of launch attribute musaLaunchAttributeSynchronizationPolicy. musaSynchronizationPolicy for work queued up in this stream.
triggerAtBlockStartint
xunsigned int
yunsigned int
zunsigned int
musaLaunchConfig_t (6 fields)
FieldTypeDescription
attrsmusaLaunchAttribute *List of attributes; nullable if musaLaunchConfig_t::numAttrs == 0
blockDimdim3Block dimensions
dynamicSmemBytessize_tDynamic shared-memory size per thread block in bytes
gridDimdim3Grid dimensions
numAttrsunsigned intNumber of attributes populated in musaLaunchConfig_t::attrs
streammusaStream_tStream identifier
musaLaunchMemSyncDomainMap (2 fields)
FieldTypeDescription
default_unsigned charThe default domain ID to use for designated kernels
remoteunsigned charThe remote domain ID to use for designated kernels
musaLaunchParams (6 fields)
FieldTypeDescription
argsvoid **Arguments
blockDimdim3Block dimentions
funcvoid *Device function symbol
gridDimdim3Grid dimentions
sharedMemsize_tShared memory
streammusaStream_tStream identifier
musalibraryHostUniversalFunctionAndDataTable (4 fields)
FieldTypeDescription
dataTablevoid *
dataWindowSizesize_t
functionTablevoid *
functionWindowSizesize_t
musaMemAccessDesc (2 fields)
FieldTypeDescription
flagsenum musaMemAccessFlagsMUmemProt accessibility flags to set on the request
locationstruct musaMemLocationLocation on which the request is to change it's accessibility
musaMemAllocNodeParams (5 fields)
FieldTypeDescription
accessDescCountsize_tin: Number of accessDescss
accessDescsconst struct musaMemAccessDesc *in: number of memory access descriptors. Must not exceed the number of GPUs.
bytesizesize_tin: size in bytes of the requested allocation
dptrvoid *out: address of the allocation returned by MUSA
poolPropsstruct musaMemPoolPropsin: location where the allocation should reside (specified in location). handleTypes must be musaMemHandleTypeNone. IPC is not supported. in: array of memory access descriptors. Used to describe peer GPU access
musaMemAllocNodeParamsV2 (5 fields)
FieldTypeDescription
accessDescCountsize_tin: Number of accessDescss
accessDescsconst struct musaMemAccessDesc *in: number of memory access descriptors. Must not exceed the number of GPUs.
bytesizesize_tin: size in bytes of the requested allocation
dptrvoid *out: address of the allocation returned by MUSA
poolPropsstruct musaMemPoolPropsin: location where the allocation should reside (specified in location). handleTypes must be musaMemHandleTypeNone. IPC is not supported. in: array of memory access descriptors. Used to describe peer GPU access
musaMemAtomicParms (4 fields)
FieldTypeDescription
dstvoid *
elementCountsize_t
operationmusaAtomicType
srcconst void *
musaMemAtomicValueParms (3 fields)
FieldTypeDescription
dstvoid *
operationmusaAtomicValueType
valuesize_t
musaMemcpy3DBatchOp (5 fields)
FieldTypeDescription
dststruct musaMemcpy3DOperandDestination memcpy operand.
extentstruct musaExtentExtents of the memcpy between src and dst. The width, height and depth components must not be 0.
flagsunsigned intAdditional flags for copy from src to dst. See musaMemcpyFlags.
srcstruct musaMemcpy3DOperandSource memcpy operand.
srcAccessOrderenum musaMemcpySrcAccessOrderSource access ordering to be observed for copy from src to dst.
musaMemcpy3DOperand (10 fields)
FieldTypeDescription
arraymusaArray_t
arraystruct musaMemcpy3DOperand::@7::@9Struct representing an operand when musaMemcpy3DOperand::type is musaMemcpyOperandTypeArray
layerHeightsize_tHeight of each layer in elements.
locHintstruct musaMemLocationHint location for the operand. Ignored when the pointers are not managed memory or memory allocated outside MUSA.
offsetstruct musaOffset3D
opunion musaMemcpy3DOperand::@7
ptrvoid *
ptrstruct musaMemcpy3DOperand::@7::@8Struct representing an operand when musaMemcpy3DOperand::type is musaMemcpyOperandTypePointer
rowLengthsize_tLength of each row in elements.
typeenum musaMemcpy3DOperandType
musaMemcpy3DParms (8 fields)
FieldTypeDescription
dstArraymusaArray_tDestination memory address
dstPosstruct musaPosDestination position offset
dstPtrstruct musaPitchedPtrPitched destination memory address
extentstruct musaExtentRequested memory copy size
kindenum musaMemcpyKindType of transfer
srcArraymusaArray_tSource memory address
srcPosstruct musaPosSource position offset
srcPtrstruct musaPitchedPtrPitched source memory address
musaMemcpy3DPeerParms (9 fields)
FieldTypeDescription
dstArraymusaArray_tDestination memory address
dstDeviceintDestination device
dstPosstruct musaPosDestination position offset
dstPtrstruct musaPitchedPtrPitched destination memory address
extentstruct musaExtentRequested memory copy size
srcArraymusaArray_tSource memory address
srcDeviceintSource device
srcPosstruct musaPosSource position offset
srcPtrstruct musaPitchedPtrPitched source memory address
musaMemcpyAttributes (4 fields)
FieldTypeDescription
dstLocHintstruct musaMemLocationHint location for the destination operand. Ignored when the pointers are not managed memory or memory allocated outside MUSA.
flagsunsigned intAdditional flags for copies with this attribute. See musaMemcpyFlags.
srcAccessOrderenum musaMemcpySrcAccessOrderSource access ordering to be observed for copies with this attribute.
srcLocHintstruct musaMemLocationHint location for the source operand. Ignored when the pointers are not managed memory or memory allocated outside MUSA.
musaMemcpyNodeParams (3 fields)
FieldTypeDescription
copyParamsstruct musaMemcpy3DParmsParameters for the memory copy
flagsintMust be zero
reservedintMust be zero
musaMemFabricHandle_t (1 field)
FieldTypeDescription
reservedchar
musaMemFreeNodeParams (1 field)
FieldTypeDescription
dptrvoid *in: the pointer to free
musaMemLocation (2 fields)
FieldTypeDescription
idintidentifier for a given this location's MUmemLocationType.
typeenum musaMemLocationTypeSpecifies the location type, which modifies the meaning of id.
musaMemPoolProps (7 fields)
FieldTypeDescription
allocTypeenum musaMemAllocationTypeAllocation type. Currently must be specified as musaMemAllocationTypePinned
handleTypesenum musaMemAllocationHandleTypeHandle types that will be supported by allocations from the pool.
locationstruct musaMemLocationLocation allocations should reside.
maxSizesize_tMaximum pool size. When set to 0, defaults to a system dependent value.
reservedunsigned charreserved for future use, must be 0
usageunsigned shortBitmask indicating intended usage for the pool.
win32SecurityAttributesvoid *Windows-specific LPSECURITYATTRIBUTES required when musaMemHandleTypeWin32 is specified. This security attribute defines the scope of which exported allocations may be tranferred to other processes. In all other cases, this field is required to be zero.
musaMemPoolPtrExportData (1 field)
FieldTypeDescription
reservedunsigned char
musaMemsetParams (6 fields)
FieldTypeDescription
dstvoid *Destination device pointer
elementSizeunsigned intSize of each element in bytes. Must be 1, 2, or 4.
heightsize_tNumber of rows
pitchsize_tPitch of destination device pointer. Unused if height is 1
valueunsigned intValue to be set
widthsize_tWidth of the row in elements
musaMemsetParamsV2 (7 fields)
FieldTypeDescription
ctxmusaExecutionContext_tContext in which to run the memset. If NULL will try to use the current context.
dstvoid *Destination device pointer
elementSizeunsigned intSize of each element in bytes. Must be 1, 2, or 4.
heightsize_tNumber of rows
pitchsize_tPitch of destination device pointer. Unused if height is 1
valueunsigned intValue to be set
widthsize_tWidth of the row in elements
musaMemTransferParms (3 fields)
FieldTypeDescription
countsize_t
dstvoid *
srcconst void *
musaMemWaitWriteParms (4 fields)
FieldTypeDescription
addrvoid *
flagsunsigned intFlags in MUstreamWaitValue_flags or MUstreamWriteValue_flags
operationmusaStreamBatchMemOpType
valuesize_t
musaOffset3D (3 fields)
FieldTypeDescription
xsize_t
ysize_t
zsize_t
musaPitchedPtr (4 fields)
FieldTypeDescription
pitchsize_tPitch of allocated memory in bytes
ptrvoid *Pointer to allocated memory
xsizesize_tLogical width of allocation in elements
ysizesize_tLogical height of allocation in elements
musaPointerAttributes (5 fields)
FieldTypeDescription
deviceintThe device against which the memory was allocated or registered. If the memory type is musaMemoryTypeDevice then this identifies the device on which the memory referred physically resides. If the memory type is musaMemoryTypeHost or::musaMemoryTypeManaged then this identifies the device which was current when the memory was allocated or registered (and if that device is deinitialized then this allocation will vanish with that device's state).
devicePointervoid *The address which may be dereferenced on the current device to access the memory or NULL if no such address exists.
hostPointervoid *The address which may be dereferenced on the host to access the memory or NULL if no such address exists.
reservedlongMust be zero
typeenum musaMemoryTypeThe type of memory - musaMemoryTypeUnregistered, musaMemoryTypeHost, musaMemoryTypeDevice or musaMemoryTypeManaged.
musaPos (3 fields)
FieldTypeDescription
xsize_tx
ysize_ty
zsize_tz
musaResourceDesc (17 fields)
FieldTypeDescription
arraymusaArray_tMUSA array
arraystruct musaResourceDesc::@1::@2
descstruct musaChannelFormatDescChannel descriptor
devPtrvoid *Device pointer
flagsunsigned intFlags (must be zero)
heightsize_tHeight of the array in elements
linearstruct musaResourceDesc::@1::@4
mipmapmusaMipmappedArray_tMUSA mipmapped array
mipmapstruct musaResourceDesc::@1::@3
pitch2Dstruct musaResourceDesc::@1::@5
pitchInBytessize_tPitch between two rows in bytes
resunion musaResourceDesc::@1
reservedint
reservedstruct musaResourceDesc::@1::@6
resTypeenum musaResourceTypeResource type
sizeInBytessize_tSize in bytes
widthsize_tWidth of the array in elements
musaResourceViewDesc (9 fields)
FieldTypeDescription
depthsize_tDepth of the resource view
firstLayerunsigned intFirst layer index
firstMipmapLevelunsigned intFirst defined mipmap level
formatenum musaResourceViewFormatResource view format
heightsize_tHeight of the resource view
lastLayerunsigned intLast layer index
lastMipmapLevelunsigned intLast defined mipmap level
reservedunsigned intMust be zero
widthsize_tWidth of the resource view
musaTextureDesc (12 fields)
FieldTypeDescription
addressModeenum musaTextureAddressModeTexture address mode for up to 3 dimensions
borderColorfloatTexture Border Color
disableTrilinearOptimizationintDisable any trilinear filtering optimizations.
filterModeenum musaTextureFilterModeTexture filter mode
maxAnisotropyunsigned intLimit to the anisotropy ratio
maxMipmapLevelClampfloatUpper end of the mipmap level range to clamp access to
minMipmapLevelClampfloatLower end of the mipmap level range to clamp access to
mipmapFilterModeenum musaTextureFilterModeMipmap filter mode
mipmapLevelBiasfloatOffset applied to the supplied mipmap level
normalizedCoordsintIndicates whether texture reads are normalized or not
readModeenum musaTextureReadModeTexture read mode
sRGBintPerform sRGB->linear conversion during texture read
MUuuid_st (1 field)
FieldTypeDescription
byteschar< MUSA definition of UUID
short1 (1 field)
FieldTypeDescription
xshort
short3 (3 fields)
FieldTypeDescription
xshort
yshort
zshort
surfaceReference (1 field)
FieldTypeDescription
channelDescstruct musaChannelFormatDescChannel descriptor for surface reference
textureReference (13 fields)
FieldTypeDescription
__musaReservedint
addressModeenum musaTextureAddressModeTexture address mode for up to 3 dimensions
channelDescstruct musaChannelFormatDescChannel descriptor for the texture reference
disableTrilinearOptimizationintDisable any trilinear filtering optimizations.
filterModeenum musaTextureFilterModeTexture filter mode
maxAnisotropyunsigned intLimit to the anisotropy ratio
maxMipmapLevelClampfloatUpper end of the mipmap level range to clamp access to
minMipmapLevelClampfloatLower end of the mipmap level range to clamp access to
mipmapFilterModeenum musaTextureFilterModeMipmap filter mode
mipmapLevelBiasfloatOffset applied to the supplied mipmap level
normalizedintIndicates whether sample coordinates are normalized or not
readModeenum musaTextureReadModeIndicates whether texture reads are normalized or not
sRGBintPerform sRGB->linear conversion during texture read
uchar1 (1 field)
FieldTypeDescription
xunsigned char
uchar3 (3 fields)
FieldTypeDescription
xunsigned char
yunsigned char
zunsigned char
uint1 (1 field)
FieldTypeDescription
xunsigned int
uint3 (3 fields)
FieldTypeDescription
xunsigned int
yunsigned int
zunsigned int
ulong1 (1 field)
FieldTypeDescription
xunsigned long
ulong3 (3 fields)
FieldTypeDescription
xunsigned long int
yunsigned long int
zunsigned long int
ulonglong1 (1 field)
FieldTypeDescription
xunsigned long long int
ulonglong3 (3 fields)
FieldTypeDescription
xunsigned long long int
yunsigned long long int
zunsigned long long int
ushort1 (1 field)
FieldTypeDescription
xunsigned short
ushort3 (3 fields)
FieldTypeDescription
xunsigned short
yunsigned short
zunsigned short

7. Deprecated List

This section lists Runtime API entries marked deprecated.

CategoryName
definemusaDeviceBlockingSync
enummusaSharedMemConfig
enumvaluemusaErrorAddressOfConstant
enumvaluemusaErrorApiFailureBase
enumvaluemusaErrorInvalidDevicePointer
enumvaluemusaErrorInvalidHostPointer
enumvaluemusaErrorMemoryValueTooLarge
enumvaluemusaErrorMixedDeviceExecution
enumvaluemusaErrorNotYetImplemented
enumvaluemusaErrorPriorLaunchFailure
enumvaluemusaErrorProfilerAlreadyStarted
enumvaluemusaErrorProfilerAlreadyStopped
enumvaluemusaErrorProfilerNotInitialized
enumvaluemusaErrorSynchronizationError
enumvaluemusaErrorTextureFetchFailed
enumvaluemusaErrorTextureNotBound
functionmusaBindSurfaceToArray
functionmusaBindTexture
functionmusaBindTexture2D
functionmusaBindTextureToArray
functionmusaBindTextureToMipmappedArray
functionmusaDeviceGetSharedMemConfig
functionmusaDeviceSetSharedMemConfig
functionmusaFuncSetSharedMemConfig
functionmusaGetSurfaceReference
functionmusaGetTextureAlignmentOffset
functionmusaGetTextureReference
functionmusaLaunchCooperativeKernelMultiDevice
functionmusaLaunchHostFunc
functionmusaMemcpyFromArray
functionmusaMemcpyFromArrayAsync
functionmusaMemcpyToArray
functionmusaMemcpyToArrayAsync
functionmusaThreadExit
functionmusaThreadGetCacheConfig
functionmusaThreadGetLimit
functionmusaThreadSetCacheConfig
functionmusaThreadSetLimit
functionmusaThreadSynchronize
functionmusaUnbindTexture

8. Experimental List

These APIs are included in the MUSA SDK 5.2.0 release scope and are marked experimental in this reference.

ModuleAPI
Device ManagementmusaMemGetDefaultMemPool
Device ManagementmusaMemGetMemPool
Device ManagementmusaMemSetMemPool
Execution ControlmusaFuncGetParamCount
Graph ManagementmusaGraphChildGraphNodeGetGraph
Graph ManagementmusaGraphNodeGetContainingGraph
Graph ManagementmusaGraphNodeGetLocalId
Graph ManagementmusaGraphNodeGetToolsId
Graph ManagementmusaGraphGetId
Graph ManagementmusaGraphExecGetId
Graph ManagementmusaGraphExecEventWaitNodeSetEvent
Graph ManagementmusaGraphExecEventRecordNodeSetEvent
Graph ManagementmusaGraphNodeGetParams
Error Log ManagementmusaLogsRegisterCallback
Error Log ManagementmusaLogsUnregisterCallback
Error Log ManagementmusaLogsCurrent
Error Log ManagementmusaLogsDumpToFile
Error Log ManagementmusaLogsDumpToMemory