1 #ifndef HALIDE_PREFETCH_DIRECTIVE_H 2 #define HALIDE_PREFETCH_DIRECTIVE_H 3 4 /** \file 5 * Defines the PrefetchDirective struct 6 */ 7 8 #include <string> 9 10 #include "Expr.h" 11 #include "Parameter.h" 12 13 namespace Halide { 14 15 /** Different ways to handle accesses outside the original extents in a prefetch. */ 16 enum class PrefetchBoundStrategy { 17 /** Clamp the prefetched exprs by intersecting the prefetched region with 18 * the original extents. This may make the exprs of the prefetched region 19 * more complicated. */ 20 Clamp, 21 22 /** Guard the prefetch with if-guards that ignores the prefetch if 23 * any of the prefetched region ever goes beyond the original extents 24 * (i.e. all or nothing). */ 25 GuardWithIf, 26 27 /** Leave the prefetched exprs as are (no if-guards around the prefetch 28 * and no intersecting with the original extents). This makes the prefetch 29 * exprs simpler but this may cause prefetching of region outside the original 30 * extents. This is good if prefetch won't fault when accessing region 31 * outside the original extents. */ 32 NonFaulting 33 }; 34 35 namespace Internal { 36 37 struct PrefetchDirective { 38 std::string name; 39 std::string var; 40 Expr offset; 41 PrefetchBoundStrategy strategy; 42 // If it's a prefetch load from an image parameter, this points to that. 43 Parameter param; 44 }; 45 46 } // namespace Internal 47 48 } // namespace Halide 49 50 #endif // HALIDE_PREFETCH_DIRECTIVE_H 51