Halide  17.0.2
Halide compiler and libraries
GPULoopInfo.h
Go to the documentation of this file.
1 #ifndef GPU_LOOP_INFO_H
2 #define GPU_LOOP_INFO_H
3 
4 /** \file
5  *
6  * Data structure containing information about the current GPU loop nest
7  * hierarchy of blocks, threads, etc. Useful when computing GPU features
8  */
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "Halide.h"
14 #include "ThreadInfo.h"
15 
16 namespace Halide {
17 namespace Internal {
18 namespace Autoscheduler {
19 
20 struct LoopNest;
21 
22 struct GPULoopInfo {
23  explicit GPULoopInfo(const LoopNest *root)
24  : root{root} {
25  }
26 
27  const LoopNest *root = nullptr;
28  const LoopNest *current_block_loop = nullptr;
29  const LoopNest *current_thread_loop = nullptr;
30  std::vector<const LoopNest *> inner_loop_stack;
34 
35  void update(const Target &target, const LoopNest *loop);
36 
38 
39  bool at_or_inside_block() const;
40 
41  bool at_or_inside_thread() const;
42 
43  std::vector<int64_t> get_inner_serial_loop_extents(const LoopNest *loop_nest) const;
44 
45  // assert-fails if create_thread_info() has *already* been called.
47 
48  // Note: if create_thread_info() has not been called yet, this will return nullptr.
49  // (Note that this is an unusual but legitimate situation, so it should *not*
50  // assert-fail if the value is null.)
51  const ThreadInfo *get_thread_info() const {
52  return thread_info.get();
53  }
54 
56 
57 private:
58  // This is a shared_ptr mainly to allow for an automatic copy ctor to be generated --
59  // it's shared between different GPULoopInfo instances, but that is never visible to
60  // the outside world.
61  std::shared_ptr<const ThreadInfo> thread_info;
62 };
63 
64 } // namespace Autoscheduler
65 } // namespace Internal
66 } // namespace Halide
67 
68 #endif // GPU_LOOP_INFO_H
int64_t get_total_inner_serial_extents_outside_realization(const LoopNest *loop_nest) const
A struct representing a target machine and os to generate code for.
Definition: Target.h:19
void update(const Target &target, const LoopNest *loop)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide&#39;s bounds tools to query properties of it.
std::vector< int64_t > get_inner_serial_loop_extents(const LoopNest *loop_nest) const
Not visible externally, similar to &#39;static&#39; linkage in C.
signed __INT64_TYPE__ int64_t
const ThreadInfo * get_thread_info() const
Definition: GPULoopInfo.h:51
std::vector< const LoopNest * > inner_loop_stack
Definition: GPULoopInfo.h:30
Data structure containing information about GPU threads for a particular location in the loop nest an...