tag | b8f1fca0f749870ad3c836ee8972c8a3dd9f0bef | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Thu Feb 02 02:17:21 2023 -0800 |
object | f40965fcc8d9c47b28aa9121723c7841de5e3b05 |
aml_sdk_331310010 (9319133,com.google.android.sdkext)
commit | f40965fcc8d9c47b28aa9121723c7841de5e3b05 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue May 10 06:56:35 2022 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue May 10 06:56:35 2022 +0000 |
tree | 9e71b2fb2df83e4bfd8abbc2bfa56c2a09d0118e | |
parent | 079faa750cb1c6f5eaece2c1c55474133b08a709 [diff] | |
parent | e3abe6d470f96474bcdb3df867f9d4cd451b9e71 [diff] |
Snap for 8564071 from e3abe6d470f96474bcdb3df867f9d4cd451b9e71 to mainline-sdkext-release Change-Id: I124aa037ed33e9ebb8acc0ddd8c4eb1b77754e60
Header-only library for division via fixed-point multiplication by inverse
On modern CPUs and GPUs integer division is several times slower than multiplication. FXdiv implements an algorithm to replace an integer division with a multiplication and two shifts. This algorithm improves performance when an application performs repeated divisions by the same divisor.
uint32_t
, uint64_t
, and size_t
#include <fxdiv.h> /* Division of array by a constant: reference implementation */ void divide_array_c(size_t length, uint32_t array[], uint32_t divisor) { for (size_t i = 0; i < length; i++) { array[i] /= divisor; } } /* Division of array by a constant: implementation with FXdiv */ void divide_array_fxdiv(size_t length, uint32_t array[], uint32_t divisor) { const struct fxdiv_divisor_uint32_t precomputed_divisor = fxdiv_init_uint32_t(divisor); for (size_t i = 0; i < length; i++) { array[i] = fxdiv_quotient_uint32_t(array[i], precomputed_divisor); } }
Currently working features:
Platform | uint32_t | uint64_t | size_t |
---|---|---|---|
x86-64 gcc | Works | Works | Works |
x86-64 clang | Works | Works | Works |
x86-64 MSVC | Works | Works | Works |
x86 gcc | Works | Works | Works |
x86 clang | Works | Works | Works |
x86 MSVC | Works | Works | Works |
ARMv7 gcc | Works | Works | Works |
ARMv7 clang | Works | Works | Works |
ARMv7 MSVC* | Compiles | Compiles | Compiles |
ARM64 gcc | Works | Works | Works |
ARM64 clang | Works | Works | Works |
ARM64 MSVC* | Compiles | Compiles | Compiles |
PPC64 gcc | Works | Works | Works |
WAsm clang | Works | Works | Works |
Asm.js clang | Works | Works | Works |
PNaCl clang | Works | Works | Works |
CUDA | Untested | Untested | Untested |
OpenCL | Untested | Untested | Untested |
*ARMv7 and ARM64 builds with MSVC are presumed to work, but were only verified to compile successfully