27inline int clz(
int x) {
29 for (
int i = 31; i >= 0; i--) {
31 if ((1 << i) & x) {
return (31 - i); }
39 int a = int(31 -
clz(x));
40 a = a + ((x & (x - 1)) != 0);
59 unsigned m = unsigned(
75 int "ient,
int &remainder,
int dividend)
const {
79 ? __ESIMD_ENS::imul(lo_part, dividend,
multiplier)
83 remainder = dividend - (quotient *
divisor);
89 int quotient, remainder;
#define __XETLA_API
Definition common.hpp:43
#define KERNEL_FUNC
KERNEL_FUNC macro.
Definition common.hpp:39
Definition arch_config.hpp:24
int find_log2(int x)
Host side utility function to compute log2 function.
Definition fastmath.hpp:37
int clz(int x)
Host side utility function to compute number of leading zeros in the binary representation.
Definition fastmath.hpp:27
Fast division + modulus operation Host code pre-computes values to avoid expensive operations in kern...
Definition fastmath.hpp:46
__XETLA_API KERNEL_FUNC void fast_divmod(int "ient, int &remainder, int dividend) const
Kernel side function to find quotient and remainder.
Definition fastmath.hpp:74
FastDivMod(int divisor_)
Definition fastmath.hpp:55
int divisor
Definition fastmath.hpp:48
unsigned int multiplier
Definition fastmath.hpp:49
FastDivMod()
Constructor, called in Hostcode to pre-compute multiplier and shift_right;.
Definition fastmath.hpp:53
__XETLA_API KERNEL_FUNC int div(int dividend) const
kernel side utility functions for query of quotient
Definition fastmath.hpp:87
unsigned int shift_right
Definition fastmath.hpp:50