singa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wang...@apache.org
Subject [10/10] incubator-singa git commit: SINGA-21 Code review
Date Wed, 24 Jun 2015 14:33:11 GMT
SINGA-21 Code review

Fix compile warnings and bugs from create_shard.cc of cifar10 example


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/8bf975cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/8bf975cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/8bf975cb

Branch: refs/heads/master
Commit: 8bf975cbc8fc55a69561d0ae59e232a81923a542
Parents: ffa2d66
Author: wang wei <wangwei@comp.nus.edu.sg>
Authored: Wed Jun 24 22:30:17 2015 +0800
Committer: wang wei <wangwei@comp.nus.edu.sg>
Committed: Wed Jun 24 22:30:17 2015 +0800

----------------------------------------------------------------------
 examples/cifar10/create_shard.cc | 1 +
 src/trainer/server.cc            | 1 +
 src/utils/cluster.cc             | 7 ++++---
 src/utils/cluster_rt.cc          | 2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8bf975cb/examples/cifar10/create_shard.cc
----------------------------------------------------------------------
diff --git a/examples/cifar10/create_shard.cc b/examples/cifar10/create_shard.cc
index 75e5abe..9df92d6 100644
--- a/examples/cifar10/create_shard.cc
+++ b/examples/cifar10/create_shard.cc
@@ -19,6 +19,7 @@
 #include "utils/data_shard.h"
 #include "utils/common.h"
 #include "proto/model.pb.h"
+#include "proto/common.pb.h"
 
 using std::string;
 

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8bf975cb/src/trainer/server.cc
----------------------------------------------------------------------
diff --git a/src/trainer/server.cc b/src/trainer/server.cc
index 5662258..04f6040 100644
--- a/src/trainer/server.cc
+++ b/src/trainer/server.cc
@@ -103,6 +103,7 @@ Msg* Server::HandleGet(shared_ptr<Param> param, Msg **msg){
     auto reply= param->HandleGetMsg(msg);
     int paramid=reply->trgt_first(), slice=reply->trgt_second();
     reply->set_trgt(paramid, slice, param->version());
+    return reply;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8bf975cb/src/utils/cluster.cc
----------------------------------------------------------------------
diff --git a/src/utils/cluster.cc b/src/utils/cluster.cc
index 347b98e..035e0c7 100644
--- a/src/utils/cluster.cc
+++ b/src/utils/cluster.cc
@@ -21,7 +21,8 @@ Cluster::Cluster(const ClusterProto &cluster, int procs_id) {
   if(nprocs_>1){
     std::ifstream ifs(cluster.hostfile(), std::ifstream::in);
     std::string line;
-    while(std::getline(ifs, line)&&endpoints_.size()<nprocs_){
+    while(std::getline(ifs, line)
+        &&endpoints_.size()<static_cast<size_t>(nprocs_)){
       endpoints_.push_back(line);
     }
     CHECK_EQ(endpoints_.size(), nprocs_);
@@ -29,7 +30,7 @@ Cluster::Cluster(const ClusterProto &cluster, int procs_id) {
 
   // locate the process id of every worker/server
   int ngrps=cluster_.nworker_groups(), grp_size=cluster_.nworkers_per_group();
-  int procs;
+  int procs=0;
   for(int i=0;i<ngrps;i++){
     for(int j=0;j<grp_size;j++){
       procs=(i*grp_size+j) / cluster_.nworkers_per_procs();
@@ -37,8 +38,8 @@ Cluster::Cluster(const ClusterProto &cluster, int procs_id) {
       procs_ids_[Hash(i,j,kWorkerParam)]=procs;
     }
   }
-  ngrps=cluster_.nserver_groups(), grp_size=cluster_.nservers_per_group();
   int offset=cluster_.server_worker_separate()? procs:0;
+  ngrps=cluster_.nserver_groups(), grp_size=cluster_.nservers_per_group();
   for(int i=0;i<ngrps;i++){
     for(int j=0;j<grp_size;j++){
       procs_ids_[Hash(i,j,kServer)]=(i*grp_size+j) / cluster_.nservers_per_procs()+offset;

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/8bf975cb/src/utils/cluster_rt.cc
----------------------------------------------------------------------
diff --git a/src/utils/cluster_rt.cc b/src/utils/cluster_rt.cc
index bedf714..61911fd 100644
--- a/src/utils/cluster_rt.cc
+++ b/src/utils/cluster_rt.cc
@@ -171,7 +171,7 @@ void ZKClusterRT::ChildChanges(zhandle_t *zh, int type, int state,
 bool ZKClusterRT::CreateZKNode(const char* path, const char* val, int flag,
                                char* output) {
   char buf[kMaxBufLen];
-  int ret;
+  int ret = 0;
   // send the zk request
   for (int i = 0; i < kNumRetry; ++i) {
     ret = zoo_create(zkhandle_, path, val, val == nullptr ? -1 : strlen(val),


Mime
View raw message