RecFilter
RecFilter Class Reference

Recursive filter class. More...

#include <recfilter.h>

Public Member Functions

 RecFilter (std::string name="")
 Empty constructor. More...
 
RecFilteroperator= (const RecFilter &r)
 Standard assignment operator. More...
 
std::string name (void) const
 Name of the filter. More...
 
void define (std::vector< RecFilterDim > pure_args, std::vector< Halide::Expr > pure_def)
 Add a pure definition to the recursive filter. More...
 
Halide::Func as_func (void)
 Cast the recfilter as a Halide::Func; this returns the function that holds the final result of this filter; useful for extracting the result of this function to use as input to other Halide Func. More...
 
Halide::Func func (std::string func_name)
 Extract the constituent function by name, useful for debugging: More...
 
Recursive filter initialization

These functions allow functional programming like syntax to initialize a recursive filter

R(x) = some_expression_involving_x // 1D filter
R(x,y) = some_expression_involving_x_y // 2D filter
R(x,y,z) = some_expression_involving_x_y_z // 3D filter
R({x,y..}) = some_expression_for_involving_x_y.. // nD filter
RecFilterRefVar operator() (RecFilterDim x)
 
RecFilterRefVar operator() (RecFilterDim x, RecFilterDim y)
 
RecFilterRefVar operator() (RecFilterDim x, RecFilterDim y, RecFilterDim z)
 
RecFilterRefVar operator() (std::vector< RecFilterDim > x)
 
Recursive filter result expression

These functions return an expression that represents the final result of the filter

R(x) // pixel x for a 1D filter
R(x,y) // pixel (x,y) for a 1D filter
R(x,y,z) // pixel (x,y,z) for a 1D filter
R({x,y..}) // pixel (x,y..) for a nD filter
RecFilterRefExpr operator() (Halide::Var x)
 
RecFilterRefExpr operator() (Halide::Var x, Halide::Var y)
 
RecFilterRefExpr operator() (Halide::Var x, Halide::Var y, Halide::Var z)
 
RecFilterRefExpr operator() (std::vector< Halide::Var > x)
 
RecFilterRefExpr operator() (Halide::Expr x)
 
RecFilterRefExpr operator() (Halide::Expr x, Halide::Expr y)
 
RecFilterRefExpr operator() (Halide::Expr x, Halide::Expr y, Halide::Expr z)
 
RecFilterRefExpr operator() (std::vector< Halide::Expr > x)
 
Compile and run
Halide::Target target (void)
 Get the compilation target, inferred from HL_JIT_TARGET. More...
 
void apply_bounds (void)
 Apply output domains bounds; this is performed implicitly for tiled filters, but it must be called by the application for non-tiled filters. More...
 
void compile_jit (std::string filename="")
 Trigger JIT compilation for specified hardware-platform target; dumps the generated codegen in human readable HTML format if filename is specified. More...
 
Halide::Realization realize (void)
 Compute the filter. More...
 
float profile (int iterations)
 Profile the filter. More...
 
Routines to add filters

Add a causal or anticausal scan to the recursive filter with given feedback and feed forward coefficients

Parameters
xfilter dimension
coeff1 feedforward and n feedback coeffs (n = filter order)

Preconditions:

  • first argument must of of the form +x, -x or x where x is a RecFilterDim object
void add_filter (RecFilterDim x, std::vector< float > coeff)
 
void add_filter (RecFilterDimAndCausality x, std::vector< float > coeff)
 
Image boundary conditions

Clamp image border to the last pixel in all boundaries, default border is 0

void set_clamped_image_border (void)
 
Tiling routines

Tile a list of dimensions into their respective tile widths specified as variable-tile width pairs.

Preconditions:

  • dimension with specified variable name must exist
  • tile width must be a multiple of image width for each dimension
void split_all_dimensions (int tx)
 
void split (RecFilterDim x, int tx)
 
void split (RecFilterDim x, int tx, RecFilterDim y, int ty)
 
void split (RecFilterDim x, int tx, RecFilterDim y, int ty, RecFilterDim z, int tz)
 
void split (std::map< std::string, int > dims)
 
Cascading API
std::vector< RecFiltercascade (std::vector< int > a, std::vector< int > b)
 Cascade the filter to produce multiple filters using list of list of scans and producing a list of recursive filters each ccomputes the corresponding list of scans in an overlapped fashion. More...
 
