mindspore.communication.comm_func.barrier

mindspore.communication.comm_func.barrier(group=GlobalComm.WORLD_COMM_GROUP)[source]

Synchronizes all processes in the specified group. Once the process call this operation, it will be blocked until all processes call this operation. After all processes finish calling the operations, the blocked processes will be woken and continue their task.

Parameters

group (str, optional) – The communication group to work on. Default: GlobalComm.WORLD_COMM_GROUP.

Raises

RuntimeError – If backend is invalid, or distributed initialization fails.

Supported Platforms:

Ascend

Examples

Note

Before running the following examples, you need to configure the communication environment variables.

For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method without any third-party or configuration file dependencies. Please see the msrun start up for more details.

This example should be run with 2 devices.

>>> from mindspore.communication import init
>>> from mindspore.communication.comm_func import barrier
>>> # Launch 2 processes.
>>> init()
>>> barrier()
Tutorial Examples: