From 95a8b90fa79ac850b0e2692cc540f60d0de018a4 Mon Sep 17 00:00:00 2001 From: Liyan Zheng Date: Fri, 28 Apr 2023 00:44:54 +0800 Subject: [PATCH] Fix: add virutal method sync in Runtime --- include/bang/bang_runtime.h | 2 +- include/core/runtime.h | 1 + include/cuda/cuda_runtime.h | 2 +- include/intelcpu/mkl_runtime.h | 2 +- src/core/runtime.cc | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/bang/bang_runtime.h b/include/bang/bang_runtime.h index 6a40ae37..81d148a3 100644 --- a/include/bang/bang_runtime.h +++ b/include/bang/bang_runtime.h @@ -36,7 +36,7 @@ class BangRuntimeObj : public RuntimeObj { bool profiling = false) const; // double runEvaluation(const Graph &graph, int nWarmups, // int nEvaluations) const; - void sync() const; + void sync() const override; BangPtr alloc(size_t size) override { void *ptr; checkBangError(cnrtMalloc(&ptr, size)); diff --git a/include/core/runtime.h b/include/core/runtime.h index 480406a9..59eed1d2 100644 --- a/include/core/runtime.h +++ b/include/core/runtime.h @@ -79,6 +79,7 @@ class RuntimeObj : public std::enable_shared_from_this { virtual void copyBlobToCPU(void *dst, const void *src, size_t bytes) const = 0; virtual string toString() const = 0; + virtual void sync() const {} map getCompileTimeComputableAttribute(const Graph &graph) const; diff --git a/include/cuda/cuda_runtime.h b/include/cuda/cuda_runtime.h index 0a05444b..d1ed9a3f 100644 --- a/include/cuda/cuda_runtime.h +++ b/include/cuda/cuda_runtime.h @@ -27,7 +27,7 @@ class CudaRuntimeObj : public RuntimeObj { bool profiling = false) const; // double runEvaluation(const Graph &graph, int nWarmups, // int nEvaluations) const; - void sync() const; + void sync() const override; CudaPtr alloc(size_t size) override { void *ptr; // printf("Try to cudaMalloc: %lu bytes\n", size); diff --git a/include/intelcpu/mkl_runtime.h b/include/intelcpu/mkl_runtime.h index e8be877f..7db41ded 100644 --- a/include/intelcpu/mkl_runtime.h +++ b/include/intelcpu/mkl_runtime.h @@ -29,7 +29,7 @@ class MklRuntimeObj : public CpuRuntimeObj { string toString() const override { return "INTELCPU Runtime"; }; dnnl::engine getEngine() const { return dnnl::engine(engine, true); } dnnl::stream getStream() const { return dnnl::stream(stream, true); } - void sync() const; + void sync() const override; }; } // namespace infini diff --git a/src/core/runtime.cc b/src/core/runtime.cc index be18bfb0..98e2eac5 100644 --- a/src/core/runtime.cc +++ b/src/core/runtime.cc @@ -241,7 +241,7 @@ double RuntimeObj::timeNonCtcOperators(const Graph &graph, int warmup, kernel->compute(op, this); } }, - [&]() { sync(); }, warmup, repeat); + [&]() { this->sync(); }, warmup, repeat); return ret; }