Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update record interface using part2 #39694

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7e44acd
fix RecordEvent interface
rainyfly Feb 17, 2022
c6fdca7
modify default level to 4
rainyfly Feb 17, 2022
6791fe0
update interface use
rainyfly Feb 17, 2022
370e952
add const default trace level
rainyfly Feb 17, 2022
decbf4e
update record event interface using
rainyfly Feb 17, 2022
c78cf02
update record event interface using
rainyfly Feb 17, 2022
5821f32
Merge branch 'develop' of https://github.com/rainyfly/Paddle into fix…
rainyfly Feb 18, 2022
c882c74
Merge branch 'develop' of https://github.com/rainyfly/Paddle into fix…
rainyfly Feb 18, 2022
bdf7564
update operator.cc
rainyfly Feb 18, 2022
4bfc1eb
Merge branch 'fix_record_event_interface' into update_record_interfac…
rainyfly Feb 18, 2022
b4196c5
Merge branch 'update_record_interface_using_part1' into update_record…
rainyfly Feb 18, 2022
8cd1182
update part2
rainyfly Feb 18, 2022
d915a60
update part1
rainyfly Feb 18, 2022
b4a482e
Merge branch 'update_record_interface_using_part1' into update_record…
rainyfly Feb 18, 2022
6078d1f
Merge branch 'develop' of https://github.com/rainyfly/Paddle into upd…
rainyfly Feb 19, 2022
5b45b6a
fix include profiler.h header in ps server
rainyfly Feb 19, 2022
f3392f8
fix include profiler.h header in ps server
rainyfly Feb 19, 2022
7c0416e
Merge branch 'update_record_interface_using_part1' into update_record…
rainyfly Feb 19, 2022
d79be47
fix profiler.h header
rainyfly Feb 19, 2022
752ca5b
Merge branch 'develop' of https://github.com/rainyfly/Paddle into upd…
rainyfly Feb 20, 2022
193b910
Merge branch 'develop' of https://github.com/rainyfly/Paddle into upd…
rainyfly Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions paddle/fluid/framework/details/scope_buffered_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

#include "paddle/fluid/framework/details/scope_buffered_monitor.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

