You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
60 lines
1.8 KiB
7 years ago
|
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
|
||
|
//
|
||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
// you may not use this file except in compliance with the License.
|
||
|
// You may obtain a copy of the License at
|
||
|
//
|
||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||
|
//
|
||
|
// Unless required by applicable law or agreed to in writing, software
|
||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
// See the License for the specific language governing permissions and
|
||
|
// limitations under the License.
|
||
|
|
||
|
#pragma once
|
||
|
|
||
7 years ago
|
#include <string>
|
||
|
#include <vector>
|
||
|
|
||
7 years ago
|
#include "paddle/fluid/framework/details/op_handle_base.h"
|
||
|
#include "paddle/fluid/framework/lod_tensor.h"
|
||
|
#include "paddle/fluid/framework/scope.h"
|
||
7 years ago
|
#ifdef PADDLE_WITH_CUDA
|
||
7 years ago
|
#include "paddle/fluid/platform/nccl_helper.h"
|
||
7 years ago
|
#endif
|
||
7 years ago
|
|
||
|
namespace paddle {
|
||
|
namespace framework {
|
||
|
namespace details {
|
||
|
|
||
7 years ago
|
struct AllReduceOpHandle : public OpHandleBase {
|
||
7 years ago
|
#ifdef PADDLE_WITH_CUDA
|
||
7 years ago
|
AllReduceOpHandle(const std::vector<Scope *> &local_scopes,
|
||
|
const std::vector<platform::Place> &places,
|
||
|
const platform::NCCLContextMap *ctxs);
|
||
7 years ago
|
#else
|
||
7 years ago
|
AllReduceOpHandle(const std::vector<Scope *> &local_scopes,
|
||
|
const std::vector<platform::Place> &places);
|
||
7 years ago
|
#endif
|
||
7 years ago
|
std::string Name() const override;
|
||
|
|
||
7 years ago
|
// Delay and buffer nccl_all_reduce together can significantly increase
|
||
|
// performance. Disable this feature by returning false.
|
||
7 years ago
|
bool IsMultiDeviceTransfer() override { return true; };
|
||
7 years ago
|
|
||
7 years ago
|
protected:
|
||
|
void RunImpl() override;
|
||
7 years ago
|
|
||
|
private:
|
||
7 years ago
|
std::vector<Scope *> local_scopes_;
|
||
|
std::vector<platform::Place> places_;
|
||
7 years ago
|
#ifdef PADDLE_WITH_CUDA
|
||
|
const platform::NCCLContextMap *nccl_ctxs_;
|
||
|
#endif
|
||
7 years ago
|
};
|
||
|
|
||
|
} // namespace details
|
||
|
} // namespace framework
|
||
|
} // namespace paddle
|