power-grid-model icon indicating copy to clipboard operation
power-grid-model copied to clipboard

[FEATURE] Static library wrapper around main model + math solver for speeding up tests

Open mgovers opened this issue 11 months ago • 2 comments

Relates to https://github.com/PowerGridModel/power-grid-model/issues/486

A major factor in the compilation is the fact that all 3 test files of the main model + the validator + the benchmark need to recompile all templates individually. Making a static library wrapper would reduce this to only 1 compilation.

The way to do that is the following:

  • [ ] Add a separate library to the tests directory: tests/cpp_test_wrappers/
    • [ ] Add a CMakeLists.txt to expose a STATIC library cpp_test_wrappers
    • [ ] Add a header tests/cpp_test_wrappers/include/cpp_test_wrappers/main_model_wrapper.hpp
      • [ ] declare class:
        class MainModelWrapper {
          private:
            class Impl;
        
          public:
            // all public methods of MainModel
        
          private:
            std::unique_ptr<Impl> impl_;
        }
        
    • [ ] Add a cpp file tests/cpp_wrappers/src/main_model_wrapper.cpp
      • [ ] declare class impl:
        class MainModelWrapper::Impl : public MainModel {
          public:
            using MainModel::MainModelImpl;
        };
        
      • [ ] implement all public methods of MainModelWrapper by forwarding the call to MainModel
      • [ ] Add all static checks from test_main_model_static.cpp to this file
  • [ ] Modify test_main_model_*.cpp, the cpp_validation tests and the benchmark to use this library instead of the static MainModel
  • [ ] Optionally: Create a separate test executable for test_main_model_* to speed up compilation for people who are developing things upstream and don't care about main model yet
  • [ ] Optionally: do the same for the MathModel
    • [ ] Split the MathModel tests into separate files

mgovers avatar Mar 13 '24 17:03 mgovers

I wonder if we are creating static library anyway, why don't we just make power_grid_model core library itself a static library. We try to compile the header files in several compilation unit.

TonyXiang8787 avatar Mar 15 '24 22:03 TonyXiang8787

I've been thinking about that as well. Let's discuss offline

mgovers avatar Mar 15 '24 22:03 mgovers

As discussed: we will solve this in a different way

mgovers avatar Jul 11 '24 11:07 mgovers