diff options
-rw-r--r-- | Android.bp | 234 | ||||
-rw-r--r-- | METADATA | 23 | ||||
-rw-r--r-- | MODULE_LICENSE_MIT | 0 | ||||
-rw-r--r-- | OWNERS | 2 | ||||
-rw-r--r-- | TEST_MAPPING | 18 | ||||
-rwxr-xr-x | run-arm-optimized-routines-tests-on-android.sh | 53 |
6 files changed, 330 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..62b947b --- /dev/null +++ b/Android.bp @@ -0,0 +1,234 @@ +package { + default_applicable_licenses: ["external_arm-optimized-routines_license"], +} + +// Added automatically by a large-scale-change +// See: http://go/android-license-faq +license { + name: "external_arm-optimized-routines_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-MIT", + ], + license_text: [ + "LICENSE", + ], +} + +cc_defaults { + name: "arm-optimized-routines-defaults", + host_supported: true, + cflags: [ + "-Werror", + "-Wno-unused-parameter", + "-O2", + "-ffp-contract=fast", + "-fno-math-errno", + + // bionic configuration. + + // We're actually implementing bionic here, so we don't want <math.h> + // to try to be helpful by renaming long double routines. + "-D__BIONIC_LP32_USE_LONG_DOUBLE", + "-DFLT_EVAL_METHOD=0", + + // arm-optimized-routines configuration. + + // BSD libm doesn't set errno, and bionic was based on the BSDs. + // https://github.com/ARM-software/optimized-routines/issues/16#issuecomment-572009659 + "-DWANT_ERRNO=0", + // TODO: we may want the vector code in future, but it's not ready yet. + "-DWANT_VMATH=0", + ], + local_include_dirs: ["math/include"], +} + +cc_defaults { + name: "libarm-optimized-routines-defaults", + defaults: ["arm-optimized-routines-defaults"], + ramdisk_available: true, + vendor_ramdisk_available: true, + recovery_available: true, + native_bridge_supported: true, + apex_available: [ + "//apex_available:platform", + "com.android.runtime", + ], + + stl: "none", + target: { + bionic: { + static: { + system_shared_libs: [], + }, + header_libs: ["libc_headers"], + }, + }, +} + +cc_library_static { + name: "libarm-optimized-routines-math", + defaults: ["libarm-optimized-routines-defaults"], + exclude_srcs: [ + // Provided by: + // bionic/libm/upstream-freebsd/lib/msun/src/s_erf.c + // bionic/libm/upstream-freebsd/lib/msun/src/s_erff.c + "math/erf.c", + "math/erf_data.c", + "math/erff.c", + "math/erff_data.c", + ], + srcs: [ + "math/*.c", + ], + + // arch-specific settings + arch: { + arm64: { + cflags: [ + "-DHAVE_FAST_FMA=1", + ], + }, + }, + + target: { + darwin: { + enabled: false, + }, + linux_bionic: { + enabled: true, + }, + }, +} + +cc_library_static { + name: "libarm-optimized-routines-string", + defaults: ["libarm-optimized-routines-defaults"], + + arch: { + arm64: { + srcs: [ + "string/aarch64/memchr-mte.S", + "string/aarch64/memchr.S", + "string/aarch64/memcmp.S", + "string/aarch64/memcpy-advsimd.S", + "string/aarch64/memcpy.S", + "string/aarch64/memrchr.S", + "string/aarch64/memset.S", + "string/aarch64/stpcpy.S", + "string/aarch64/strchrnul-mte.S", + "string/aarch64/strchrnul.S", + "string/aarch64/strchr-mte.S", + "string/aarch64/strchr.S", + "string/aarch64/strcmp.S", + "string/aarch64/strcpy.S", + "string/aarch64/strlen-mte.S", + "string/aarch64/strlen.S", + "string/aarch64/strncmp.S", + "string/aarch64/strnlen.S", + "string/aarch64/strrchr-mte.S", + "string/aarch64/strrchr.S", + ], + asflags: [ + "-D__memcmp_aarch64=memcmp", + "-D__memset_aarch64=memset", + "-D__memrchr_aarch64=memrchr", + "-D__strnlen_aarch64=strnlen", + ] + }, + }, +} + +// Memory intrinsics for bare-metal Rust binaries. +cc_library_static { + name: "libarm-optimized-routines-mem", + nocrt: true, + system_shared_libs: [], + stl: "none", + sanitize: { + hwaddress: false, + }, + arch: { + arm64: { + srcs: [ + "string/aarch64/memchr.S", + "string/aarch64/memcmp.S", + "string/aarch64/memcpy.S", + "string/aarch64/memrchr.S", + "string/aarch64/memset.S", + "string/aarch64/stpcpy.S", + "string/aarch64/strchr.S", + "string/aarch64/strchrnul.S", + "string/aarch64/strcmp.S", + "string/aarch64/strcpy.S", + "string/aarch64/strlen.S", + "string/aarch64/strncmp.S", + "string/aarch64/strnlen.S", + "string/aarch64/strrchr.S", + ], + asflags: [ + "-D__memchr_aarch64=memchr", + "-D__memcmp_aarch64=memcmp", + "-D__memcpy_aarch64=memcpy", + "-D__memmove_aarch64=memmove", + "-D__memrchr_aarch64=memrchr", + "-D__memset_aarch64=memset", + "-D__stpcpy_aarch64=stpcpy", + "-D__strchr_aarch64=strchr", + "-D__strchrnul_aarch64=strchrnul", + "-D__strcmp_aarch64=strcmp", + "-D__strcpy_aarch64=strcpy", + "-D__strlen_aarch64=strlen", + "-D__strncmp_aarch64=strncmp", + "-D__strnlen_aarch64=strnlen", + "-D__strrchr_aarch64=strrchr", + ], + }, + }, + visibility: ["//bionic/libc"], +} + +// adb shell "/data/nativetest64/mathtest/mathtest /data/nativetest64/mathtest/test/testcases/directed/*" +// adb shell "/data/nativetest/mathtest/mathtest /data/nativetest/mathtest/test/testcases/directed/*" +cc_test { + name: "mathtest", + defaults: ["arm-optimized-routines-defaults"], + gtest: false, + cflags: ["-Wno-missing-braces"], + srcs: ["math/test/mathtest.c"], + data: ["math/test/testcases/directed/*.tst"], + target: { + darwin: { + enabled: false, + }, + linux_bionic: { + enabled: true, + }, + }, +} + +cc_test { + name: "ulp", + defaults: ["arm-optimized-routines-defaults"], + gtest: false, + + // https://github.com/ARM-software/optimized-routines/issues/53 + local_include_dirs: ["math/"], + + srcs: ["math/test/ulp.c"], + data: ["math/test/runulp.sh"], +} + +sh_test { + name: "arm-optimized-routines-tests", + src: "run-arm-optimized-routines-tests-on-android.sh", + filename: "run-arm-optimized-routines-tests-on-android.sh", + test_suites: ["general-tests"], + host_supported: true, + device_supported: false, + require_root: true, + target_required: [ + "mathtest", + "ulp", + ], +} diff --git a/METADATA b/METADATA new file mode 100644 index 0000000..97f7332 --- /dev/null +++ b/METADATA @@ -0,0 +1,23 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update arm-optimized-routines +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + +name: "ARM-software/optimized-routines" +description: "Optimized implementations of various library functions for ARM architecture processors " +third_party { + url { + type: HOMEPAGE + value: "https://github.com/ARM-software/optimized-routines" + } + url { + type: GIT + value: "https://github.com/ARM-software/optimized-routines.git" + } + version: "v23.01" + license_type: NOTICE + last_upgrade_date { + year: 2023 + month: 1 + day: 25 + } +} diff --git a/MODULE_LICENSE_MIT b/MODULE_LICENSE_MIT new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MODULE_LICENSE_MIT @@ -0,0 +1,2 @@ +include platform/bionic:/OWNERS +adhemerval.zanella@linaro.org diff --git a/TEST_MAPPING b/TEST_MAPPING new file mode 100644 index 0000000..75ec323 --- /dev/null +++ b/TEST_MAPPING @@ -0,0 +1,18 @@ +{ + "presubmit": [ + { + "name": "CtsBionicTestCases" + }, + { + "name": "arm-optimized-routines-tests" + } + ], + "hwasan-postsubmit": [ + { + "name": "CtsBionicTestCases" + }, + { + "name": "arm-optimized-routines-tests" + } + ] +} diff --git a/run-arm-optimized-routines-tests-on-android.sh b/run-arm-optimized-routines-tests-on-android.sh new file mode 100755 index 0000000..21163a3 --- /dev/null +++ b/run-arm-optimized-routines-tests-on-android.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Copy the tests across. +adb sync + +if tty -s; then + green="\033[1;32m" + red="\033[1;31m" + plain="\033[0m" +else + green="" + red="" + plain="" +fi + +failures=0 + +check_failure() { + if [ $? -eq 0 ]; then + echo -e "${green}[PASS]${plain}" + else + failures=$(($failures+1)) + echo -e "${red}[FAIL]${plain}" + fi +} + +# Run the 32-bit tests. +if [ -e "$ANDROID_PRODUCT_OUT/data/nativetest/mathtest/mathtest" ]; then + adb shell /data/nativetest/mathtest/mathtest /data/nativetest/mathtest/math/test/testcases/directed/* + check_failure +fi + +# TODO: these tests are currently a bloodbath. +#adb shell 'cp /data/nativetest/ulp/math/test/runulp.sh /data/nativetest/ulp/ && sh /data/nativetest/ulp/runulp.sh' +#check_failure + +# Run the 64-bit tests. +if [ -e "$ANDROID_PRODUCT_OUT/data/nativetest64/mathtest/mathtest" ]; then + adb shell /data/nativetest64/mathtest/mathtest /data/nativetest64/mathtest/math/test/testcases/directed/* + check_failure +fi + +# TODO: these tests are currently a bloodbath. +#adb shell 'cp /data/nativetest64/ulp/math/test/runulp.sh /data/nativetest64/ulp/ && sh /data/nativetest64/ulp/runulp.sh' +#check_failure + +echo +echo "_________________________________________________________________________" +echo +if [ $failures -ne 0 ]; then + echo -e "${red}FAILED${plain}: $failures" +fi +exit $failures |