From 06e6c152171c4f653d806e35cfe295dc9ef0fc3c Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 1 Jun 2015 11:16:01 +0800 Subject: [PATCH] test/perf_local: disable tests if not supported * pass appropriate "-m" args to compiler Signed-off-by: Kefu Chai --- src/test/Makefile-server.am | 4 ++++ src/test/perf_local.cc | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/test/Makefile-server.am b/src/test/Makefile-server.am index 2d5964ef3c09..6ced749e34d9 100644 --- a/src/test/Makefile-server.am +++ b/src/test/Makefile-server.am @@ -32,6 +32,10 @@ bin_DEBUGPROGRAMS += ceph_perf_objectstore ceph_perf_local_SOURCES = test/perf_local.cc test/perf_helper.cc ceph_perf_local_LDADD = $(LIBOS) $(CEPH_GLOBAL) +ceph_perf_local_CXXFLAGS = ${AM_CXXFLAGS} \ + ${INTEL_SSE_FLAGS} \ + ${INTEL_SSE2_FLAGS} + noinst_HEADERS += test/perf_helper.h bin_DEBUGPROGRAMS += ceph_perf_local diff --git a/src/test/perf_local.cc b/src/test/perf_local.cc index f388f6102055..ba3bc0fa086d 100644 --- a/src/test/perf_local.cc +++ b/src/test/perf_local.cc @@ -35,7 +35,9 @@ // * Create a new entry for the test in the #tests table. #include #include -#if defined(__x86_64__) || defined(__amd64__) + +#include "acconfig.h" +#ifdef HAVE_SSE #include #endif @@ -600,7 +602,7 @@ double perf_cycles_to_nanoseconds() } -#if defined(__x86_64__) || defined(__amd64__) +#ifdef HAVE_SSE /** * Prefetch the cache lines containing [object, object + numBytes) into the * processor's caches. @@ -613,19 +615,17 @@ double perf_cycles_to_nanoseconds() */ static inline void prefetch(const void *object, uint64_t num_bytes) { -#if defined(__x86_64__) || defined(__amd64__) uint64_t offset = reinterpret_cast(object) & 0x3fUL; const char* p = reinterpret_cast(object) - offset; for (uint64_t i = 0; i < offset + num_bytes; i += 64) _mm_prefetch(p + i, _MM_HINT_T0); -#endif } #endif // Measure the cost of the prefetch instruction. double perf_prefetch() { -#if defined(__x86_64__) || defined(__amd64__) +#ifdef HAVE_SSE uint64_t total_ticks = 0; int count = 10; char buf[16 * 64]; @@ -689,6 +689,7 @@ double perf_serialize() { // Measure the cost of an lfence instruction. double lfence() { +#ifdef HAVE_SSE2 int count = 1000000; uint64_t start = Cycles::rdtsc(); for (int i = 0; i < count; i++) { @@ -696,11 +697,15 @@ double lfence() } uint64_t stop = Cycles::rdtsc(); return Cycles::to_seconds(stop - start)/count; +#else + return -1; +#endif } // Measure the cost of an sfence instruction. double sfence() { +#ifdef HAVE_SSE int count = 1000000; uint64_t start = Cycles::rdtsc(); for (int i = 0; i < count; i++) { @@ -708,6 +713,9 @@ double sfence() } uint64_t stop = Cycles::rdtsc(); return Cycles::to_seconds(stop - start)/count; +#else + return -1; +#endif } // Measure the cost of acquiring and releasing a SpinLock (assuming the -- 2.47.3