|
|
|
@ -65,7 +65,6 @@ void ParameterClient2::initThreads() {
|
|
|
|
|
LOG(INFO) << "parallel_thread_num dosent need to set";
|
|
|
|
|
}
|
|
|
|
|
syncThreadPool_.reset(new SyncThreadPool(threadNum_));
|
|
|
|
|
|
|
|
|
|
startThreads();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -224,6 +223,14 @@ void ParameterClient2::prepareSendData(
|
|
|
|
|
request.set_cost(cost);
|
|
|
|
|
request.set_batch_status(batchStatus);
|
|
|
|
|
CHECK_EQ(request.blocks_size(), 0);
|
|
|
|
|
VLOG(10) << "request: trainer_id: " << request.trainer_id()
|
|
|
|
|
<< " update_mode" << request.update_mode()
|
|
|
|
|
<< " send_back_parameter: " << request.send_back_parameter()
|
|
|
|
|
<< " send_back_parameter_type: "
|
|
|
|
|
<< request.send_back_parameter_type()
|
|
|
|
|
<< " num_samples: " << request.num_samples()
|
|
|
|
|
<< " cost: " << request.cost()
|
|
|
|
|
<< " batch_status: " << request.batch_status();
|
|
|
|
|
}
|
|
|
|
|
for (const auto& segments : parameterSegments) {
|
|
|
|
|
const auto it = parameterMap_.find(segments.id);
|
|
|
|
@ -251,11 +258,17 @@ void ParameterClient2::prepareSendData(
|
|
|
|
|
CHECK(sendMat != nullptr) << "sendMat is nullptr";
|
|
|
|
|
|
|
|
|
|
syncThreadPool_->exec([&](int tid, size_t numThreads) {
|
|
|
|
|
std::lock_guard<std::mutex> guard(sparseAutoGrowthMutex_);
|
|
|
|
|
const auto& localIndices = prefetchMat->getLocalIndices();
|
|
|
|
|
/// num of sparse rows
|
|
|
|
|
size_t nLocalBlocks = localIndices.size();
|
|
|
|
|
uint64_t beginDim = 0;
|
|
|
|
|
uint64_t endDim = 0;
|
|
|
|
|
|
|
|
|
|
// FIXME(typhoonzero): let it resize first
|
|
|
|
|
prefetchMat->getLocalRow(nLocalBlocks + 1);
|
|
|
|
|
sendMat->getLocalRow(nLocalBlocks + 1);
|
|
|
|
|
|
|
|
|
|
for (size_t row = 0; row < nLocalBlocks; ++row) {
|
|
|
|
|
int64_t blockId = localIndices[row]; // local row -> sparse row
|
|
|
|
|
int serverId = std::abs((blockId + nameHash) % serviceNum_);
|
|
|
|
@ -275,7 +288,6 @@ void ParameterClient2::prepareSendData(
|
|
|
|
|
block->set_begin_pos(row * blockSize);
|
|
|
|
|
/// block len
|
|
|
|
|
block->set_block_size(endDim - beginDim);
|
|
|
|
|
|
|
|
|
|
if (sendingPara) {
|
|
|
|
|
sendJob->parallelInputIovs[serverId].push_back(
|
|
|
|
|
{sendMat->getLocalRow(row), sizeof(real) * (size_t)blockSize});
|
|
|
|
|