message: Benchmark memory operations in solvers
diff: @@ -48,22 +48,57 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  // A logger that accumulates the time of all operations
  struct OperationLogger : gko::log::Logger {
  + void on_allocation_started(const gko::Executor *exec,
  + const gko::size_type &) const override
  + {
  + this->start_operation(exec, "allocate");
  + }
  +
  + void on_allocation_completed(const gko::Executor *exec,
  + const gko::size_type &,
  + const gko::uintptr &) const override
  + {
  + this->end_operation(exec, "allocate");
  + }
  +
  + void on_free_started(const gko::Executor *exec,
  + const gko::uintptr &) const override
  + {
  + this->start_operation(exec, "free");
  + }
  +
  + void on_free_completed(const gko::Executor *exec,
  + const gko::uintptr &) const override
  + {
  + this->end_operation(exec, "free");
  + }
  +
  + void on_copy_started(const gko::Executor *from, const gko::Executor *to,
  + const gko::uintptr &, const gko::uintptr &,
  + const gko::size_type &) const override
  + {
  + from->synchronize();
  + this->start_operation(to, "copy");
  + }
  +
  + void on_copy_completed(const gko::Executor *from, const gko::Executor *to,
  + const gko::uintptr &, const gko::uintptr &,
  + const gko::size_type &) const override
  + {
  + from->synchronize();
  + this->end_operation(to, "copy");
  + }
  +
  void on_operation_launched(const gko::Executor *exec,
  const gko::Operation *op) const override
  {
  - const auto name = op->get_name();
  - exec->synchronize();
  - start[name] = std::chrono::system_clock::now();
  + this->start_operation(exec, op->get_name());
  }
  void on_operation_completed(const gko::Executor *exec,
  const gko::Operation *op) const override
  {
  - exec->synchronize();
  - const auto end = std::chrono::system_clock::now();
  -
  - const auto name = op->get_name();
  - total[name] += end - start[name];
  + this->end_operation(exec, op->get_name());
  }
  void write_data(rapidjson::Value &object,
  @@ -86,6 +121,20 @@ struct OperationLogger : gko::log::Logger {
  {}
  private:
  + void start_operation(const gko::Executor *exec,
  + const std::string &name) const
  + {
  + exec->synchronize();
  + start[name] = std::chrono::system_clock::now();
  + }
  +
  + void end_operation(const gko::Executor *exec, const std::string &name) const
  + {
  + exec->synchronize();
  + const auto end = std::chrono::system_clock::now();
  + total[name] += end - start[name];
  + }
  +
  mutable std::map<std::string, std::chrono::system_clock::time_point> start;
  mutable std::map<std::string, std::chrono::system_clock::duration> total;
  };
  