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_KERNELS_COLLECTIVE_NCCL_REDUCER_H_ 16 #define TENSORFLOW_CORE_KERNELS_COLLECTIVE_NCCL_REDUCER_H_ 17 18 #include "tensorflow/core/framework/collective.h" 19 20 namespace tensorflow { 21 #ifdef GOOGLE_CUDA 22 23 class NcclReducer : public CollectiveImplementationInterface { 24 public: 25 NcclReducer(); 26 ~NcclReducer() override = default; 27 28 // No-op for this collective implementation. 29 Status InitializeCollectiveParams(CollectiveParams* col_params) override; 30 31 // Initializes the device objects and device localities. 32 Status InitializeCollectiveContext(CollectiveContext* col_ctx) override; 33 34 // Initialize nccl communicator key. 35 Status InitializeInstanceBeforeGroupDiscovery( 36 CollectiveParams* col_params) override; 37 38 // Hands off all reduce to NcclManager. 39 void Run(StatusCallback done) override; 40 41 private: 42 CollectiveContext* col_ctx_; // Not owned 43 const CollectiveParams* col_params_; // Not owned 44 }; 45 46 #endif // GOOGLE_CUDA 47 } // namespace tensorflow 48 49 #endif // TENSORFLOW_CORE_KERNELS_COLLECTIVE_NCCL_REDUCER_H_ 50