STADLS
playback_program_builder.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iosfwd>
4 #include <memory>
5 #include <unordered_set>
6 
7 #include "halco/hicann-dls/vx/barrier.h"
8 #include "haldls/vx/barrier.h"
9 #include "haldls/vx/common.h"
10 #include "hate/visibility.h"
11 #include "hxcomm/vx/target.h"
12 #include "stadls/vx/dumper.h"
13 #include "stadls/vx/genpybind.h"
15 
16 // clang-format off
17 #if defined(__GENPYBIND__) or defined(__GENPYBIND_GENERATED__)
18 #include "haldls/vx/pickle.h"
19 #endif
20 
21 #ifdef __GENPYBIND_GENERATED__
22 #include "fisch/vx/playback_program_builder.h"
23 #endif
24 // clang-format on
25 
26 namespace fisch::vx {
28 } // namespace fisch::vx
29 
31 
32 #if defined(__GENPYBIND__) or defined(__GENPYBIND_GENERATED__)
33 namespace v2 {
34 class DumperDone;
35 using Dumper = class stadls::vx::detail::Dumper<stadls::vx::v2::DumperDone>;
36 } // namespace v2
37 #endif
38 
39 namespace detail {
40 
41 template <typename, typename, template <typename> class>
42 class PlaybackProgramBuilderAdapterImpl;
43 
44 template <typename, typename, template <typename> class>
46 
47 template <typename T, typename U, template <typename> class C>
48 std::ostream& operator<<(std::ostream& os, PlaybackProgramBuilderAdapter<T, U, C> const& builder)
49  SYMBOL_VISIBLE;
50 
54 template <
55  typename BuilderStorage,
56  typename DoneType,
57  template <typename>
58  class CoordinateToContainer>
59 class SYMBOL_VISIBLE PlaybackProgramBuilderAdapter
60 {
61 public:
64 
69 
70  typedef BuilderStorage Builder;
71 
78  void wait_until(
79  typename haldls::vx::Timer::coordinate_type const& coord, haldls::vx::Timer::Value time);
80 
87  typename haldls::vx::Timer::coordinate_type const& coord, haldls::vx::Timer::Value time);
88 
94  void block_until(halco::hicann_dls::vx::BarrierOnFPGA const& coord, haldls::vx::Barrier sync);
95 
96  /*
97  * Add instruction to block execution until configured Omnibus address has (not) defined value.
98  * @param coord Coordinate for which to block
99  * @param sync PollingOmnibusBlock value for which to block execution
100  */
102  halco::hicann_dls::vx::PollingOmnibusBlockOnFPGA const& coord,
103  haldls::vx::PollingOmnibusBlock sync);
104 
111  template <typename Type>
112  void write(
113  typename Type::coordinate_type const& coord,
114  Type const& config,
115  haldls::vx::Backend backend);
116 
125  template <typename Type>
126  void write(typename Type::coordinate_type const& coord, Type const& config);
127 
135  template <typename Type>
136  void write(
137  typename Type::coordinate_type const& coord,
138  Type const& config,
139  Type const& config_reference,
140  haldls::vx::Backend backend);
141 
151  template <typename Type>
152  void write(
153  typename Type::coordinate_type const& coord,
154  Type const& config,
155  Type const& config_reference);
156 
162  template <typename CoordinateType>
164  CoordinateType const& coord, haldls::vx::Backend backend);
165 
173  template <typename CoordinateType>
175  CoordinateType const& coord);
176 
183 
189  void merge_back(PlaybackProgramBuilderAdapter&& other) GENPYBIND(hidden);
190 
196  void merge_back(BuilderStorage& other);
197 
203  void merge_back(BuilderStorage&& other) GENPYBIND(hidden);
204 
212 
219  void copy_back(BuilderStorage const& other);
220 
225  DoneType done();
226 
227  template <typename T, typename U, template <typename> class C>
228  friend std::ostream& operator<<(
229  std::ostream& os, PlaybackProgramBuilderAdapter<T, U, C> const& builder);
230 
231  GENPYBIND_MANUAL({
232  parent.def("__repr__", [](GENPYBIND_PARENT_TYPE const& p) {
233  std::stringstream ss;
234  typedef hate::type_list<::stadls::vx::v2::Dumper> dumper_types;
235  if constexpr (hate::is_in_type_list<
236  typename std::decay<decltype(p)>::type::Builder,
237  dumper_types>::value) {
238  ss << "PlaybackProgramBuilderDumper()";
239  } else {
240  ss << "PlaybackProgramBuilder(to FPGA size: " << p.size_to_fpga()
241  << ", is write only: " << std::boolalpha << p.is_write_only() << ")";
242  }
243  return ss.str();
244  });
245  parent.def("__str__", [](GENPYBIND_PARENT_TYPE const& p) {
246  std::stringstream ss;
247  ss << p;
248  return ss.str();
249  });
250  })
251 
256  bool empty() const;
257 
262  size_t size_to_fpga() const;
263 
268  bool is_write_only() const;
269 
270 private:
271  using Impl =
273  friend Impl;
274 
275  friend class cereal::access;
276  template <class Archive>
277  void serialize(Archive& ar, std::uint32_t const version);
278 
279  std::unique_ptr<BuilderStorage> m_builder_impl;
280 
281  std::unordered_set<hxcomm::vx::Target> m_unsupported_targets;
282 };
283 
284 } // namespace detail
285 
286 } // namespace stadls::vx
Ticket for to-be-available container data corresponding to a read instruction.
Dumper implements an interface derived from fisch::vx::PlaybackProgramBuilder.
Definition: dumper.h:26
DoneType done()
Close PlaybackProgram build process and return executable program.
void write(typename Type::coordinate_type const &coord, Type const &config, haldls::vx::Backend backend)
Add instructions to write given container to given location.
void write(typename Type::coordinate_type const &coord, Type const &config, Type const &config_reference)
Add instructions to write given container to given location.
void merge_back(PlaybackProgramBuilderAdapter &&other)
Merge other PlaybackProgramBuilderAdapter to the end of this builder instance.
void copy_back(BuilderStorage const &other)
Copy BuilderStorage to the end of this builder instance.
void block_until(typename haldls::vx::Timer::coordinate_type const &coord, haldls::vx::Timer::Value time)
Add instruction to block execution until specified timer has reached specified value.
hate::type_list<::stadls::vx::v2::Dumper > dumper_types
void copy_back(PlaybackProgramBuilderAdapter const &other)
Copy other PlaybackProgramBuilderAdapter to the end of this builder instance.
PlaybackProgramBuilderAdapter(PlaybackProgramBuilderAdapter &&other)
void merge_back(PlaybackProgramBuilderAdapter &other)
Merge other PlaybackProgramBuilderAdapter to the end of this builder instance.
PlaybackProgramBuilderAdapter & operator=(PlaybackProgramBuilderAdapter &&other)
void merge_back(BuilderStorage &&other)
Merge BuilderStorage to the end of this builder instance.
PlaybackProgram::ContainerTicket< typename CoordinateToContainer< CoordinateType >::type > read(CoordinateType const &coord)
Add instructions to read container data from given location.
void merge_back(BuilderStorage &other)
Merge BuilderStorage to the end of this builder instance.
void write(typename Type::coordinate_type const &coord, Type const &config, Type const &config_reference, haldls::vx::Backend backend)
Add instructions to write given container to given location.
void block_until(halco::hicann_dls::vx::PollingOmnibusBlockOnFPGA const &coord, haldls::vx::PollingOmnibusBlock sync)
void wait_until(typename haldls::vx::Timer::coordinate_type const &coord, haldls::vx::Timer::Value time)
Add instruction to block execution until specified timer has reached specified value.
void write(typename Type::coordinate_type const &coord, Type const &config)
Add instructions to write given container to given location.
PlaybackProgram::ContainerTicket< typename CoordinateToContainer< CoordinateType >::type > read(CoordinateType const &coord, haldls::vx::Backend backend)
Add instructions to read container data from given location.
void block_until(halco::hicann_dls::vx::BarrierOnFPGA const &coord, haldls::vx::Barrier sync)
Add instruction to block execution until specified barrier is completed.
friend std::ostream & operator<<(std::ostream &os, PlaybackProgramBuilderAdapter< T, U, C > const &builder)
PlaybackProgramBuilderAdapter(PlaybackProgramBuilderAdapter const &)=delete
#define GENPYBIND_TAG_STADLS_VX
Definition: genpybind.h:4
bool is_write_only() const
Get whether builder only stores write instructions.
class SYMBOL_VISIBLE stadls::vx::detail::PlaybackProgramBuilderAdapter empty() const
Get whether builder is empty, i.e.
size_t size_to_fpga() const
Get number of UT messages to FPGA.
struct stadls::vx::v2::DumperDone access
void serialize(Archive &ar, std::uint32_t)
stadls::vx::detail::Dumper< DumperDone > Dumper
Definition: dumper.h:18
detail::PlaybackProgramBuilderAdapter< fisch::vx::PlaybackProgramBuilder, PlaybackProgram, CoordinateToContainer > PlaybackProgramBuilder
Definition: visitors.h:9
hate::type_list<::stadls::vx::v2::Dumper > dumper_types
BuilderStorage Builder
friend std::ostream & operator<<(std::ostream &os, PlaybackProgramBuilderAdapter< T, U, C > const &builder)
PlaybackProgramBuilderAdapter()
Construct builder.