Halide 19.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
13namespace Halide {
14
15struct Target;
16
17namespace Internal {
18
19class Function;
20struct PrefetchDirective;
21struct 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. */
26Stmt 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. */
32Stmt 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. */
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 */
49
50} // namespace Internal
51} // namespace Halide
52
53#endif
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...
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'.
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.
Stmt hoist_prefetches(const Stmt &s)
Hoist all the prefetches in a Block to the beginning of the Block.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
A reference-counted handle to a statement node.
Definition Expr.h:427
A struct representing a target machine and os to generate code for.
Definition Target.h:19