SHMEM Python API Reference
shmem.core API
External APIs
-
get_version — Obtain the current library version. The ACLSHMEM library version is returned.
def get_version() -> strParameter/Return Value Direction Meaning Return Value [out] A string containing the version information, in the format of "libaclshmem_version=X.Y" -
get_unique_id — Generate a unique ID for UID initialization. The API should be called by a single process (for example, rank 0) and broadcast to other processes.
def get_unique_id(empty: bool=False) -> bytesParameter/Return Value Direction Meaning empty [in] Reserved. It has no actual meaning. Return Value [out] Serialized native unique ID as bytes, suitable for object broadcast. If generation fails,AclshmemErroris raised. -
init — Initialize the ACLSHMEM runtime using a unique ID. This is a collective operation and must be called by all PEs.
def init(device: int=None, uid: Optional[Union[UniqueID, bytes]]=None, rank: int=None, nranks: int=None, mpi_comm=None, initializer_method: str="", mem_size: int=None, instance_id: int=0) -> NoneParameter/Return Value Direction Meaning device [in] Reserved. It has no actual meaning. uid [in] (Required) Unique identifier for initialization. rank [in] (Required) Rank (0-based) of the current process in the ACLSHMEM job. nranks [in] (Required) Total number of processes involved in the ACLSHMEM job. mpi_comm [in] Reserved. It has no actual meaning. initializer_method [in] Initialization method. The value must be "uid".mem_size [in] (Required) Size of the symmetric memory allocated to each PE, in bytes. instance_id [in] Instance ID. It must be a non-bool integer in the range 0 to 254. The default is 0. Return Value - No return value. AclshmemInvalidis thrown due to missing parameters, andAclshmemErroris thrown due to an initialization failure. -
finalize — Destroy the ACLSHMEM runtime and resource allocations. Each process should call this API once after completing all ACLSHMEM operations.
def finalize(instance_id: int=None) -> NoneParameter/Return Value Direction Meaning instance_id [in] If omitted, finalize the active instance. If supplied, finalize that instance; it must be a non-bool integer in the range 0 to 254. Return Value - No return value. Invalid IDs raise AclshmemInvalid; finalization failures raiseAclshmemError. -
buffer — Allocate an NPU buffer supported by ACLSHMEM. This is a collective operation and must be called by all PEs synchronously.
def buffer(size, release=False, except_on_del=True, mem_type: MemType=MemType.DEVICE_SIDE) -> BufferParameter/Return Value Direction Meaning size [in] Size of the buffer to be allocated, in bytes release [in] Reserved. It has no actual meaning. except_on_del [in] Reserved. It has no actual meaning. mem_type [in] Symmetric heap type: MemType.DEVICE_SIDEorMemType.HOST_SIDE. The default is device-side memory.Return Value [out] Original memory buffer represented by the address and byte length If the allocation fails, AclshmemErroris thrown. -
free — Free the buffer allocated by
buffer(). This is a collective operation.def free(buf: Buffer) -> NoneParameter/Return Value Direction Meaning buf [in] Buffer to be freed Return Value - No return value. -
get_peer_buffer — Convert a local symmetric address to the corresponding symmetric address on a specified PE. The access mode supported by the returned address depends on the transfer engine and topology.
def get_peer_buffer(buf: Buffer, pe: int) -> BufferParameter/Return Value Direction Meaning buf [in] Symmetric address on the local PE pe [in] PE ID Return Value [out] Corresponding symmetric address buffer on the specified PE. If the input address or PE is invalid, AclshmemErroris thrown. -
put_signal — Copy contiguous data from the local PE to the symmetric memory address of a specified PE and update the remote signal variable after the copy completes. This call completes the operation before returning; all addresses must remain valid for the duration of the call.
def put_signal(dst: Buffer, src: Buffer, signal_var: Buffer, signal_val: int, signal_operation: SignalOp, remote_pe: int, stream=None) -> NoneParameter/Return Value Direction Meaning dst [in] Symmetric address of the target data on the remote PE src [in] Address of the source data in the local memory signal_var [in] Symmetric address of the signal word to be updated on the remote PE; at least 4 bytes and 4-byte aligned signal_val [in] Value of the signal variable to be updated signal_operation [in] Signal variable update operation. Supported operation: SignalOp.SIGNAL_SETorSignalOp.SIGNAL_ADDremote_pe [in] Required non-bool integer satisfying 0 <= remote_pe < pe_count()stream [in] Reserved and ignored; this interface does not provide explicit stream ordering. Return Value - No return value. -
put — Copy contiguous data from the local PE to symmetric memory on a specified PE, ordered on the supplied stream. The host call only enqueues the operation; synchronize that stream before observing completion.
def put(dst: Buffer, src: Buffer, remote_pe: int, stream: int=None) -> NoneParameter/Return Value Direction Meaning dst [in] Symmetric address of the target data on the remote PE src [in] Address of the source data in the local memory remote_pe [in] Required non-bool integer satisfying 0 <= remote_pe < pe_count()stream [in] ACL stream object, which is used for sorting. Pass 0orNoneto use the default stream.Return Value - No return value. -
get — Copy contiguous data from symmetric memory on a specified PE to a local buffer, ordered on the supplied stream. The host call only enqueues the operation; synchronize that stream before reading the result.
def get(dst: Buffer, src: Buffer, remote_pe: int, stream: int=None) -> NoneParameter/Return Value Direction Meaning dst [in] Address of the target data in the local memory src [in] Symmetric address of the source data on the remote PE remote_pe [in] Required non-bool integer satisfying 0 <= remote_pe < pe_count()stream [in] ACL stream object, which is used for sorting. Pass 0orNoneto use the default stream.Return Value - No return value. -
signal_op — Update a remote signal variable on a specified PE, ordered on the supplied stream. The host call only enqueues the operation; synchronize that stream before observing completion.
def signal_op(signal_var: Buffer, signal_val: int, signal_operation: SignalOp, remote_pe: int, stream: int=None) -> NoneParameter/Return Value Direction Meaning signal_var [in] Local address of the signal variable that can be accessed on the target PE signal_val [in] Value used for atomic operations signal_operation [in] Operation performed on a remote signal. Supported operation: SignalOp.SIGNAL_SETorSignalOp.SIGNAL_ADDremote_pe [in] Required non-bool integer satisfying 0 <= remote_pe < pe_count()stream [in] Non-bool, non-negative ACL stream address. 0is the default stream;Noneis rejected.Return Value - No return value. Invalid buffers, enum values, PE IDs, or streams raise AclshmemInvalid. -
signal_wait — Wait until a symmetric signal variable satisfies the specified comparison. The wait is ordered on the supplied stream and the host call returns immediately; after synchronizing that stream,
signal_varcmpsignal_valis guaranteed to be true.def signal_wait(signal_var: Buffer, signal_val: int, signal_operation: ComparisonType, stream: int) -> NoneParameter/Return Value Direction Meaning signal_var [in] Local address of the source signal variable signal_val [in] Value to be compared with the value pointed to by signal_var signal_operation [in] Comparison operator. Supported comparison operator: ComparisonType.CMP_EQ,CMP_NE,CMP_GT,CMP_GE,CMP_LT, orCMP_LEstream [in] Non-bool, non-negative ACL stream address. 0is the default stream;Noneis rejected.Return Value - No return value. Invalid buffers, comparison values, or streams raise AclshmemInvalid. -
quiet — Enqueue a completion point so that symmetric-data operations previously issued by the calling context finish before that point on the supplied stream. The host call returns immediately; synchronize the stream before observing completion.
def quiet(stream: int) -> NoneParameter/Return Value Direction Meaning stream [in] Non-bool, non-negative ACL stream address. 0is the default stream;Noneis rejected.Return Value - No return value. Invalid streams raise AclshmemInvalid. -
my_pe — Obtain the local PE ID.
def my_pe() -> intParameter/Return Value Direction Meaning Return Value [out] Local PE ID -
team_my_pe — Obtain the PE ID of the current process in a specified team.
def team_my_pe(team) -> intParameter/Return Value Direction Meaning team [in] Target team ID Return Value [out] PE ID in the specified team. If the team is invalid, -1is returned. -
n_pes — Obtain the total number of PEs running in the program (world team dimension).
def n_pes() -> intParameter/Return Value Direction Meaning Return Value [out] Total number of PEs -
team_n_pes — Obtain the total number of PEs in a specified team.
def team_n_pes(team) -> intParameter/Return Value Direction Meaning team [in] Target team ID Return Value [out] The number of PEs in the specified team. If the team is invalid, -1is returned. -
init_status — Query the current initialization status of the shared memory module.
def init_status() -> InitStatusParameter/Return Value Direction Meaning Return Value [out] The initialization status is returned. The enumerated values are as follows: NOT_INITIALIZED,SHM_CREATED,INITIALIZED, andINVALID. -
calloc — Allocate zero-initialized memory by element count from a selected symmetric heap. This is a collective operation.
def calloc(count: int, size: int, mem_type: MemType=MemType.DEVICE_SIDE) -> BufferParameter/Return Value Direction Meaning count [in] Number of elements; must be a positive integer size [in] Size of one element in bytes; must be positive and count * sizemust fit insize_tmem_type [in] Symmetric heap type: MemType.DEVICE_SIDEorMemType.HOST_SIDEReturn Value [out] Zero-initialized owning Bufferwith lengthcount * size; allocation failure raisesAclshmemError -
align — Allocate power-of-two-aligned memory from a selected symmetric heap. This is a collective operation.
def align(alignment: int, size: int, mem_type: MemType=MemType.DEVICE_SIDE) -> BufferParameter/Return Value Direction Meaning alignment [in] Alignment in bytes; must be a positive power of two size [in] Allocation size in bytes; must be positive and fit in size_tmem_type [in] Symmetric heap type: MemType.DEVICE_SIDEorMemType.HOST_SIDEReturn Value [out] Owning Bufferwith the requested alignment; allocation failure raisesAclshmemError -
barrier — Block the current host thread until all PEs in a specified team reach the barrier. This is a collective operation.
def barrier(team: int) -> NoneParameter/Return Value Direction Meaning team [in] Currently live team ID in the range 0 to 2047 Return Value - No return value; a never-created, destroyed, or out-of-range team raises AclshmemInvalid -
barrier_all — Block the current host thread until all PEs in the world team reach the barrier. This is a collective operation.
def barrier_all() -> NoneParameter/Return Value Direction Meaning Return Value - No return value; all PEs must call in the same order -
sync — Synchronize all PEs in a specified team and make prior host stores complete and visible. This is a collective operation.
def sync(team: int) -> NoneParameter/Return Value Direction Meaning team [in] Currently live team ID in the range 0 to 2047 Return Value - No return value; a never-created, destroyed, or out-of-range team raises AclshmemInvalid -
sync_all — Synchronize all PEs in the world team and make prior host stores complete and visible. This is a collective operation.
def sync_all() -> NoneParameter/Return Value Direction Meaning Return Value - No return value; all PEs must call in the same order -
barrier_on_stream — Enqueue a barrier for a specified team on an ACL stream. The API does not synchronize the stream implicitly.
def barrier_on_stream(team: int, stream: int) -> NoneParameter/Return Value Direction Meaning team [in] Currently live team ID in the range 0 to 2047 stream [in] Non-bool, nonnegative integer aclrtStreamaddress;0selects the default streamReturn Value - No return value; an invalid team or stream raises AclshmemInvalid -
barrier_all_on_stream — Enqueue a world-team barrier on an ACL stream. The API does not synchronize the stream implicitly.
def barrier_all_on_stream(stream: int) -> NoneParameter/Return Value Direction Meaning stream [in] Non-bool, nonnegative integer aclrtStreamaddress;0selects the default streamReturn Value - No return value; an invalid stream raises AclshmemInvalid -
current_instance — Obtain the currently active SHMEM instance ID.
def current_instance() -> intParameter/Return Value Direction Meaning Return Value [out] Active instance ID; raises AclshmemErrorif no instance context is available -
set_instance — Switch the active context to a specified SHMEM instance.
def set_instance(instance_id: int) -> NoneParameter/Return Value Direction Meaning instance_id [in] Initialized target instance ID; must be a non-bool integer in the range 0 to 254 Return Value - No return value; invalid IDs raise AclshmemInvalidand switch failures raiseAclshmemError -
multi_instance — Switch instances within a context-manager scope and restore the original instance when leaving the scope.
@contextmanager def multi_instance(instance_id: int)Parameter/Return Value Direction Meaning instance_id [in] Initialized instance ID used inside the scope; must be a non-bool integer from 0 to 254 Return Value [out] Context manager that switches to the target instance on entry and restores the previous instance on exit -
set_mte_config — Configure MTE workspace parameters for the active instance. Call it after initializing and selecting that instance and before issuing operations that use the configuration.
def set_mte_config(offset: int, ub_size: int, sync_id: int) -> NoneParameter/Return Value Direction Meaning offset [in] Workspace offset/address in bytes; a non-bool integer in [0, 2**64 - 1]ub_size [in] Workspace size in bytes; a non-bool integer in [0, 2**32 - 1]sync_id [in] Synchronization identifier; a non-bool integer in [0, 2**32 - 1]Return Value - No return value; invalid arguments raise AclshmemInvalid, and failure to apply the configuration to the active instance raisesAclshmemError -
set_sdma_config — Configure SDMA workspace parameters for the active instance. Call it after initializing and selecting that instance and before issuing operations that use the configuration. Availability depends on the current platform and runtime.
def set_sdma_config(offset: int, ub_size: int, sync_id: int) -> NoneParameter/Return Value Direction Meaning offset [in] Workspace offset/address in bytes; a non-bool integer in [0, 2**64 - 1]ub_size [in] Workspace size in bytes; a non-bool integer in [0, 2**32 - 1]sync_id [in] Synchronization identifier; a non-bool integer in [0, 2**32 - 1]Return Value - No return value; invalid arguments raise AclshmemInvalid, and failure to apply the configuration to the active instance raisesAclshmemError -
set_rdma_config — Configure RDMA workspace parameters for the active instance. Call it after initializing and selecting that instance and before issuing operations that use the configuration. Availability depends on the current platform and runtime.
def set_rdma_config(offset: int, ub_size: int, sync_id: int) -> NoneParameter/Return Value Direction Meaning offset [in] Workspace offset/address in bytes; a non-bool integer in [0, 2**64 - 1]ub_size [in] Workspace size in bytes; a non-bool integer in [128, 2**32 - 1]sync_id [in] Synchronization identifier; a non-bool integer in [0, 2**32 - 1]Return Value - No return value; invalid arguments raise AclshmemInvalid, and failure to apply the configuration to the active instance raisesAclshmemError -
set_udma_config — Configure UDMA workspace parameters for the active instance. Call it after initializing and selecting that instance and before issuing operations that use the configuration. Availability depends on the current platform and runtime.
def set_udma_config(offset: int, ub_size: int, sync_id: int) -> NoneParameter/Return Value Direction Meaning offset [in] Workspace offset/address in bytes; a non-bool integer in [0, 2**64 - 1]ub_size [in] Workspace size in bytes; a non-bool integer in [128, 2**32 - 1]sync_id [in] Synchronization identifier; a non-bool integer in [0, 2**32 - 1]Return Value - No return value; invalid arguments raise AclshmemInvalid, and failure to apply the configuration to the active instance raisesAclshmemError -
handle_wait — Enqueue a completion wait and member rendezvous for the Handle's team on the supplied stream. Every PE in that team must participate in matching order after issuing the asynchronous operations to be covered; only a Handle for
ACLSHMEM_TEAM_WORLDrequires every PE. The host call only enqueues the operation, so synchronize the stream before observing completion.def handle_wait(handle: Handle, stream: int) -> NoneParameter/Return Value Direction Meaning handle [in] Handlebound to a currently active team; that team defines the participating PEsstream [in] Non-bool, nonnegative integer aclrtStreamaddress;0selects the default streamReturn Value - No return value; an invalid Handle, team, or stream raises AclshmemInvalid. Mismatched participation or call order can wait indefinitely -
get_prof — Obtain a deep copy of profiling data for the current instance and PE.
def get_prof(verbose: bool=False) -> Optional[ProfData]Parameter/Return Value Direction Meaning verbose [in] Whether to also print profiling data; default is FalseReturn Value [out] The PE selected by SHMEM_CYCLE_PROF_PEreturnsProfData; other PEs returnNone; data is isolated per instance -
show_prof — Print profiling data for the current instance.
def show_prof() -> NoneParameter/Return Value Direction Meaning Return Value - No return value; compatibility API, with get_profpreferred for new code -
UniqueId class: unique identifier handle for UID initialization
Class
-
UniqueId class — Unique identifier handle for UID initialization
class UniqueId: def __init__(self):Attribute Direction Meaning version [out] Version my_pe [out] PE ID of the current process n_pes [out] Total number of PEs of all processes internal [out] Internal information about the UID (bytes) -
InitStatus enumeration class — Initialization statuses of the shared memory module
class InitStatus(Enum): NOT_INITIALIZED SHM_CREATED INITIALIZED INVALIDEnumerated Value Meaning NOT_INITIALIZED Not initialized SHM_CREATED Shared memory created INITIALIZED Initialization completed INVALID Invalid -
SignalOp enumeration class — Atomic operation types of signal variables
class SignalOp(Enum): SIGNAL_SET SIGNAL_ADDEnumerated Value Meaning SIGNAL_SET Atomic setting: writes a given value to a remote signal. SIGNAL_ADD Atomic addition: adds a given value to the existing value of a remote signal. -
ComparisonType enumeration class — Signal waiting comparison operation types
class ComparisonType(Enum): CMP_EQ CMP_NE CMP_GT CMP_GE CMP_LT CMP_LEEnumerated Value Meaning CMP_EQ Equal to (==) CMP_NE Not equal to (!=) CMP_GT Greater than (>) CMP_GE Greater than or equal to (>=) CMP_LT Less than (<) CMP_LE Less than or equal to (<=) -
MemType enumeration class — Symmetric heap type.
class MemType(Enum): HOST_SIDE DEVICE_SIDEEnumerated Value Meaning HOST_SIDE Host-side symmetric heap; availability depends on the CANN runtime DEVICE_SIDE Device-side symmetric heap and the default value -
Buffer class — Describe memory used by SHMEM APIs through its address, length, and symmetric heap type.
class Buffer: def __init__( self, addr: int, length: int, mem_type: MemType=MemType.DEVICE_SIDE, ) -> None:Attributes
Attribute Direction Meaning addr [in/out] Start address of the memory length [in/out] Memory length in bytes mem_type [in/out] Symmetric heap type: MemType.DEVICE_SIDEorMemType.HOST_SIDEowned [out] Read-only; whether this object owns the right to free the memory instance_id [out] Read-only; instance ID for a factory-allocated Buffer, or Nonefor an external-address descriptorrelease_called [out] Read-only; whether a free operation has been initiated for the memory Functionality and Constraints
- Direct
Buffer(addr, length)construction describes an external address and does not own the memory, so it cannot be passed tofree. Buffers returned bybuffer,calloc, oralignown the right to free their memory. addrandlengthmust be non-bool integers satisfying0 < addr <= INTPTR_MAXand0 < length <= SIZE_T_MAX.- A factory-allocated Buffer and its peer views can be used for
free, peer-address translation, and RMA/Signal operations only while their allocation instance is active. An instance mismatch raisesAclshmemInvalid. - After a free operation is initiated, neither the original Buffer nor its peer views can be reused for free, peer-address translation, or RMA/Signal operations. Repeated free calls are rejected.
- Buffer destruction does not automatically free symmetric memory. Free is collective and must be called explicitly by all PEs in the same order.
- Direct
-
InstanceContext class — Read-only value snapshot of the active instance context.
class InstanceContext: @property def id(self) -> int:Attribute Direction Meaning id [out] Read-only instance ID -
Handle class — Team-scoped asynchronous-operation handle.
class Handle: def __init__(self, team_id: int=ACLSHMEM_TEAM_WORLD) -> None: @property def team_id(self) -> int:Attribute/Parameter Direction Meaning team_id [in/out] Team ID; defaults to ACLSHMEM_TEAM_WORLDand must refer to a currently live team in the range 0 to 2047 on construction and assignmentA bool, out-of-range, never-created, or destroyed
team_idraisesValueError. -
ProfData class — NumPy-independent deep-copy snapshot of profiling data for the current PE.
class ProfData: @property def pe_id(self) -> int: @property def ccount(self) -> list[list[int]]: @property def cycles(self) -> list[list[int]]:Attribute Direction Meaning pe_id [out] Read-only PE ID associated with the profiling data ccount [out] Read-only 64 x 1024two-dimensional integer list of countscycles [out] Read-only 64 x 1024two-dimensional integer list of cycles
shmem._pyshmem API
External APIs
-
aclshmem_init — Initialize the shared memory module. This is a collective operation.
def aclshmem_init(attributes: InitAttr) -> intParameter/Return Value Direction Meaning attributes [in] Initialization attributes (of the InitAttrtype), includingmy_pe(local PE index, ranging from0ton_pes-1),n_pes(total number of PEs), andlocal_mem_size(size of the memory allocated to each PE, in bytes)Return Value [out] Result code. Success: 0. Failure: -1. -
aclshmem_finalize — Destroy the shared memory module and release all resources.
def aclshmem_finalize() -> intParameter/Return Value Direction Meaning No parameter [in] - Return Value [out] Result code. Success: 0. Failure: error code. Use aclshmemx_finalize(instance_id)to finalize a selected instance. -
aclshmemx_init_status — Query the current initialization status of the shared memory module.
def aclshmemx_init_status() -> InitStatusParameter/Return Value Direction Meaning Return Value [out] Enumeration value of the initialization status. INITIALIZEDindicates that the initialization is complete. -
set_conf_store_tls_key — Set the TLS private key and password, and register the decryption callback function.
def set_conf_store_tls_key(tls_pk, tls_pk_pw, py_decrypt_func:Callable[[str], str]) -> intParameter/Return Value Direction Meaning tls_pk [in] TLS private key content tls_pk_pw [in] TLS private key password py_decrypt_func [in] Decryption callback function. It receives (str cipher_text)and returns(str plain_text).Return Value [out] Result code. Success: 0. Failure: error code. -
set_conf_store_tls — Set whether to enable TLS encryption, and specify the TLS configuration information.
def set_conf_store_tls(enable, tls_info) -> intParameter/Return Value Direction Meaning enable [in] Whether to enable TLS encryption. Trueindicates enabling, andFalseindicates disabling.tls_info [in] TLS configuration information string, which can be an empty string Return Value [out] Result code. Success: 0. Failure: error code. -
aclshmem_malloc — Allocate symmetric memory. This is a collective operation with an implicit barrier.
def aclshmem_malloc(size) -> intParameter/Return Value Direction Meaning size [in] Size of the allocated memory, in bytes Return Value [out] If the operation is successful, a pointer (int) to the allocated memory is returned. If sizeis0or the allocation fails,0is returned, and an exception is thrown. -
aclshmem_calloc — Allocate zero-initialized symmetric memory. This is a collective operation with an implicit barrier.
def aclshmem_calloc(nmemb, size) -> intParameter/Return Value Direction Meaning nmemb [in] The number of elements size [in] Size of each element, in bytes Return Value [out] If the operation is successful, a pointer (int) to the allocated memory is returned. If nmemborsizeis0,0is returned, and an exception is thrown. -
aclshmem_align — Allocate symmetric memory with a specified alignment mode. This is a collective operation with an implicit barrier.
def aclshmem_align(alignment, size) -> intParameter/Return Value Direction Meaning alignment [in] Memory alignment requirement (The value must be a power of 2.) size [in] The number of bytes to be allocated Return Value [out] If the operation is successful, a pointer (int) to the allocated memory is returned. If the allocation fails, an exception is thrown. -
aclshmem_free — Free the memory allocated by the symmetric memory allocation function. This is a collective operation with an implicit barrier.
def aclshmem_free(ptr) -> NoneParameter/Return Value Direction Meaning ptr [in] Pointer to the memory to be freed Return Value - No return value. -
aclshmem_ptr — Convert a local symmetric address to the corresponding symmetric address on a specified PE. The access mode supported by the returned address depends on the transfer engine and topology.
def aclshmem_ptr(ptr, peer) -> intParameter/Return Value Direction Meaning ptr [in] Symmetric address on the local PE peer [in] PE ID Return Value [out] If the operation is successful, the corresponding symmetric address (int) on the specified PE is returned. If the input address or PE is invalid, 0is returned. -
aclshmemx_get_heap_base — Obtain the start address of the local symmetric memory heap.
def aclshmemx_get_heap_base(mem_type: MemType=None) -> intParameter/Return Value Direction Meaning mem_type [in] Symmetric memory allocation location: MemType.HOST_SIDE(host side) /MemType.DEVICE_SIDE(device side, default)Return Value [out] If the operation is successful, the pointer (int) to the start address of the symmetric memory heap is returned. If the module is not initialized, 0is returned. -
my_pe — Obtain the PE ID (world team dimension).
def my_pe() -> intParameter/Return Value Direction Meaning Return Value [out] Local PE ID -
team_my_pe — Obtain the PE ID in a specified team.
def team_my_pe(team_id) -> intParameter/Return Value Direction Meaning team_id [in] Handle of the team Return Value [out] ID of the PE in the specified team. If an error occurs, -1is returned. -
pe_count — Obtain the total number of PEs (world team dimension).
def pe_count() -> intParameter/Return Value Direction Meaning Return Value [out] Total number of PEs -
team_n_pes — Obtain the number of PEs in a specified team.
def team_n_pes(team_id) -> intParameter/Return Value Direction Meaning team_id [in] Handle of the team Return Value [out] The number of PEs in the specified team. If an error occurs, -1is returned. -
team_split_strided — Split child teams from the existing parent team by stride. This is a collective operation.
def team_split_strided(parent, start, stride, size) -> intParameter/Return Value Direction Meaning parent [in] Parent team ID start [in] Start PE ID of a child team stride [in] Stride between PE IDs size [in] The number of PEs in a child team Return Value [out] Returns the new team ID when successful and the current PE is a member; returns ACLSHMEM_TEAM_INVALIDfor a non-member PE; raisesRuntimeErrorwhen the native call returns an error code. -
team_split_2d — Split a team from the parent team based on the two-dimensional Cartesian space. This is a collective operation.
def team_split_2d(parent, x_range) -> tupleParameter/Return Value Direction Meaning parent [in] Handle of the parent team x_range [in] The number of elements in the first dimension Return Value [out] If the operation is successful, the (x_team_id, y_team_id) tuple is returned. If the operation fails, an exception is thrown. -
aclshmem_team_get_config — Obtain the team configuration passed during team creation.
def aclshmem_team_get_config(team) -> TeamConfigParameter/Return Value Direction Meaning team [in] team ID Return Value [out] If the operation is successful, the TeamConfigobject is returned. If the operation fails, an exception is thrown. -
aclshmem_putmem — Copy contiguous data from the local PE to the symmetric address of a specified PE. This is a synchronous (blocking) API.
def aclshmem_putmem(dst, src, elem_size, pe) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmem_getmem — Copy contiguous data from the symmetric memory of a specified PE to the local PE. This is a synchronous (blocking) API.
def aclshmem_getmem(dst, src, elem_size, pe) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the local target memory src [in] Pointer to the symmetric address of the remote PE elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmem_{TYPE}_iput — Copy the data arranged by the sst stride in the local memory to the corresponding position in the symmetric memory of a specified PE by the dst stride. This is a synchronous (blocking) API.
def aclshmem_{TYPE}_iput(dest, source, dst, sst, nelems, pe)Parameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,double,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orchardest [in] Symmetric memory pointer to the remote target data source [in] Pointer to the local source data dst [in] Stride between consecutive elements in the target address sst [in] Stride between consecutive elements in the source address nelems [in] The number of consecutive element blocks pe [in] Remote PE ID Return Value - No return value. -
aclshmem_{TYPE}_iget — Copy the data arranged by the sst stride in the symmetric memory of a remote PE to the corresponding position of the local memory by the dst stride. This is a synchronous (blocking) API.
def aclshmem_{TYPE}_iget(dest, source, dst, sst, nelems, pe)Parameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,double,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orchardest [in] Pointer to the local target data source [in] Symmetric memory pointer to the remote source data dst [in] Stride between consecutive elements in the target address sst [in] Stride between consecutive elements in the source address nelems [in] The number of consecutive element blocks pe [in] Remote PE ID Return Value - No return value. -
aclshmem_put{BITS} — Copy contiguous data from the local PE to the symmetric memory address of a specified PE. This is a synchronous (blocking) API.
def aclshmem_put{BITS}(dst, src, elem_size, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmem_get{BITS} — Copy contiguous data from the symmetric memory of a specified PE to the local PE. This is a synchronous (blocking) API.
def aclshmem_get{BITS}(dst, src, elem_size, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dst [in] Pointer to the local target memory src [in] Pointer to the symmetric address of the remote PE elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmem_iput{BITS} — Copy the data arranged by the sst stride in the local memory to the corresponding position (bit width version) of a specified PE by the dst stride. This is a synchronous (blocking) API.
def aclshmem_iput{BITS}(dest, source, dst, sst, nelems, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dest [in] Symmetric memory pointer to the remote target data source [in] Pointer to the local source data dst [in] Stride between consecutive elements in the target address sst [in] Stride between consecutive elements in the source address nelems [in] The number of consecutive element blocks pe [in] Remote PE ID Return Value - No return value. -
aclshmem_iget{BITS} — Copy the data arranged by the sst stride in the symmetric memory of a remote PE to the corresponding position of the local memory by the dst stride (bit width version). This is a synchronous (blocking) API.
def aclshmem_iget{BITS}(dest, source, dst, sst, nelems, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dest [in] Pointer to the local target data source [in] Symmetric memory pointer to the remote source data dst [in] Stride between consecutive elements in the target address sst [in] Stride between consecutive elements in the source address nelems [in] The number of consecutive element blocks pe [in] Remote PE ID Return Value - No return value. -
aclshmem_info_get_version — Return the major and minor version numbers of the library.
def aclshmem_info_get_version() -> tupleParameter/Return Value Direction Meaning Return Value [out] (major, minor) tuple -
aclshmem_info_get_name — Return the vendor-defined name string.
def aclshmem_info_get_name() -> strParameter/Return Value Direction Meaning Return Value [out] Vendor-defined name string -
team_translate_pe — Convert a given PE ID in one team to the corresponding PE ID in another team.
def team_translate_pe(src_team, src_pe, dest_team) -> intParameter/Return Value Direction Meaning src_team [in] Source team ID src_pe [in] Source PE ID dest_team [in] Target team ID Return Value [out] If the operation is successful, the ID of the corresponding PE in the target team is returned. If an error occurs, -1is returned. -
team_destroy — Destroy a team.
def team_destroy(team) -> NoneParameter/Return Value Direction Meaning team [in] ID of the team to be destroyed Return Value - No return value. -
get_ffts_config — Obtain the runtime FFTS configuration.
def get_ffts_config() -> strParameter/Return Value Direction Meaning Return Value [out] FFTS configuration string -
set_log_level — Set the log level of all modules.
def set_log_level(level) -> intParameter/Return Value Direction Meaning level [in] Log level Return Value [out] Result code. Success: 0. Failure: error code. -
set_extern_logger — Register an external log callback function to take over the log output of all modules.
def set_extern_logger(func) -> intParameter/Return Value Direction Meaning func [in] Log callback function. The signature is func(level: int, msg: str)Return Value [out] Result code. Success: 0. Failure: error code. -
aclshmem_putmem_nbi — Copy contiguous data from the local PE to the symmetric address of a specified PE. This is an asynchronous (non-blocking) API.
def aclshmem_putmem_nbi(dst, src, elem_size, pe) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmem_getmem_nbi — Copy contiguous data from the symmetric memory of a specified PE to the local PE. This is an asynchronous (non-blocking) API.
def aclshmem_getmem_nbi(dst, src, elem_size, pe) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the local target memory src [in] Pointer to the symmetric address of the remote PE elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmem_put{BITS}_nbi — Copy contiguous data from the local PE to the symmetric memory address of a specified PE (bit width version). This is an asynchronous (non-blocking) API.
def aclshmem_put{BITS}_nbi(dst, src, elem_size, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmem_get{BITS}_nbi — Copy contiguous data from the symmetric memory of a specified PE to the local PE (bit width version). This is an asynchronous (non-blocking) API.
def aclshmem_get{BITS}_nbi(dst, src, elem_size, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dst [in] Pointer to the local target memory src [in] Pointer to the symmetric address of the remote PE elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID Return Value - No return value. -
aclshmemx_putmem_signal_nbi — Copy contiguous data from the local PE to the symmetric address of a specified PE and update the remote signal variable after the operation is complete. This is an asynchronous (non-blocking) API.
def aclshmemx_putmem_signal_nbi(dst, src, elem_size, sig, signal, sig_op, pe) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses sig [in] Symmetric address of the signal word to be updated signal [in] Value of the signal to be updated sig_op [in] Signal update operation. Supported operation: SIGNAL_SET/SIGNAL_ADDpe [in] Remote PE ID Return Value - No return value. -
aclshmemx_putmem_signal — Copy contiguous data from the local PE to the symmetric address of a specified PE and update the remote signal variable. This is a synchronous (blocking) API.
def aclshmemx_putmem_signal(dst, src, elem_size, sig, signal, sig_op, pe) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses sig [in] Symmetric address of the signal word to be updated signal [in] Value of the signal to be updated sig_op [in] Signal update operation. Supported operation: SIGNAL_SET/SIGNAL_ADDpe [in] Remote PE ID Return Value - No return value. -
aclshmemx_put{BITS}_signal_nbi — Copy contiguous data from the local PE to the symmetric address of a specified PE and update the remote signal (bit width version). This is an asynchronous (non-blocking) API.
def aclshmemx_put{BITS}_signal_nbi(dst, src, elem_size, sig, signal, sig_op, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses sig [in] Symmetric address of the signal word to be updated signal [in] Value of the signal to be updated sig_op [in] Signal update operation. Supported operation: SIGNAL_SET/SIGNAL_ADDpe [in] Remote PE ID Return Value - No return value. -
aclshmemx_put{BITS}_signal — Copy contiguous data from the local PE to the symmetric address of a specified PE and update the remote signal (bit width version). This is a synchronous (blocking) API.
def aclshmemx_put{BITS}_signal(dst, src, elem_size, sig, signal, sig_op, pe)Parameter/Return Value Direction Meaning BITS - Data bit width. Supported option: 8,16,32,64, or128dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses sig [in] Symmetric address of the signal word to be updated signal [in] Value of the signal to be updated sig_op [in] Signal update operation. Supported operation: SIGNAL_SET/SIGNAL_ADDpe [in] Remote PE ID Return Value - No return value. -
aclshmem_global_exit — All PEs call exit() through broadcast to exit the process.
def aclshmem_global_exit(status) -> NoneParameter/Return Value Direction Meaning status [in] Status value passed to exit() Return Value - No return value. -
my_pe — Obtain the PE ID in a specified team.
def my_pe(team) -> intParameter/Return Value Direction Meaning team [in] team ID Return Value [out] ID of the PE in the specified team. If an error occurs, -1is returned. -
pe_count — Obtain the number of PEs in a specified team.
def pe_count(team) -> intParameter/Return Value Direction Meaning team [in] team ID Return Value [out] The number of PEs in the specified team. If an error occurs, -1is returned. -
aclshmem_signal_wait_until — Wait until the signal variable meets the comparison condition
*sig_addr cmp cmp_val. This is a blocking API.def aclshmem_signal_wait_until(sig_addr, cmp, cmp_val) -> intParameter/Return Value Direction Meaning sig_addr [in] Local address of the source signal variable cmp [in] Comparison operator. Supported comparison operator: CMP_EQ,CMP_NE,CMP_GT,CMP_GE,CMP_LT, orCMP_LEcmp_val [in] Comparison value Return Value [out] Value of sig_addrwhen the condition is met -
aclshmem_{TYPE}_wait_until — Wait until a single element meets the comparison condition
ivar cmp cmp_val. This is a blocking API.def aclshmem_{TYPE}_wait_until(ivar, cmp, cmp_val) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivar [in] Pointer to the signal variable in the symmetric memory cmp [in] Comparison operator cmp_val [in] Comparison value Return Value - No return value. -
aclshmem_{TYPE}_wait — Wait until the signal variable is not equal to the given value. This is a blocking API.
def aclshmem_{TYPE}_wait(ivar, cmp_val) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivar [in] Pointer to the signal variable in the symmetric memory cmp_val [in] Comparison value Return Value - No return value. -
aclshmem_{TYPE}_wait_until_all — Wait until all elements in the array meet the comparison condition
ivars[i] cmp cmp_val. This is a blocking API.def aclshmem_{TYPE}_wait_until_all(ivars_ptr, nelems, status_ptr, cmp, cmp_val) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_val [in] Comparison value Return Value - No return value. -
aclshmem_{TYPE}_wait_until_any — Wait until at least one element in the array meets the comparison condition
ivars[i] cmp cmp_val. This is a blocking API.def aclshmem_{TYPE}_wait_until_any(ivars_ptr, nelems, status_ptr, cmp, cmp_val, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_val [in] Comparison value res_out_ptr [out] Index values of elements that meet the comparison condition Return Value - No return value. -
aclshmem_{TYPE}_wait_until_some — Wait until at least one element in the array meets the comparison condition and return the indexes of all elements that meet the condition. This is a blocking API.
def aclshmem_{TYPE}_wait_until_some(ivars_ptr, nelems, indices_ptr, status_ptr, cmp, cmp_val, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements indices_ptr [out] Array of index values of elements that meet the condition status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_val [in] Comparison value res_out_ptr [out] The number of elements that meet the comparison condition Return Value - No return value. -
aclshmem_{TYPE}_wait_until_all_vector — Wait until all elements in the array meet the vector comparison condition
ivars[i] cmp cmp_values[i]. This is a blocking API.def aclshmem_{TYPE}_wait_until_all_vector(ivars_ptr, nelems, status_ptr, cmp, cmp_values_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_values_ptr [in] Comparison value array Return Value - No return value. -
aclshmem_{TYPE}_wait_until_any_vector — Wait until at least one element in the array meets the vector comparison condition
ivars[i] cmp cmp_values[i]. This is a blocking API.def aclshmem_{TYPE}_wait_until_any_vector(ivars_ptr, nelems, status_ptr, cmp, cmp_values_ptr, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_values_ptr [in] Comparison value array res_out_ptr [out] Index values of elements that meet the comparison condition Return Value - No return value. -
aclshmem_{TYPE}_wait_until_some_vector — Wait until at least one element in the array meets the vector comparison condition and return the index values of all elements that meet the condition. This is a blocking API.
def aclshmem_{TYPE}_wait_until_some_vector(ivars_ptr, nelems, indices_ptr, status_ptr, cmp, cmp_values_ptr, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements indices_ptr [out] Array of index values of elements that meet the condition status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_values_ptr [in] Comparison value array res_out_ptr [out] The number of elements that meet the comparison condition Return Value - No return value. -
aclshmem_{TYPE}_test — Check whether a single element meets the comparison condition
ivar cmp cmp_value. This is a non-blocking query API.def aclshmem_{TYPE}_test(ivar, cmp, cmp_value, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivar [in] Pointer to the signal variable in the symmetric memory cmp [in] Comparison operator cmp_value [in] Comparison value res_out_ptr [out] If the condition is met, 1is returned. Otherwise,0is returned.Return Value - No return value. The result is returned through res_out_ptr. -
aclshmem_{TYPE}_test_any — Check whether at least one element in the array meets the comparison condition
ivars[i] cmp cmp_value. This is a non-blocking query API.def aclshmem_{TYPE}_test_any(ivars_ptr, nelems, status_ptr, cmp, cmp_value, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_value [in] Comparison value res_out_ptr [out] Index of the element that meets the condition. If no element meets the condition or the test dataset is empty, SIZE_MAXis returned.Return Value - No return value. The result is returned through res_out_ptr. -
aclshmem_{TYPE}_test_some — Check whether at least one element in the array meets the comparison condition and return the index values of all elements that meet the condition. This is a non-blocking query API.
def aclshmem_{TYPE}_test_some(ivars_ptr, nelems, indices_ptr, status_ptr, cmp, cmp_value, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements indices_ptr [out] Array of index values of elements that meet the condition status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_value [in] Comparison value res_out_ptr [out] The number of elements that meet the condition. If the test dataset is empty, 0is returned.Return Value - No return value. The result is returned through res_out_ptrandindices_ptr. -
aclshmem_{TYPE}_test_all_vector — Check whether all elements in the array meet the vector comparison condition
ivars[i] cmp cmp_values[i]. This is a non-blocking query API.def aclshmem_{TYPE}_test_all_vector(ivars_ptr, nelems, status_ptr, cmp, cmp_values_ptr, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_values_ptr [in] Comparison value array res_out_ptr [out] If all elements meet the condition or nelemsis0,1is returned. Otherwise,0is returned.Return Value - No return value. The result is returned through res_out_ptr. -
aclshmem_{TYPE}_test_any_vector — Check whether at least one element in the array meets the vector comparison condition
ivars[i] cmp cmp_values[i]. This is a non-blocking query API.def aclshmem_{TYPE}_test_any_vector(ivars_ptr, nelems, status_ptr, cmp, cmp_values_ptr, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_values_ptr [in] Comparison value array res_out_ptr [out] Index of the first element that meets the condition. If no element meets the condition or the test dataset is empty, SIZE_MAXis returned.Return Value - No return value. The result is returned through res_out_ptr. -
aclshmem_{TYPE}_test_some_vector — Check whether at least one element in the array meets the vector comparison condition and return the indexes of all elements that meet the condition. This is a non-blocking query API.
def aclshmem_{TYPE}_test_some_vector(ivars_ptr, nelems, indices_ptr, status_ptr, cmp, cmp_values_ptr, res_out_ptr) -> NoneParameter/Return Value Direction Meaning TYPE - Data type. Supported type: float,int8,int16,int32,int64,uint8,uint16,uint32,uint64, orcharivars_ptr [in] Array with a length of nelemsin symmetric memorynelems [in] The number of array elements indices_ptr [out] Array of index values of elements that meet the condition status_ptr [in] Optional local mask array. The value 0indicates that the mask is not used.cmp [in] Comparison operator cmp_values_ptr [in] Comparison value array res_out_ptr [out] The number of elements that meet the condition. If the test dataset is empty, 0is returned.Return Value - No return value. The result is returned through res_out_ptrandindices_ptr. -
aclshmemx_putmem_on_stream — Copy contiguous data from the local PE to the symmetric address of a specified PE through a specified stream. This is a non-blocking API.
def aclshmemx_putmem_on_stream(dst, src, elem_size, pe, stream) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the symmetric address of the remote PE src [in] Pointer to the local source data memory elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID stream [in] Integer ACL stream address; pass 0for the default stream.Noneis not accepted.Return Value - No return value. -
aclshmemx_getmem_on_stream — Copy contiguous data from the symmetric memory of a specified PE to the local PE through a specified stream. This is a non-blocking API.
def aclshmemx_getmem_on_stream(dst, src, elem_size, pe, stream) -> NoneParameter/Return Value Direction Meaning dst [in] Pointer to the local target memory src [in] Pointer to the symmetric address of the remote PE elem_size [in] Total number of bytes of elements in the target and source addresses pe [in] Remote PE ID stream [in] Integer ACL stream address; pass 0for the default stream.Noneis not accepted.Return Value - No return value. -
aclshmemx_signal_op_on_stream — Enqueue a remote signal update on the supplied stream. The host call returns immediately; synchronize that stream before observing completion.
def aclshmemx_signal_op_on_stream(sig, signal, sig_op, pe, stream) -> NoneParameter/Return Value Direction Meaning sig [in] Local address of the signal variable that can be accessed on the target PE signal [in] Value used for atomic operations sig_op [in] Operation performed on a remote signal. Supported operation: SIGNAL_SET/SIGNAL_ADDpe [in] Remote PE ID stream [in] Integer ACL stream address; pass 0for the default stream.Noneis not accepted.Return Value - No return value. -
aclshmemx_signal_wait_until_on_stream — Enqueue a signal-condition wait on the supplied stream. The host call returns immediately; synchronize that stream before assuming the condition has been satisfied.
def aclshmemx_signal_wait_until_on_stream(sig, cmp, cmp_val, stream) -> NoneParameter/Return Value Direction Meaning sig [in] Local address of the source signal variable cmp [in] Comparison operator. Supported comparison operator: CMP_EQ/CMP_NE/CMP_GT/CMP_GE/CMP_LT/CMP_LEcmp_val [in] Value to be compared with the value pointed to by sigstream [in] ACL stream object, which is used for sorting. A valid stream must be passed. Return Value - No return value. -
aclshmemx_quiet_on_stream — Enqueue a completion point so that symmetric-data operations previously issued by the calling context finish before that point on the supplied stream. The host call returns immediately; synchronize the stream before observing completion.
def aclshmemx_quiet_on_stream(stream) -> NoneParameter/Return Value Direction Meaning stream [in] Integer ACL stream address for the quiet operation; pass 0for the default stream.Noneis not accepted.Return Value - No return value.
Extended Host API Bindings
The following APIs expose the same operations as their Host counterparts. Address and stream parameters are represented by non-bool integers; 0 selects the default stream, and a nonzero stream must remain valid during the call. Entries with collective semantics state their participant set, matching-order requirement, and completion condition explicitly.
-
aclshmemx_finalize — Finalize a specified SHMEM instance and release its resources.
def aclshmemx_finalize(instance_id: int) -> intParameter/Return Value Direction Meaning instance_id [in] Instance ID; accepts only non-bool integers from 0 to 254 Return Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmemx_set_qp_num — Configure the number of QPs created per peer connection before initialization.
def aclshmemx_set_qp_num(engine: OpEngineType, qp_num: int) -> intThe process-wide setting must be identical on every PE.
qp_nummust be in the range[1, ACLSHMEM_MAX_QP_NUM]; unsupported engines or backends returnACLSHMEM_NOT_SUPPORTED. -
aclshmemx_set_attr_uniqueid_args — Populate an
InitAttrobject from unique-ID initialization arguments.def aclshmemx_set_attr_uniqueid_args(my_pe: int, n_pes: int, local_mem_size: int, uid: UniqueId, attr: InitAttr) -> intParameter/Return Value Direction Meaning my_pe [in] Current PE ID satisfying 0 <= my_pe < n_pesn_pes [in] Total number of PEs in the instance local_mem_size [in] Local symmetric-memory size per PE in bytes uid [in] UniqueIdused for initialization; after success, the populatedattrremains usable even if the originaluidvariable is deletedattr [in/out] InitAttrobject to populateReturn Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmemx_init_attr — Initialize a SHMEM instance from an initialization mode and
InitAttr. This is a collective operation.def aclshmemx_init_attr(bootstrap_flags: InitMode, attributes: InitAttr) -> intParameter/Return Value Direction Meaning bootstrap_flags [in] Initialization method; use InitMode.UNIQUEIDfor UID multi-instance initializationattributes [in] Initialization attributes containing PE, memory, instance-ID, and engine options Return Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmemx_instance_ctx_get — Obtain a value snapshot of the active instance context.
def aclshmemx_instance_ctx_get() -> Optional[InstanceContext]Parameter/Return Value Direction Meaning Return Value [out] InstanceContextsnapshot containing the current instance ID, orNoneif unavailable -
aclshmemx_instance_ctx_set — Switch the active runtime context to a specified instance.
def aclshmemx_instance_ctx_set(instance_id: int) -> intParameter/Return Value Direction Meaning instance_id [in] Target instance ID; accepts only non-bool integers from 0 to 254 Return Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmemx_malloc — Allocate memory from a selected symmetric heap. This is a collective operation.
def aclshmemx_malloc(size: int, mem_type: MemType=MemType.DEVICE_SIDE) -> intParameter/Return Value Direction Meaning size [in] Allocation size in bytes mem_type [in] Symmetric heap type; default is MemType.DEVICE_SIDEReturn Value [out] Integer address on success or 0 on failure -
aclshmemx_calloc — Allocate and zero memory from a selected symmetric heap. This is a collective operation.
def aclshmemx_calloc(count: int, size: int, mem_type: MemType=MemType.DEVICE_SIDE) -> intParameter/Return Value Direction Meaning count [in] Number of elements size [in] Size of one element in bytes mem_type [in] Symmetric heap type; default is MemType.DEVICE_SIDEReturn Value [out] Integer address of zero-initialized memory on success or 0 on failure -
aclshmemx_align — Allocate aligned memory from a selected symmetric heap. This is a collective operation.
def aclshmemx_align(alignment: int, size: int, mem_type: MemType=MemType.DEVICE_SIDE) -> intParameter/Return Value Direction Meaning alignment [in] Alignment in bytes satisfying native alignment requirements size [in] Allocation size in bytes mem_type [in] Symmetric heap type; default is MemType.DEVICE_SIDEReturn Value [out] Aligned integer address on success or 0 on failure -
aclshmemx_free — Free memory from a selected symmetric heap. This is a collective operation.
def aclshmemx_free(ptr: int, mem_type: MemType=MemType.DEVICE_SIDE) -> NoneParameter/Return Value Direction Meaning ptr [in] Integer address returned by the corresponding allocation API mem_type [in] Symmetric heap type, which must match the allocation Return Value - No return value -
aclshmemx_set_mte_config — Configure the MTE UB workspace and synchronization ID.
def aclshmemx_set_mte_config(offset: int, ub_size: int, sync_id: int) -> intParameter/Return Value Direction Meaning offset [in] UB offset ub_size [in] UB size sync_id [in] Synchronization ID Return Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmemx_set_sdma_config — Configure the SDMA UB workspace and synchronization ID.
def aclshmemx_set_sdma_config(offset: int, ub_size: int, sync_id: int) -> intParameter/Return Value Direction Meaning offset [in] UB offset ub_size [in] UB size sync_id [in] Synchronization ID Return Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmemx_set_rdma_config — Configure the RDMA UB workspace and synchronization ID.
def aclshmemx_set_rdma_config(offset: int, ub_size: int, sync_id: int) -> intParameter/Return Value Direction Meaning offset [in] UB offset ub_size [in] UB size, at least 128 bytes sync_id [in] Synchronization ID Return Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmemx_set_udma_config — Configure the UDMA UB workspace and synchronization ID.
def aclshmemx_set_udma_config(offset: int, ub_size: int, sync_id: int) -> intParameter/Return Value Direction Meaning offset [in] UB offset ub_size [in] UB size, at least 128 bytes sync_id [in] Synchronization ID Return Value [out] Returns ACLSHMEM_SUCCESSon success or a native error code on failure -
aclshmem_barrier — Block the host until all PEs in a specified team reach the barrier. This is a collective operation.
def aclshmem_barrier(team: int) -> NoneParameter/Return Value Direction Meaning team [in] Currently live team ID in the range 0 to 2047 Return Value - No return value; an invalid or stale team raises ValueError -
aclshmem_barrier_all — Block the host until all PEs in the world team reach the barrier. This is a collective operation.
def aclshmem_barrier_all() -> NoneParameter/Return Value Direction Meaning Return Value - No return value -
aclshmem_sync — Synchronize all PEs in a specified team. This is a collective operation.
def aclshmem_sync(team: int) -> NoneParameter/Return Value Direction Meaning team [in] Currently live team ID in the range 0 to 2047 Return Value - No return value; an invalid or stale team raises ValueError -
aclshmem_sync_all — Synchronize all PEs in the world team. This is a collective operation.
def aclshmem_sync_all() -> NoneParameter/Return Value Direction Meaning Return Value - No return value -
aclshmemx_barrier_on_stream — Enqueue a barrier for a specified team on an ACL stream.
def aclshmemx_barrier_on_stream(team: int, stream: int) -> NoneParameter/Return Value Direction Meaning team [in] Currently live team ID in the range 0 to 2047 stream [in] Integer aclrtStreamaddress;0selects the default streamReturn Value - No return value; an invalid or stale team raises ValueError -
aclshmemx_barrier_all_on_stream — Enqueue a world-team barrier on an ACL stream.
def aclshmemx_barrier_all_on_stream(stream: int) -> NoneParameter/Return Value Direction Meaning stream [in] Integer aclrtStreamaddress;0selects the default streamReturn Value - No return value -
aclshmemx_handle_wait — Enqueue a completion wait and member rendezvous for the Handle's team on the supplied stream. Every PE in that team must participate in matching order after issuing the asynchronous operations to be covered; only a world-team Handle requires every PE. The host call only enqueues the operation, so synchronize the stream before observing completion.
def aclshmemx_handle_wait(handle: Handle, stream: int) -> NoneParameter/Return Value Direction Meaning handle [in] Handlebound to a currently active team; that team defines the participating PEsstream [in] Integer aclrtStreamaddress;0selects the default streamReturn Value - No return value; a stale team in the Handle raises ValueError. Mismatched participation or call order can wait indefinitely -
aclshmemx_get_prof — Obtain a deep copy of profiling data for the current instance and PE.
def aclshmemx_get_prof(verbose: bool=False) -> Optional[ProfData]Parameter/Return Value Direction Meaning verbose [in] Whether to also print profiling data; default is FalseReturn Value [out] Returns ProfDataon the selected PE orNonewhen unavailable; data is isolated per instance -
aclshmemx_show_prof — Print profiling data for the current instance.
def aclshmemx_show_prof() -> NoneParameter/Return Value Direction Meaning Return Value - No return value
Class
-
OpEngineType enumeration class — Data transfer engine types
class OpEngineType(Enum): MTE SDMA ROCE UDMAEnumerated Value Meaning MTE Memory Transfer Engine SDMA System DMA ROCE RDMA over Converged Ethernet UDMA Unified DMA -
MemType enumeration class — Symmetric memory allocation location
class MemType(Enum): HOST_SIDE DEVICE_SIDEEnumerated Value Meaning HOST_SIDE Host-side memory DEVICE_SIDE Device-side memory (default) -
OptionalAttr class — Optional attribute configurations for initialization
class OptionalAttr: def __init__(self):Attribute Direction Meaning version [in] Configuration version data_op_engine_type [in] Data transfer engine type (an enumerated value of OpEngineType)shm_init_timeout [in] Timeout period of the init operation shm_create_timeout [in] Timeout period of the create operation control_operation_timeout [in] Timeout period of the control operation sockFd [in] Socket file descriptor. The default value is -1. -
InitAttr class — Attribute configurations for initialization
class InitAttr: def __init__(self):Attribute Direction Meaning my_rank [in] PE ID of the current process n_ranks [in] Total number of PEs ip_port [in] IP address and port number of the communication server local_mem_size [in] Size of the symmetric memory allocated to the current PE, in bytes option_attr [in] OptionalAttroptional attribute configurationsinstance_id [in] Multi-instance ID; the binding accepts only non-bool integers from 0 to 254. The default is 0. -
TeamConfig class — Team configurations
class TeamConfig:Attribute Direction Meaning num_contexts [in] The number of contexts that can run simultaneously in a team -
UniqueId class — Unique identifier handle for UID initialization
class UniqueId: def __init__(self):Attribute Direction Meaning version [out] Version my_pe [out] PE ID of the current process n_pes [out] Total number of PEs of all processes internal [out] Internal information about the UID (bytes) to_bytes()[out] Serialize the UID using the exact native structure size from_bytes(data)[in] Restore a UID from an exactly sized byte string -
InitStatus enumeration class — Initialization statuses of the shared memory module
class InitStatus(Enum): NOT_INITIALIZED SHM_CREATED INITIALIZED INVALIDEnumerated Value Meaning NOT_INITIALIZED Not initialized SHM_CREATED Shared memory created INITIALIZED Initialization completed INVALID Invalid -
SignalOp enumeration class — Atomic operation types of signal variables
class SignalOp(Enum): SIGNAL_SET SIGNAL_ADDEnumerated Value Meaning SIGNAL_SET Atomic setting: writes a given value to a remote signal. SIGNAL_ADD Atomic addition: adds a given value to the existing value of a remote signal. -
CmpOp enumeration class — Signal comparison operation types
class CmpOp(Enum): CMP_EQ CMP_NE CMP_GT CMP_GE CMP_LT CMP_LEEnumerated Value Meaning CMP_EQ Equal to (==) CMP_NE Not equal to (!=) CMP_GT Greater than (>) CMP_GE Greater than or equal to (>=) CMP_LT Less than (<) CMP_LE Less than or equal to (<=) -
InstanceContext class — Read-only value snapshot of the active instance context.
class InstanceContext: @property def id(self) -> int:Attribute Direction Meaning id [out] Read-only instance ID -
Handle class — Constructible team-scoped asynchronous-operation handle.
class Handle: def __init__(self, team_id: int=ACLSHMEM_TEAM_WORLD) -> None: @property def team_id(self) -> int:Attribute/Parameter Direction Meaning team_id [in/out] Team ID; defaults to ACLSHMEM_TEAM_WORLDand must refer to a currently live team in the range 0 to 2047 on construction and assignment -
ProfData class — Deep-copy snapshot of profiling data for the current PE.
class ProfData: @property def pe_id(self) -> int: @property def ccount(self) -> list[list[int]]: @property def cycles(self) -> list[list[int]]:Attribute Direction Meaning pe_id [out] Read-only PE ID associated with the profiling data ccount [out] Read-only 64 x 1024two-dimensional integer list of countscycles [out] Read-only 64 x 1024two-dimensional integer list of cycles -
InitMode enumeration class — Initialization methods used by
aclshmemx_init_attr.class InitMode(Enum): DEFAULT MPI UNIQUEIDEnumerated Value Meaning DEFAULT Use the default initialization method MPI Use MPI initialization UNIQUEID Use unique-ID initialization, including multi-instance initialization
Python API Constraints and Limitations
buffer/calloc/align/free,barrier/sync, initialization, and finalization have collective semantics. All participating PEs must call them with matching parameters and in the same order. Usetorchrunand an external timeout to detect mismatches or deadlocks.barriercompletes host-issued communication. To wait on NPU-issued operations from the host, synchronize the relevant ACL stream or use the stream barrier APIs.- Stream APIs enqueue work without implicit synchronization. High-level APIs reject bool, negative, and non-integer values;
0represents the default stream. A nonzero stream integer must identify a live ACL stream for the duration of the call. - Public
Bufferconstruction rejects zero addresses, bool values, negative values, and arguments beyond the current platform's address or length limits. A Buffer with an allocation instance can only be used for peer lookup, RMA/Signal, and free while that instance is active; cross-instance use raisesAclshmemInvalid. handle_waitparticipation is scoped to the Handle's team, and every team member must call it in matching order. The operation is only enqueued; synchronize the corresponding stream before observing completion.- The runtime chooses the stream-RMA transport path from initialization, target-PE, and platform capabilities; callers must not rely on a particular engine being selected for an individual call.
signal_waitwaits on a local address and does not provide remote-wait semantics. - Multi-instance mode currently supports at most 255 instances. High-level APIs and corresponding low-level entry points accept only non-bool
instance_idvalues from 0 to 254. Each instance heap is limited to 128 GB; nonzero instances retain only the world team and do not support advanced team split/translate/get-config operations. - The
HOST_SIDEsymmetric heap requires a CANN runtime withHAS_ACLRT_MEM_FABRIC_HANDLE; otherwise allocation fails and the high-level API raisesAclshmemError.
shmem API (Python Top-Level Wrapper)
The following Tensor APIs are available from the shmem package top level and can be called as shmem.<API name>. They create and release Tensors in symmetric memory and maintain their metadata; callers must follow the collective-participation and lifetime requirements stated for each entry.
External APIs
-
aclshmem_create_tensor — Allocate a torch.Tensor of a specified shape and data type on the symmetric memory. This is a collective operation. It calls
aclshmem_mallocinternally, so all PEs must participate in the call in the same order, and the shape/dtype (that is, the equivalent memory size) allocated by each PE must be the same. Otherwise, the symmetric heap layout will be corrupted.def aclshmem_create_tensor(shape, dtype: torch.dtype=torch.float32, device_id=0) -> torch.TensorParameter/Return Value Direction Meaning shape [in] Tensor shape, for example, (2, 3)dtype [in] Tensor data type ( torch.dtype). The default value istorch.float32device_id [in] NPU device ID. The default value is 0Return Value [out] torch.Tensorcreated on the symmetric memory. If the allocation fails, an exception is thrown. -
aclshmem_free_tensor — Release the symmetric memory corresponding to the tensor allocated by
aclshmem_create_tensor. This is a collective operation. It callsaclshmem_freeinternally, so all PEs must participate in the call in the same order as the allocation. After the release is complete, do not access the tensor or its address again.def aclshmem_free_tensor(tensor: torch.Tensor) -> NoneParameter/Return Value Direction Meaning tensor [in] Symmetric memory tensor to be released Return Value - No return value.