Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Prefetch.h
Go to the documentation of this file.
1#ifndef HALIDE_PREFETCH_H
2#define HALIDE_PREFETCH_H
3
4/** \file
5 * Defines the lowering pass that injects prefetch calls when prefetching
6 * appears in the schedule.
7 */
8
9#include <map>
10#include <string>
11#include <vector>
12
13 namespace Halide {
14
15 struct Target;
16
17 namespace Internal {
18
19 class Function;
20 struct PrefetchDirective;
21 struct Stmt;
22
23/** Inject placeholder prefetches to 's'. This placholder prefetch
24 * does not have explicit region to be prefetched yet. It will be computed
25 * during call to \ref inject_prefetch. */
26 Stmt inject_placeholder_prefetch(const Stmt &s, const std::map<std::string, Function> &env,
27 const std::string &prefix,
28 const std::vector<PrefetchDirective> &prefetches);
29/** Compute the actual region to be prefetched and place it to the
30 * placholder prefetch. Wrap the prefetch call with condition when
31 * applicable. */
32 Stmt inject_prefetch(const Stmt &s, const std::map<std::string, Function> &env);
33
34/** Reduce a multi-dimensional prefetch into a prefetch of lower dimension
35 * (max dimension of the prefetch is specified by target architecture).
36 * This keeps the 'max_dim' innermost dimensions and adds loops for the rest
37 * of the dimensions. If maximum prefetched-byte-size is specified (depending
38 * on the architecture), this also adds an outer loops that tile the prefetches. */
39 Stmt reduce_prefetch_dimension(Stmt stmt, const Target &t);
40
41/** Hoist all the prefetches in a Block to the beginning of the Block.
42 * This generally only happens when a loop with prefetches is unrolled;
43 * in some cases, LLVM's code generation can be suboptimal (unnecessary register spills)
44 * when prefetches are scattered through the loop. Hoisting to the top of the
45 * loop is a good way to mitigate this, at the cost of the prefetch calls possibly
46 * being less useful due to distance from use point. (This is a bit experimental
47 * and may need revisiting.) See also https://bugs.llvm.org/show_bug.cgi?id=51172 */
48 Stmt hoist_prefetches(const Stmt &s);
49
50} // namespace Internal
51} // namespace Halide
52
53#endif
Halide::Internal::ArgInfoKind::Function
@ Function
Halide::Internal::reduce_prefetch_dimension
Stmt reduce_prefetch_dimension(Stmt stmt, const Target &t)
Reduce a multi-dimensional prefetch into a prefetch of lower dimension (max dimension of the prefetch...
Halide::Internal::inject_placeholder_prefetch
Stmt inject_placeholder_prefetch(const Stmt &s, const std::map< std::string, Function > &env, const std::string &prefix, const std::vector< PrefetchDirective > &prefetches)
Inject placeholder prefetches to 's'.
Halide::Internal::inject_prefetch
Stmt inject_prefetch(const Stmt &s, const std::map< std::string, Function > &env)
Compute the actual region to be prefetched and place it to the placholder prefetch.
Halide::Internal::hoist_prefetches
Stmt hoist_prefetches(const Stmt &s)
Hoist all the prefetches in a Block to the beginning of the Block.
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.
Halide::OutputFileType::stmt
@ stmt
Halide::cast
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
Halide::Internal::Stmt
A reference-counted handle to a statement node.
Definition Expr.h:427
Halide::Target
A struct representing a target machine and os to generate code for.
Definition Target.h:19