Home | History | Annotate | Download | only in verbs
      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 TENSORFLOW_CONTRIB_VERBS_RDMA_MGR_H_
     17 #define TENSORFLOW_CONTRIB_VERBS_RDMA_MGR_H_
     18 
     19 #ifdef TENSORFLOW_USE_VERBS
     20 
     21 #include <string>
     22 #include <unordered_map>
     23 
     24 #include "tensorflow/contrib/verbs/rdma.h"
     25 #include "tensorflow/core/distributed_runtime/rpc/grpc_channel.h"
     26 #include "tensorflow/core/distributed_runtime/worker_env.h"
     27 
     28 namespace tensorflow {
     29 
     30 class RdmaMgr {
     31   friend class RdmaChannel;
     32   friend class RdmaAdapter;
     33 
     34  public:
     35   explicit RdmaMgr(const WorkerEnv* const worker_env,
     36                    GrpcChannelCache* const channel_cache);
     37   ~RdmaMgr();
     38   RdmaChannel* FindChannel(const string& key);
     39   void SetupChannels();
     40   bool ConnectivityCheck();
     41   void InitAllocators();
     42   const string& local_worker() { return local_worker_; }
     43 
     44  private:
     45   string local_worker_;
     46   size_t num_remote_workers_;
     47   const WorkerEnv* const worker_env_;
     48   GrpcChannelCache* const channel_cache_;
     49   RdmaAdapter* rdma_adapter_;
     50   typedef std::unordered_map<string, RdmaChannel*> ChannelTable;
     51   ChannelTable channel_table_;
     52   TF_DISALLOW_COPY_AND_ASSIGN(RdmaMgr);
     53 };
     54 
     55 }  // namespace tensorflow
     56 
     57 #endif  // TENSORFLOW_USE_VERBS
     58 #endif  // TENSORFLOW_CONTRIB_VERBS_RDMA_MGR_H_
     59