Skip to content

Commit

Permalink
misc: strip trailing whitespace (#235)
Browse files Browse the repository at this point in the history
Remove trailing whitespace from all files.

Signed-off-by: Yulu Jia <[email protected]>
  • Loading branch information
pleasantrabbit authored Apr 10, 2020
1 parent 2620851 commit 4a5b5c9
Show file tree
Hide file tree
Showing 29 changed files with 204 additions and 204 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1.
2.
3.
1.
2.
3.
4. See error

**Expected behavior**
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ python3 setup.py install
```

Notes for above two options:
- BytePS assumes that you have already installed one or more of the following frameworks: TensorFlow / PyTorch / MXNet.
- BytePS assumes that you have already installed one or more of the following frameworks: TensorFlow / PyTorch / MXNet.
- BytePS depends on CUDA and NCCL. You should specify the NCCL path with `export BYTEPS_NCCL_HOME=/path/to/nccl`. By default it points to `/usr/local/nccl`.
- The installation requires gcc>=4.9. If you are working on CentOS/Redhat and have gcc<4.9, you can try `yum install devtoolset-7` before everything else. In general, we recommend using gcc 4.9 for best compatibility ([an example](https://github.com/bytedance/byteps/blob/3fba75def0d81c1d3225f8f397cc985200f57de7/docker/Dockerfile.mxnet#L72-L80) to pin gcc).
- RDMA support: During setup, the script will automatically detect the RDMA header file. If you want to use RDMA, make sure your RDMA environment has been properly installed and tested before install ([an example](https://github.com/bytedance/byteps/blob/3fba75def0d81c1d3225f8f397cc985200f57de7/docker/Dockerfile.mxnet#L29-L33) for Ubuntu-18.04).
- RDMA support: During setup, the script will automatically detect the RDMA header file. If you want to use RDMA, make sure your RDMA environment has been properly installed and tested before install ([an example](https://github.com/bytedance/byteps/blob/3fba75def0d81c1d3225f8f397cc985200f57de7/docker/Dockerfile.mxnet#L29-L33) for Ubuntu-18.04).


## Use BytePS in Your Code
Expand Down
2 changes: 1 addition & 1 deletion byteps/common/communicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void BytePSCommSocket::startListenThread() { // only root starts this in
<< ", signal=" << message.signal << ", key=" << message.key
<< ", myrank=" << _local_rank;
}
BPS_LOG(DEBUG) << "listen thread joined"
BPS_LOG(DEBUG) << "listen thread joined"
<< " (rank=" << _local_rank << ")";
}

Expand Down
4 changes: 2 additions & 2 deletions byteps/common/core_loops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void FinishOrProceed(std::shared_ptr<TensorTableEntry> task) {
<< " tensor: " << task->tensor_name
<< " task->key:" << task->key
<< " type:" << this_op;

task->context->part_comm_time[task->key][this_op].back()->dur = (long long)(us.count()) - _ts;
}

Expand All @@ -102,7 +102,7 @@ void FinishOrProceed(std::shared_ptr<TensorTableEntry> task) {
BPS_LOG(TRACE) << "Rank=" << BytePSGlobal::GetRank()
<< " finish processing tensor: " << task->tensor_name;
task->callback(Status::OK());
//* Add for profiling communication events
//* Add for profiling communication events
if (task->context->profile_flag) {
BPS_CHECK(task->context->comm_time.back()->dur == 0)
<< " tensor: " << task->tensor_name
Expand Down
2 changes: 1 addition & 1 deletion byteps/common/cpu_reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int CpuReducer::sum(void* dst, void* src, size_t len, DataType dtype) {
BPS_CHECK(0) << "Unsupported data type: " << dtype;
}
return 0;
}
}

template <typename T>
int CpuReducer::_sum(T* dst, T* src, size_t len) {
Expand Down
32 changes: 16 additions & 16 deletions byteps/common/global.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void BytePSGlobal::Init() {
&_my_role);

_is_root_device = (_my_role == LOCAL_ROOT) ? true : false;

// should round up partition bytes in order to be page aligned
if (getenv("BYTEPS_PARTITION_BYTES")) {
_partition_bytes = atoi(getenv("BYTEPS_PARTITION_BYTES"));
Expand All @@ -138,7 +138,7 @@ void BytePSGlobal::Init() {
if (_is_distributed_job) {
BPS_CHECK(getenv("DMLC_NUM_SERVER"))
<< "error: launch distributed job, but env DMLC_NUM_SERVER not set";

// set hash function
_hash_knob = std::string(getenv("BYTEPS_KEY_HASH_FN") ? getenv("BYTEPS_KEY_HASH_FN") : "djb2");
_mixed_mode = getenv("BYTEPS_ENABLE_MIXED_MODE") ? atoi(getenv("BYTEPS_ENABLE_MIXED_MODE")) : false;
Expand Down Expand Up @@ -408,7 +408,7 @@ void BytePSGlobal::ReDeclareTensor() {
void BytePSGlobal::SetProfileFlag(BytePSContext *ctxt) {
if (_is_trace == 1) {
// Enable trace, check the start and end step
BPS_CHECK(_start_step >= 1 && _end_step > _start_step)
BPS_CHECK(_start_step >= 1 && _end_step > _start_step)
<< "BYTEPS_TRACE_START_STEP must be larger than 1, "
<< "BYTEPS_TRACE_END_STEP must be larger than BYTEPS_TRACE_START_STEP.";
if(ctxt->step_cnt == _start_step-1){
Expand All @@ -420,7 +420,7 @@ void BytePSGlobal::SetProfileFlag(BytePSContext *ctxt) {
std::thread _t(BytePSGlobal::OutputTraces);
_t.detach();
}
}
}
} else {
ctxt->profile_flag = false;
}
Expand Down Expand Up @@ -470,7 +470,7 @@ void BytePSGlobal::OutputTraces(){
file << "{" << std::endl;
file << " \"traceEvents\": [" << std::endl;
auto first = true;
for(std::unordered_map<std::string, int>::iterator iter = _name2end.begin();
for(std::unordered_map<std::string, int>::iterator iter = _name2end.begin();
iter != _name2end.end(); iter++){
BPSContext *ctxt = &_name_to_cxt[iter->first];
while (ctxt->comm_time.size() > 0) {
Expand All @@ -492,7 +492,7 @@ void BytePSGlobal::OutputTraces(){
BPSCommTime *ret = _part_comm_time_queue.front();
if (!first) file << ",\n";
else first = false;
BytePSGlobal::EmitTrace(&file, ret, ctxt);
BytePSGlobal::EmitTrace(&file, ret, ctxt);
_part_comm_time_queue.pop();
}
type2part_comm_time.erase(type);
Expand All @@ -515,15 +515,15 @@ uint64_t BytePSGlobal::Hash_Mixed_Mode(uint64_t key) {
size_t num_server_noncolocate = num_server_total-num_worker_total;
size_t num_server_colocate = num_worker_total;

// The bound should be larger than num_server_total
// in order to cover each server, but it also
// The bound should be larger than num_server_total
// in order to cover each server, but it also
// cannot be too large because it might cause unbalance
auto bound = getenv("BYTEPS_MIXED_MODE_BOUND") ? atoi(getenv("BYTEPS_MIXED_MODE_BOUND")) : 101;
BPS_CHECK_GE(bound, num_server_total);
auto ratio = (2.0 * num_server_noncolocate * (num_worker_total - 1)) /
BPS_CHECK_GE(bound, num_server_total);
auto ratio = (2.0 * num_server_noncolocate * (num_worker_total - 1)) /
((num_worker_total) * (num_worker_total+num_server_noncolocate) - 2 * num_server_noncolocate);
BPS_CHECK_LE(ratio, 1)
<< "number of (non-colocate servers) > number of (worker)"
BPS_CHECK_LE(ratio, 1)
<< "number of (non-colocate servers) > number of (worker)"
<< ", which is not permitted in the mixed mode";
BPS_CHECK_GE(ratio, 0);
auto threshold = ratio * bound;
Expand All @@ -549,7 +549,7 @@ uint64_t BytePSGlobal::Hash_DJB2(uint64_t key) {
uint64_t hash = 5381;
int c;
while ((c = *str)) { // hash(i) = hash(i-1) * 33 ^ str[i]
hash = ((hash << 5) + hash) + c;
hash = ((hash << 5) + hash) + c;
str++;
}
return hash;
Expand Down Expand Up @@ -587,20 +587,20 @@ PSKV& BytePSGlobal::EncodeDefaultKey(uint64_t key, size_t len) {
} else if (!_hash_knob.compare(std::string("sdbm"))) {
server = Hash_SDBM(key) % num_servers;
} else if (!_hash_knob.compare(std::string("mixed"))) {
BPS_CHECK(_mixed_mode)
BPS_CHECK(_mixed_mode)
<< "mixed mode should also set: BYTEPS_ENABLE_MIXED_MODE";
server = Hash_Mixed_Mode(key);
CHECK_LT(server, num_servers);
} else {
BPS_CHECK(0) << "Unsupported BYTEPS_KEY_HASH_FN, "
<< "must be one of [naive, built_in, djb2, sdbm]";
}

_server_accumulated_len[server] += len;
_total_accumulated_len += len;
BPS_LOG(DEBUG) << "key " << key << " assigned to server " << server
<< ", accumulated workload for this server is "
<< _server_accumulated_len[server]
<< _server_accumulated_len[server]
<< " (" << (100.0 * _server_accumulated_len[server] / _total_accumulated_len)
<< "%)";

Expand Down
2 changes: 1 addition & 1 deletion byteps/common/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class BytePSGlobal {
static uint64_t _sample_key;

static int AlignTo(int input, int alignment) { return input / alignment * alignment; }

static int _pagesize;
static int DivUp(int x, int y) { return (x + y - 1) / y; }
static int RoundUp(int x, int y) { return DivUp(x, y) * y; }
Expand Down
2 changes: 1 addition & 1 deletion byteps/common/scheduled_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void BytePSScheduledQueue::recorderTs(std::shared_ptr<TensorTableEntry> task) {
BPSCommTime *ret = new BPSCommTime;
ret->start_t = (long long)(us.count());
ret->key = task->key;
ret->type = this_op;
ret->type = this_op;
context->part_comm_time[task->key][this_op].push(ret);
}
}
Expand Down
2 changes: 1 addition & 1 deletion byteps/misc/imagenet18/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, params, named_parameters, model, fp16_params, fp32_params, l
# We use two loops for load-balancing
for name in self._parameter_names.values():
declare("Parameter."+name)

self.priorities = {}
self.gradient_count = 0

Expand Down
2 changes: 1 addition & 1 deletion byteps/mxnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def update_multi_precision(self, index, weight, grad, state):

# push delta weight, and pull weight back to the same tensor
self._do_push_pull_param(index, weight)

else:
self._do_push_pull(index, grad)
self._optimizer.update_multi_precision(index, weight, grad, state)
Expand Down
10 changes: 5 additions & 5 deletions byteps/server/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace server {
*/
class PriorityQueue {
public:
PriorityQueue(bool is_schedule) {
PriorityQueue(bool is_schedule) {
enable_schedule_ = is_schedule;
if (enable_schedule_) {
std::make_heap(queue_.begin(), queue_.end(),
Expand All @@ -50,8 +50,8 @@ class PriorityQueue {
mu_.lock();
queue_.push_back(std::move(new_value));
if (enable_schedule_) {
++push_cnt_[new_value.key];
std::push_heap(queue_.begin(), queue_.end(),
++push_cnt_[new_value.key];
std::push_heap(queue_.begin(), queue_.end(),
[this](const BytePSEngineMessage& a, const BytePSEngineMessage& b) {
return ComparePriority(a, b);
}
Expand All @@ -69,15 +69,15 @@ class PriorityQueue {
std::unique_lock<std::mutex> lk(mu_);
cond_.wait(lk, [this]{return !queue_.empty();});
if (enable_schedule_) {
std::pop_heap(queue_.begin(), queue_.end(),
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());
*value = std::move(queue_.front());
queue_.erase(queue_.begin());
}
}
Expand Down
Loading

0 comments on commit 4a5b5c9

Please sign in to comment.