Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:11

0001 /**
0002  * Copyright (c) 2017-present, Facebook, Inc.
0003  * All rights reserved.
0004  *
0005  * This source code is licensed under the BSD-style license found in the
0006  * LICENSE file in the root directory of this source tree.
0007  */
0008 
0009 #pragma once
0010 
0011 #include <chrono>
0012 #include <memory>
0013 #include <vector>
0014 
0015 #include <gloo/transport/pair.h>
0016 
0017 namespace gloo {
0018 
0019 // There is no need to materialize all transport types here.
0020 namespace transport {
0021 class Context;
0022 class Device;
0023 class UnboundBuffer;
0024 }
0025 
0026 class Context {
0027  public:
0028   Context(int rank, int size, int base = 2);
0029   virtual ~Context();
0030 
0031   const int rank;
0032   const int size;
0033   int base;
0034 
0035   std::shared_ptr<transport::Device>& getDevice();
0036 
0037   std::unique_ptr<transport::Pair>& getPair(int i);
0038 
0039   // Factory function to create an unbound buffer for use with the
0040   // transport used for this context. Use this function to avoid tying
0041   // downstream code to a specific transport.
0042   std::unique_ptr<transport::UnboundBuffer> createUnboundBuffer(
0043       void* ptr, size_t size);
0044 
0045   int nextSlot(int numToSkip = 1);
0046 
0047   void closeConnections();
0048 
0049   void setTimeout(std::chrono::milliseconds timeout);
0050 
0051   std::chrono::milliseconds getTimeout() const;
0052 
0053  protected:
0054   std::shared_ptr<transport::Device> device_;
0055   std::shared_ptr<transport::Context> transportContext_;
0056   int slot_;
0057   std::chrono::milliseconds timeout_;
0058 };
0059 
0060 } // namespace gloo