45#include <unordered_map>
69 mutable std::mutex mutex_;
70 std::unordered_map<std::type_index, NodeDispatcherFn> factory_map_;
79 std::lock_guard<std::mutex> lock(mutex_);
80 if (factory_map_.find(type) != factory_map_.end()) {
83 factory_map_[type] = std::move(fn);
87 auto it = factory_map_.find(type);
88 if (it != factory_map_.end()) {
95 return factory_map_.size();
127 mutable std::mutex mutex_;
128 std::unordered_map<std::string, MapDispatcherFn> factory_map_;
137 std::lock_guard<std::mutex> lock(mutex_);
138 if (factory_map_.find(schedule_type) != factory_map_.end()) {
141 factory_map_[schedule_type] = std::move(fn);
145 auto it = factory_map_.find(schedule_type);
146 if (it != factory_map_.end()) {
153 return factory_map_.size();
177 mutable std::mutex mutex_;
178 std::unordered_map<std::string, ReduceDispatcherFn> factory_map_;
187 std::lock_guard<std::mutex> lock(mutex_);
188 if (factory_map_.find(schedule_type) != factory_map_.end()) {
191 factory_map_[schedule_type] = std::move(fn);
195 auto it = factory_map_.find(schedule_type);
196 if (it != factory_map_.end()) {
203 return factory_map_.size();
247 mutable std::mutex mutex_;
248 std::unordered_map<std::string, LibraryNodeDispatcherFn> factory_map_;
261 "use register_library_node_dispatcher(const data_flow::LibraryNodeCode&, const data_flow::ImplementationType&, "
262 "LibraryNodeDispatcherFn) instead"
265 std::lock_guard<std::mutex> lock(mutex_);
266 if (factory_map_.find(library_node_code) != factory_map_.end()) {
269 factory_map_[library_node_code] = std::move(fn);
283 std::string full_code = code.
value() +
"::" + impl_type.
value();
284 std::lock_guard<std::mutex> lock(mutex_);
285 if (factory_map_.find(full_code) != factory_map_.end()) {
288 factory_map_[full_code] = std::move(fn);
292 auto it = factory_map_.find(library_node_code);
293 if (it != factory_map_.end()) {
300 return factory_map_.size();
Dispatchers for dataflow blocks and library nodes.
std::string value() const
Definition exceptions.h:47
Definition structured_sdfg.h:30
Definition arg_capture_plan.h:36
Definition instrumentation_plan.h:26
Definition language_extension.h:39
Registry for library node dispatchers.
Definition node_dispatcher_registry.h:245
size_t size() const
Definition node_dispatcher_registry.h:299
void register_library_node_dispatcher(std::string library_node_code, LibraryNodeDispatcherFn fn)
Definition node_dispatcher_registry.h:264
static LibraryNodeDispatcherRegistry & instance()
Definition node_dispatcher_registry.h:251
LibraryNodeDispatcherFn get_library_node_dispatcher(std::string library_node_code) const
Definition node_dispatcher_registry.h:291
void register_library_node_dispatcher(const data_flow::LibraryNodeCode &code, const data_flow::ImplementationType &impl_type, LibraryNodeDispatcherFn fn)
Designed to make the way the lookup of impl-type specific dispatchers work implementation detail.
Definition node_dispatcher_registry.h:278
Registry for map-specific dispatchers based on schedule type.
Definition node_dispatcher_registry.h:125
void register_map_dispatcher(std::string schedule_type, MapDispatcherFn fn)
Definition node_dispatcher_registry.h:136
MapDispatcherFn get_map_dispatcher(std::string schedule_type) const
Definition node_dispatcher_registry.h:144
size_t size() const
Definition node_dispatcher_registry.h:152
static MapDispatcherRegistry & instance()
Definition node_dispatcher_registry.h:131
Definition node_dispatcher_registry.h:67
NodeDispatcherFn get_dispatcher(std::type_index type) const
Definition node_dispatcher_registry.h:86
size_t size() const
Definition node_dispatcher_registry.h:94
static NodeDispatcherRegistry & instance()
Definition node_dispatcher_registry.h:73
void register_dispatcher(std::type_index type, NodeDispatcherFn fn)
Definition node_dispatcher_registry.h:78
Registry for reduce-specific dispatchers based on schedule type.
Definition node_dispatcher_registry.h:175
ReduceDispatcherFn get_reduce_dispatcher(std::string schedule_type) const
Definition node_dispatcher_registry.h:194
void register_reduce_dispatcher(std::string schedule_type, ReduceDispatcherFn fn)
Definition node_dispatcher_registry.h:186
static ReduceDispatcherRegistry & instance()
Definition node_dispatcher_registry.h:181
size_t size() const
Definition node_dispatcher_registry.h:202
Definition data_flow_graph.h:29
Base class for all library nodes in the dataflow graph.
Definition library_node.h:106
Base class for all structured control flow nodes in a StructuredSDFG.
Definition control_flow_node.h:44
Represents a parallel map loop with configurable scheduling.
Definition map.h:47
Represents a loop with an associative/commutative reduction carried dependency.
Definition reduce.h:106
Definition argument_registry.h:10
std::function< std::unique_ptr< NodeDispatcher >( LanguageExtension &, StructuredSDFG &, analysis::AnalysisManager &, structured_control_flow::Reduce &, InstrumentationPlan &, ArgCapturePlan &)> ReduceDispatcherFn
Definition node_dispatcher_registry.h:157
std::unique_ptr< NodeDispatcher > create_dispatcher(LanguageExtension &language_extension, StructuredSDFG &sdfg, analysis::AnalysisManager &analysis_manager, structured_control_flow::ControlFlowNode &node, InstrumentationPlan &instrumentation_plan, ArgCapturePlan &arg_capture_plan)
std::function< std::unique_ptr< NodeDispatcher >( LanguageExtension &, StructuredSDFG &, analysis::AnalysisManager &, structured_control_flow::ControlFlowNode &, InstrumentationPlan &, ArgCapturePlan &)> NodeDispatcherFn
Definition node_dispatcher_registry.h:58
void register_default_dispatchers()
std::function< std::unique_ptr< LibraryNodeDispatcher >( LanguageExtension &, const Function &, const data_flow::DataFlowGraph &, const data_flow::LibraryNode &)> LibraryNodeDispatcherFn
Definition node_dispatcher_registry.h:207
std::function< std::unique_ptr< NodeDispatcher >( LanguageExtension &, StructuredSDFG &, analysis::AnalysisManager &, structured_control_flow::Map &, InstrumentationPlan &, ArgCapturePlan &)> MapDispatcherFn
Definition node_dispatcher_registry.h:108
StringEnum ImplementationType
Implementation type identifier for library nodes.
Definition library_node.h:75
StringEnum LibraryNodeCode
Definition library_node.h:65
Dispatcher base class for code generation from control flow nodes.