LCOV - code coverage report
Current view: top level - include/Module/Adaptor - Adaptor_n_to_1.hpp (source / functions) Hit Total Coverage
Test: streampu_clean.info Lines: 1 1 100.0 %
Date: 2024-06-12 12:04:18 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*!
       2             :  * \file
       3             :  * \brief Class module::Adaptor_n_to_1.
       4             :  */
       5             : #ifndef ADAPTOR_N_TO_1_HPP_
       6             : #define ADAPTOR_N_TO_1_HPP_
       7             : 
       8             : #include <atomic>
       9             : #include <condition_variable>
      10             : #include <cstddef>
      11             : #include <cstdint>
      12             : #include <memory>
      13             : #include <mutex>
      14             : #include <typeindex>
      15             : #include <vector>
      16             : 
      17             : #include "Module/Adaptor/Adaptor.hpp"
      18             : #include "Runtime/Socket/Socket.hpp"
      19             : #include "Runtime/Task/Task.hpp"
      20             : 
      21             : namespace spu
      22             : {
      23             : namespace module
      24             : {
      25             : 
      26             : class Adaptor_n_to_1 : public Adaptor
      27             : {
      28             :   public:
      29             :     inline runtime::Task& operator[](const adp::tsk t);
      30             :     inline runtime::Socket& operator[](const adp::sck::push_n s);
      31             :     inline runtime::Socket& operator[](const adp::sck::pull_1 s);
      32             : 
      33             :     const bool active_waiting;
      34             : 
      35             :     std::shared_ptr<std::vector<std::condition_variable>> cnd_put;
      36             :     std::shared_ptr<std::vector<std::mutex>> mtx_put;
      37             :     std::shared_ptr<std::condition_variable> cnd_pull;
      38             :     std::shared_ptr<std::mutex> mtx_pull;
      39             : 
      40             :   public:
      41             :     inline Adaptor_n_to_1(const size_t n_elmts,
      42             :                           const std::type_index datatype,
      43             :                           const size_t buffer_size = 1,
      44             :                           const bool active_waiting = true);
      45             :     inline Adaptor_n_to_1(const std::vector<size_t>& n_elmts,
      46             :                           const std::vector<std::type_index>& datatype,
      47             :                           const size_t buffer_size = 1,
      48             :                           const bool active_waiting = true);
      49        3944 :     virtual ~Adaptor_n_to_1() = default;
      50             :     virtual Adaptor_n_to_1* clone() const;
      51             : 
      52             :     inline void init();
      53             : 
      54             :     void wake_up();
      55             :     void cancel_waiting();
      56             : 
      57             :   protected:
      58             :     virtual void push_n(const std::vector<const int8_t*>& in, const size_t frame_id);
      59             :     virtual void pull_1(const std::vector<int8_t*>& out, const size_t frame_id);
      60             : 
      61             :     void wait_push();
      62             :     void wait_pull();
      63             :     void* get_empty_buffer(const size_t sid);
      64             :     void* get_filled_buffer(const size_t sid);
      65             :     void* get_empty_buffer(const size_t sid, void* swap_buffer);
      66             :     void* get_filled_buffer(const size_t sid, void* swap_buffer);
      67             :     void wake_up_pusher();
      68             :     void wake_up_puller();
      69             : };
      70             : }
      71             : }
      72             : 
      73             : #ifndef DOXYGEN_SHOULD_SKIP_THIS
      74             : #include "Module/Adaptor/Adaptor_n_to_1.hxx"
      75             : #endif
      76             : 
      77             : #endif /* ADAPTOR_N_TO_1_HPP_ */

Generated by: LCOV version 1.14