diff options
author | 2018-02-19 11:16:57 +0000 | |
---|---|---|
committer | 2018-02-19 11:17:28 +0000 | |
commit | ca33590b6af032bff57d9cc70455660466a654b2 (patch) | |
tree | 0b68b090bd9b4a78a3614b62400b29279d76d553 /lib/librte_sched/rte_reciprocal.h | |
parent | 169a9de21e263aa6599cdc2d87a45ae158d9f509 (diff) |
New upstream version 18.02upstream/18.02
Change-Id: I89ed24cb2a49b78fe5be6970b99dd46c1499fcc3
Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'lib/librte_sched/rte_reciprocal.h')
-rw-r--r-- | lib/librte_sched/rte_reciprocal.h | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/lib/librte_sched/rte_reciprocal.h b/lib/librte_sched/rte_reciprocal.h deleted file mode 100644 index 5e21f096..00000000 --- a/lib/librte_sched/rte_reciprocal.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Reciprocal divide - * - * Used with permission from original authors - * Hannes Frederic Sowa and Daniel Borkmann - * - * This algorithm is based on the paper "Division by Invariant - * Integers Using Multiplication" by Torbjörn Granlund and Peter - * L. Montgomery. - * - * The assembler implementation from Agner Fog, which this code is - * based on, can be found here: - * http://www.agner.org/optimize/asmlib.zip - * - * This optimization for A/B is helpful if the divisor B is mostly - * runtime invariant. The reciprocal of B is calculated in the - * slow-path with reciprocal_value(). The fast-path can then just use - * a much faster multiplication operation with a variable dividend A - * to calculate the division A/B. - */ - -#ifndef _RTE_RECIPROCAL_H_ -#define _RTE_RECIPROCAL_H_ - -#include <stdint.h> - -struct rte_reciprocal { - uint32_t m; - uint8_t sh1, sh2; -}; - -static inline uint32_t rte_reciprocal_divide(uint32_t a, struct rte_reciprocal R) -{ - uint32_t t = (uint32_t)(((uint64_t)a * R.m) >> 32); - - return (t + ((a - t) >> R.sh1)) >> R.sh2; -} - -struct rte_reciprocal rte_reciprocal_value(uint32_t d); - -#endif /* _RTE_RECIPROCAL_H_ */ |