Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

fix: substract overflow error for decentralized op #39

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ impl CommOpTrait for DecentralizedFullPrecisionSynchronous {
"you cannot use decentralized algorithm with average_all off when there are odd number of ranks, current n_ranks {}",
c.nranks
);
let comm_step = step / comm_interval;
let comm_step = (step / comm_interval) as i64;
let rank = c.rank as i64;
let nranks = c.nranks as i64;
let peer_rank = if c.rank < c.nranks / 2 {
((comm_step + c.rank) % ((c.nranks + 1) / 2)) + (c.nranks / 2)
((comm_step + rank) % ((nranks + 1) / 2)) + (nranks / 2)
} else {
(c.rank - (c.nranks / 2) - comm_step).rem_euclid(c.nranks / 2)
(rank - (nranks / 2) - comm_step).rem_euclid(nranks / 2)
} as i32;
tracing::debug!("rank {} peer_rank {}", c.rank, peer_rank);
{
Expand Down