std::vector< RecFiltercascade (std::vector< std::vector< int > > scan)
 Cascade the filter to produce multiple filters using list of list of scans and producing a list of recursive filters each ccomputes the corresponding list of scans in an overlapped fashion. More...
 
std::vector< RecFiltercascade_by_causality (void)
 Computing all causal scans in all dimensions in an overlapped fashion and all anticausal scans in an overlapped fashion and cascade the two groups. More...
 
std::vector< RecFiltercascade_by_dimension (void)
 Compute all scans in the same dimension in an overlapped fashion and cascade different dimensions. More...
 
RecFilter overlap_to_higher_order_filter (RecFilter fA, std::string name="O")
 Overlap a given filter with the current filter creating a higher order filter. More...
 
Collective scheduling handles
RecFilterSchedule intra_schedule (int id=0)
 Extract a handle to schedule intra-tile functions of the tiled filter. More...
 
RecFilterSchedule inter_schedule (void)
 Extract a handle to schedule intra-tile functions of the tiled filter. More...
 
RecFilterSchedule full_schedule (void)
 Extract a handle to schedule non-tiled filter. More...
 
void compute_at (RecFilter external)
 Set final result of filter to be computed at an external recursive filter, useful for merging the filter with external stages; the filter must not depend upon the external function. More...
 
void compute_at (Halide::Func external, Halide::Var granularity)
 Set final result of filter to be computed at an external Func, useful for merging the filter with external stages; the filter must not depend upon the external function. More...
 
Automatic scheduling for GPU targets
void gpu_auto_full_schedule (int tile_width=32)
 Automatic GPU schedule for non-tiled filter and return a handle for additional scheduling. More...
 
void gpu_auto_schedule (int tile_width=32)
 Automatic GPU schedule for tiled or non-tiled recursive filter; calls RecFilter::gpu_auto_full_schedule(), RecFilter::gpu_auto_intra_schedule() and RecFilter::gpu_auto_inter_schedule(). More...
 
void gpu_auto_inter_schedule (void)
 Automatic GPU schedule for inter-tile functions of tiled filter. More...
 
void gpu_auto_intra_schedule (int id)
 Automatic GPU schedule for intra-tile functions if tiled filter. More...
 
Automatic scheduling for CPU targets
void cpu_auto_schedule (void)
 Automatic CPU schedule for tiled or non-tiled recursive filter; calls RecFilter::cpu_auto_full_schedule(), RecFilter::cpu_auto_intra_schedule() and RecFilter::cpu_auto_inter_schedule(). More...
 
void cpu_auto_full_schedule (void)
 Automatic CPU schedule for non-tiled filter. More...
 
void cpu_auto_inter_schedule (void)
 Automatic CPU schedule for inter-tile functions of tiled filter. More...
 
void cpu_auto_intra_schedule (void)
 Automatic CPU schedule for intra-tile functions if tiled filter. More...
 
Generic handles to write schedules for dimensions of internal functions
VarTag full (int i=-1)
 
VarTag inner (int i=-1)
 
VarTag outer (int i=-1)
 
VarTag tail (void)
 
VarTag full_scan (void)
 
VarTag inner_scan (void)
 
VarTag outer_scan (void)
 
VarTag inner_channels (void)
 
VarTag outer_channels (void)
 
Print Halide code for the recursive filter
std::string print_functions (void) const
 
std::string print_synopsis (void) const
 
std::string print_schedule (void) const
 
std::string print_hl_code (void) const
 

Static Public Member Functions

Global constants for scheduling
static void set_max_threads_per_cuda_warp (int v)
 Set the maximum threads to launch per CUDA warp, must be called before scheduling the RecFilter object. More...
 
static void set_vectorization_width (int v)
 Set the vectorization width, must be called before scheduling the RecFilter object. More...
 

Detailed Description

Recursive filter class.

Definition at line 146 of file recfilter.h.

Constructor & Destructor Documentation

RecFilter::RecFilter ( std::string  name = "")

Empty constructor.

Member Function Documentation

RecFilter& RecFilter::operator= ( const RecFilter r)

Standard assignment operator.

std::string RecFilter::name ( void  ) const

Name of the filter.

