未验证 提交 5169197f 编写于 作者: Y Yuan Shuai 提交者: GitHub

[LITE][PROFILE] Fix unit test segfault when profiler on (#3744)


* [LITE][PROFILER] Fix unit test segfault when profiler on. test=develop
上级 b7064517
...@@ -70,6 +70,10 @@ class KernelBase { ...@@ -70,6 +70,10 @@ class KernelBase {
ch->cl_event = event_; ch->cl_event = event_;
#endif #endif
} }
virtual void SetIsKernelTest(bool is_kernel_test) {
is_kernel_test_ = is_kernel_test;
}
#endif #endif
void Launch() { void Launch() {
...@@ -94,16 +98,23 @@ class KernelBase { ...@@ -94,16 +98,23 @@ class KernelBase {
#if defined(LITE_WITH_MLU) #if defined(LITE_WITH_MLU)
WorkSpace::Global_MLU().AllocReset(); WorkSpace::Global_MLU().AllocReset();
#endif #endif
#ifdef LITE_WITH_PROFILE #ifdef LITE_WITH_PROFILE
profiler_->StopTiming(profile::Type::kCreate, profile_id_, ctx_.get()); if (!is_kernel_test_) {
profiler_->StartTiming(profile::Type::kDispatch, profile_id_, ctx_.get()); profiler_->StopTiming(profile::Type::kCreate, profile_id_, ctx_.get());
profiler_->StartTiming(profile::Type::kDispatch, profile_id_, ctx_.get());
}
Run(); Run();
if (is_first_epoch_for_profiler_) { if (is_first_epoch_for_profiler_ && (!is_kernel_test_)) {
SetProfileRuntimeKernelInfo(profiler_->GetOpCharacter(profile_id_)); SetProfileRuntimeKernelInfo(profiler_->GetOpCharacter(profile_id_));
is_first_epoch_for_profiler_ = false; is_first_epoch_for_profiler_ = false;
} }
profiler_->StopTiming(profile::Type::kDispatch, profile_id_, ctx_.get());
if (!is_kernel_test_) {
profiler_->StopTiming(profile::Type::kDispatch, profile_id_, ctx_.get());
}
#else #else
Run(); Run();
...@@ -197,11 +208,11 @@ class KernelBase { ...@@ -197,11 +208,11 @@ class KernelBase {
profile::Profiler* profiler_{nullptr}; profile::Profiler* profiler_{nullptr};
int profile_id_{-1}; int profile_id_{-1};
bool is_first_epoch_for_profiler_{true}; bool is_first_epoch_for_profiler_{true};
#endif bool is_kernel_test_{true};
#ifdef LITE_WITH_OPENCL #ifdef LITE_WITH_OPENCL
cl::Event event_; cl::Event event_;
#endif #endif
#endif
}; };
// Light-weight kernel implementation. // Light-weight kernel implementation.
......
...@@ -302,6 +302,7 @@ void Instruction::Run() { ...@@ -302,6 +302,7 @@ void Instruction::Run() {
#ifdef LITE_WITH_PROFILE #ifdef LITE_WITH_PROFILE
if (first_epoch_for_profiler_) { if (first_epoch_for_profiler_) {
kernel_->SetIsKernelTest(false);
SetProfileRuntimeOpInfo(profiler_->GetOpCharacter(profile_id_)); SetProfileRuntimeOpInfo(profiler_->GetOpCharacter(profile_id_));
first_epoch_for_profiler_ = false; first_epoch_for_profiler_ = false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册