|
|
|
@ -12,8 +12,10 @@ 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. */
|
|
|
|
|
|
|
|
|
|
#include "grpc_client.h"
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include "paddle/fluid/operators/detail/grpc_client.h"
|
|
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
|
|
#include "paddle/fluid/framework/threadpool.h"
|
|
|
|
|
|
|
|
|
|
namespace paddle {
|
|
|
|
@ -52,7 +54,7 @@ bool RPCClient::AsyncSendVariable(const std::string& ep,
|
|
|
|
|
auto call = s->stub_g_.PrepareUnaryCall(
|
|
|
|
|
s->context_.get(), "/sendrecv.SendRecvService/SendVariable", req, &cq_);
|
|
|
|
|
call->StartCall();
|
|
|
|
|
call->Finish(&s->reply_, &s->status_, (void*)s);
|
|
|
|
|
call->Finish(&s->reply_, &s->status_, static_cast<void*>(s));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
req_count_++;
|
|
|
|
@ -70,8 +72,7 @@ void ProcGetResponse(const VarHandle& var_h,
|
|
|
|
|
template <typename T>
|
|
|
|
|
void RequestToByteBuffer(const T& proto, ::grpc::ByteBuffer* result) {
|
|
|
|
|
::grpc::Slice slice(proto.ByteSizeLong());
|
|
|
|
|
proto.SerializeWithCachedSizesToArray(
|
|
|
|
|
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(slice.begin())));
|
|
|
|
|
proto.SerializeWithCachedSizesToArray(const_cast<uint8_t*>(slice.begin()));
|
|
|
|
|
::grpc::ByteBuffer tmp(&slice, 1);
|
|
|
|
|
result->Swap(&tmp);
|
|
|
|
|
}
|
|
|
|
@ -109,7 +110,7 @@ bool RPCClient::AsyncGetVariable(const std::string& ep,
|
|
|
|
|
auto call = s->stub_g_.PrepareUnaryCall(
|
|
|
|
|
s->context_.get(), "/sendrecv.SendRecvService/GetVariable", buf, &cq_);
|
|
|
|
|
call->StartCall();
|
|
|
|
|
call->Finish(&s->reply_, &s->status_, (void*)s);
|
|
|
|
|
call->Finish(&s->reply_, &s->status_, static_cast<void*>(s));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
req_count_++;
|
|
|
|
@ -153,7 +154,7 @@ bool RPCClient::AsyncPrefetchVariable(const std::string& ep,
|
|
|
|
|
s->context_.get(), "/sendrecv.SendRecvService/PrefetchVariable", req,
|
|
|
|
|
&cq_);
|
|
|
|
|
call->StartCall();
|
|
|
|
|
call->Finish(&s->reply_, &s->status_, (void*)s);
|
|
|
|
|
call->Finish(&s->reply_, &s->status_, static_cast<void*>(s));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
req_count_++;
|
|
|
|
@ -169,7 +170,7 @@ void RPCClient::AsyncSendBatchBarrier(const std::string& ep, int64_t time_out) {
|
|
|
|
|
sendrecv::VariableMessage req;
|
|
|
|
|
req.set_varname(BATCH_BARRIER_MESSAGE);
|
|
|
|
|
auto rpc = s->stub_->AsyncSendVariable(s->context_.get(), req, &cq_);
|
|
|
|
|
rpc->Finish(&s->reply_, &s->status_, (void*)s);
|
|
|
|
|
rpc->Finish(&s->reply_, &s->status_, static_cast<void*>(s));
|
|
|
|
|
req_count_++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -181,7 +182,7 @@ void RPCClient::AsyncSendFetchBarrier(const std::string& ep, int64_t time_out) {
|
|
|
|
|
sendrecv::VariableMessage req;
|
|
|
|
|
req.set_varname(FETCH_BARRIER_MESSAGE);
|
|
|
|
|
auto rpc = s->stub_->AsyncGetVariable(s->context_.get(), req, &cq_);
|
|
|
|
|
rpc->Finish(&s->reply_, &s->status_, (void*)s);
|
|
|
|
|
rpc->Finish(&s->reply_, &s->status_, static_cast<void*>(s));
|
|
|
|
|
req_count_++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|