1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_CORE_COMMON_RUNTIME_RING_GATHERER_H_ |
16 | #define TENSORFLOW_CORE_COMMON_RUNTIME_RING_GATHERER_H_ |
17 | |
18 | #include <deque> |
19 | #include <memory> |
20 | #include <string> |
21 | #include <vector> |
22 | |
23 | #include "tensorflow/core/common_runtime/base_collective_executor.h" |
24 | #include "tensorflow/core/common_runtime/ring_alg.h" |
25 | #include "tensorflow/core/framework/collective.h" |
26 | |
27 | namespace tensorflow { |
28 | class Device; |
29 | |
30 | // Ring-algorithm implementation of collective all-gather. |
31 | class RingGatherer : public RingAlg { |
32 | public: |
33 | RingGatherer() : RingAlg(GATHER_COLLECTIVE, "Gather" ) {} |
34 | ~RingGatherer() override {} |
35 | |
36 | Status InitializeCollectiveParams(CollectiveParams* col_params) override; |
37 | |
38 | // Begins async execution of the ring gather algorithm. |
39 | // Must be called in a blockable thread. |
40 | // TODO(b/80529858): remove the previous warning when we have a dedicated |
41 | // collective threadpool. |
42 | void Run(StatusCallback done) override; |
43 | |
44 | private: |
45 | bool RunAsyncParts(); |
46 | |
47 | friend class RingGathererTest; |
48 | }; |
49 | |
50 | } // namespace tensorflow |
51 | #endif // TENSORFLOW_CORE_COMMON_RUNTIME_RING_GATHERER_H_ |
52 | |