tag | 95ceb9b4d4278e0a066a2a11cbb64c1d19d9dd38 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Mon Apr 27 18:55:55 2020 -0700 |
object | 90094136cbccd98bc2b50adb6fbf6d7e4d2d24ec |
Platform Tools Release 30.0.0 (6405830)
commit | 90094136cbccd98bc2b50adb6fbf6d7e4d2d24ec | [log] [tgz] |
---|---|---|
author | android-build-prod (mdb) <android-build-team-robot@google.com> | Fri Apr 17 21:30:16 2020 +0000 |
committer | android-build-prod (mdb) <android-build-team-robot@google.com> | Fri Apr 17 21:30:16 2020 +0000 |
tree | e14feefc15be0a7f4621370bb1bce1db9b8c50fa | |
parent | ad0959a13e978d3f85d8a6697d60038c311fb206 [diff] | |
parent | 74c9d9ef6a828998ac9aab120bc94410ce99e3d1 [diff] |
Snap for 6405781 from 74c9d9ef6a828998ac9aab120bc94410ce99e3d1 to sdk-release Change-Id: I02e5342547121650fbe92693ff3c4a87f7ad14df
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