summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorarvindk <arvindk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-09-13 14:22:07 +0000
committerarvindk <arvindk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-09-13 14:22:07 +0000
commitee744357ffb703b851b8622ac6a466c043de50d6 (patch)
treeb45c4d73229130f5d652a8c1be88b8f3cd1f49e9 /configure.ac
parentc89584008e58b93469fc458e97a512b8d6c339c3 (diff)
downloadATCD-ee744357ffb703b851b8622ac6a466c043de50d6.tar.gz
ChangelogTag: Tue Sep 13 09:18:54 2005 Arvind S. Krishna <arvindk@dre.vanderbilt.edu>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac103
1 files changed, 54 insertions, 49 deletions
diff --git a/configure.ac b/configure.ac
index 9d79c7244a4..52abec20796 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6409,23 +6409,11 @@ smemcpy (void* dest, const void* src, const size_t n)
}
}
-void
-testit (int type)
-{
- char buffer[16] ;
- size_t size = 16 ;
- size = 4 ;
-
- switch (type)
- {
- case 0: smemcpy ((void*)buffer, (void*)" THIS IS A TEST", size) ;
-break ;
- case 1: memcpy ((void*)buffer, (void*)" THIS IS A TEST", size) ; break ;
- }
-}
-
-namespace { enum { ITERATIONS = 1000000 }; }
-
+// Function pointer
+void* (* test_func) (void *dst, const void* src, size_t);
+
+namespace { enum { ITERATIONS = 100000 }; }
+
#include <sys/time.h>
#include <time.h>
@@ -6434,38 +6422,55 @@ main(int argc, char* argv[])
{
struct timeval start, now;
double value;
-
- // Warm up
- for (int i = ITERATIONS ; i > 0 ; --i)
- testit (0);
-
- gettimeofday (&start, 0) ;
- for( int i = ITERATIONS ; i > 0 ; --i)
- testit (0);
-
- gettimeofday (&now, 0);
- double fast = 1000000 * (now.tv_sec - start.tv_sec) +
- now.tv_usec - start.tv_usec ;
-
- gettimeofday (&start, 0) ;
- for (int i = ITERATIONS ; i > 0 ; --i)
- testit (1) ;
-
- gettimeofday( &now, 0) ;
- double slow = 1000000 * (now.tv_sec-start.tv_sec) +
- now.tv_usec - start.tv_usec ;
-
- if (fast > slow)
- return 0; // Value of 1 indicates that the test succeeded
- else
- return 1; // Value of 0 indicates that the test failed
-}]])], [ace_cv_memcpy_loop_unroll="yes"], [ace_cv_memcpy_loop_unroll="no"], [:])])
-
-if test "$ace_cv_memcpy_loop_unroll" = yes; then
- echo "loop unrolling of memcpy necessary"
-else
- echo "loop unrolling un-necessary"
-fi
+
+ // Test buffer
+ char dest [16];
+ const void* src = " THIS IS A TEST";
+
+ // We want to test if the loop unrolling is faster for sizes
+ // from 1..16
+ for (size_t counter = 16; counter >=1; counter--)
+ {
+ test_func = smemcpy;
+
+ // Warm up
+ for (int i = ITERATIONS ; i > 0 ; --i)
+ test_func ((void *)dest, src, counter);
+
+ gettimeofday (&start, 0) ;
+ for (int j = ITERATIONS ; j > 0 ; --j)
+ test_func ((void *)dest, src, counter);
+ gettimeofday (&now, 0);
+
+ double fast = 1000000 * (now.tv_sec - start.tv_sec) +
+ now.tv_usec - start.tv_usec ;
+
+ test_func = memcpy;
+
+ // Warm up
+ for (int k = ITERATIONS ; k > 0 ; --k)
+ test_func ((void *)dest, src, counter);
+
+ gettimeofday (&start, 0) ;
+ for (int l = ITERATIONS ; l > 0 ; --l)
+ test_func ((void *)dest, src, counter);
+ gettimeofday (&now, 0) ;
+
+ double slow = 1000000 * (now.tv_sec-start.tv_sec) +
+ now.tv_usec - start.tv_usec ;
+ if (fast > slow)
+ return 1; // Unrolling was slower than actual memcpy
+
+ if (1.10*fast > slow)
+ return 1; // Unrolling was not faster by 10%
+ }
+ return 0; // Unrolling was faster -- success
+}]])], [ace_cv_memcpy_loop_unroll=yes],
+ [ace_cv_memcpy_loop_unroll=no],
+ dnl Cross compilation case
+ [ace_cv_memcpy_loop_unroll=no])],
+ dnl only if the test succeeds set the macro
+ [AC_DEFINE([ACE_HAS_MEMCPY_LOOP_UNROLL])],)
dnl TODO: We only check for ACE_HAS_AUTOMATIC_INIT_FINI on platforms that
dnl have SVR4 dynamic linking since ACE doesn't support it otherwise.