Skip to content

Commit

Permalink
Migrate platform/profiler/utils.h to phi [fluid_ops] (#67682)
Browse files Browse the repository at this point in the history
* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix
  • Loading branch information
co63oc authored Aug 26, 2024
1 parent fd79ff5 commit a25a2d5
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 51 deletions.
2 changes: 1 addition & 1 deletion paddle/fluid/framework/new_executor/executor_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include "glog/logging.h"
#include "paddle/common/flags.h"
#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/phi/core/os_info.h"
#include "paddle/phi/core/platform/profiler/utils.h"

PD_DECLARE_bool(use_stream_safe_cuda_allocator);
PHI_DEFINE_EXPORTED_string(static_executor_perfstat_filepath,
Expand Down
17 changes: 5 additions & 12 deletions paddle/fluid/platform/profiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,25 @@ cc_library(
event_node
SRCS event_node.cc
DEPS phi common)
cc_library(
profiler_utils
SRCS utils.cc
DEPS phi glog common)
add_subdirectory(dump)
cc_library(
profiler_logger
SRCS chrometracing_logger.cc dump/serialization_logger.cc
dump/deserialization_reader.cc
DEPS nodetreeproto event_node profiler_utils)
DEPS nodetreeproto event_node phi glog common)
cc_library(
event_bind
SRCS event_python.cc
DEPS profiler_logger)
cc_library(
cpu_utilization
SRCS cpu_utilization.cc
DEPS phi common glog)
cc_library(
new_profiler
SRCS profiler.cc
DEPS host_tracer
cuda_tracer
xpu_tracer
profiler_utils
cpu_utilization
phi
common
glog
event_bind
custom_tracer)
cc_test(
Expand All @@ -50,7 +43,7 @@ cc_test(
cc_test(
test_extra_info
SRCS test_extra_info.cc
DEPS profiler_utils)
DEPS phi glog common)
cc_test(
test_serialization_logger
SRCS dump/test_serialization_logger.cc
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/chrometracing_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ limitations under the License. */
#include "glog/logging.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler/event_node.h"
#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/phi/core/platform/device/gpu/gpu_info.h"
#include "paddle/phi/core/platform/profiler/utils.h"

namespace paddle::platform {

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/chrometracing_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ limitations under the License. */
#include <unordered_map>
#include <utility>

#include "paddle/fluid/platform/profiler/output_logger.h"
#include "paddle/phi/core/platform/device/gpu/gpu_info.h"
#include "paddle/phi/core/platform/profiler/output_logger.h"

namespace paddle {
namespace platform {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/cupti_data_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <cstdio>

#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/phi/core/os_info.h"
#include "paddle/phi/core/platform/device/gpu/gpu_info.h"
#include "paddle/phi/core/platform/profiler/utils.h"

namespace paddle {
namespace platform {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ limitations under the License. */

#include <cstring>

#include "paddle/fluid/platform/profiler/extra_info.h"
#include "paddle/phi/core/platform/profiler/extra_info.h"

namespace paddle::platform {

Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/platform/profiler/dump/serialization_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ limitations under the License. */

#include "glog/logging.h"
#include "paddle/fluid/platform/profiler/event_node.h"
#include "paddle/fluid/platform/profiler/extra_info.h"
#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/phi/core/platform/profiler/extra_info.h"
#include "paddle/phi/core/platform/profiler/utils.h"

namespace paddle::platform {

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/dump/serialization_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License. */
#include <unordered_map>

#include "paddle/fluid/platform/profiler/dump/nodetree.pb.h"
#include "paddle/fluid/platform/profiler/output_logger.h"
#include "paddle/phi/core/platform/device/gpu/gpu_info.h"
#include "paddle/phi/core/platform/profiler/output_logger.h"

namespace paddle {
namespace platform {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/event_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License. */
#include <set>
#include <stack>

#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/phi/core/platform/profiler/utils.h"

namespace paddle::platform {

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/event_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ limitations under the License. */
#include <vector>

#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler/output_logger.h"
#include "paddle/fluid/platform/profiler/trace_event.h"
#include "paddle/phi/common/place.h"
#include "paddle/phi/core/platform/profiler/output_logger.h"

namespace paddle {
namespace platform {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/event_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ limitations under the License. */
#include "paddle/fluid/platform/profiler/chrometracing_logger.h"
#include "paddle/fluid/platform/profiler/dump/deserialization_reader.h"
#include "paddle/fluid/platform/profiler/dump/serialization_logger.h"
#include "paddle/fluid/platform/profiler/extra_info.h"
#include "paddle/phi/core/platform/profiler/extra_info.h"

namespace paddle::platform {

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/event_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ limitations under the License. */
#include <unordered_map>

#include "paddle/fluid/platform/profiler/event_node.h"
#include "paddle/fluid/platform/profiler/extra_info.h"
#include "paddle/phi/core/platform/device/gpu/gpu_info.h"
#include "paddle/phi/core/platform/profiler/extra_info.h"

namespace paddle {
namespace platform {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/host_tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "glog/logging.h"
#include "paddle/fluid/framework/op_proto_maker.h"
#include "paddle/fluid/platform/profiler/common_event.h"
#include "paddle/fluid/platform/profiler/host_event_recorder.h"
#include "paddle/phi/core/platform/profiler/host_event_recorder.h"

namespace paddle::platform {

Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/platform/profiler/profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler/cuda_tracer.h"
#include "paddle/fluid/platform/profiler/custom_device/custom_tracer.h"
#include "paddle/fluid/platform/profiler/extra_info.h"
#include "paddle/fluid/platform/profiler/host_tracer.h"
#include "paddle/fluid/platform/profiler/trace_event_collector.h"
#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/fluid/platform/profiler/xpu_tracer.h"
#include "paddle/phi/core/platform/profiler/extra_info.h"
#include "paddle/phi/core/platform/profiler/utils.h"
#ifdef PADDLE_WITH_CUSTOM_DEVICE
#include "paddle/phi/backends/device_manager.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#include <memory>

#include "paddle/common/macros.h"
#include "paddle/fluid/platform/profiler/cpu_utilization.h"
#include "paddle/fluid/platform/profiler/event_node.h"
#include "paddle/fluid/platform/profiler/event_python.h"
#include "paddle/fluid/platform/profiler/tracer_base.h"
#include "paddle/phi/core/platform/profiler/cpu_utilization.h"

COMMON_DECLARE_int64(host_trace_level);

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/platform/profiler/test_extra_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

#include "gtest/gtest.h"
#include "paddle/fluid/platform/profiler/extra_info.h"
#include "paddle/phi/core/platform/profiler/extra_info.h"

using paddle::platform::ExtraInfo;

Expand Down
2 changes: 2 additions & 0 deletions paddle/phi/core/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ endif()

list(APPEND DEVICE_SRCS cuda_graph_with_memory_pool.cc)
list(APPEND DEVICE_SRCS device_context.cc gen_comm_id_helper.cc)
list(APPEND DEVICE_SRCS profiler/utils.cc profiler/cpu_utilization.cc)

collect_srcs(core_srcs SRCS ${DEVICE_SRCS})
2 changes: 1 addition & 1 deletion paddle/phi/core/platform/profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler/common_event.h"
#include "paddle/fluid/platform/profiler/host_event_recorder.h"
#include "paddle/fluid/platform/profiler/host_tracer.h"
#include "paddle/fluid/platform/profiler/profiler.h"
#include "paddle/phi/api/profiler/device_tracer.h"
#include "paddle/phi/core/platform/profiler/host_event_recorder.h"
#include "paddle/phi/core/platform/profiler_helper.h"
#ifdef PADDLE_WITH_CUDA
#include "paddle/phi/backends/dynload/nvtx.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under 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.

#include "paddle/fluid/platform/profiler/cpu_utilization.h"
#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h
#include "paddle/phi/core/platform/profiler/cpu_utilization.h"
#include <array>
#include "glog/logging.h"

namespace paddle {
namespace platform {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <cinttypes>
#include <cstdint>

#include "glog/logging.h"
#ifdef _MSC_VER
#include <windows.h>
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <unordered_map>
#include <vector>

#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/phi/core/platform/profiler/utils.h"

namespace paddle {
namespace platform {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ 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. */

#include "paddle/fluid/platform/profiler/utils.h"
#include "paddle/phi/core/platform/profiler/utils.h"

#include <sstream>
#include <vector>
Expand Down Expand Up @@ -147,7 +147,7 @@ float CalculateEstOccupancy(uint32_t DeviceId,

#endif // PADDLE_WITH_CUPTI

const char* StringTracerMemEventType(TracerMemEventType type) {
const char* StringTracerMemEventType(phi::TracerMemEventType type) {
static const char* category_name_[] = {// NOLINT
"Allocate",
"Free",
Expand All @@ -156,7 +156,7 @@ const char* StringTracerMemEventType(TracerMemEventType type) {
return category_name_[static_cast<int>(type)];
}

const char* StringTracerEventType(TracerEventType type) {
const char* StringTracerEventType(phi::TracerEventType type) {
static const char* category_name_[] = {"Operator", // NOLINT
"Dataloader",
"ProfileStep",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ limitations under the License. */
#include <string>
#include <vector>

#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler/trace_event.h"
#include "paddle/phi/api/profiler/trace_event.h"
#include "paddle/phi/backends/dynload/cupti.h"
#include "paddle/phi/core/enforce.h"
#include "paddle/phi/core/os_info.h"

namespace paddle {
Expand Down Expand Up @@ -113,9 +113,9 @@ static int64_t nsToUs(uint64_t end_ns, uint64_t start_ns = 0) {
return (end_ns - start_ns) / 1000;
}

const char* StringTracerMemEventType(TracerMemEventType type);
const char* StringTracerMemEventType(phi::TracerMemEventType type);

const char* StringTracerEventType(TracerEventType type);
const char* StringTracerEventType(phi::TracerEventType type);

static float nsToUsFloat(uint64_t end_ns, uint64_t start_ns = 0) {
return static_cast<float>(end_ns - start_ns) / 1000;
Expand Down

0 comments on commit a25a2d5

Please sign in to comment.