Untitled
unknown
python
6 months ago
762 B
11
Indexable
async def ringallreduce(self, rank: int, inp: T, time: int) -> Tuple[T, int]: # STUDENT CODE START # raise NotImplementedError("RingAllReduce is not implemented yet") q: T = inp rec: T = inp self.mtime = max(time, self.mtime) # total - 1 round for i in range(self.ranks - 1): await self.pass_to((rank + 1) % self.ranks, rec) # pass what you receive to the right, wrap around await self.barrier.wait(rank) # make sure everyone pass rec = await self.receive(rank) q = q + rec # update await self.barrier.wait(rank) # make sure everyone receive and upate before passing in next round mtime = self.mtime if rank == 0: self.mtime = 0 return q, mtime # STUDENT CODE END
Editor is loading...
Leave a Comment