Repository: incubator-singa Updated Branches: refs/heads/master 348c5e54d -> 259422c41
SIGNA-141 Undesired Hash collision when locating process id to workers and servers Circumvent undesired collision in Hash function by adding maximum range from calculating for workers as the offset when calculating for servers. Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/122d3626 Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/122d3626 Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/122d3626 Branch: refs/heads/master Commit: 122d3626b637e3b8b522dd3038acb19d64bad456 Parents: 8d4953a Author: ijingo <[email protected]> Authored: Tue Feb 23 20:00:41 2016 +0800 Committer: ijingo <[email protected]> Committed: Tue Feb 23 20:00:41 2016 +0800 ---------------------------------------------------------------------- src/utils/cluster.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/122d3626/src/utils/cluster.cc ---------------------------------------------------------------------- diff --git a/src/utils/cluster.cc b/src/utils/cluster.cc index 391deee..5a8b87a 100644 --- a/src/utils/cluster.cc +++ b/src/utils/cluster.cc @@ -116,8 +116,10 @@ const vector<int> Cluster::ExecutorRng(int pid, int grp_size, int procs_size) { int Cluster::Hash(int gid, int id, int flag) { int ret = -1; if (flag == kServer) { - ret = (flag * cluster_.nserver_groups() + gid) - * cluster_.nservers_per_group() + id; + ret = kServer * cluster_.nworker_groups() + * cluster_.nworkers_per_group() + + (cluster_.nserver_groups() + gid) + * cluster_.nservers_per_group() + id; } else { ret = (flag * cluster_.nworker_groups() + gid) * cluster_.nworkers_per_group() + id;
