Skip to content

Commit

Permalink
[kvstore] bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mli committed Oct 20, 2015
1 parent 55694dd commit a2f4750
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ps-lite
11 changes: 6 additions & 5 deletions src/kvstore/kvstore_dist.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,17 @@ class KVStoreDist : public KVStoreLocal {
const NDArray& merged = MergePushValue(key, grouped_vals[i], priority);

// push to servers
auto push_to_servers =
auto push_to_servers =
[this, key, merged](RunContext rctx, Engine::CallbackOnComplete cb) {
// convert to ps keys
// convert to ps keys
size_t size = merged.shape().Size();
PSKV& pskv = EncodeKey(key, size);

// do push
real_t* data = static_cast<real_t*>(merged.data().dptr_);
ps::SArray<real_t> vals(data, size, false); // false means no delete
CHECK_NOTNULL(ps_worker_)->ZPush(
// false means no delete
ps::SArray<real_t> vals(data, size, false);
CHECK_NOTNULL(ps_worker_)->ZPush(
pskv.keys, vals, pskv.lens, 0, [cb]() { cb(); });
};
Engine::Get()->PushAsync(
Expand Down Expand Up @@ -122,7 +123,7 @@ CHECK_NOTNULL(ps_worker_)->ZPush(
// issue pull, false means no delete
auto vals = new ps::SArray<real_t>(data, size, false);
CHECK_NOTNULL(ps_worker_)->ZPull(
pskv.keys, vals, &pskv.lens, 0, [vals, cb](){ delete vals; cb(); });
pskv.keys, vals, &pskv.lens, 0, [vals, cb](){ delete vals; cb(); });
};

CHECK_NOTNULL(Engine::Get())->PushAsync(
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/kvstore_dist_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class KVStoreDistServer {
int key = DecodeKey(req_data.keys[0]);
auto& stored = store_[key];

// there are several WaitToRead here, this is because \a recved's memory
// there used several WaitToRead, this is because \a recved's memory
// could be deallocated when this function returns. so we need to make sure
// the operators with \a NDArray are actually finished
if (req_meta.push) {
Expand Down

0 comments on commit a2f4750

Please sign in to comment.