Skip to content

Commit

Permalink
restore
Browse files Browse the repository at this point in the history
  • Loading branch information
walkalone20 committed Apr 29, 2024
1 parent 5430186 commit 81bfd81
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 36 deletions.
4 changes: 3 additions & 1 deletion paddle/fluid/distributed/fleet_executor/sink_interceptor.cc
Expand Up @@ -20,7 +20,9 @@ namespace paddle {
namespace distributed {

SinkInterceptor::SinkInterceptor(int64_t interceptor_id, TaskNode* node)
: Interceptor(interceptor_id, node), max_run_times_(node->max_run_times()) {
: Interceptor(interceptor_id, node),
max_run_times_(node->max_run_times()),
upstream_step_() {
// prepare the upstream running status
for (const auto& up : node->upstream()) {
upstream_step_.emplace(up.first, 0);
Expand Down
Expand Up @@ -20,7 +20,9 @@ namespace paddle {
namespace distributed {

SourceInterceptor::SourceInterceptor(int64_t interceptor_id, TaskNode* node)
: Interceptor(interceptor_id, node), max_run_times_(node->max_run_times()) {
: Interceptor(interceptor_id, node),
max_run_times_(node->max_run_times()),
downstream_step_() {
// prepare the downstream running status
for (const auto& down : node->downstream()) {
downstream_step_.emplace(down.first, 0);
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/distributed/ps/wrapper/fleet.cc
Expand Up @@ -914,7 +914,7 @@ std::default_random_engine& FleetWrapper::LocalRandomEngine() {
std::default_random_engine engine;

engine_wrapper_t() {
struct timespec tp;
struct timespec tp = {0, 0};
clock_gettime(CLOCK_REALTIME, &tp);
double cur_time = tp.tv_sec + tp.tv_nsec * 1e-9;
static std::atomic<uint64_t> x(0);
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/fleet/metrics.cc
Expand Up @@ -298,7 +298,7 @@ void BasicAucCalculator::add_uid_unlock_data(double pred,
platform::errors::PreconditionNotMet(
"label must be equal to 0 or 1, but its value is: %d", label));

WuaucRecord record;
WuaucRecord record = {0, 0, 0};
record.uid_ = uid;
record.label_ = label;
record.pred_ = static_cast<float>(pred);
Expand All @@ -320,7 +320,7 @@ void BasicAucCalculator::computeWuAuc() {
}
});

WuaucRocData roc_data;
WuaucRocData roc_data = {0, 0, 0};
uint64_t prev_uid = 0;
size_t prev_pos = 0;
for (size_t i = 0; i < wuauc_records_.size(); ++i) {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/lod_rank_table.cc
Expand Up @@ -35,7 +35,7 @@ void LoDRankTable::Reset(const LoD& lod, size_t level) {
}
auto& vec = lod[level];
for (size_t i = 0; i < vec.size() - 1; ++i) {
TableItem item;
TableItem item = {0, 0};
item.index = i;
item.length = vec[i + 1] - vec[i];
VLOG(10) << "Add item to rank table " << item.index << " " << item.length;
Expand Down
Expand Up @@ -49,7 +49,17 @@ IfInstruction::IfInstruction(size_t id,
pir::Operation* op,
ValueExecutionInfo* value_exec_info,
interpreter::ExecutionConfig execution_config)
: InstructionBase(id, place) {
: InstructionBase(id, place),
op_(op),
cond_name_("if_instruction"),
cond_var_(nullptr),
output_vars_(),
true_branch_inter_(nullptr),
false_branch_inter_(nullptr),
true_branch_outputs_(),
false_branch_outputs_(),
true_skip_gc_names_(),
false_skip_gc_names_() {
PADDLE_ENFORCE(
op->isa<paddle::dialect::IfOp>(),
phi::errors::PreconditionNotMet("Cond instruction only support if op"));
Expand Down
78 changes: 70 additions & 8 deletions paddle/fluid/framework/new_executor/pir_interpreter.cc
Expand Up @@ -111,13 +111,46 @@ PirInterpreter::PirInterpreter(const platform::Place& place,
const ::pir::Block* ir_block,
framework::Scope* scope,
const ExecutionConfig& execution_config)
: place_(place),
: is_build_(false),
static_build_(false),
is_shared_results_build_(false),
place_(place),
unfinished_op_number_(0),
execution_config_(execution_config),
force_events_to_wait_(nullptr),
var_scope_(scope),
scope_(scope),
local_scope_(nullptr),
main_thread_blocker_(),
async_work_queue_(),
exception_holder_(),
exception_notifier_(nullptr),
completion_notifier_(nullptr),
gc_(nullptr),
last_live_ops_(),
dependency_count_(nullptr),
deps_(),
refs_(),
sync_op_num_(-1),
nccl_op_num_(-1),
onednn_op_num_(-1),
trace_execute_order_(),
pir_output_hookfuncs_(),
pir_input_hookfuncs_(),
ir_instruction_scheduling_priority_less(),
ir_block_(ir_block),
sub_blocks_(),
vec_instruction_base_(),
value_exe_info_(nullptr),
var_ref_count_(),
ir_dependency_builder_(),
ir_stream_analyzer_(place),
fetch_var_names_(fetch_var_names),
parameter_var_names_(),
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
calculate_stream_timer_(nullptr),
#endif
last_calculate_instr_id_(0),
enable_job_schedule_profiler_(false) {
VLOG(2) << "PirInterpreter(): " << this << " on " << place_;

Expand Down Expand Up @@ -161,10 +194,6 @@ PirInterpreter::PirInterpreter(const platform::Place& place,
ss << this
<< std::chrono::high_resolution_clock::now().time_since_epoch().count();
BuildScope(*ir_block_, ss.str(), value_exe_info_.get());

#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
calculate_stream_timer_ = std::make_unique<phi::CalculateStreamTimer>(place);
#endif
}

PirInterpreter::PirInterpreter(
Expand All @@ -174,14 +203,47 @@ PirInterpreter::PirInterpreter(
framework::Scope* scope,
std::shared_ptr<ValueExecutionInfo> value_exe_info,
const ExecutionConfig& execution_config)
: place_(place),
: is_build_(false),
static_build_(false),
is_shared_results_build_(false),
place_(place),
unfinished_op_number_(0),
execution_config_(execution_config),
force_events_to_wait_(nullptr),
var_scope_(scope),
scope_(scope),
local_scope_(nullptr),
main_thread_blocker_(),
async_work_queue_(),
exception_holder_(),
exception_notifier_(nullptr),
completion_notifier_(nullptr),
gc_(nullptr),
last_live_ops_(),
dependency_count_(nullptr),
deps_(),
refs_(),
sync_op_num_(-1),
nccl_op_num_(-1),
onednn_op_num_(-1),
trace_execute_order_(),
pir_output_hookfuncs_(),
pir_input_hookfuncs_(),
ir_instruction_scheduling_priority_less(),
ir_block_(ir_block),
value_exe_info_(value_exe_info),
sub_blocks_(),
vec_instruction_base_(),
value_exe_info_(nullptr),
var_ref_count_(),
ir_dependency_builder_(),
ir_stream_analyzer_(place),
fetch_var_names_(fetch_var_names) {
fetch_var_names_(fetch_var_names),
parameter_var_names_(),
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
calculate_stream_timer_(nullptr),
#endif
last_calculate_instr_id_(0),
enable_job_schedule_profiler_(false) {
VLOG(2) << "PirInterpreter(): " << this << " on " << place_;

exception_notifier_ = main_thread_blocker_.RegisterEvent(kExceptionCaught);
Expand Down
41 changes: 34 additions & 7 deletions paddle/fluid/framework/new_executor/program_interpreter.cc
Expand Up @@ -52,19 +52,50 @@ ProgramInterpreter::ProgramInterpreter(const platform::Place& place,
const BlockDesc& block,
framework::Scope* scope,
const ExecutionConfig& execution_config)
: place_(place),
: is_build_(false),
static_build_(false),
is_shared_results_build_(false),
is_in_op_profiling_mode_(false),
place_(place),
block_(block),
dependency_builder_(),
stream_analyzer_(place),
copy_program_(nullptr),
var_list_(),
name2id_(),
vec_meta_info_(),
vec_instruction_(),
unfinished_op_number_(0),
execution_config_(execution_config),
force_events_to_wait_(nullptr),
var_scope_(scope),
local_scope_(nullptr),
main_thread_blocker_(),
async_work_queue_(nullptr),
exception_holder_(),
exception_notifier_(nullptr),
completion_notifier_(nullptr),
gc_(nullptr),
last_live_ops_(),
dependency_count_(std::make_shared<std::vector<size_t>>()),
deps_(),
refs_(),
sync_op_num_(-1),
trace_execute_order_(),
instruction_scheduling_priority_less(),
output_hookfuncs_(),
input_hookfuncs_(),
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
calculate_stream_timer_(
std::make_unique<phi::CalculateStreamTimer>(place)),
#endif
last_calculate_instr_id_(0),
enable_job_schedule_profiler_(false) {
VLOG(4) << "ProgramInterpreter(): " << this << " on " << place_;

exception_notifier_ = main_thread_blocker_.RegisterEvent(kExceptionCaught);
completion_notifier_ = main_thread_blocker_.RegisterEvent(kTaskCompletion);

dependency_count_ = std::make_shared<std::vector<size_t>>();

if (!FLAGS_new_executor_use_local_scope) {
execution_config_.create_local_scope = false;
}
Expand Down Expand Up @@ -93,10 +124,6 @@ ProgramInterpreter::ProgramInterpreter(const platform::Place& place,
};

PrepareForCUDAGraphCapture();

#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
calculate_stream_timer_ = std::make_unique<phi::CalculateStreamTimer>(place);
#endif
}

ProgramInterpreter::~ProgramInterpreter() {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/imperative/data_loader.cc
Expand Up @@ -61,7 +61,7 @@ void EraseLoadProcessPIDs(int64_t key) {
#define SIGNAL_HANDLE(SIGNAL) \
do { \
memory::allocation::MemoryMapFdSet::Instance().Clear(); \
struct sigaction sa; \
struct sigaction sa = {}; \
sa.sa_handler = SIG_DFL; \
sa.sa_flags = 0; \
if (sigemptyset(&sa.sa_mask) != 0 || \
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/platform/profiler/cpu_utilization.cc
Expand Up @@ -57,7 +57,7 @@ void CpuUtilization::RecordBeginTimeInfo() {
static char proc_stat_path[proc_path_size] = "/proc/stat"; // NOLINTf
FILE *stat_file = fopen(proc_stat_path, "r");
if (stat_file != nullptr) {
std::array<char, 200> temp_str;
std::array<char, 200> temp_str = {};
uint64_t temp_lu;
int retval =
fscanf(stat_file,
Expand Down Expand Up @@ -102,7 +102,7 @@ void CpuUtilization::RecordEndTimeInfo() {
static char proc_stat_path[proc_path_size] = "/proc/stat"; // NOLINT
FILE *stat_file = fopen(proc_stat_path, "r");
if (stat_file != nullptr) {
std::array<char, 200> temp_str;
std::array<char, 200> temp_str = {};
uint64_t temp_lu;
int retval =
fscanf(stat_file,
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pybind/distributed_py.cc
Expand Up @@ -564,7 +564,7 @@ void BindDistributed(py::module *m) {
.def(
"barrier",
[](distributed::ProcessGroup &self, int8_t device_id) {
distributed::BarrierOptions opts;
distributed::BarrierOptions opts{0};
opts.device_id = device_id;
return self.Barrier(opts);
},
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/api/lib/tensor_utils.cc
Expand Up @@ -37,7 +37,7 @@ phi::Place GetPlaceFromPtr(void* data) {
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#ifdef PADDLE_WITH_CUDA
#if CUDA_VERSION >= 10000
cudaPointerAttributes attr;
cudaPointerAttributes attr = {};
cudaError_t status = cudaPointerGetAttributes(&attr, data);
if (status == cudaSuccess && attr.type == cudaMemoryTypeDevice) {
return phi::GPUPlace(attr.device);
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/backends/gpu/cuda/cuda_info.cc
Expand Up @@ -187,7 +187,7 @@ std::array<unsigned int, 3> GetGpuMaxGridDimSize(int id) {
"but received id is: %d. GPU count is: %d.",
id,
GetGPUDeviceCount()));
std::array<unsigned int, 3> ret;
std::array<unsigned int, 3> ret = {};
int size;
auto error_code_x = cudaDeviceGetAttribute(&size, cudaDevAttrMaxGridDimX, id);
PADDLE_ENFORCE_GPU_SUCCESS(error_code_x);
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/core/distributed/gloo_utils.cc
Expand Up @@ -48,7 +48,7 @@ std::shared_ptr<gloo::transport::Device> CreateDeviceForHostname(
}

std::shared_ptr<gloo::transport::Device> CreateDefaultDevice() {
std::array<char, HOST_NAME_MAX> hostname;
std::array<char, HOST_NAME_MAX> hostname = {};
auto ret = ::gethostname(hostname.data(), HOST_NAME_MAX);
PADDLE_ENFORCE_EQ(
ret,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/cpu/cumprod_grad_kernel.cc
Expand Up @@ -85,7 +85,7 @@ void CumprodGradKernel(const Context& dev_ctx,
d_x_data[index] = 0;
for (size_t n = 0; n < mid_dim; n++) {
size_t pos = i * mid_dim * inner_dim + n * inner_dim + k;
T elem;
T elem = T();
if (j == 0) {
elem = d_out_data[pos];
} else {
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/cpu/fill_diagonal_tensor_grad_kernel.cc
Expand Up @@ -39,8 +39,8 @@ void FillDiagonalTensorGradKernel(const Context& ctx,
}
}

std::array<int64_t, 2> new_dims;
std::array<int64_t, 2> strides;
std::array<int64_t, 2> new_dims = {};
std::array<int64_t, 2> strides = {};
std::vector<int64_t> matdim;
matdim.resize(matrows);
CalMatDims(dx_dims,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/strided_reshape_utils.cc
Expand Up @@ -25,7 +25,7 @@ bool ReshapeStride(const DDim& old_dims,
DDim& new_stride) { // NOLINT
int64_t numel = product(old_dims);
if (numel < 0) {
std::array<int64_t, 2> tmp;
std::array<int64_t, 2> tmp = {};
tmp[0] = 1;
tmp[1] = new_dims.size();
new_stride = DDim(tmp.data(), 2);
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/fluid/math/im2col_test.cc
Expand Up @@ -362,7 +362,7 @@ void benchIm2col(int ic, int ih, int iw, int fh, int fw, int ph, int pw) {
PREPARE_IM2COL_CPU;
constexpr int repeat = 100;
auto GetCurrentMs = []() -> double {
struct timeval time;
struct timeval time = {0, 0};
gettimeofday(&time, nullptr);
return 1e+3 * time.tv_sec + 1e-3 * time.tv_usec; // NOLINT
};
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/phi/core/unroll_array_ops_test.cc
Expand Up @@ -29,7 +29,7 @@ bool CheckEquality(const T* p, size_t n, T val) {
template <int D1, int D2>
bool FillConstantTestMain() {
static_assert(D1 >= D2, "");
std::array<int, D1> arr;
std::array<int, D1> arr = {};
arr.fill(0);

common::UnrollFillConstant<D2>::Run(arr.data(), 1);
Expand Down
2 changes: 1 addition & 1 deletion third_party/pybind
Submodule pybind updated 139 files

0 comments on commit 81bfd81

Please sign in to comment.