Halide  19.0.0
Halide compiler and libraries
SearchSpace.h
Go to the documentation of this file.
1 #ifndef SEARCH_SPACE_H
2 #define SEARCH_SPACE_H
3 
4 #include "ASLog.h"
5 #include "CostModel.h"
6 #include "DefaultCostModel.h"
7 #include "Featurization.h"
8 #include "FunctionDAG.h"
9 #include "LoopNest.h"
10 #include "LoopNestParser.h"
11 #include "PerfectHashMap.h"
12 #include "SearchSpaceOptions.h"
13 #include "State.h"
14 #include <set>
15 #include <unordered_map>
16 #include <unordered_set>
17 #include <vector>
18 
19 namespace Halide {
20 namespace Internal {
21 namespace Autoscheduler {
22 
23 struct SearchSpace {
24  using StateVector = std::vector<IntrusivePtr<State>>;
25  const FunctionDAG &dag;
27  const Target &target;
29  std::mt19937 &rng;
33 
37 
40  const Target &target,
41  std::mt19937 &rng,
45 
46  // Sort / filter parallel tile options
48  vector<int64_t> outer_tiling;
49  vector<int64_t> inner_tiling;
53  bool operator<(const ParallelTileOption &other) const {
54  return idle_core_wastage < other.idle_core_wastage;
55  }
56 
57  // Ensure we don't accidentally copy this type
58  ParallelTileOption() = default;
63  };
64 
65  vector<ParallelTileOption> filter_parallel_tile_options(const IntrusivePtr<State> &state,
66  const FunctionDAG::Node *node,
67  vector<vector<int64_t>> &inner_tilings,
68  const vector<int64_t> &pure_size) const;
69 
70  vector<ThreadTileOption> filter_thread_tile_options(vector<IntrusivePtr<const LoopNest>> &loop_nests) const;
71 
73  LoopNest *new_root);
74 
76  std::function<void(IntrusivePtr<State> &&)> &accept_child,
77  const FunctionDAG::Node *node,
78  int &num_children) const;
79 
80  // Generate successor states for given 'state'
82  std::function<void(IntrusivePtr<State> &&)> &accept_child,
83  int pass_idx,
84  bool is_pre_pass);
85 
87 
88  vector<vector<int64_t>> generate_compute_root_serial_tilings(const IntrusivePtr<const LoopNest> &pure_stage,
89  const FunctionDAG::Node *node) const;
90 
91  bool add_child(const IntrusivePtr<State> &state,
92  const IntrusivePtr<const LoopNest> &new_root,
93  std::function<void(IntrusivePtr<State> &&)> &accept_child) const;
94 
95  void process_pending_states(std::unordered_map<uint64_t, StateVector> &primary_options,
96  std::unordered_map<uint64_t, StateVector> &secondary_options,
97  int &num_children,
98  std::function<void(IntrusivePtr<State> &&)> &accept_child,
99  const FunctionDAG::Node *node);
100 
101  bool is_in_partial_schedule(const FunctionDAG::Node *node) const;
102 };
103 
104 } // namespace Autoscheduler
105 } // namespace Internal
106 } // namespace Halide
107 
108 #endif // SEARCH_SPACE_H
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
signed __INT64_TYPE__ int64_t
ParallelTileOption & operator=(const ParallelTileOption &)=delete
bool operator<(const ParallelTileOption &other) const
Definition: SearchSpace.h:53
ParallelTileOption & operator=(ParallelTileOption &&)=default
bool add_states_from_memoized_blocks(const IntrusivePtr< State > &state, std::function< void(IntrusivePtr< State > &&)> &accept_child, const FunctionDAG::Node *node, int &num_children) const
void memoize_blocks(const FunctionDAG::Node *node, LoopNest *new_root)
void process_pending_states(std::unordered_map< uint64_t, StateVector > &primary_options, std::unordered_map< uint64_t, StateVector > &secondary_options, int &num_children, std::function< void(IntrusivePtr< State > &&)> &accept_child, const FunctionDAG::Node *node)
NodeMap< std::vector< IntrusivePtr< const LoopNest > > > compute_root_nodes
Definition: SearchSpace.h:35
vector< ThreadTileOption > filter_thread_tile_options(vector< IntrusivePtr< const LoopNest >> &loop_nests) const
bool add_child(const IntrusivePtr< State > &state, const IntrusivePtr< const LoopNest > &new_root, std::function< void(IntrusivePtr< State > &&)> &accept_child) const
bool is_in_partial_schedule(const FunctionDAG::Node *node) const
void freeze_lowest_cost_stages(const IntrusivePtr< State > &best)
NodeMap< std::map< int, std::vector< IntrusivePtr< const LoopNest > > > > memoized_compute_root_blocks
Definition: SearchSpace.h:36
void generate_children(const IntrusivePtr< State > &state, std::function< void(IntrusivePtr< State > &&)> &accept_child, int pass_idx, bool is_pre_pass)
std::vector< IntrusivePtr< State > > StateVector
Definition: SearchSpace.h:24
vector< vector< int64_t > > generate_compute_root_serial_tilings(const IntrusivePtr< const LoopNest > &pure_stage, const FunctionDAG::Node *node) const
SearchSpace(const FunctionDAG &dag, const Anderson2021Params &params, const Target &target, std::mt19937 &rng, CostModel *cost_model, Statistics &stats, const LoopNestParser *partial_schedule)
vector< ParallelTileOption > filter_parallel_tile_options(const IntrusivePtr< State > &state, const FunctionDAG::Node *node, vector< vector< int64_t >> &inner_tilings, const vector< int64_t > &pure_size) const
Intrusive shared pointers have a reference count (a RefCount object) stored in the class itself.
Definition: IntrusivePtr.h:71
A struct representing a target machine and os to generate code for.
Definition: Target.h:19