Skip to content

Commit

Permalink
common: make socket path configurable, and fix env check
Browse files Browse the repository at this point in the history
  • Loading branch information
ymjiang committed Jun 28, 2019
1 parent 23b161e commit 5dabf0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 7 additions & 2 deletions byteps/common/communicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ void BytePSCommSocket::init(int* rank, int* size, int* local_rank, int* local_si
*my_role = (_local_rank == _root) ? LOCAL_ROOT : LOCAL_WORKER;
bool is_root = (*my_role == LOCAL_ROOT) ? true : false;

_send_path = std::string(BASE_SOCKET_PATH_SEND);
_recv_path = std::string(BASE_SOCKET_PATH_RECV);
if (getenv("BYTEPS_SOCKET_PATH")) {
_send_path = std::string(getenv("BYTEPS_SOCKET_PATH")) + std::string("/socket_send_");
_recv_path = std::string(getenv("BYTEPS_SOCKET_PATH")) + std::string("/socket_recv_");
} else {
_send_path = std::string(DEFAULT_BASE_SOCKET_PATH_SEND);
_recv_path = std::string(DEFAULT_BASE_SOCKET_PATH_RECV);
}

_send_fd = initSocket(_local_rank, _send_path);
_recv_fd = initSocket(_local_rank, _recv_path);
Expand Down
4 changes: 2 additions & 2 deletions byteps/common/communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include <mutex>
#include "logging.h"

#define BASE_SOCKET_PATH_RECV "/usr/local/socket_recv_"
#define BASE_SOCKET_PATH_SEND "/usr/local/socket_send_"
#define DEFAULT_BASE_SOCKET_PATH_RECV "/tmp/socket_recv_"
#define DEFAULT_BASE_SOCKET_PATH_SEND "/tmp/socket_send_"
#define MAX_LINE 8000

namespace byteps {
Expand Down
5 changes: 4 additions & 1 deletion byteps/common/global.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ void BytePSGlobal::Init() {
_partition_bytes = AlignTo(_partition_bytes, (8 * _local_size));

BPS_CHECK(getenv("DMLC_NUM_WORKER")) << "error: env DMLC_NUM_WORKER not set";
BPS_CHECK(getenv("DMLC_NUM_SERVER")) << "error: env DMLC_NUM_SERVER not set";

_num_worker = atoi(getenv("DMLC_NUM_WORKER"));

Expand All @@ -107,6 +106,10 @@ void BytePSGlobal::Init() {
}
_is_distributed_job = (_num_worker>1) ? true : _is_distributed_job;

if (_is_distributed_job) {
BPS_CHECK(getenv("DMLC_NUM_SERVER")) << "error: launch distributed job, but env DMLC_NUM_SERVER not set";
}

BPS_LOG(DEBUG) << "Number of worker=" << _num_worker << ", launching "
<< (IsDistributed() ? "" : "non-") << "distributed job";

Expand Down

0 comments on commit 5dabf0c

Please sign in to comment.