Halide
FastIntegerDivide.h
Go to the documentation of this file.
1
#ifndef HALIDE_FAST_INTEGER_DIVIDE_H
2
#define HALIDE_FAST_INTEGER_DIVIDE_H
3
4
#include "
Buffer.h
"
5
#include "
Expr.h
"
6
7
namespace
Halide
{
8
9
/** Integer division by small values can be done exactly as multiplies
10
* and shifts. This function does integer division for numerators of
11
* various integer types (8, 16, 32 bit signed and unsigned)
12
* numerators and uint8 denominators. The type of the result is the
13
* type of the numerator. The unsigned version is faster than the
14
* signed version, so cast the numerator to an unsigned int if you
15
* know it's positive.
16
*
17
* If your divisor is compile-time constant, Halide performs a
18
* slightly better optimization automatically, so there's no need to
19
* use this function (but it won't hurt).
20
*
21
* This function vectorizes well on arm, and well on x86 for 16 and 8
22
* bit vectors. For 32-bit vectors on x86 you're better off using
23
* native integer division.
24
*
25
* Also, this routine treats division by zero as division by
26
* 256. I.e. it interprets the uint8 divisor as a number from 1 to 256
27
* inclusive.
28
*/
29
Expr
fast_integer_divide
(
const
Expr &numerator,
const
Expr &denominator);
30
31
/** A variant of the above which rounds towards zero instead of rounding towards
32
* negative infinity. */
33
Expr
fast_integer_divide_round_to_zero
(
const
Expr &numerator,
const
Expr &denominator);
34
35
/** Use the fast integer division tables to implement a modulo
36
* operation via the Euclidean identity: a%b = a - (a/b)*b
37
*/
38
Expr
fast_integer_modulo
(
const
Expr &numerator,
const
Expr &denominator);
39
40
}
// namespace Halide
41
42
#endif
Halide::fast_integer_divide
Expr fast_integer_divide(const Expr &numerator, const Expr &denominator)
Integer division by small values can be done exactly as multiplies and shifts.
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition:
AbstractGenerator.h:19
Buffer.h
Expr.h
Halide::fast_integer_divide_round_to_zero
Expr fast_integer_divide_round_to_zero(const Expr &numerator, const Expr &denominator)
A variant of the above which rounds towards zero instead of rounding towards negative infinity.
Halide::fast_integer_modulo
Expr fast_integer_modulo(const Expr &numerator, const Expr &denominator)
Use the fast integer division tables to implement a modulo operation via the Euclidean identity: ab =...
src
FastIntegerDivide.h
Generated by
1.8.17