Skip to content

Commit

Permalink
fix: substract overflow error for decentralized op (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangraying authored Jul 16, 2021
1 parent 1a072a4 commit 54f2ad1
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit 54f2ad1

Please sign in to comment.