Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
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 "HalidePlugin.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;
31 int64_t num_blocks = 1;
32 int64_t total_outer_serial_extents = 1;
33 int64_t total_inner_serial_extents = 1;
34
35 void update(const Target &target, const LoopNest *loop);
36
37 int64_t total_serial_extents() const;
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.
46 const ThreadInfo *create_thread_info();
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
55 int64_t get_total_inner_serial_extents_outside_realization(const LoopNest *loop_nest) const;
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
HalidePlugin.h
ThreadInfo.h
Data structure containing information about GPU threads for a particular location in the loop nest an...
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
int64_t
signed __INT64_TYPE__ int64_t
Definition runtime_internal.h:22
Halide::Internal::Autoscheduler::GPULoopInfo
Definition GPULoopInfo.h:22
Halide::Internal::Autoscheduler::GPULoopInfo::get_total_inner_serial_extents_outside_realization
int64_t get_total_inner_serial_extents_outside_realization(const LoopNest *loop_nest) const
Halide::Internal::Autoscheduler::GPULoopInfo::num_blocks
int64_t num_blocks
Definition GPULoopInfo.h:31
Halide::Internal::Autoscheduler::GPULoopInfo::total_serial_extents
int64_t total_serial_extents() const
Halide::Internal::Autoscheduler::GPULoopInfo::update
void update(const Target &target, const LoopNest *loop)
Halide::Internal::Autoscheduler::GPULoopInfo::at_or_inside_thread
bool at_or_inside_thread() const
Halide::Internal::Autoscheduler::GPULoopInfo::total_inner_serial_extents
int64_t total_inner_serial_extents
Definition GPULoopInfo.h:33
Halide::Internal::Autoscheduler::GPULoopInfo::root
const LoopNest * root
Definition GPULoopInfo.h:27
Halide::Internal::Autoscheduler::GPULoopInfo::total_outer_serial_extents
int64_t total_outer_serial_extents
Definition GPULoopInfo.h:32
Halide::Internal::Autoscheduler::GPULoopInfo::get_thread_info
const ThreadInfo * get_thread_info() const
Definition GPULoopInfo.h:51
Halide::Internal::Autoscheduler::GPULoopInfo::inner_loop_stack
std::vector< const LoopNest * > inner_loop_stack
Definition GPULoopInfo.h:30
Halide::Internal::Autoscheduler::GPULoopInfo::create_thread_info
const ThreadInfo * create_thread_info()
Halide::Internal::Autoscheduler::GPULoopInfo::GPULoopInfo
GPULoopInfo(const LoopNest *root)
Definition GPULoopInfo.h:23
Halide::Internal::Autoscheduler::GPULoopInfo::current_thread_loop
const LoopNest * current_thread_loop
Definition GPULoopInfo.h:29
Halide::Internal::Autoscheduler::GPULoopInfo::get_inner_serial_loop_extents
std::vector< int64_t > get_inner_serial_loop_extents(const LoopNest *loop_nest) const
Halide::Internal::Autoscheduler::GPULoopInfo::current_block_loop
const LoopNest * current_block_loop
Definition GPULoopInfo.h:28
Halide::Internal::Autoscheduler::GPULoopInfo::at_or_inside_block
bool at_or_inside_block() const
Halide::Internal::Autoscheduler::LoopNest
Definition LoopNest.h:34
Halide::Internal::Autoscheduler::ThreadInfo
Definition ThreadInfo.h:40
Halide::Target
A struct representing a target machine and os to generate code for.
Definition Target.h:19