forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* server: first commit * server: quick fix * server: fix building * server: fix launcher * server: add new server logic * common: fix compile warning * server: attempt to fix rdma compile * server: add init_global_env() * server: improve the log * server: improve engine load balance * server: use omp to speed up memcpy (#152) * server: remove recvmap_mu_ * server: avoid global mutex * server: remove recv->merged copy * server: attempt to fix correctness * server: PriorityQueue for server (#153) * server: add priority queue to server * server: quick fix for pq * server: fix compile * server: improve with heap * server: fix disable schedule * server: fix heap sorting correctness * server: another fix of heap correctness * 3rdparty: update pslite * server: improve priority compare * common: disable numa control when not summing locally (#157) * docker: update dockerfile for new server * docker: clean up dockerfiles * docker: refactor and test all (#169) * preliminary refactor for tf * can compile for tf * refactor mxnet and torch * test all * nit * docs: clean examples and update tutorial * docker: quick fix * docs: fix tutorial * docs: update performance * docs: update readme * docs: improve legend in readme
- Loading branch information
Showing
42 changed files
with
1,034 additions
and
1,788 deletions.
There are no files selected for viewing
Submodule ps-lite
updated
5 files
+0 −23 | include/ps/internal/customer.h | |
+13 −406 | src/customer.cc | |
+29 −11 | src/rdma_van.h | |
+1 −1 | src/van.cc | |
+1 −1 | tests/test_kv_app_benchmark.cc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2019 Bytedance Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
|
||
import ctypes | ||
import os | ||
from byteps.common import get_ext_suffix | ||
|
||
dll_path = os.path.join(os.path.dirname(__file__), | ||
'c_lib' + get_ext_suffix()) | ||
SERVER_LIB_CTYPES = ctypes.CDLL(dll_path, ctypes.RTLD_GLOBAL) | ||
SERVER_LIB_CTYPES.byteps_server() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Copyright 2019 Bytedance Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ============================================================================= | ||
|
||
#ifndef BYTEPS_SERVER_QUEUE_H | ||
#define BYTEPS_SERVER_QUEUE_H | ||
|
||
#include <vector> | ||
#include <mutex> | ||
#include <condition_variable> | ||
#include <memory> | ||
#include <algorithm> | ||
|
||
namespace byteps { | ||
namespace server { | ||
|
||
/** | ||
* \brief thread-safe queue allowing push and waited pop | ||
*/ | ||
class PriorityQueue { | ||
public: | ||
PriorityQueue(bool is_schedule) { | ||
enable_schedule_ = is_schedule; | ||
if (enable_schedule_) { | ||
std::make_heap(queue_.begin(), queue_.end(), | ||
[this](const BytePSEngineMessage& a, const BytePSEngineMessage& b) { | ||
return ComparePriority(a, b); | ||
} | ||
); | ||
} | ||
} | ||
~PriorityQueue() { } | ||
|
||
/** | ||
* \brief push an value and sort using heap. threadsafe. | ||
* \param new_value the value | ||
*/ | ||
void Push(BytePSEngineMessage new_value) { | ||
mu_.lock(); | ||
queue_.push_back(std::move(new_value)); | ||
if (enable_schedule_) { | ||
++push_cnt_[new_value.key]; | ||
std::push_heap(queue_.begin(), queue_.end(), | ||
[this](const BytePSEngineMessage& a, const BytePSEngineMessage& b) { | ||
return ComparePriority(a, b); | ||
} | ||
); | ||
} | ||
mu_.unlock(); | ||
cond_.notify_all(); | ||
} | ||
|
||
/** | ||
* \brief wait until pop an element from the beginning, threadsafe | ||
* \param value the poped value | ||
*/ | ||
void WaitAndPop(BytePSEngineMessage* value) { | ||
std::unique_lock<std::mutex> lk(mu_); | ||
cond_.wait(lk, [this]{return !queue_.empty();}); | ||
if (enable_schedule_) { | ||
std::pop_heap(queue_.begin(), queue_.end(), | ||
[this](const BytePSEngineMessage& a, const BytePSEngineMessage& b) { | ||
return ComparePriority(a, b); | ||
} | ||
); | ||
*value = queue_.back(); | ||
queue_.pop_back(); | ||
} else { | ||
*value = std::move(queue_.front()); | ||
queue_.erase(queue_.begin()); | ||
} | ||
} | ||
|
||
void ClearCounter(uint64_t key) { | ||
if (!enable_schedule_) return; | ||
std::unique_lock<std::mutex> lk(mu_); | ||
push_cnt_[key] = 0; | ||
} | ||
|
||
bool ComparePriority(const BytePSEngineMessage& a, const BytePSEngineMessage& b) { | ||
if (push_cnt_[a.key] == push_cnt_[b.key]) { | ||
return (a.id > b.id); | ||
} else { | ||
return (push_cnt_[a.key] > push_cnt_[b.key]); | ||
} | ||
} | ||
|
||
private: | ||
mutable std::mutex mu_; | ||
std::vector<BytePSEngineMessage> queue_; | ||
std::condition_variable cond_; | ||
std::unordered_map<uint64_t, uint64_t> push_cnt_; | ||
volatile bool enable_schedule_ = false; | ||
}; | ||
|
||
} // namespace server | ||
} // namespace byteps | ||
|
||
#endif // BYTEPS_SERVER_QUEUE_H |
Oops, something went wrong.