tag | c30b61c3b1af1d904d6794e746f345e538e430a7 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Mon Apr 29 09:53:43 2024 -0700 |
object | b4fb96dbbc9936c17f6e18710257c449627649ee |
aml_art_341514450 (11720836,com.google.android.art,com.google.android.go.art)
commit | b4fb96dbbc9936c17f6e18710257c449627649ee | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Fri Jul 07 04:38:43 2023 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Fri Jul 07 04:38:43 2023 +0000 |
tree | b0d778382e65123821d6af73cf53d38d94ecdd68 | |
parent | 5144338765a1b61c30cd933779e2357c02735172 [diff] | |
parent | a555e78cea9d472dc5c3dfe6a1cb2f0979d93864 [diff] |
Snap for 10453563 from a555e78cea9d472dc5c3dfe6a1cb2f0979d93864 to mainline-art-release Change-Id: I805f201c093c595e315b30faef2f3404d36ba026
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