Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -74,6 +74,14 @@ ) endif() +if(TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_custom_target(rsync_android + COMMAND ${PROJECT_SOURCE_DIR}/utils/rsync_android.sh + ${TEST_SUITE_REMOTE_HOST} ${PROJECT_BINARY_DIR} + USES_TERMINAL + ) +endif() + # Run Under configuration for RunSafely.sh (will be set in lit.site.cfg) set(TEST_SUITE_RUN_UNDER "" CACHE STRING "RunSafely.sh run-under (-u) parameter") Index: External/SPEC/CFP2006/CMakeLists.txt =================================================================== --- External/SPEC/CFP2006/CMakeLists.txt +++ External/SPEC/CFP2006/CMakeLists.txt @@ -2,9 +2,12 @@ if(TEST_SUITE_SPEC2006_ROOT) cpu2006_subdir(433.milc) cpu2006_subdir(444.namd) - cpu2006_subdir(447.dealII) cpu2006_subdir(450.soplex) cpu2006_subdir(453.povray) cpu2006_subdir(470.lbm) cpu2006_subdir(482.sphinx3) + + if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + cpu2006_subdir(447.dealII) + endif() endif() Index: External/SPEC/CINT2006/462.libquantum/CMakeLists.txt =================================================================== --- External/SPEC/CINT2006/462.libquantum/CMakeLists.txt +++ External/SPEC/CINT2006/462.libquantum/CMakeLists.txt @@ -8,11 +8,20 @@ # diff --strip-trailing-cr # (This flag is a gnu extension, maybe we should rather extend fpcmp or # somehow copy+fix the reference outputs?) - llvm_test_verify(RUN_TYPE ${run_type} WORKDIR ${CMAKE_CURRENT_BINARY_DIR} - diff --strip-trailing-cr - data/${run_type}/output/${run_type}.out - ${run_type}.out - ) + # diff in Android doesn't have --strip-trailing-cr, use -w instead + if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + llvm_test_verify(RUN_TYPE ${run_type} WORKDIR ${CMAKE_CURRENT_BINARY_DIR} + diff --strip-trailing-cr + data/${run_type}/output/${run_type}.out + ${run_type}.out + ) + else() + llvm_test_verify(RUN_TYPE ${run_type} WORKDIR ${CMAKE_CURRENT_BINARY_DIR} + diff -w + data/${run_type}/output/${run_type}.out + ${run_type}.out + ) + endif() endmacro() test_input(test 33 5) Index: External/SPEC/CINT2006/CMakeLists.txt =================================================================== --- External/SPEC/CINT2006/CMakeLists.txt +++ External/SPEC/CINT2006/CMakeLists.txt @@ -1,6 +1,5 @@ include(${CMAKE_SOURCE_DIR}/External/SPEC/SpecCPU2006.cmake) if(TEST_SUITE_SPEC2006_ROOT) - cpu2006_subdir(400.perlbench) cpu2006_subdir(401.bzip2) cpu2006_subdir(403.gcc) cpu2006_subdir(429.mcf) @@ -8,8 +7,12 @@ cpu2006_subdir(456.hmmer) cpu2006_subdir(458.sjeng) cpu2006_subdir(462.libquantum) - cpu2006_subdir(464.h264ref) cpu2006_subdir(471.omnetpp) cpu2006_subdir(473.astar) - cpu2006_subdir(483.xalancbmk) + + if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + cpu2006_subdir(400.perlbench) + cpu2006_subdir(464.h264ref) + cpu2006_subdir(483.xalancbmk) + endif() endif() Index: MicroBenchmarks/CMakeLists.txt =================================================================== --- MicroBenchmarks/CMakeLists.txt +++ MicroBenchmarks/CMakeLists.txt @@ -1,8 +1,10 @@ file(COPY lit.local.cfg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -add_subdirectory(libs) -add_subdirectory(XRay) -add_subdirectory(LCALS) -add_subdirectory(harris) -add_subdirectory(ImageProcessing) -add_subdirectory(LoopInterchange) +if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(libs) + add_subdirectory(XRay) + add_subdirectory(LCALS) + add_subdirectory(harris) + add_subdirectory(ImageProcessing) + add_subdirectory(LoopInterchange) +endif() Index: MultiSource/Applications/CMakeLists.txt =================================================================== --- MultiSource/Applications/CMakeLists.txt +++ MultiSource/Applications/CMakeLists.txt @@ -1,4 +1,6 @@ -add_subdirectory(JM) +if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(JM) +endif() add_subdirectory(SIBsim4) add_subdirectory(aha) add_subdirectory(d) @@ -8,37 +10,46 @@ add_subdirectory(oggenc) endif() add_subdirectory(sgefa) -add_subdirectory(spiff) +if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(spiff) +endif() add_subdirectory(viterbi) add_subdirectory(ALAC) add_subdirectory(hbd) add_subdirectory(lambda-0.1.3) add_subdirectory(minisat) -if(NOT TARGET_OS STREQUAL "SunOS") +if(NOT TARGET_OS STREQUAL "SunOS" + AND (NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb")) add_subdirectory(hexxagon) endif() if(NOT DEFINED SMALL_PROBLEM_SIZE) add_subdirectory(lua) endif() -if(TARGET_OS STREQUAL "Linux" AND (NOT ARCH STREQUAL "XCore")) +if(TARGET_OS STREQUAL "Linux" AND (NOT ARCH STREQUAL "XCore") + AND (NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb")) add_subdirectory(obsequi) endif() if(NOT TARGET_OS STREQUAL "SunOS") add_subdirectory(kimwitu++) endif() -if(NOT TARGET_OS STREQUAL "SunOS") +if(NOT TARGET_OS STREQUAL "SunOS" + AND (NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb")) add_subdirectory(SPASS) endif() if(NOT ARCH STREQUAL "XCore") - add_subdirectory(ClamAV) add_subdirectory(lemon) - add_subdirectory(siod) + if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(ClamAV) + add_subdirectory(siod) + endif() endif() if((NOT ARCH STREQUAL "PowerPC") AND (NOT ARCH STREQUAL "XCore")) add_subdirectory(sqlite3) endif() if(NOT TEST_SUITE_BENCHMARKING_ONLY) - add_subdirectory(Burg) + if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(Burg) + endif() add_subdirectory(treecc) endif() Index: MultiSource/Benchmarks/CMakeLists.txt =================================================================== --- MultiSource/Benchmarks/CMakeLists.txt +++ MultiSource/Benchmarks/CMakeLists.txt @@ -29,7 +29,9 @@ add_subdirectory(tramp3d-v4) add_subdirectory(DOE-ProxyApps-C++) if(NOT "${ARCH}" STREQUAL "XCore") - add_subdirectory(7zip) + if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(7zip) + endif() add_subdirectory(PAQ8p) endif() if(NOT DEFINED SMALL_PROBLEM_SIZE) Index: MultiSource/Benchmarks/DOE-ProxyApps-C++/CMakeLists.txt =================================================================== --- MultiSource/Benchmarks/DOE-ProxyApps-C++/CMakeLists.txt +++ MultiSource/Benchmarks/DOE-ProxyApps-C++/CMakeLists.txt @@ -1,5 +1,7 @@ add_subdirectory(HPCCG) add_subdirectory(PENNANT) add_subdirectory(miniFE) -add_subdirectory(CLAMR) +if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(CLAMR) +endif() add_subdirectory(HACCKernels) Index: MultiSource/Benchmarks/MiBench/CMakeLists.txt =================================================================== --- MultiSource/Benchmarks/MiBench/CMakeLists.txt +++ MultiSource/Benchmarks/MiBench/CMakeLists.txt @@ -4,7 +4,9 @@ add_subdirectory(consumer-jpeg) add_subdirectory(consumer-typeset) add_subdirectory(network-dijkstra) -add_subdirectory(network-patricia) +if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(network-patricia) +endif() add_subdirectory(security-rijndael) add_subdirectory(security-sha) add_subdirectory(telecomm-CRC32) @@ -17,7 +19,8 @@ add_subdirectory(office-stringsearch) add_subdirectory(security-blowfish) add_subdirectory(telecomm-adpcm) - if((NOT "${ARCH}" STREQUAL "XCore") AND (NOT "${ARCH}" STREQUAL "ARM")) + if((NOT "${ARCH}" STREQUAL "XCore") AND (NOT "${ARCH}" STREQUAL "ARM") + AND (NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb")) add_subdirectory(office-ispell) endif() endif() Index: MultiSource/Benchmarks/Prolangs-C/CMakeLists.txt =================================================================== --- MultiSource/Benchmarks/Prolangs-C/CMakeLists.txt +++ MultiSource/Benchmarks/Prolangs-C/CMakeLists.txt @@ -1,6 +1,7 @@ add_subdirectory(agrep) add_subdirectory(gnugo) -if((NOT "${ARCH}" STREQUAL "Sparc") AND (NOT "${ARCH}" STREQUAL "Alpha")) +if((NOT "${ARCH}" STREQUAL "Sparc") AND (NOT "${ARCH}" STREQUAL "Alpha") + AND (NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb")) add_subdirectory(bison) endif() if(NOT TEST_SUITE_BENCHMARKING_ONLY) @@ -17,6 +18,8 @@ add_subdirectory(unix-tbl) if(NOT "${ARCH}" STREQUAL "XCore") add_subdirectory(archie-client) - add_subdirectory(unix-smail) + if(NOT TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + add_subdirectory(unix-smail) + endif() endif() endif() Index: SingleSource/UnitTests/CMakeLists.txt =================================================================== --- SingleSource/UnitTests/CMakeLists.txt +++ SingleSource/UnitTests/CMakeLists.txt @@ -42,4 +42,7 @@ ms_struct_pack_layout-1.c ) endif() +if(TEST_SUITE_REMOTE_CLIENT STREQUAL "adb") + list(REMOVE_ITEM Source 2005-05-11-Popcount-ffs-fls.c) +endif() llvm_singlesource() Index: cmake/caches/target-arm64-android-template.sh =================================================================== --- /dev/null +++ cmake/caches/target-arm64-android-template.sh @@ -0,0 +1,46 @@ +#!/bin/bash +rm -r CMakeCache.txt + + +# path to the test-suite source file +TEST_SUITE_LOCATION="/data/local/tmp/devspace/test-suite" +# path to android ndk that contains necessary header files and libraries +ANDROID_NDK_LOCATION="/data/local/tmp/docspace/android-ndk-r20" +# path to llvm build bin +COMPILER_BIN="/data/local/tmp/docspace/llvm-build/bin" +# OPTIONA: path to SPEC CPU2006 folder. Leave it empty if there is no SPEC CPU2006. +SPEC2006_LOCATION="/data/local/tmp/docspace/cpu2006" +# host system name +# look inside $ANDROID_NDK_LOCATION/toolchains/llvm/prebuilt to figure out +HOST_SYSTEM="linux-x86_64" +# target android device serial number +DEVICE_SERIAL="872Y00ETB" +# the location on the device to store shared c++ library +EXTRA_LIB_LOCATION="/data/local/tmp/docspace" +# flag used during compilation +COMPILE_FLAGS="--target=aarch64-linux-androideabi29 -fuse-ld=lld -L \ +$ANDROID_NDK_LOCATION/toolchains/llvm/prebuilt/$HOST_SYSTEM/lib/gcc/aarch64-linux-android/4.9.x/" + + +# push the shared library onto the device +adb -s $DEVICE_SERIAL push $ANDROID_NDK_LOCATION/toolchains/llvm/prebuilt/\ +$HOST_SYSTEM/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so \ +$EXTRA_LIB_LOCATION/libc++_shared.so + +cmake \ + -D CMAKE_C_FLAGS="$COMPILE_FLAGS -D BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD -D SPEC_CPU_LINUX" \ + -D CMAKE_CXX_FLAGS="$COMPILE_FLAGS" \ + -D CMAKE_C_COMPILER=$COMPILER_BIN/clang \ + -D CMAKE_CXX_COMPILER=$COMPILER_BIN/clang++ \ + -D CMAKE_STRIP=$COMPILER_BIN/llvm-strip \ + -D CMAKE_SYSROOT=$ANDROID_NDK_LOCATION/toolchains/llvm/prebuilt/$HOST_SYSTEM/sysroot \ + -D TEST_SUITE_REMOTE_CLIENT="adb" \ + -D TEST_SUITE_REMOTE_HOST=$DEVICE_SERIAL \ + -D TEST_SUITE_EXTRA_LIB_LOCATION=$EXTRA_LIB_LOCATION \ + -D TEST_SUITE_BENCHMARKING_ONLY=true \ + -D TEST_SUITE_COLLECT_CODE_SIZE=OFF \ + -D TEST_SUITE_SPEC2006_ROOT=$SPEC2006_LOCATION \ + -D TEST_SUITE_RUN_TYPE=ref \ + -G "Ninja" \ + -C $TEST_SUITE_LOCATION/cmake/caches/O3.cmake \ + $TEST_SUITE_LOCATION \ No newline at end of file Index: lit.cfg =================================================================== --- lit.cfg +++ lit.cfg @@ -31,6 +31,9 @@ config.remote_host = lit_config.params.get('remote_host', config.remote_host) if config.remote_host: config.test_modules.append('remote') +if config.remote_client == "adb": + config.test_modules.remove("remote") + config.test_modules.append("android") # Load previous test results so we can skip tests that did not change. previous_results_file = lit_config.params.get('previous', None) Index: lit.site.cfg.in =================================================================== --- lit.site.cfg.in +++ lit.site.cfg.in @@ -5,8 +5,9 @@ config.remote_client = "@TEST_SUITE_REMOTE_CLIENT@" config.remote_host = "@TEST_SUITE_REMOTE_HOST@" config.run_under = "@TEST_SUITE_RUN_UNDER@" +config.extra_lib_loc = "@TEST_SUITE_EXTRA_LIB_LOCATION@" config.strip_tool = "@CMAKE_STRIP@" -config.profile_generate = @TEST_SUITE_PROFILE_GENERATE@ +config.profile_generate = "@TEST_SUITE_PROFILE_GENERATE@" config.llvm_profdata = "@TEST_SUITE_LLVM_PROFDATA@" config.llvm_size = "@TEST_SUITE_LLVM_SIZE@" config.test_modules = "@LIT_MODULES@".split(';') Index: litsupport/modules/android.py =================================================================== --- /dev/null +++ litsupport/modules/android.py @@ -0,0 +1,44 @@ +"""Test module to execute a benchmark through adb on a connected Android +device. This assumes all relevant directories and files are present on the remote +device.""" +from litsupport import testplan +import logging +import os +import subprocess + + +def mutatePlan(context, plan): + # serial number of the device + if hasattr(context.config, "remote_host") and context.config.remote_host != "": + remote_host = "-s " + context.config.remote_host + else: + remote_host = "" + # the path to load libc++_shared.so + if hasattr(context.config, "extra_lib_loc") and context.config.extra_lib_loc != "": + extra_lib_loc = "LD_LIBRARY_PATH=" + context.config.extra_lib_loc + else: + extra_lib_loc = "" + + # append `adb [-s remote_host] shell` in front of each command + # append LD_LIBRARY_PATH to resolve libc++_shared.so + def append_adb_shell(s_in): + s_out = "adb {} shell \"{} {}\"".format( + remote_host, extra_lib_loc, s_in) + return s_out + + plan.preparescript = [append_adb_shell(script) + for script in plan.preparescript] + plan.runscript = [append_adb_shell(script) + for script in plan.runscript] + plan.verifyscript = [append_adb_shell(script) + for script in plan.verifyscript] + + # create output directory if nonexist + plan.preparescript.append("adb {} shell mkdir -p {}".format( + remote_host, context.tmpDir)) + + # then adb pull timeit time file + if hasattr(context, "timefiles"): + for timefile in context.timefiles: + plan.profilescript.append("adb {} pull {} {}".format( + remote_host, timefile, timefile)) Index: utils/rsync_android.sh =================================================================== --- /dev/null +++ utils/rsync_android.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# the target id +TARGET=$1 + +# build source path +TEST_SUITE_BUILD=$2 + +# convert the sym-linked directories +# into actual directories by making a copy +find $TEST_SUITE_BUILD -type l -exec bash -c 'cp -r $(readlink -m "$0") "$0.new"; rm "$0"; mv "$0.new" "$0"' {} \; + +# exclude all the files that won't be needed in the run +# transfer the rest onto the device +for file in $(find $TEST_SUITE_BUILD -type f \ + ! -name "*.o" \ + ! -name "*.a" \ + ! -name "*.cmake" \ + ! -name "*.test" \ + ! -name "*.time" \ + ! -name "*lit.local.cfg" \ + ! -name ".ninja_deps" \ + ! -name ".ninja_log" \ + ! -name "build.ninja" \ + ! -name "rules.ninja" \ + ! -name "CMakeFiles") +do + if [[ -z $TARGET ]]; then + adb push $file $file + else + adb -s $TARGET push $file $file + fi +done