1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef GDR_WORKER_H_ 17 #define GDR_WORKER_H_ 18 19 #include "tensorflow/contrib/gdr/gdr_memory_manager.h" 20 21 #include "tensorflow/core/distributed_runtime/recent_request_ids.h" 22 #include "tensorflow/core/distributed_runtime/rpc/grpc_worker_service.h" 23 24 namespace tensorflow { 25 26 class GdrWorker : public GrpcWorker { 27 public: 28 GdrWorker(WorkerEnv* env, RemoteMemoryManager* remote_memory_manager); 29 30 // Serve the RecvTensorRequest but omit the tensor content and transmit it 31 // out-of-band using GPU Direct RDMA whenever possible. 32 // If it's not possible, it falls back to gRPC in-band tensor transport by 33 // encoding the tensor content into the grpc::ByteBuffer. 34 // The RecvTensorResponse will carry the necessary information for RDMA. 35 virtual void GrpcRecvTensorAsync(CallOptions* opts, 36 const RecvTensorRequest* request, 37 ::grpc::ByteBuffer* response, 38 StatusCallback done) override; 39 40 private: 41 RemoteMemoryManager* remote_memory_manager_; // Not owned 42 RecentRequestIds recv_tensor_recent_request_ids_; 43 }; 44 45 } // namespace tensorflow 46 47 #endif // GDR_WORKER_H_ 48