namespace paddle {
namespace framework {
Expand Down Expand Up @@ -91,7 +91,8 @@ void ScopeBufferedMonitor::Apply(const std::function<void()> &callback,
bool has_fetch) {
std::unique_ptr<platform::RecordEvent> pre_local_exec_scopes_event(
new platform::RecordEvent(
"ScopeBufferedMonitor::pre_local_exec_scopes_process"));
"ScopeBufferedMonitor::pre_local_exec_scopes_process",
platform::TracerEventType::UserDefined, 2));
for (size_t scope_id = 0; scope_id < local_exec_scopes_.size(); ++scope_id) {
pre_local_exec_scopes_.at(scope_id).clear();
auto scopes = local_exec_scopes_.at(scope_id)->kids();
Expand All @@ -105,7 +106,8 @@ void ScopeBufferedMonitor::Apply(const std::function<void()> &callback,

std::unique_ptr<platform::RecordEvent> post_local_exec_scopes_event(
new platform::RecordEvent(
"ScopeBufferedMonitor::post_local_exec_scopes_process"));
"ScopeBufferedMonitor::post_local_exec_scopes_process",
platform::TracerEventType::UserDefined, 2));
for (size_t scope_id = 0; scope_id < local_exec_scopes_.size(); ++scope_id) {
post_local_exec_scopes_.at(scope_id).clear();
auto scopes = local_exec_scopes_.at(scope_id)->kids();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/variable_helper.h"
#include "paddle/fluid/platform/cuda_graph_with_memory_pool.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

namespace paddle {
namespace framework {
Expand Down Expand Up @@ -75,7 +75,8 @@ FetchResultType ScopeBufferedSSAGraphExecutor::Run(
#endif

if (drop_scope_counter_ == 0) {
platform::RecordEvent e("InitLocalVars");
platform::RecordEvent e("InitLocalVars",
platform::TracerEventType::UserDefined, 2);
InitVariables();
}

Expand Down Expand Up @@ -164,7 +165,8 @@ void ScopeBufferedSSAGraphExecutor::InitVariables() {
}

void ScopeBufferedSSAGraphExecutor::DropLocalExeScopes(bool need_wait) {
platform::RecordEvent drop_scope_event("DropLocalExeScopes");
platform::RecordEvent drop_scope_event(
"DropLocalExeScopes", platform::TracerEventType::UserDefined, 2);
drop_scope_counter_ = 0;
if (need_wait) {
for (auto &p : places_) {
Expand Down
7 changes: 5 additions & 2 deletions paddle/fluid/framework/details/sparse_all_reduce_op_handle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "paddle/fluid/memory/malloc.h"
#include "paddle/fluid/platform/cuda_device_guard.h"
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

DECLARE_bool(sync_nccl_allreduce);

Expand Down Expand Up @@ -66,7 +66,8 @@ SparseAllReduceOpHandle::SparseAllReduceOpHandle(
}

void SparseAllReduceOpHandle::RunImplEncoded() {
platform::RecordEvent record_event(Name());
platform::RecordEvent record_event(Name(),
platform::TracerEventType::UserDefined, 2);

auto in_var_handles = DynamicCast<VarHandle>(this->Inputs());
auto out_var_handles = DynamicCast<VarHandle>(this->Outputs());
Expand Down Expand Up @@ -279,6 +280,8 @@ bool SparseAllReduceOpHandle::IsEncoded() {
}

void SparseAllReduceOpHandle::RunImpl() {
platform::RecordEvent record_event(
Name(), platform::TracerEventType::Communication, 1);
if (!IsEncoded()) {
AllReduceOpHandle::RunImpl();
return;
Expand Down
5 changes: 3 additions & 2 deletions paddle/fluid/framework/details/threaded_ssa_graph_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "paddle/fluid/framework/details/threaded_ssa_graph_executor.h"

#include "paddle/fluid/framework/ir/graph_helper.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

#if defined PADDLE_WITH_PSCORE
#include "paddle/fluid/distributed/ps/service/communicator/communicator.h"
Expand Down Expand Up @@ -56,7 +56,8 @@ ThreadedSSAGraphExecutor::ThreadedSSAGraphExecutor(
inline FetchResultType ThreadedSSAGraphExecutor::RunImpl(
const std::vector<std::string> &fetch_tensors, bool return_merged) {
std::unique_ptr<platform::RecordEvent> event(
new platform::RecordEvent("ThreadedSSAGraphExecutorPrepare"));
new platform::RecordEvent("ThreadedSSAGraphExecutorPrepare",
platform::TracerEventType::UserDefined, 2));
std::unique_ptr<OpDependentData> op_deps = op_deps_futures_.get();
CopyOpDeps();

Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/framework/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License. */
#include "paddle/fluid/operators/controlflow/while_op_helper.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h"
#endif
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/framework/ir/cost_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "paddle/fluid/framework/ir/node.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/fluid/platform/variant.h"

namespace paddle {
Expand Down
8 changes: 6 additions & 2 deletions paddle/fluid/framework/new_executor/interpretercore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
: global_scope_->GetMutableScope();
auto op_with_kernel = dynamic_cast<const framework::OperatorWithKernel*>(op);
{
platform::RecordEvent infershape_event("InferShape");
platform::RecordEvent infershape_event(
"InferShape", platform::TracerEventType::OperatorInner, 1,
platform::EventRole::kInnerOp);
// If it is OperatorBase, InferShape do nothing.
if (op_with_kernel != nullptr)
op_with_kernel->Info().infer_shape_(
Expand All @@ -408,7 +410,9 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
}
}
{
platform::RecordEvent compute_event("Compute");
platform::RecordEvent compute_event(
"Compute", platform::TracerEventType::OperatorInner, 1,
platform::EventRole::kInnerOp);
if (op_with_kernel == nullptr) {
instr_node.OpBase()->Run(*local_scope, place_);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ class ThreadPoolTempl {
ec_.Notify(true);
return false;
}
platform::RecordEvent("SleepWaitForWork");
platform::RecordEvent("SleepWaitForWork",
platform::TracerEventType::UserDefined, 2);
ec_.CommitWait(waiter);
blocked_--;
return true;
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/framework/parallel_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ limitations under the License. */
#include "paddle/fluid/platform/cuda_graph_with_memory_pool.h"
#include "paddle/fluid/platform/event.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#include "paddle/fluid/platform/cuda_device_guard.h"
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/tensor_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ limitations under the License. */
#include "paddle/fluid/framework/data_type.h"
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/platform/complex.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

#include "paddle/phi/core/dense_tensor.h"

Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/imperative/basic_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ void BasicEngine::Execute() {
auto& inplace_grad_name_map = shared_cur_node->InplaceGradNameMap();

for (auto& cur_op : *shared_cur_node) {
platform::RecordEvent op_type_record_event(cur_op.Type());
platform::RecordEvent op_type_record_event(
cur_op.Type(), platform::TracerEventType::Operator, 1);

++op_num;

Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/imperative/layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ void VarBase::ClearGradient(bool set_to_zero) {
grad_t->mutable_value()->clear();
}
} else {
platform::RecordEvent record_event("ClearGradient");
platform::RecordEvent record_event(
"ClearGradient", platform::TracerEventType::UserDefined, 2);
auto* grad_t =
grad_var_->MutableVar()->GetMutable<framework::LoDTensor>();
if (grad_t->IsInitialized()) {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/imperative/partial_grad_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "paddle/fluid/imperative/op_base.h"
#include "paddle/fluid/imperative/tracer.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/fluid/string/string_helper.h"
#include "paddle/phi/kernels/funcs/math_function.h"

Expand Down
4 changes: 3 additions & 1 deletion paddle/fluid/imperative/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "paddle/fluid/platform/denormal.h"
#include "paddle/fluid/platform/device/device_wrapper.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/fluid/string/string_helper.h"

DECLARE_bool(use_mkldnn);
Expand Down Expand Up @@ -171,7 +172,8 @@ void Tracer::TraceOp(const std::string& type, const NameVarMap<VarType>& ins,
const std::map<std::string, std::string>& inplace_map,
paddle::framework::AttributeMap* passed_default_attrs_,
bool use_default_attr_map) {
platform::RecordEvent op_type_record_event(type);
platform::RecordEvent op_type_record_event(
type, platform::TracerEventType::Operator, 2);
platform::ScopedFlushDenormal flush;
VLOG(1) << "Trace Op: " << type;
if (FLAGS_use_mkldnn) {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/tensorrt/plugin/trt_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "paddle/fluid/inference/tensorrt/helper.h"
#include "paddle/fluid/inference/tensorrt/plugin/trt_plugin_utils.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

namespace nvinfer1 {
class ITensor;
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/tests/api/tester_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "paddle/fluid/inference/tests/api/config_printer.h"
#include "paddle/fluid/inference/tests/test_helper.h"
#include "paddle/fluid/inference/utils/benchmark.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"

DEFINE_string(model_name, "", "model name");
DEFINE_string(infer_model, "", "model path");
Expand Down