From 66a4b2e818376549d22d0c0d1123f599088053f7 Mon Sep 17 00:00:00 2001 From: limingshu <61349199+JamesLim-sy@users.noreply.github.com> Date: Thu, 22 Sep 2022 09:43:49 +0800 Subject: [PATCH] [Code Clean] Clarify once_flag setting for kernel autotune module (#44141) * first commit * clarify the quotes * change code style format * rerun for ci --- paddle/phi/kernels/autotune/auto_tune_base.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/paddle/phi/kernels/autotune/auto_tune_base.h b/paddle/phi/kernels/autotune/auto_tune_base.h index 91685c2ed54..1f79855107e 100644 --- a/paddle/phi/kernels/autotune/auto_tune_base.h +++ b/paddle/phi/kernels/autotune/auto_tune_base.h @@ -120,8 +120,8 @@ class AutoTuneBase { template float RunAndMeasureKernel(const Context& ctx, const int idx, Args&&... args) { - // Regard 1st run as warmup. Judge the result by the time cost of rest run - // cycles. + // Regard 1st run as warmup, judge the compare result by the time cost + // of rest cycles. constexpr int repeats = 3; phi::GpuTimer timer; float time_cost = 0; @@ -153,20 +153,15 @@ template class TransposeAutoTuner : public AutoTuneBase { public: static AutoTuneBase* Instance(KernelType kernel) { + static std::once_flag transpose_init_flag_; static std::unique_ptr> instance_; - std::call_once(init_flag_, [&] { + std::call_once(transpose_init_flag_, [&] { instance_.reset(new AutoTuneBase(kernel)); }); return instance_.get(); } - - private: - static std::once_flag init_flag_; }; -template -std::once_flag TransposeAutoTuner::init_flag_; - template static AutoTuneBase>* MakeTransposeTuner(RetureType (*func)(Args...)) { -- GitLab