Profiling Backend does not compile

Hello,

I wanted to implement a profiling component like PAPI, but for the power measurement infrastructure of a cluster:

I mostly followed the approach that was used by the PAPI component:

A CMake module has been added. The header and source are stored in the runtime contrib folder. The Python class was added to the init.py and I am using TVM_REGISTER_GLOBAL, TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS and TVM_DECLARE_FINAL_OBJECT_INFO just like in papi.cc.

However, when I try to compile it, I get the error: error: ‘tvm::runtime::profiling::HDEEMMetricCollector::HDEEMMetricCollector()’ cannot be overloaded with ‘tvm::runtime::profiling::HDEEMMetricCollector::HDEEMMetricCollector()’

I am not really sure how the FFI works internally, but it seems to be related to it, as the error occurs in:

class HDEEMMetricCollector : public MetricCollector {
 public:
  explicit HDEEMMetricCollector() {
    data_ = make_object<HDEEMMetricCollectorNode>();
  }
  TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(HDEEMMetricCollector, MetricCollector,
                                        HDEEMMetricCollectorNode);
};

Hi Max, it will be a little hard to diagnose your error without more information, but it maybe you have an issue where you are including a file twice in cmake. If you can provide a small example or a link to a branch containing this code, we will be able to debug. Also please provide the full compilation error.

Hi Tristan,

yes of course. I pushed the minimal version to MaxS1996/tvm_power: TVM with added power consumption measurement abilities for the profiler (github.com).

I hope that helps :slight_smile:

Unfortunately, I cannot figure out where to find HDEEM. Can you provide the full output of compilation (including the error you are getting).

Oh, I am sorry. It looks like HDEEM is only available on this cluster, as it relies on additional hardware to be present for the power measurements. I had hoped that it could compile without the hdeem library, but maybe that won’t work.

I compiled TVM with LLVM 9 (auto-detect), Profiler enabled, no CUDA or anything and just the HDEEM Profiler.

The error during the execution of make is:

Built target tvm_objs
In file included from /home/s0144002/tvm_hdeem/include/tvm/runtime/memory.h:26,
                 from /home/s0144002/tvm_hdeem/include/tvm/runtime/container/./base.h:29,
                 from /home/s0144002/tvm_hdeem/include/tvm/runtime/container/array.h:32,
                 from /home/s0144002/tvm_hdeem/include/tvm/runtime/contrib/hdeem.h:23,
                 from /home/s0144002/tvm_hdeem/src/runtime/contrib/hdeem/hdeem.cc:19:
/home/s0144002/tvm_hdeem/src/runtime/contrib/hdeem/hdeem.cc:78:41: error: ‘tvm::runtime::profiling::HDEEMMetricCollector::HDEEMMetricCollector()’ cannot be overloaded with ‘tvm::runtime::profiling::HDEEMMetricCollector::HDEEMMetricCollector()’
   78 |   TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(HDEEMMetricCollector, MetricCollector,
      |                                         ^~~~~~~~~~~~~~~~~~~~
/home/s0144002/tvm_hdeem/include/tvm/runtime/object.h:738:3: note: in definition of macro ‘TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS’
  738 |   TypeName() = default;                                                                     \
      |   ^~~~~~~~
/home/s0144002/tvm_hdeem/src/runtime/contrib/hdeem/hdeem.cc:75:12: note: previous declaration ‘tvm::runtime::profiling::HDEEMMetricCollector::HDEEMMetricCollector()’
   75 |   explicit HDEEMMetricCollector() {
      |            ^~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/tvm_runtime_objs.dir/src/runtime/contrib/hdeem/hdeem.cc.o] Error 1
make[1]: *** [CMakeFiles/tvm_runtime_objs.dir/all] Error 2
make: *** [all] Error 2

Thank you very much for your help.

So the problem is that TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS already defines a default constructor for you. This default constructor with be “nullable”—that is it will construct the object with data_ = nullptr. If you want to prevent that (by using the constructor you’ve already written), use TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS instead.