implement shared memory hogwild. update param at worker side
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/806826eb Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/806826eb Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/806826eb Branch: refs/heads/master Commit: 806826eb1877ef33d6b9b231f3c206300ec36ab1 Parents: b9680a2 Author: wang wei <[email protected]> Authored: Tue Jun 9 20:16:46 2015 +0800 Committer: wang wei <[email protected]> Committed: Tue Jun 9 20:16:46 2015 +0800 ---------------------------------------------------------------------- examples/cifar10/cluster.conf | 4 +- examples/cifar10/model.conf | 12 +- include/trainer/worker.h | 2 + include/utils/param.h | 49 +-- src/proto/cluster.pb.h | 136 ++----- src/proto/model.pb.h | 811 ++++++++++--------------------------- src/trainer/trainer.cc | 40 +- src/trainer/worker.cc | 22 +- src/utils/param.cc | 110 +++++ 9 files changed, 432 insertions(+), 754 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/806826eb/examples/cifar10/cluster.conf ---------------------------------------------------------------------- diff --git a/examples/cifar10/cluster.conf b/examples/cifar10/cluster.conf index 97c64fd..734350d 100644 --- a/examples/cifar10/cluster.conf +++ b/examples/cifar10/cluster.conf @@ -1,6 +1,6 @@ -nworker_groups: 1 +nworker_groups: 4 nserver_groups: 1 nservers_per_group: 1 nworkers_per_group: 1 -nworkers_per_procs: 1 +nworkers_per_procs: 4 workspace: "examples/cifar10/" http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/806826eb/examples/cifar10/model.conf ---------------------------------------------------------------------- diff --git a/examples/cifar10/model.conf b/examples/cifar10/model.conf index 72ebf8e..c809e06 100644 --- a/examples/cifar10/model.conf +++ b/examples/cifar10/model.conf @@ -1,10 +1,11 @@ name: "cifar10-convnet" -train_steps: 70000 +train_steps: 60000 test_steps:100 test_frequency:1000 -display_frequency:30 +display_frequency:100 +hogwild: true updater{ - momentum:0.9 + momentum:0.0 weight_decay:0.004 learning_rate_change_method:kFixedStep step:0 @@ -21,7 +22,8 @@ layer{ type: "kShardData" data_param { path: "examples/cifar10/cifar10_train_shard" - batchsize: 128 + batchsize: 16 + random_skip: 10000 } exclude: kTest } @@ -30,7 +32,7 @@ layer{ type: "kShardData" data_param { path: "examples/cifar10/cifar10_test_shard" - batchsize: 128 + batchsize: 100 } exclude: kTrain } http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/806826eb/include/trainer/worker.h ---------------------------------------------------------------------- diff --git a/include/trainer/worker.h b/include/trainer/worker.h index 87be83b..09262e6 100644 --- a/include/trainer/worker.h +++ b/include/trainer/worker.h @@ -5,6 +5,7 @@ #include "neuralnet/neuralnet.h" #include "proto/model.pb.h" #include "utils/cluster.h" +#include "utils/updater.h" #include "communication/socket.h" #include "communication/msg.h" @@ -148,6 +149,7 @@ class Worker { shared_ptr<NeuralNet> train_net_, test_net_, validation_net_; shared_ptr<Dealer> layer_dealer_, param_dealer_; Poller layer_poller_, param_poller_; + shared_ptr<Updater> updater_; }; class BPWorker: public Worker{ http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/806826eb/include/utils/param.h ---------------------------------------------------------------------- diff --git a/include/utils/param.h b/include/utils/param.h index 0574b2c..529c349 100644 --- a/include/utils/param.h +++ b/include/utils/param.h @@ -133,39 +133,32 @@ class Param { int fan_in_; }; /** - * Sync with server by randomly sampling some parameters for every sync. -class RandomSyncParam: public Param{ + * To support the shared memory and distributed Hogwild algorithm. + * Each worker group has one worker. Workers from the same process share the + * memory space for parameter values. Each process has one server group which + * also shares the same memory space. Messages except synchronization messages + * only transfer pointers to parameter value or gradient space. Hence memory + * copy is avoided for intra-process communication. + */ +class HogwildParam: public Param{ public: - virtual zmsg_t* HandleSyncMsg(zmsg_t** msg); - virtual zmsg_t *GenSyncMsgFromWorker(float sample_ratio); - virtual void ParseSyncMsgFromPS(zmsg_t** msg); - virtual void Setup(const ParamProto& proto, const vector<int>& shape, int fan_in); - virtual void Init(); - - float* mutable_cpu_snapshot(){ - return snapshot_.mutable_cpu_data(); - } - const float* cpu_snapshot(){ - return snapshot_.cpu_data(); - } + virtual Msg* GenGetMsg(void* arg=nullptr); + virtual Msg* GenPutMsg(void* arg=nullptr); + virtual Msg* GenUpdateMsg(void* arg=nullptr); + virtual Msg* GenSyncMsg(void* arg=nullptr); - protected: - const vector<int> RandomSample(int seed, int m, int n); + virtual Msg* HandleGetMsg(Msg** msg); + virtual Msg* HandlePutMsg(Msg** msg); + virtual int ParseUpdateMsg(Msg** msg); + virtual Msg* GenUpdateResponseMsg(void* arg=nullptr); + virtual Msg* HandleSyncMsg(Msg** msg); + virtual int ParseGetResponseMsg(Msg** msg); + virtual int ParsePutResponseMsg(Msg** msg); + virtual int ParseUpdateResponseMsg(Msg** msg); + virtual int ParseSyncResponseMsg(Msg** msg); - Blob<float> snapshot_; }; - */ -/** - * Sync with server by elastic SGD see http://arxiv.org/abs/1412.6651. -class ElasticParam: public Param{ - public: - virtual zmsg_t* HandleSyncMsg(zmsg_t** msg); - virtual zmsg_t *GenSyncMsgFromWorker(float moving_rate); - virtual void ParseSyncMsgFromPS(zmsg_t** msg); -}; - */ - } // namespace singa http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/806826eb/src/proto/cluster.pb.h ---------------------------------------------------------------------- diff --git a/src/proto/cluster.pb.h b/src/proto/cluster.pb.h index 7468c31..564be1f 100644 --- a/src/proto/cluster.pb.h +++ b/src/proto/cluster.pb.h @@ -8,12 +8,12 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 2006000 +#if GOOGLE_PROTOBUF_VERSION < 2005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 2006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -85,6 +85,7 @@ class ClusterProto : public ::google::protobuf::Message { void SharedDtor(); void SetCachedSize(int size) const; public: + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -272,8 +273,6 @@ class ClusterProto : public ::google::protobuf::Message { ::google::protobuf::UnknownFieldSet _unknown_fields_; - ::google::protobuf::uint32 _has_bits_[1]; - mutable int _cached_size_; ::google::protobuf::int32 nworker_groups_; ::google::protobuf::int32 nserver_groups_; ::google::protobuf::int32 nworkers_per_group_; @@ -287,11 +286,15 @@ class ClusterProto : public ::google::protobuf::Message { ::std::string* log_dir_; ::google::protobuf::int32 start_port_; ::google::protobuf::int32 stub_timeout_; - static ::std::string* _default_zookeeper_host_; ::std::string* zookeeper_host_; + static ::std::string* _default_zookeeper_host_; ::google::protobuf::RepeatedPtrField< ::singa::ServerTopology > server_group_; ::google::protobuf::int32 worker_timeout_; ::google::protobuf::int32 server_timeout_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(17 + 31) / 32]; + friend void protobuf_AddDesc_cluster_2eproto(); friend void protobuf_AssignDesc_cluster_2eproto(); friend void protobuf_ShutdownFile_cluster_2eproto(); @@ -348,6 +351,7 @@ class ServerTopology : public ::google::protobuf::Message { void SharedDtor(); void SetCachedSize(int size) const; public: + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- @@ -389,11 +393,13 @@ class ServerTopology : public ::google::protobuf::Message { ::google::protobuf::UnknownFieldSet _unknown_fields_; - ::google::protobuf::uint32 _has_bits_[1]; - mutable int _cached_size_; ::google::protobuf::int32 id_; ::google::protobuf::int32 sync_interval_; ::google::protobuf::RepeatedField< ::google::protobuf::int32 > neighbor_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; + friend void protobuf_AddDesc_cluster_2eproto(); friend void protobuf_AssignDesc_cluster_2eproto(); friend void protobuf_ShutdownFile_cluster_2eproto(); @@ -423,13 +429,11 @@ inline void ClusterProto::clear_nworker_groups() { clear_has_nworker_groups(); } inline ::google::protobuf::int32 ClusterProto::nworker_groups() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.nworker_groups) return nworker_groups_; } inline void ClusterProto::set_nworker_groups(::google::protobuf::int32 value) { set_has_nworker_groups(); nworker_groups_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.nworker_groups) } // optional int32 nserver_groups = 2; @@ -447,13 +451,11 @@ inline void ClusterProto::clear_nserver_groups() { clear_has_nserver_groups(); } inline ::google::protobuf::int32 ClusterProto::nserver_groups() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.nserver_groups) return nserver_groups_; } inline void ClusterProto::set_nserver_groups(::google::protobuf::int32 value) { set_has_nserver_groups(); nserver_groups_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.nserver_groups) } // optional int32 nworkers_per_group = 3 [default = 1]; @@ -471,13 +473,11 @@ inline void ClusterProto::clear_nworkers_per_group() { clear_has_nworkers_per_group(); } inline ::google::protobuf::int32 ClusterProto::nworkers_per_group() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.nworkers_per_group) return nworkers_per_group_; } inline void ClusterProto::set_nworkers_per_group(::google::protobuf::int32 value) { set_has_nworkers_per_group(); nworkers_per_group_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.nworkers_per_group) } // optional int32 nservers_per_group = 4 [default = 1]; @@ -495,13 +495,11 @@ inline void ClusterProto::clear_nservers_per_group() { clear_has_nservers_per_group(); } inline ::google::protobuf::int32 ClusterProto::nservers_per_group() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.nservers_per_group) return nservers_per_group_; } inline void ClusterProto::set_nservers_per_group(::google::protobuf::int32 value) { set_has_nservers_per_group(); nservers_per_group_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.nservers_per_group) } // optional int32 nworkers_per_procs = 5 [default = 1]; @@ -519,13 +517,11 @@ inline void ClusterProto::clear_nworkers_per_procs() { clear_has_nworkers_per_procs(); } inline ::google::protobuf::int32 ClusterProto::nworkers_per_procs() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.nworkers_per_procs) return nworkers_per_procs_; } inline void ClusterProto::set_nworkers_per_procs(::google::protobuf::int32 value) { set_has_nworkers_per_procs(); nworkers_per_procs_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.nworkers_per_procs) } // optional int32 nservers_per_procs = 6 [default = 1]; @@ -543,13 +539,11 @@ inline void ClusterProto::clear_nservers_per_procs() { clear_has_nservers_per_procs(); } inline ::google::protobuf::int32 ClusterProto::nservers_per_procs() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.nservers_per_procs) return nservers_per_procs_; } inline void ClusterProto::set_nservers_per_procs(::google::protobuf::int32 value) { set_has_nservers_per_procs(); nservers_per_procs_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.nservers_per_procs) } // optional string hostfile = 10; @@ -563,59 +557,54 @@ inline void ClusterProto::clear_has_hostfile() { _has_bits_[0] &= ~0x00000040u; } inline void ClusterProto::clear_hostfile() { - if (hostfile_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (hostfile_ != &::google::protobuf::internal::kEmptyString) { hostfile_->clear(); } clear_has_hostfile(); } inline const ::std::string& ClusterProto::hostfile() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.hostfile) return *hostfile_; } inline void ClusterProto::set_hostfile(const ::std::string& value) { set_has_hostfile(); - if (hostfile_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (hostfile_ == &::google::protobuf::internal::kEmptyString) { hostfile_ = new ::std::string; } hostfile_->assign(value); - // @@protoc_insertion_point(field_set:singa.ClusterProto.hostfile) } inline void ClusterProto::set_hostfile(const char* value) { set_has_hostfile(); - if (hostfile_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (hostfile_ == &::google::protobuf::internal::kEmptyString) { hostfile_ = new ::std::string; } hostfile_->assign(value); - // @@protoc_insertion_point(field_set_char:singa.ClusterProto.hostfile) } inline void ClusterProto::set_hostfile(const char* value, size_t size) { set_has_hostfile(); - if (hostfile_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (hostfile_ == &::google::protobuf::internal::kEmptyString) { hostfile_ = new ::std::string; } hostfile_->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:singa.ClusterProto.hostfile) } inline ::std::string* ClusterProto::mutable_hostfile() { set_has_hostfile(); - if (hostfile_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (hostfile_ == &::google::protobuf::internal::kEmptyString) { hostfile_ = new ::std::string; } - // @@protoc_insertion_point(field_mutable:singa.ClusterProto.hostfile) return hostfile_; } inline ::std::string* ClusterProto::release_hostfile() { clear_has_hostfile(); - if (hostfile_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (hostfile_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = hostfile_; - hostfile_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + hostfile_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void ClusterProto::set_allocated_hostfile(::std::string* hostfile) { - if (hostfile_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (hostfile_ != &::google::protobuf::internal::kEmptyString) { delete hostfile_; } if (hostfile) { @@ -623,9 +612,8 @@ inline void ClusterProto::set_allocated_hostfile(::std::string* hostfile) { hostfile_ = hostfile; } else { clear_has_hostfile(); - hostfile_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + hostfile_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } - // @@protoc_insertion_point(field_set_allocated:singa.ClusterProto.hostfile) } // optional bool server_worker_separate = 11 [default = false]; @@ -643,13 +631,11 @@ inline void ClusterProto::clear_server_worker_separate() { clear_has_server_worker_separate(); } inline bool ClusterProto::server_worker_separate() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.server_worker_separate) return server_worker_separate_; } inline void ClusterProto::set_server_worker_separate(bool value) { set_has_server_worker_separate(); server_worker_separate_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.server_worker_separate) } // optional int32 nprocs = 12; @@ -667,13 +653,11 @@ inline void ClusterProto::clear_nprocs() { clear_has_nprocs(); } inline ::google::protobuf::int32 ClusterProto::nprocs() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.nprocs) return nprocs_; } inline void ClusterProto::set_nprocs(::google::protobuf::int32 value) { set_has_nprocs(); nprocs_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.nprocs) } // optional int32 start_port = 13 [default = 6723]; @@ -691,13 +675,11 @@ inline void ClusterProto::clear_start_port() { clear_has_start_port(); } inline ::google::protobuf::int32 ClusterProto::start_port() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.start_port) return start_port_; } inline void ClusterProto::set_start_port(::google::protobuf::int32 value) { set_has_start_port(); start_port_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.start_port) } // required string workspace = 14; @@ -711,59 +693,54 @@ inline void ClusterProto::clear_has_workspace() { _has_bits_[0] &= ~0x00000400u; } inline void ClusterProto::clear_workspace() { - if (workspace_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (workspace_ != &::google::protobuf::internal::kEmptyString) { workspace_->clear(); } clear_has_workspace(); } inline const ::std::string& ClusterProto::workspace() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.workspace) return *workspace_; } inline void ClusterProto::set_workspace(const ::std::string& value) { set_has_workspace(); - if (workspace_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (workspace_ == &::google::protobuf::internal::kEmptyString) { workspace_ = new ::std::string; } workspace_->assign(value); - // @@protoc_insertion_point(field_set:singa.ClusterProto.workspace) } inline void ClusterProto::set_workspace(const char* value) { set_has_workspace(); - if (workspace_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (workspace_ == &::google::protobuf::internal::kEmptyString) { workspace_ = new ::std::string; } workspace_->assign(value); - // @@protoc_insertion_point(field_set_char:singa.ClusterProto.workspace) } inline void ClusterProto::set_workspace(const char* value, size_t size) { set_has_workspace(); - if (workspace_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (workspace_ == &::google::protobuf::internal::kEmptyString) { workspace_ = new ::std::string; } workspace_->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:singa.ClusterProto.workspace) } inline ::std::string* ClusterProto::mutable_workspace() { set_has_workspace(); - if (workspace_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (workspace_ == &::google::protobuf::internal::kEmptyString) { workspace_ = new ::std::string; } - // @@protoc_insertion_point(field_mutable:singa.ClusterProto.workspace) return workspace_; } inline ::std::string* ClusterProto::release_workspace() { clear_has_workspace(); - if (workspace_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (workspace_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = workspace_; - workspace_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + workspace_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void ClusterProto::set_allocated_workspace(::std::string* workspace) { - if (workspace_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (workspace_ != &::google::protobuf::internal::kEmptyString) { delete workspace_; } if (workspace) { @@ -771,9 +748,8 @@ inline void ClusterProto::set_allocated_workspace(::std::string* workspace) { workspace_ = workspace; } else { clear_has_workspace(); - workspace_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + workspace_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } - // @@protoc_insertion_point(field_set_allocated:singa.ClusterProto.workspace) } // optional string log_dir = 15; @@ -787,59 +763,54 @@ inline void ClusterProto::clear_has_log_dir() { _has_bits_[0] &= ~0x00000800u; } inline void ClusterProto::clear_log_dir() { - if (log_dir_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (log_dir_ != &::google::protobuf::internal::kEmptyString) { log_dir_->clear(); } clear_has_log_dir(); } inline const ::std::string& ClusterProto::log_dir() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.log_dir) return *log_dir_; } inline void ClusterProto::set_log_dir(const ::std::string& value) { set_has_log_dir(); - if (log_dir_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (log_dir_ == &::google::protobuf::internal::kEmptyString) { log_dir_ = new ::std::string; } log_dir_->assign(value); - // @@protoc_insertion_point(field_set:singa.ClusterProto.log_dir) } inline void ClusterProto::set_log_dir(const char* value) { set_has_log_dir(); - if (log_dir_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (log_dir_ == &::google::protobuf::internal::kEmptyString) { log_dir_ = new ::std::string; } log_dir_->assign(value); - // @@protoc_insertion_point(field_set_char:singa.ClusterProto.log_dir) } inline void ClusterProto::set_log_dir(const char* value, size_t size) { set_has_log_dir(); - if (log_dir_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (log_dir_ == &::google::protobuf::internal::kEmptyString) { log_dir_ = new ::std::string; } log_dir_->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:singa.ClusterProto.log_dir) } inline ::std::string* ClusterProto::mutable_log_dir() { set_has_log_dir(); - if (log_dir_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (log_dir_ == &::google::protobuf::internal::kEmptyString) { log_dir_ = new ::std::string; } - // @@protoc_insertion_point(field_mutable:singa.ClusterProto.log_dir) return log_dir_; } inline ::std::string* ClusterProto::release_log_dir() { clear_has_log_dir(); - if (log_dir_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (log_dir_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = log_dir_; - log_dir_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + log_dir_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void ClusterProto::set_allocated_log_dir(::std::string* log_dir) { - if (log_dir_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) { + if (log_dir_ != &::google::protobuf::internal::kEmptyString) { delete log_dir_; } if (log_dir) { @@ -847,9 +818,8 @@ inline void ClusterProto::set_allocated_log_dir(::std::string* log_dir) { log_dir_ = log_dir; } else { clear_has_log_dir(); - log_dir_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + log_dir_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } - // @@protoc_insertion_point(field_set_allocated:singa.ClusterProto.log_dir) } // optional string zookeeper_host = 16 [default = "localhost:2181"]; @@ -869,7 +839,6 @@ inline void ClusterProto::clear_zookeeper_host() { clear_has_zookeeper_host(); } inline const ::std::string& ClusterProto::zookeeper_host() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.zookeeper_host) return *zookeeper_host_; } inline void ClusterProto::set_zookeeper_host(const ::std::string& value) { @@ -878,7 +847,6 @@ inline void ClusterProto::set_zookeeper_host(const ::std::string& value) { zookeeper_host_ = new ::std::string; } zookeeper_host_->assign(value); - // @@protoc_insertion_point(field_set:singa.ClusterProto.zookeeper_host) } inline void ClusterProto::set_zookeeper_host(const char* value) { set_has_zookeeper_host(); @@ -886,7 +854,6 @@ inline void ClusterProto::set_zookeeper_host(const char* value) { zookeeper_host_ = new ::std::string; } zookeeper_host_->assign(value); - // @@protoc_insertion_point(field_set_char:singa.ClusterProto.zookeeper_host) } inline void ClusterProto::set_zookeeper_host(const char* value, size_t size) { set_has_zookeeper_host(); @@ -894,14 +861,12 @@ inline void ClusterProto::set_zookeeper_host(const char* value, size_t size) { zookeeper_host_ = new ::std::string; } zookeeper_host_->assign(reinterpret_cast<const char*>(value), size); - // @@protoc_insertion_point(field_set_pointer:singa.ClusterProto.zookeeper_host) } inline ::std::string* ClusterProto::mutable_zookeeper_host() { set_has_zookeeper_host(); if (zookeeper_host_ == _default_zookeeper_host_) { zookeeper_host_ = new ::std::string(*_default_zookeeper_host_); } - // @@protoc_insertion_point(field_mutable:singa.ClusterProto.zookeeper_host) return zookeeper_host_; } inline ::std::string* ClusterProto::release_zookeeper_host() { @@ -925,7 +890,6 @@ inline void ClusterProto::set_allocated_zookeeper_host(::std::string* zookeeper_ clear_has_zookeeper_host(); zookeeper_host_ = const_cast< ::std::string*>(_default_zookeeper_host_); } - // @@protoc_insertion_point(field_set_allocated:singa.ClusterProto.zookeeper_host) } // repeated .singa.ServerTopology server_group = 20; @@ -936,25 +900,20 @@ inline void ClusterProto::clear_server_group() { server_group_.Clear(); } inline const ::singa::ServerTopology& ClusterProto::server_group(int index) const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.server_group) return server_group_.Get(index); } inline ::singa::ServerTopology* ClusterProto::mutable_server_group(int index) { - // @@protoc_insertion_point(field_mutable:singa.ClusterProto.server_group) return server_group_.Mutable(index); } inline ::singa::ServerTopology* ClusterProto::add_server_group() { - // @@protoc_insertion_point(field_add:singa.ClusterProto.server_group) return server_group_.Add(); } inline const ::google::protobuf::RepeatedPtrField< ::singa::ServerTopology >& ClusterProto::server_group() const { - // @@protoc_insertion_point(field_list:singa.ClusterProto.server_group) return server_group_; } inline ::google::protobuf::RepeatedPtrField< ::singa::ServerTopology >* ClusterProto::mutable_server_group() { - // @@protoc_insertion_point(field_mutable_list:singa.ClusterProto.server_group) return &server_group_; } @@ -973,13 +932,11 @@ inline void ClusterProto::clear_stub_timeout() { clear_has_stub_timeout(); } inline ::google::protobuf::int32 ClusterProto::stub_timeout() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.stub_timeout) return stub_timeout_; } inline void ClusterProto::set_stub_timeout(::google::protobuf::int32 value) { set_has_stub_timeout(); stub_timeout_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.stub_timeout) } // optional int32 worker_timeout = 31 [default = 5000]; @@ -997,13 +954,11 @@ inline void ClusterProto::clear_worker_timeout() { clear_has_worker_timeout(); } inline ::google::protobuf::int32 ClusterProto::worker_timeout() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.worker_timeout) return worker_timeout_; } inline void ClusterProto::set_worker_timeout(::google::protobuf::int32 value) { set_has_worker_timeout(); worker_timeout_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.worker_timeout) } // optional int32 server_timeout = 32 [default = 5000]; @@ -1021,13 +976,11 @@ inline void ClusterProto::clear_server_timeout() { clear_has_server_timeout(); } inline ::google::protobuf::int32 ClusterProto::server_timeout() const { - // @@protoc_insertion_point(field_get:singa.ClusterProto.server_timeout) return server_timeout_; } inline void ClusterProto::set_server_timeout(::google::protobuf::int32 value) { set_has_server_timeout(); server_timeout_ = value; - // @@protoc_insertion_point(field_set:singa.ClusterProto.server_timeout) } // ------------------------------------------------------------------- @@ -1049,13 +1002,11 @@ inline void ServerTopology::clear_id() { clear_has_id(); } inline ::google::protobuf::int32 ServerTopology::id() const { - // @@protoc_insertion_point(field_get:singa.ServerTopology.id) return id_; } inline void ServerTopology::set_id(::google::protobuf::int32 value) { set_has_id(); id_ = value; - // @@protoc_insertion_point(field_set:singa.ServerTopology.id) } // optional int32 sync_interval = 2; @@ -1073,13 +1024,11 @@ inline void ServerTopology::clear_sync_interval() { clear_has_sync_interval(); } inline ::google::protobuf::int32 ServerTopology::sync_interval() const { - // @@protoc_insertion_point(field_get:singa.ServerTopology.sync_interval) return sync_interval_; } inline void ServerTopology::set_sync_interval(::google::protobuf::int32 value) { set_has_sync_interval(); sync_interval_ = value; - // @@protoc_insertion_point(field_set:singa.ServerTopology.sync_interval) } // repeated int32 neighbor = 3; @@ -1090,25 +1039,20 @@ inline void ServerTopology::clear_neighbor() { neighbor_.Clear(); } inline ::google::protobuf::int32 ServerTopology::neighbor(int index) const { - // @@protoc_insertion_point(field_get:singa.ServerTopology.neighbor) return neighbor_.Get(index); } inline void ServerTopology::set_neighbor(int index, ::google::protobuf::int32 value) { neighbor_.Set(index, value); - // @@protoc_insertion_point(field_set:singa.ServerTopology.neighbor) } inline void ServerTopology::add_neighbor(::google::protobuf::int32 value) { neighbor_.Add(value); - // @@protoc_insertion_point(field_add:singa.ServerTopology.neighbor) } inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& ServerTopology::neighbor() const { - // @@protoc_insertion_point(field_list:singa.ServerTopology.neighbor) return neighbor_; } inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* ServerTopology::mutable_neighbor() { - // @@protoc_insertion_point(field_mutable_list:singa.ServerTopology.neighbor) return &neighbor_; }
