Skip to content

Commit

Permalink
use GradientMachine::start and finish
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesqiao committed Jun 26, 2017
1 parent 55684af commit 9f05a0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions paddle/gserver/gradientmachines/MultiGradientMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,16 @@ MultiGradientMachine::MultiGradientMachine(const ModelConfig& config,

outArgStream_ = HPPL_STREAM_1;

start();
}

void MultiGradientMachine::start() {
for (auto& thread : threads_) {
thread->start();
}
}

MultiGradientMachine::~MultiGradientMachine() {
void MultiGradientMachine::finish() {
for (auto& thread : threads_) {
thread->stop();
}
Expand Down Expand Up @@ -445,14 +449,18 @@ TrainerThread::TrainerThread(const ModelConfig& config,

gradStream_ = HPPL_STREAM_2;
valueStream_ = HPPL_STREAM_3;
stopping_ = false;
stopping_ = true;
updateCounter_ = 0;
parameterUpdated_ = false;
}

TrainerThread::~TrainerThread() { stop(); }

void TrainerThread::start() {
if (!stopping_) return;

stopping_ = false;

gradientMachine_->start();

computeThread_.reset(new std::thread([this]() { computeThread(); }));
Expand Down
4 changes: 3 additions & 1 deletion paddle/gserver/gradientmachines/MultiGradientMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ class MultiGradientMachine : public GradientMachine {

explicit MultiGradientMachine(const ModelConfig& config, bool useGpu);

virtual ~MultiGradientMachine();
virtual void start();

virtual void finish();

virtual void prefetch(const std::vector<Argument>& inArgs);

Expand Down

0 comments on commit 9f05a0f

Please sign in to comment.