diff --git a/paddle/fluid/framework/new_executor/executor_statistics.cc b/paddle/fluid/framework/new_executor/executor_statistics.cc index 98deb871c1371..00131359e0019 100644 --- a/paddle/fluid/framework/new_executor/executor_statistics.cc +++ b/paddle/fluid/framework/new_executor/executor_statistics.cc @@ -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, diff --git a/paddle/fluid/platform/profiler/CMakeLists.txt b/paddle/fluid/platform/profiler/CMakeLists.txt index 6faa7ecac86d8..fcc96af30289a 100644 --- a/paddle/fluid/platform/profiler/CMakeLists.txt +++ b/paddle/fluid/platform/profiler/CMakeLists.txt @@ -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( @@ -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 diff --git a/paddle/fluid/platform/profiler/chrometracing_logger.cc b/paddle/fluid/platform/profiler/chrometracing_logger.cc index 0a26faaa0ff9b..0faeb0fd5c472 100644 --- a/paddle/fluid/platform/profiler/chrometracing_logger.cc +++ b/paddle/fluid/platform/profiler/chrometracing_logger.cc @@ -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 { diff --git a/paddle/fluid/platform/profiler/chrometracing_logger.h b/paddle/fluid/platform/profiler/chrometracing_logger.h index 4b58b80e5bf85..140f63438e3e8 100644 --- a/paddle/fluid/platform/profiler/chrometracing_logger.h +++ b/paddle/fluid/platform/profiler/chrometracing_logger.h @@ -19,8 +19,8 @@ limitations under the License. */ #include #include -#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 { diff --git a/paddle/fluid/platform/profiler/cupti_data_process.cc b/paddle/fluid/platform/profiler/cupti_data_process.cc index 7837f3554d0e4..e86ad019fbba2 100644 --- a/paddle/fluid/platform/profiler/cupti_data_process.cc +++ b/paddle/fluid/platform/profiler/cupti_data_process.cc @@ -17,9 +17,9 @@ #include #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 { diff --git a/paddle/fluid/platform/profiler/dump/deserialization_reader.cc b/paddle/fluid/platform/profiler/dump/deserialization_reader.cc index 06eced72fdc33..245ce51d64de1 100644 --- a/paddle/fluid/platform/profiler/dump/deserialization_reader.cc +++ b/paddle/fluid/platform/profiler/dump/deserialization_reader.cc @@ -12,7 +12,7 @@ limitations under the License. */ #include -#include "paddle/fluid/platform/profiler/extra_info.h" +#include "paddle/phi/core/platform/profiler/extra_info.h" namespace paddle::platform { diff --git a/paddle/fluid/platform/profiler/dump/serialization_logger.cc b/paddle/fluid/platform/profiler/dump/serialization_logger.cc index 36be7b618e12b..b188f4818cd87 100644 --- a/paddle/fluid/platform/profiler/dump/serialization_logger.cc +++ b/paddle/fluid/platform/profiler/dump/serialization_logger.cc @@ -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 { diff --git a/paddle/fluid/platform/profiler/dump/serialization_logger.h b/paddle/fluid/platform/profiler/dump/serialization_logger.h index 4df38be0306f2..0d51b95c4dc0b 100644 --- a/paddle/fluid/platform/profiler/dump/serialization_logger.h +++ b/paddle/fluid/platform/profiler/dump/serialization_logger.h @@ -15,8 +15,8 @@ limitations under the License. */ #include #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 { diff --git a/paddle/fluid/platform/profiler/event_node.cc b/paddle/fluid/platform/profiler/event_node.cc index 07f3d4f26b734..6e25f4546b87b 100644 --- a/paddle/fluid/platform/profiler/event_node.cc +++ b/paddle/fluid/platform/profiler/event_node.cc @@ -18,7 +18,7 @@ limitations under the License. */ #include #include -#include "paddle/fluid/platform/profiler/utils.h" +#include "paddle/phi/core/platform/profiler/utils.h" namespace paddle::platform { diff --git a/paddle/fluid/platform/profiler/event_node.h b/paddle/fluid/platform/profiler/event_node.h index 0915381872879..de20e060ab5ab 100644 --- a/paddle/fluid/platform/profiler/event_node.h +++ b/paddle/fluid/platform/profiler/event_node.h @@ -21,9 +21,9 @@ limitations under the License. */ #include #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 { diff --git a/paddle/fluid/platform/profiler/event_python.cc b/paddle/fluid/platform/profiler/event_python.cc index 91ec92fe80b9b..f99a1aef8dd48 100644 --- a/paddle/fluid/platform/profiler/event_python.cc +++ b/paddle/fluid/platform/profiler/event_python.cc @@ -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 { diff --git a/paddle/fluid/platform/profiler/event_python.h b/paddle/fluid/platform/profiler/event_python.h index a9f5c550a59c9..cf96ad58e94fa 100644 --- a/paddle/fluid/platform/profiler/event_python.h +++ b/paddle/fluid/platform/profiler/event_python.h @@ -19,8 +19,8 @@ limitations under the License. */ #include #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 { diff --git a/paddle/fluid/platform/profiler/host_tracer.cc b/paddle/fluid/platform/profiler/host_tracer.cc index f9ab67a18ded9..093df80aa4bee 100644 --- a/paddle/fluid/platform/profiler/host_tracer.cc +++ b/paddle/fluid/platform/profiler/host_tracer.cc @@ -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 { diff --git a/paddle/fluid/platform/profiler/profiler.cc b/paddle/fluid/platform/profiler/profiler.cc index bcc594a018784..04089a6a462f6 100644 --- a/paddle/fluid/platform/profiler/profiler.cc +++ b/paddle/fluid/platform/profiler/profiler.cc @@ -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 diff --git a/paddle/fluid/platform/profiler/profiler.h b/paddle/fluid/platform/profiler/profiler.h index 7c36ab1325d56..e72e321b1dc3c 100644 --- a/paddle/fluid/platform/profiler/profiler.h +++ b/paddle/fluid/platform/profiler/profiler.h @@ -22,10 +22,10 @@ #include #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); diff --git a/paddle/fluid/platform/profiler/test_extra_info.cc b/paddle/fluid/platform/profiler/test_extra_info.cc index 7274c9de977e9..06d5f72d2d964 100644 --- a/paddle/fluid/platform/profiler/test_extra_info.cc +++ b/paddle/fluid/platform/profiler/test_extra_info.cc @@ -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; diff --git a/paddle/phi/core/platform/CMakeLists.txt b/paddle/phi/core/platform/CMakeLists.txt index 06184d537f486..9f64ba0483d1d 100644 --- a/paddle/phi/core/platform/CMakeLists.txt +++ b/paddle/phi/core/platform/CMakeLists.txt @@ -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}) diff --git a/paddle/phi/core/platform/profiler.cc b/paddle/phi/core/platform/profiler.cc index 143bd4d064499..735a862d65922 100644 --- a/paddle/phi/core/platform/profiler.cc +++ b/paddle/phi/core/platform/profiler.cc @@ -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" diff --git a/paddle/fluid/platform/profiler/cpu_utilization.cc b/paddle/phi/core/platform/profiler/cpu_utilization.cc similarity index 92% rename from paddle/fluid/platform/profiler/cpu_utilization.cc rename to paddle/phi/core/platform/profiler/cpu_utilization.cc index dad52452e2d61..20be9d700f7b6 100644 --- a/paddle/fluid/platform/profiler/cpu_utilization.cc +++ b/paddle/phi/core/platform/profiler/cpu_utilization.cc @@ -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 +#include "glog/logging.h" namespace paddle { namespace platform { diff --git a/paddle/fluid/platform/profiler/cpu_utilization.h b/paddle/phi/core/platform/profiler/cpu_utilization.h similarity index 98% rename from paddle/fluid/platform/profiler/cpu_utilization.h rename to paddle/phi/core/platform/profiler/cpu_utilization.h index aa25ae5a43c10..05b24d0d4b6e7 100644 --- a/paddle/fluid/platform/profiler/cpu_utilization.h +++ b/paddle/phi/core/platform/profiler/cpu_utilization.h @@ -19,7 +19,6 @@ #include #include -#include "glog/logging.h" #ifdef _MSC_VER #include #else diff --git a/paddle/fluid/platform/profiler/extra_info.h b/paddle/phi/core/platform/profiler/extra_info.h similarity index 96% rename from paddle/fluid/platform/profiler/extra_info.h rename to paddle/phi/core/platform/profiler/extra_info.h index 5ca92a1cf5f2e..a1041a3a81279 100644 --- a/paddle/fluid/platform/profiler/extra_info.h +++ b/paddle/phi/core/platform/profiler/extra_info.h @@ -18,7 +18,7 @@ #include #include -#include "paddle/fluid/platform/profiler/utils.h" +#include "paddle/phi/core/platform/profiler/utils.h" namespace paddle { namespace platform { diff --git a/paddle/fluid/platform/profiler/host_event_recorder.h b/paddle/phi/core/platform/profiler/host_event_recorder.h similarity index 100% rename from paddle/fluid/platform/profiler/host_event_recorder.h rename to paddle/phi/core/platform/profiler/host_event_recorder.h diff --git a/paddle/fluid/platform/profiler/output_logger.h b/paddle/phi/core/platform/profiler/output_logger.h similarity index 100% rename from paddle/fluid/platform/profiler/output_logger.h rename to paddle/phi/core/platform/profiler/output_logger.h diff --git a/paddle/fluid/platform/profiler/utils.cc b/paddle/phi/core/platform/profiler/utils.cc similarity index 97% rename from paddle/fluid/platform/profiler/utils.cc rename to paddle/phi/core/platform/profiler/utils.cc index da2847c36483b..f253f0952f57c 100644 --- a/paddle/fluid/platform/profiler/utils.cc +++ b/paddle/phi/core/platform/profiler/utils.cc @@ -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 #include @@ -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", @@ -156,7 +156,7 @@ const char* StringTracerMemEventType(TracerMemEventType type) { return category_name_[static_cast(type)]; } -const char* StringTracerEventType(TracerEventType type) { +const char* StringTracerEventType(phi::TracerEventType type) { static const char* category_name_[] = {"Operator", // NOLINT "Dataloader", "ProfileStep", diff --git a/paddle/fluid/platform/profiler/utils.h b/paddle/phi/core/platform/profiler/utils.h similarity index 95% rename from paddle/fluid/platform/profiler/utils.h rename to paddle/phi/core/platform/profiler/utils.h index bc1646cf8c496..a521df12818f8 100644 --- a/paddle/fluid/platform/profiler/utils.h +++ b/paddle/phi/core/platform/profiler/utils.h @@ -19,9 +19,9 @@ limitations under the License. */ #include #include -#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 { @@ -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(end_ns - start_ns) / 1000;