Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:40

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/Engine/JPerfMetrics.h>  // TODO: Should't be here
0011 
0012 #include <JANA/Services/JParameterManager.h>
0013 #include <JANA/Services/JComponentManager.h>
0014 
0015 
0016 class JParameterManager;
0017 class JComponentManager;
0018 class JArrow;
0019 class JQueue;
0020 class JPoolBase;
0021 class JQueue;
0022 class JFoldArrow;
0023 class JUnfoldArrow;
0024 class JEventPool;
0025 
0026 class JTopologyBuilder : public JService {
0027 public:
0028     // Services
0029     Service<JParameterManager> m_params {this};
0030     std::shared_ptr<JComponentManager> m_components;
0031 
0032     // The topology itself
0033     std::vector<JArrow*> arrows;
0034     std::vector<JQueue*> queues;            // Queues shared between arrows
0035     std::vector<JPoolBase*> pools;          // Pools shared between arrows
0036     
0037     // Topology configuration
0038     size_t m_event_pool_size = 4;
0039     size_t m_event_queue_threshold = 80;
0040     size_t m_event_source_chunksize = 40;
0041     size_t m_event_processor_chunksize = 1;
0042     size_t m_location_count = 1;
0043     bool m_enable_stealing = false;
0044     bool m_limit_total_events_in_flight = true;
0045     int m_affinity = 0;
0046     int m_locality = 0;
0047 
0048     // Things that probably shouldn't be here
0049     std::function<void(JTopologyBuilder&)> m_configure_topology;
0050     JEventPool* event_pool = nullptr; // TODO: Move into pools eventually
0051     JPerfMetrics metrics;
0052     JProcessorMapping mapping;
0053 
0054 public:
0055 
0056     JTopologyBuilder();
0057     ~JTopologyBuilder() override;
0058 
0059     void acquire_services(JServiceLocator *sl) override;
0060 
0061     /// set_cofigure_fn lets the user provide a lambda that sets up a topology after all components have been loaded.
0062     /// It provides an 'empty' JArrowTopology which has been furnished with a pointer to the JComponentManager, the JEventPool,
0063     /// and the JProcessorMapping (in case you care about NUMA details). However, it does not contain any queues or arrows.
0064     /// You have to furnish those yourself.
0065     void set_configure_fn(std::function<void(JTopologyBuilder&)> configure_fn);
0066 
0067     void create_topology();
0068 
0069     void attach_lower_level(JEventLevel current_level, JUnfoldArrow* parent_unfolder, JFoldArrow* parent_folder, bool found_sink);
0070 
0071     void attach_top_level(JEventLevel current_level);
0072 
0073     std::string print_topology();
0074 
0075 
0076 };
0077 
0078