RecFilterRefVar RecFilter::operator() ( RecFilterDim  x)
RecFilterRefVar RecFilter::operator() ( RecFilterDim  x,
RecFilterDim  y 
)
RecFilterRefVar RecFilter::operator() ( RecFilterDim  x,
RecFilterDim  y,
RecFilterDim  z 
)
RecFilterRefVar RecFilter::operator() ( std::vector< RecFilterDim x)
RecFilterRefExpr RecFilter::operator() ( Halide::Var  x)
RecFilterRefExpr RecFilter::operator() ( Halide::Var  x,
Halide::Var  y 
)
RecFilterRefExpr RecFilter::operator() ( Halide::Var  x,
Halide::Var  y,
Halide::Var  z 
)
RecFilterRefExpr RecFilter::operator() ( std::vector< Halide::Var >  x)
RecFilterRefExpr RecFilter::operator() ( Halide::Expr  x)
RecFilterRefExpr RecFilter::operator() ( Halide::Expr  x,
Halide::Expr  y 
)
RecFilterRefExpr RecFilter::operator() ( Halide::Expr  x,
Halide::Expr  y,
Halide::Expr  z 
)
RecFilterRefExpr RecFilter::operator() ( std::vector< Halide::Expr >  x)
void RecFilter::define ( std::vector< RecFilterDim pure_args,
std::vector< Halide::Expr >  pure_def 
)

Add a pure definition to the recursive filter.

Parameters
pure_argslist of pure args
pure_deflist of expressions to initialize the filter
Halide::Target RecFilter::target ( void  )

Get the compilation target, inferred from HL_JIT_TARGET.

void RecFilter::apply_bounds ( void  )

Apply output domains bounds; this is performed implicitly for tiled filters, but it must be called by the application for non-tiled filters.

void RecFilter::compile_jit ( std::string  filename = "")

Trigger JIT compilation for specified hardware-platform target; dumps the generated codegen in human readable HTML format if filename is specified.

Halide::Realization RecFilter::realize ( void  )

Compute the filter.

Returns
Realization object that contains all the buffers
float RecFilter::profile ( int  iterations)

Profile the filter.

Parameters
iterationsnumber of profiling iterations
Returns
computation time in milliseconds
void RecFilter::add_filter ( RecFilterDim  x,
std::vector< float >  coeff 
)
void RecFilter::add_filter ( RecFilterDimAndCausality  x,
std::vector< float >  coeff 
)
void RecFilter::set_clamped_image_border ( void  )
Halide::Func RecFilter::as_func ( void  )

Cast the recfilter as a Halide::Func; this returns the function that holds the final result of this filter; useful for extracting the result of this function to use as input to other Halide Func.

Halide::Func RecFilter::func ( std::string  func_name)

Extract the constituent function by name, useful for debugging:

  • realize only a particular stage for correctness or profiling
  • debugging/testing schedules by using Halide's scheduling primitives directly on the function instead of the high level collective scheduling
void RecFilter::split_all_dimensions ( int  tx)
void RecFilter::split ( RecFilterDim  x,
int  tx 
)
void RecFilter::split ( RecFilterDim  x,
int  tx,
RecFilterDim  y,
int  ty 
)
void RecFilter::split ( RecFilterDim  x,
int  tx,
RecFilterDim  y,
int  ty,
RecFilterDim  z,
int  tz 
)
void RecFilter::split ( std::map< std::string, int >  dims)
std::vector<RecFilter> RecFilter::cascade ( std::vector< int >  a,
std::vector< int >  b 
)

Cascade the filter to produce multiple filters using list of list of scans and producing a list of recursive filters each ccomputes the corresponding list of scans in an overlapped fashion.

Preconditions:

  • filter must not be tiled
  • list of list of scans spans all the scans of the original filter
  • no scan is repeated in the list of list of scans
  • the relative order of scans with respect to causality remains preserved
Parameters
alist of scans for first filter
blist of scans for second filter
Returns
two cascaded filters
std::vector<RecFilter> RecFilter::cascade ( std::vector< std::vector< int > >  scan)

Cascade the filter to produce multiple filters using list of list of scans and producing a list of recursive filters each ccomputes the corresponding list of scans in an overlapped fashion.

Preconditions:

  • filter must not be tiled
  • list of list of scans spans all the scans of the original filter
  • no scan is repeated in the list of list of scans
  • the relative order of scans with respect to causality remains preserved
Parameters
scanlist of list of scans, each inner list becomes a separate filter
Returns
list of cascaded filters
std::vector<RecFilter> RecFilter::cascade_by_causality ( void  )

Computing all causal scans in all dimensions in an overlapped fashion and all anticausal scans in an overlapped fashion and cascade the two groups.

Preconditions:

  • filter must not be tiled
Returns
list of cascaded filters
std::vector<RecFilter> RecFilter::cascade_by_dimension ( void  )

