geopm 3.1.1.dev579+g75d9c8b9
GEOPM - Global Extensible Open Power Manager
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TreeCommLevel.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 - 2025 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef TREECOMMLEVEL_HPP_INCLUDE
7#define TREECOMMLEVEL_HPP_INCLUDE
8
9#include <vector>
10#include <memory>
11
12namespace geopm
13{
15 {
16 public:
17 TreeCommLevel() = default;
18 virtual ~TreeCommLevel() = default;
20 virtual int level_rank(void) const = 0;
22 virtual void send_up(const std::vector<double> &sample) = 0;
24 virtual void send_down(const std::vector<std::vector<double> > &policy) = 0;
26 virtual bool receive_up(std::vector<std::vector<double> > &sample) = 0;
28 virtual bool receive_down(std::vector<double> &policy) = 0;
31 virtual size_t overhead_send(void) const = 0;
32 };
33
34 class Comm;
35
37 {
38 public:
39 TreeCommLevelImp(std::shared_ptr<Comm> comm, int num_send_up, int num_send_down);
40 TreeCommLevelImp(const TreeCommLevelImp &other) = delete;
42 virtual ~TreeCommLevelImp();
43 int level_rank(void) const override;
44 void send_up(const std::vector<double> &sample) override;
45 void send_down(const std::vector<std::vector<double> > &policy) override;
46 bool receive_up(std::vector<std::vector<double> > &sample) override;
47 bool receive_down(std::vector<double> &policy) override;
48 size_t overhead_send(void) const override;
49 private:
50 void create_window();
51 std::shared_ptr<Comm> m_comm;
52 int m_size;
53 int m_rank;
54 double *m_sample_mailbox;
55 double *m_policy_mailbox;
56 size_t m_sample_window;
57 size_t m_policy_window;
58 size_t m_overhead_send;
59 std::vector<std::vector<double> > m_policy_last;
60 size_t m_num_send_up;
61 size_t m_num_send_down;
62 };
63}
64
65#endif
Abstract base class for interprocess communication in geopm.
Definition Comm.hpp:20
Definition TreeCommLevel.hpp:15
virtual size_t overhead_send(void) const =0
Returns the total number of bytes sent at this level.
virtual bool receive_up(std::vector< std::vector< double > > &sample)=0
Receive samples up from children.
virtual int level_rank(void) const =0
Returns the rank for this level.
virtual ~TreeCommLevel()=default
virtual void send_up(const std::vector< double > &sample)=0
Send samples up to the parent.
virtual bool receive_down(std::vector< double > &policy)=0
Receive policies down from the parent.
virtual void send_down(const std::vector< std::vector< double > > &policy)=0
Send policies down to children.
Definition TreeCommLevel.hpp:37
virtual ~TreeCommLevelImp()
Definition TreeCommLevel.cpp:35
void send_up(const std::vector< double > &sample) override
Send samples up to the parent.
Definition TreeCommLevel.cpp:55
TreeCommLevelImp(const TreeCommLevelImp &other)=delete
TreeCommLevelImp & operator=(const TreeCommLevelImp &other)=delete
size_t overhead_send(void) const override
Returns the total number of bytes sent at this level.
Definition TreeCommLevel.cpp:177
bool receive_down(std::vector< double > &policy) override
Receive policies down from the parent.
Definition TreeCommLevel.cpp:157
void send_down(const std::vector< std::vector< double > > &policy) override
Send policies down to children.
Definition TreeCommLevel.cpp:77
int level_rank(void) const override
Returns the rank for this level.
Definition TreeCommLevel.cpp:50
bool receive_up(std::vector< std::vector< double > > &sample) override
Receive samples up from children.
Definition TreeCommLevel.cpp:111
Definition Accumulator.cpp:12