From 7b2ca9e787a204f2a57f390bc7249bb7f9997fea Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 27 Aug 2013 21:08:02 -0700 Subject: [PATCH] Client (Android): run the Whetstone benchmarks using VFP or Neon if available. From Carl. --- client/Makefile.am | 10 ++++++++++ client/cs_benchmark.cpp | 24 ++++++++++++++++++++++++ client/whetstone.cpp | 19 +++++++++++++++++++ client/whetstone.h | 20 ++++++++++++++++++++ configure.ac | 1 + 5 files changed, 74 insertions(+) create mode 100644 client/whetstone.h diff --git a/client/Makefile.am b/client/Makefile.am index 0f474b8caf..df8994d643 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -95,6 +95,16 @@ boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD boinc_clientdir = $(bindir) +if OS_ARM_LINUX +boinc_client_LDADD += libwhetneon.a libwhetvfp.a +noinst_LIBRARIES = libwhetneon.a libwhetvfp.a +libwhetneon_a_SOURCES = whetstone.cpp whetstone.h +libwhetneon_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_NEON -mfloat-abi=softfp -mfpu=neon + +libwhetvfp_a_SOURCES = whetstone.cpp whetstone.h +libwhetvfp_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_VFP -mfloat-abi=softfp -mfpu=vfp +endif + switcher_SOURCES = switcher.cpp switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib switcher_LDADD = $(LIBBOINC) diff --git a/client/cs_benchmark.cpp b/client/cs_benchmark.cpp index e41302f31f..a3371fa41f 100644 --- a/client/cs_benchmark.cpp +++ b/client/cs_benchmark.cpp @@ -60,6 +60,12 @@ #include "filesys.h" #include "util.h" #include "cpu_benchmark.h" + +// CMC HERE - header file for whetstone namespaces (neon & vfp) +#ifdef ANDROID +#include "whetstone.h" +#endif + #include "client_msgs.h" #include "log_flags.h" #include "client_state.h" @@ -171,7 +177,25 @@ int cpu_benchmarks(BENCHMARK_DESC* bdp) { bdp->error_str[0] = '\0'; host_info.clear_host_info(); +// CMC here +#ifdef ANDROID + // check for vfp or neon process or no special fp process + // namespaces separate the different compilations of the same whetstone.cpp file + if ( strstr(gstate.host_info.p_features, " neon ") != NULL ) { + // have ARM neon FP capabilities + retval = android_neon::whetstone(host_info.p_fpops, fp_time, MIN_CPU_TIME); + } + else if ( strstr(gstate.host_info.p_features, " vfp ") != NULL ) { + // have ARM vfp FP capabilities + retval = android_vfp::whetstone(host_info.p_fpops, fp_time, MIN_CPU_TIME); + } + else { // just run normal test + retval = whetstone(host_info.p_fpops, fp_time, MIN_CPU_TIME); + } +#else retval = whetstone(host_info.p_fpops, fp_time, MIN_CPU_TIME); +#endif +// CMC end if (retval) { bdp->error = true; sprintf(bdp->error_str, "FP benchmark ran only %f sec; ignoring", fp_time); diff --git a/client/whetstone.cpp b/client/whetstone.cpp index 0aec5d1ce9..666364cc46 100644 --- a/client/whetstone.cpp +++ b/client/whetstone.cpp @@ -34,9 +34,25 @@ #endif #include "util.h" +// CMC android +#ifdef ANDROID +#include "whetstone.h" +#endif #include "cpu_benchmark.h" +#ifndef SPDP #define SPDP double +#endif + +#ifdef ANDROID +#ifdef ANDROID_NEON + namespace android_neon { +#else + #ifdef ANDROID_VFP + namespace android_vfp { + #endif +#endif +#endif // External array; store results here so that optimizing compilers // don't do away with their computation. @@ -278,3 +294,6 @@ int whetstone(double& flops, double& cpu_time, double min_cpu_time) { return 0; } +#if defined(ANDROID_NEON) || defined(ANDROID_VFP) + } +#endif // namespace closure diff --git a/client/whetstone.h b/client/whetstone.h new file mode 100644 index 0000000000..1970f28963 --- /dev/null +++ b/client/whetstone.h @@ -0,0 +1,20 @@ + +// CMC here +// separate different compilations of whetstone.cpp which will utilize +// various ARM fp features ie neon, vfp, or "normal" +#ifdef ANDROID +#ifdef ANDROID_NEON + // add CXXFLAGS/CFLAGS for gcc: -DANDROID_NEON -mfloat-abi=softfp -mfpu=neon + #include +#endif // ANDROID_NEON + +namespace android_neon { + int whetstone(double& flops, double& cpu_time, double min_cpu_time); +} + +namespace android_vfp { + int whetstone(double& flops, double& cpu_time, double min_cpu_time); +} + +#endif // ANDROID + diff --git a/configure.ac b/configure.ac index 2823dc30fe..033541c24b 100644 --- a/configure.ac +++ b/configure.ac @@ -779,6 +779,7 @@ dnl In case anyone wants to try building the windows code using mingw! AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null]) dnl or OS2 AM_CONDITIONAL(OS_OS2, [echo $host_os | grep '^os2' > /dev/null]) +AM_CONDITIONAL(OS_ARM_LINUX, [echo $host_alias | grep '^arm-linux' > /dev/null]) dnl Whether to build fcgi components AM_CONDITIONAL(ENABLE_FCGI,[test "${enable_fcgi}" = yes])