Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-13 08:53:04

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 #pragma once
0006 
0007 #include <memory>
0008 #include <JANA/JService.h>
0009 #include <JANA/Utils/JProcessorMapping.h>
0010 #include <JANA/Topology/JEventQueue.h>
0011 #include <JANA/Topology/JEventPool.h>
0012 
0013 #include <JANA/Services/JParameterManager.h>
0014 #include <JANA/Services/JComponentManager.h>
0015 
0016 
0017 class JParameterManager;
0018 class JComponentManager;
0019 class JArrow;
0020 class JFoldArrow;
0021 class JUnfoldArrow;
0022 class JEventTapArrow;
0023 
0024 class JTopologyBuilder : public JService {
0025 public:
0026     // Services
0027     Service<JParameterManager> m_params {this};
0028     std::shared_ptr<JComponentManager> m_components;
0029 
0030     // The topology itself
0031     std::vector<JArrow*> arrows;
0032     std::vector<JEventQueue*> queues;            // Queues shared between arrows
0033     std::vector<JEventPool*> pools;          // Pools shared between arrows
0034     
0035     // Topology configuration
0036     size_t m_max_inflight_events = 1;
0037     size_t m_location_count = 1;
0038     bool m_enable_stealing = false;
0039     int m_affinity = 0;
0040     int m_locality = 0;
0041 
0042     // Things that probably shouldn't be here
0043     std::function<void(JTopologyBuilder&)> m_configure_topology;
0044     JProcessorMapping mapping;
0045 
0046 public:
0047 
0048     JTopologyBuilder();
0049     ~JTopologyBuilder() override;
0050 
0051     void acquire_services(JServiceLocator *sl) override;
0052 
0053     /// set_cofigure_fn lets the user provide a lambda that sets up a topology after all components have been loaded.
0054     /// It provides an 'empty' JArrowTopology which has been furnished with a pointer to the JComponentManager, the JEventPool,
0055     /// and the JProcessorMapping (in case you care about NUMA details). However, it does not contain any queues or arrows.
0056     /// You have to furnish those yourself.
0057     void set_configure_fn(std::function<void(JTopologyBuilder&)> configure_fn);
0058 
0059     void create_topology();
0060 
0061     void attach_level(JEventLevel current_level, JUnfoldArrow* parent_unfolder, JFoldArrow* parent_folder);
0062     void connect_to_first_available(JArrow* upstream, size_t upstream_port_id, std::vector<std::pair<JArrow*, size_t>> downstreams);
0063     void connect(JArrow* upstream, size_t upstream_port_id, JArrow* downstream, size_t downstream_port_id);
0064     std::pair<JEventTapArrow*, JEventTapArrow*> create_tap_chain(std::vector<JEventProcessor*>& procs, std::string name);
0065 
0066     std::string print_topology();
0067 
0068 
0069 };
0070 
0071