未验证 提交 66a4b2e8 编写于 作者: L limingshu 提交者: GitHub

[Code Clean] Clarify once_flag setting for kernel autotune module (#44141)

* first commit

* clarify the quotes

* change code style format

* rerun for ci
上级 b7a1ae22
......@@ -120,8 +120,8 @@ class AutoTuneBase {
template <typename Context, typename... Args>
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 <typename T, typename KernelType>
class TransposeAutoTuner : public AutoTuneBase<T, KernelType> {
public:
static AutoTuneBase<T, KernelType>* Instance(KernelType kernel) {
static std::once_flag transpose_init_flag_;
static std::unique_ptr<AutoTuneBase<T, KernelType>> instance_;
std::call_once(init_flag_, [&] {
std::call_once(transpose_init_flag_, [&] {
instance_.reset(new AutoTuneBase<T, KernelType>(kernel));
});
return instance_.get();
}
private:
static std::once_flag init_flag_;
};
template <typename T, typename KernelType>
std::once_flag TransposeAutoTuner<T, KernelType>::init_flag_;
template <typename T, typename RetureType, typename... Args>
static AutoTuneBase<T, KernelCallback<T, RetureType, Args...>>*
MakeTransposeTuner(RetureType (*func)(Args...)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册