Compute all scans in the same dimension in an overlapped fashion and cascade different dimensions.

Preconditions:

  • filter must not be tiled
Returns
list of cascaded filters
RecFilter RecFilter::overlap_to_higher_order_filter ( RecFilter  fA,
std::string  name = "O" 
)

Overlap a given filter with the current filter creating a higher order filter.

Preconditions:

  • filter must not be tiled
  • given filter must have same number of dimensions in the same order
  • each scan of each dimension of given filter must have same causality
Todo:
This function is only partially tested and may be unstable
Parameters
fAfilter to be overlapped with current filter
namename of the overlapped filter (optional)
Returns
overlapped computation of all scans in both filters
RecFilterSchedule RecFilter::intra_schedule ( int  id = 0)

Extract a handle to schedule intra-tile functions of the tiled filter.

Parameters
id0 for all intra tile functions, 1 for nD intra-tile functions, otherwise 1D intra-tile functions
RecFilterSchedule RecFilter::inter_schedule ( void  )

Extract a handle to schedule intra-tile functions of the tiled filter.

RecFilterSchedule RecFilter::full_schedule ( void  )

Extract a handle to schedule non-tiled filter.

void RecFilter::compute_at ( RecFilter  external)

Set final result of filter to be computed at an external recursive filter, useful for merging the filter with external stages; the filter must not depend upon the external function.

Parameters
externalfunction inside which the filter must be computed
void RecFilter::compute_at ( Halide::Func  external,
Halide::Var  granularity 
)

Set final result of filter to be computed at an external Func, useful for merging the filter with external stages; the filter must not depend upon the external function.

Parameters
externalfunction inside which the filter must be computed
granularityvariable where this filter's result should be computed
void RecFilter::gpu_auto_full_schedule ( int  tile_width = 32)

Automatic GPU schedule for non-tiled filter and return a handle for additional scheduling.

Parameters
tile_widthtiling factor to split non-tiled dimensions into CUDA blocks and CUDA tiles
void RecFilter::gpu_auto_schedule ( int  tile_width = 32)

Automatic GPU schedule for tiled or non-tiled recursive filter; calls RecFilter::gpu_auto_full_schedule(), RecFilter::gpu_auto_intra_schedule() and RecFilter::gpu_auto_inter_schedule().

Parameters
tile_widthtiling factor to non-tiled full dimensions into CUDA blocks and CUDA tiles (only used if filter is not tiled)
void RecFilter::gpu_auto_inter_schedule ( void  )

Automatic GPU schedule for inter-tile functions of tiled filter.

void RecFilter::gpu_auto_intra_schedule ( int  id)

Automatic GPU schedule for intra-tile functions if tiled filter.

Parameters
id0 for all intra tile functions, 1 for nD intra-tile functions, otherwise 1D intra-tile functions
void RecFilter::cpu_auto_schedule ( void  )

Automatic CPU schedule for tiled or non-tiled recursive filter; calls RecFilter::cpu_auto_full_schedule(), RecFilter::cpu_auto_intra_schedule() and RecFilter::cpu_auto_inter_schedule().

void RecFilter::cpu_auto_full_schedule ( void  )

Automatic CPU schedule for non-tiled filter.

void RecFilter::cpu_auto_inter_schedule ( void  )

Automatic CPU schedule for inter-tile functions of tiled filter.

void RecFilter::cpu_auto_intra_schedule ( void  )

Automatic CPU schedule for intra-tile functions if tiled filter.

VarTag RecFilter::full ( int  i = -1)
VarTag RecFilter::inner ( int  i = -1)
VarTag RecFilter::outer ( int  i = -1)
VarTag RecFilter::tail ( void  )
VarTag RecFilter::full_scan ( void  )
VarTag RecFilter::inner_scan ( void  )
VarTag RecFilter::outer_scan ( void  )
VarTag RecFilter::inner_channels ( void  )
VarTag RecFilter::outer_channels ( void  )
std::string RecFilter::print_functions ( void  ) const
std::string RecFilter::print_synopsis ( void  ) const
std::string RecFilter::print_schedule ( void  ) const
std::string RecFilter::print_hl_code ( void  ) const
static void RecFilter::set_max_threads_per_cuda_warp ( int  v)
static

Set the maximum threads to launch per CUDA warp, must be called before scheduling the RecFilter object.

static void RecFilter::set_vectorization_width ( int  v)
static

Set the vectorization width, must be called before scheduling the RecFilter object.


The documentation for this class was generated from the following file: