Line data Source code
1 : /*! 2 : * \file 3 : * \brief Class sched::Scheduler_from_file. 4 : */ 5 : #ifndef SCHEDULER_FROM_FILE_HPP__ 6 : #define SCHEDULER_FROM_FILE_HPP__ 7 : 8 : #include "Scheduler/Scheduler.hpp" 9 : #include <nlohmann/json.hpp> 10 : 11 : namespace spu 12 : { 13 : namespace sched 14 : { 15 : 16 : class Scheduler_from_file : public Scheduler 17 : { 18 : protected: 19 : // Construct policy function for V1 file 20 : uint8_t file_version; 21 : std::vector<std::pair<size_t, size_t>> solution_from_file; 22 : std::vector<size_t> sync_buff_sizes_from_file; 23 : std::vector<bool> sync_active_waitings_from_file; 24 : std::vector<std::vector<size_t>> puids_from_file; 25 : void contsruct_policy_v1(nlohmann::json& data, runtime::Sequence& sequence); 26 : 27 : // Construct policy function for V2 file 28 : std::vector<std::vector<size_t>> p_core_pu_list; 29 : std::vector<std::vector<size_t>> e_core_pu_list; 30 : std::vector<std::string> pinning_policy; 31 : void build_stage_policy_packed(std::vector<std::vector<size_t>>& pu_list, size_t n_replicates); 32 : void build_stage_policy_guided(std::vector<std::vector<size_t>>& pu_list, size_t n_replicates); 33 : void build_stage_policy_distant(std::vector<std::vector<size_t>>& pu_list, 34 : size_t n_replicates, 35 : size_t curr_type_index, 36 : size_t smt_value); 37 : void contsruct_policy_v2(nlohmann::json& data, runtime::Sequence& sequence); 38 : 39 : public: 40 : Scheduler_from_file(runtime::Sequence& sequence, const std::string filename, uint8_t file_version = 2); 41 : Scheduler_from_file(runtime::Sequence* sequence, const std::string filename, uint8_t file_version = 2); 42 0 : ~Scheduler_from_file() = default; 43 : virtual void schedule() override; 44 : 45 : std::vector<bool> get_thread_pinnings() const override; 46 : std::vector<size_t> get_sync_buff_sizes() const override; 47 : std::vector<bool> get_sync_active_waitings() const override; 48 : std::string get_threads_mapping() const override; 49 : }; 50 : } // namespace sched 51 : } // namespace spu 52 : 53 : #endif // SCHEDULER_FROM_FILE_HPP__