MCPcopy Create free account
hub / github.com/pytorch/pytorch / barrier

Method barrier

test/distributed/test_c10d_common.py:1538–1555  ·  view source on GitHub ↗
(self, opts=None)

Source from the content-addressed store, hash-verified

1536 return DummyWork()
1537
1538 def barrier(self, opts=None):
1539 store = c10d._get_default_store()
1540 key = "TEST:DummyProcessGroup:barrier"
1541 if self.rank() == 0:
1542 worker_count = 0
1543 # By default, TCPServer lives on rank 0. So rank 0 needs to make
1544 # sure that it does not exit too early before other ranks finish
1545 # using the store.
1546 # Note that, _store_based_barrier does not solve this problem, as
1547 # all ranks need to run at least one store.add(key, 0) before
1548 # exiting, but there is no guarantee that rank 0 is still alive at
1549 # that point.
1550 while worker_count < self.size() - 1:
1551 worker_count = store.add(key, 0)
1552 else:
1553 store.add(key, 1)
1554
1555 return DummyWork()
1556
1557 def broadcast(self, tensor_list, opts=None):
1558 for tensor in tensor_list:

Calls 4

rankMethod · 0.95
sizeMethod · 0.95
DummyWorkClass · 0.85
addMethod · 0.45

Tested by

no test coverage detected