From f1e61f04c6be0ab1c4e85e3a65dc47a0a369ae9a Mon Sep 17 00:00:00 2001 From: jack603047588 <603047588@qq.com> Date: Mon, 4 Jul 2022 10:19:06 +0800 Subject: [PATCH] fix vlog print problem in fleet (#44011) * fix vlog print problem in fleet * fix log_patch.h code style --- paddle/fluid/framework/fleet/fleet_wrapper.h | 1 + .../framework/fleet/heter_ps/log_patch.h | 34 +++++++++++++++++++ paddle/fluid/framework/fleet/ps_gpu_wrapper.h | 1 + 3 files changed, 36 insertions(+) create mode 100644 paddle/fluid/framework/fleet/heter_ps/log_patch.h diff --git a/paddle/fluid/framework/fleet/fleet_wrapper.h b/paddle/fluid/framework/fleet/fleet_wrapper.h index 982c1b85a5b..c9c03fb66f8 100644 --- a/paddle/fluid/framework/fleet/fleet_wrapper.h +++ b/paddle/fluid/framework/fleet/fleet_wrapper.h @@ -38,6 +38,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_HETERPS #include "paddle/fluid/platform/device/gpu/gpu_types.h" #endif +#include "paddle/fluid/framework/fleet/heter_ps/log_patch.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/fleet/heter_ps/log_patch.h b/paddle/fluid/framework/fleet/heter_ps/log_patch.h new file mode 100644 index 00000000000..84c83a56f30 --- /dev/null +++ b/paddle/fluid/framework/fleet/heter_ps/log_patch.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2020 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 + +#include + +#undef VLOG_IS_ON +#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel)) + +#undef COMPACT_GOOGLE_LOG_INFO +#define COMPACT_GOOGLE_LOG_INFO google::LogMessage(__FILE__, __LINE__) + +#undef LOG +#define LOG(severity) COMPACT_GOOGLE_LOG_##severity.stream() + +#undef LOG_IF +#define LOG_IF(severity, condition) \ + static_cast(0), \ + !(condition) ? (void)0 : google::LogMessageVoidify() & LOG(severity) + +#undef VLOG +#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel)) diff --git a/paddle/fluid/framework/fleet/ps_gpu_wrapper.h b/paddle/fluid/framework/fleet/ps_gpu_wrapper.h index 0e816beef0d..fae30a45d2e 100644 --- a/paddle/fluid/framework/fleet/ps_gpu_wrapper.h +++ b/paddle/fluid/framework/fleet/ps_gpu_wrapper.h @@ -59,6 +59,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_PSLIB #include "downpour_accessor.h" // NOLINT #endif +#include "paddle/fluid/framework/fleet/heter_ps/log_patch.h" namespace paddle { namespace framework { -- GitLab