Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:36

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 
0023 class JTopologyBuilder : public JService {
0024 public:
0025     // Services
0026     Service<JParameterManager> m_params {this};
0027     std::shared_ptr<JComponentManager> m_components;
0028 
0029     // The topology itself
0030     std::vector<JArrow*> arrows;
0031     std::vector<JEventQueue*> queues;            // Queues shared between arrows
0032     std::vector<JEventPool*> pools;          // Pools shared between arrows
0033     
0034     // Topology configuration
0035     size_t m_max_inflight_events = 4;
0036     size_t m_location_count = 1;
0037     bool m_enable_stealing = false;
0038     int m_affinity = 0;
0039     int m_locality = 0;
0040 
0041     // Things that probably shouldn't be here
0042     std::function<void(JTopologyBuilder&)> m_configure_topology;
0043     JProcessorMapping mapping;
0044 
0045 public:
0046 
0047     JTopologyBuilder();
0048     ~JTopologyBuilder() override;
0049 
0050     void acquire_services(JServiceLocator *sl) override;
0051 
0052     /// set_cofigure_fn lets the user provide a lambda that sets up a topology after all components have been loaded.
0053     /// It provides an 'empty' JArrowTopology which has been furnished with a pointer to the JComponentManager, the JEventPool,
0054     /// and the JProcessorMapping (in case you care about NUMA details). However, it does not contain any queues or arrows.
0055     /// You have to furnish those yourself.
0056     void set_configure_fn(std::function<void(JTopologyBuilder&)> configure_fn);
0057 
0058     void create_topology();
0059 
0060     void attach_level(JEventLevel current_level, JUnfoldArrow* parent_unfolder, JFoldArrow* parent_folder);
0061     void connect_to_first_available(JArrow* upstream, std::vector<JArrow*> downstreams);
0062     void connect(JArrow* upstream, size_t upstream_index, JArrow* downstream, size_t downstream_index);
0063 
0064     std::string print_topology();
0065 
0066 
0067 };
0068 
0069