Skip to content

Commit

Permalink
Introduce a new 'Module::Stateful' class.
Browse files Browse the repository at this point in the history
  • Loading branch information
kouchy committed Jul 26, 2024
1 parent 58a56ac commit be8df53
Show file tree
Hide file tree
Showing 94 changed files with 268 additions and 195 deletions.
10 changes: 8 additions & 2 deletions include/Module/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace spu
{
namespace module
{
class Stateful;
class Stateless;
/*!
* \class Module
*
Expand All @@ -30,6 +32,9 @@ class Module
: public tools::Interface_clone
, public tools::Interface_get_set_n_frames
{
friend Stateful;
friend Stateless;

protected:
size_t n_frames; /*!< Number of frames to process in this Module */
size_t n_frames_per_wave;
Expand All @@ -44,11 +49,13 @@ class Module
public:
std::vector<std::shared_ptr<runtime::Task>> tasks;

protected:
/*!
* \brief Constructor.
*/
explicit Module();

public:
/*!
* \brief Destructor.
*/
Expand Down Expand Up @@ -96,7 +103,7 @@ class Module
bool is_stateful() const;
bool is_clonable() const;

protected:
private:
void deep_copy(const Module& m);

void set_name(const std::string& name);
Expand Down Expand Up @@ -261,7 +268,6 @@ class Module

void set_single_wave(const bool enable_single_wave);

private:
void _set_n_frames_per_wave(const size_t n_frames_per_wave);
void _set_n_frames(const size_t n_frames);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <typeindex>
#include <vector>

#include "Module/Module.hpp"
#include "Module/Stateful/Stateful.hpp"
#include "Runtime/Sequence/Sequence.hpp"
#include "Runtime/Socket/Socket.hpp"
#include "Runtime/Task/Task.hpp"
Expand Down Expand Up @@ -71,7 +71,7 @@ enum class pull_1 : size_t
}

class Adaptor
: public Module
: public Stateful
, public tools::Interface_waiting
{
friend runtime::Sequence; // Sequence is friend to enable the no copy mode (0 copy)
Expand Down Expand Up @@ -111,7 +111,7 @@ class Adaptor
inline Adaptor(const std::vector<size_t>& n_elmts,
const std::vector<std::type_index>& datatype,
const size_t buffer_size);
using Module::deep_copy;
using Stateful::deep_copy;
virtual void deep_copy(const Adaptor& m);
inline bool is_full(const size_t id);
inline bool is_empty(const size_t id);
Expand All @@ -134,7 +134,7 @@ class Adaptor
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Adaptor/Adaptor.hxx"
#include "Module/Stateful/Adaptor/Adaptor.hxx"
#endif

#endif /* ADAPTOR_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sstream>
#include <string>

#include "Module/Adaptor/Adaptor.hpp"
#include "Module/Stateful/Adaptor/Adaptor.hpp"
#include "Tools/Exception/exception.hpp"
#include "Tools/compute_bytes.h"

Expand All @@ -12,7 +12,7 @@ namespace module
{

Adaptor::Adaptor(const size_t n_elmts, const std::type_index datatype, const size_t buffer_size)
: Module()
: Stateful()
, n_elmts(1, n_elmts)
, n_bytes(1, tools::compute_bytes(n_elmts, datatype))
, datatype(1, datatype)
Expand Down Expand Up @@ -65,7 +65,7 @@ Adaptor::Adaptor(const size_t n_elmts, const std::type_index datatype, const siz
Adaptor::Adaptor(const std::vector<size_t>& n_elmts,
const std::vector<std::type_index>& datatype,
const size_t buffer_size)
: Module()
: Stateful()
, n_elmts(n_elmts)
, n_bytes(tools::compute_bytes(n_elmts, datatype))
, datatype(datatype)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <typeindex>
#include <vector>

#include "Module/Adaptor/Adaptor.hpp"
#include "Module/Stateful/Adaptor/Adaptor.hpp"
#include "Runtime/Socket/Socket.hpp"
#include "Runtime/Task/Task.hpp"

Expand Down Expand Up @@ -71,7 +71,7 @@ class Adaptor_1_to_n : public Adaptor
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Adaptor/Adaptor_1_to_n.hxx"
#include "Module/Stateful/Adaptor/Adaptor_1_to_n.hxx"
#endif

#endif /* ADAPTOR_1_TO_N_HPP_ */
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <sstream>
#include <string>

#include "Module/Adaptor/Adaptor_1_to_n.hpp"
#include "Module/Stateful/Adaptor/Adaptor_1_to_n.hpp"
#include "Tools/Exception/exception.hpp"

namespace spu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <typeindex>
#include <vector>

#include "Module/Adaptor/Adaptor.hpp"
#include "Module/Stateful/Adaptor/Adaptor.hpp"
#include "Runtime/Socket/Socket.hpp"
#include "Runtime/Task/Task.hpp"

Expand Down Expand Up @@ -71,7 +71,7 @@ class Adaptor_n_to_1 : public Adaptor
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Adaptor/Adaptor_n_to_1.hxx"
#include "Module/Stateful/Adaptor/Adaptor_n_to_1.hxx"
#endif

#endif /* ADAPTOR_N_TO_1_HPP_ */
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <sstream>
#include <string>

#include "Module/Adaptor/Adaptor_n_to_1.hpp"
#include "Module/Stateful/Adaptor/Adaptor_n_to_1.hpp"
#include "Tools/Exception/exception.hpp"

namespace spu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <memory>
#include <vector>

#include "Module/Module.hpp"
#include "Module/Stateful/Stateful.hpp"
#include "Runtime/Socket/Socket.hpp"
#include "Runtime/Task/Task.hpp"
#include "Tools/Math/binaryop.h"
Expand Down Expand Up @@ -47,7 +47,7 @@ enum class performf : size_t
}

template<typename TI, typename TO, tools::proto_bop<TI, TO> BOP>
class Binaryop : public Module
class Binaryop : public Stateful
{
public:
inline runtime::Task& operator[](const bop::tsk t);
Expand Down Expand Up @@ -150,7 +150,7 @@ using Binaryop_eq = Binaryop<TI, TO, tools::bop_eq<TI, TO>>;
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Binaryop/Binaryop.hxx"
#include "Module/Stateful/Binaryop/Binaryop.hxx"
#endif

#endif /* BINARYOP_HPP_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Module/Binaryop/Binaryop.hpp"
#include "Module/Stateful/Binaryop/Binaryop.hpp"

namespace spu
{
Expand Down Expand Up @@ -35,7 +35,7 @@ Binaryop<TI, TO, BOP>::operator[](const std::string& tsk_sck)

template<typename TI, typename TO, tools::proto_bop<TI, TO> BOP>
Binaryop<TI, TO, BOP>::Binaryop(const size_t n_in0, const size_t n_in1)
: Module()
: Stateful()
, n_elmts(n_in0 > n_in1 ? n_in0 : n_in1)
{
const std::string name = "Binaryop";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <cstdint>

#include "Module/Module.hpp"
#include "Module/Stateful/Stateful.hpp"
#include "Tools/Interface/Interface_reset.hpp"

namespace spu
Expand All @@ -34,7 +34,7 @@ enum class control : size_t
}

class Controller
: public Module
: public Stateful
, public tools::Interface_reset
{
public:
Expand Down Expand Up @@ -67,7 +67,7 @@ class Controller
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Controller/Controller.hxx"
#include "Module/Stateful/Controller/Controller.hxx"
#endif

#endif /* CONTROLLER_HPP_ */
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <string>

#include "Module/Controller/Controller.hpp"
#include "Module/Stateful/Controller/Controller.hpp"

namespace spu
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <cstdint>

#include "Module/Controller/Controller.hpp"
#include "Module/Stateful/Controller/Controller.hpp"

namespace spu
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <cstdint>

#include "Module/Controller/Controller.hpp"
#include "Module/Stateful/Controller/Controller.hpp"

namespace spu
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <cstdint>

#include "Module/Controller/Controller.hpp"
#include "Module/Stateful/Controller/Controller.hpp"

namespace spu
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string>
#include <vector>

#include "Module/Module.hpp"
#include "Module/Stateful/Stateful.hpp"

namespace spu
{
Expand Down Expand Up @@ -36,7 +36,7 @@ enum class produce : uint8_t
}

template<typename D = int>
class Delayer : public Module
class Delayer : public Stateful
{
public:
inline runtime::Task& operator[](const dly::tsk t);
Expand Down Expand Up @@ -66,6 +66,6 @@ class Delayer : public Module
}
}

#include "Module/Delayer/Delayer.hxx"
#include "Module/Stateful/Delayer/Delayer.hxx"

#endif /* DELAYER_HPP_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Module/Delayer/Delayer.hpp"
#include "Module/Stateful/Delayer/Delayer.hpp"

namespace spu
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cstdint>
#include <vector>

#include "Module/Module.hpp"
#include "Module/Stateful/Stateful.hpp"

#include "Tools/Interface/Interface_reset.hpp"

Expand Down Expand Up @@ -36,7 +36,7 @@ enum class finalize : size_t

template<typename T = int>
class Finalizer
: public Module
: public Stateful
, public tools::Interface_reset
{
public:
Expand Down Expand Up @@ -73,7 +73,7 @@ class Finalizer
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Finalizer/Finalizer.hxx"
#include "Module/Stateful/Finalizer/Finalizer.hxx"
#endif

#endif /* FINALIZER_HPP_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Module/Finalizer/Finalizer.hpp"
#include "Module/Stateful/Finalizer/Finalizer.hpp"

namespace spu
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <cstdint>
#include <vector>

#include "Module/Module.hpp"
#include "Module/Stateful/Stateful.hpp"

namespace spu
{
Expand Down Expand Up @@ -40,7 +40,7 @@ enum class incrementf : size_t
}

template<typename T = int>
class Incrementer : public Module
class Incrementer : public Stateful
{
public:
inline runtime::Task& operator[](const inc::tsk t);
Expand Down Expand Up @@ -76,7 +76,7 @@ class Incrementer : public Module
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Incrementer/Incrementer.hxx"
#include "Module/Stateful/Incrementer/Incrementer.hxx"
#endif

#endif /* INCREMENTER_HPP_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Module/Incrementer/Incrementer.hpp"
#include "Module/Stateful/Incrementer/Incrementer.hpp"

namespace spu
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <cstdint>

#include "Module/Module.hpp"
#include "Module/Stateful/Stateful.hpp"

namespace spu
{
Expand All @@ -32,7 +32,7 @@ enum class initialize : size_t
}

template<typename T = int>
class Initializer : public Module
class Initializer : public Stateful
{
public:
inline runtime::Task& operator[](const ini::tsk t);
Expand Down Expand Up @@ -66,7 +66,7 @@ class Initializer : public Module
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Module/Initializer/Initializer.hxx"
#include "Module/Stateful/Initializer/Initializer.hxx"
#endif

#endif /* INITIALIZER_HPP_ */
Loading

0 comments on commit be8df53

Please sign in to comment.