diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-05 08:17:09 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-05 08:17:09 +0000 |
commit | acf34b227763218114b1fd9901b183ff050c93bb (patch) | |
tree | f61c5a4aaa4d6158c9ea03f496f987dfa42265ea /tools | |
parent | 43d88ef1d783b107c1ec2132020b8f388f1075f7 (diff) | |
download | mpfr-acf34b227763218114b1fd9901b183ff050c93bb.tar.gz |
[tools/mbench/timp.h] Updated TIMP_MEASURE() to handle the case where
the return value is 0: this probably means that timp_overhead was too
large and incorrect. In this case, TIMP_OVERHEAD() is called again to
recompute timp_overhead and the timing is redone.
Note: if we do not call TIMP_OVERHEAD() again, then TIMP_MEASURE()
loops indefinitely, meaning that timp_overhead was really too large.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11461 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tools')
-rw-r--r-- | tools/mbench/timp.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/mbench/timp.h b/tools/mbench/timp.h index 1c958ebd2..6239a8639 100644 --- a/tools/mbench/timp.h +++ b/tools/mbench/timp.h @@ -147,10 +147,10 @@ static unsigned long long int timp_overhead = 0; #define TIMP_NUM_TRY 4327 #define TIMP_MAX_WAIT_FOR_MEASURE 10000000ULL -#define TIMP_MEASURE(CODE) \ +#define TIMP_MEASURE_AUX(CODE) \ ({ \ volatile unsigned long long int num_cycle, num_cycle2; \ - unsigned long long min_num_cycle, start_num_cycle; \ + unsigned long long int min_num_cycle, start_num_cycle; \ int _i; \ timp_rdtsc_before (start_num_cycle); \ min_num_cycle = 0xFFFFFFFFFFFFFFFFLL; \ @@ -167,7 +167,18 @@ static unsigned long long int timp_overhead = 0; } \ min_num_cycle < timp_overhead ? 0 : min_num_cycle - timp_overhead; }) +/* If the return value of TIMP_MEASURE_AUX() is 0, this probably means + that timp_overhead was too large and incorrect; this can occur just + after starting the process. In this case, TIMP_OVERHEAD() is called + again to recompute timp_overhead and the timing is redone. */ +#define TIMP_MEASURE(CODE) \ + ({ \ + unsigned long long int _m; \ + while ((_m = TIMP_MEASURE_AUX(CODE)) == 0) \ + TIMP_OVERHEAD(); \ + _m; }) + #define TIMP_OVERHEAD() \ - (timp_overhead = 0, timp_overhead = TIMP_MEASURE((void) 0) ) + (timp_overhead = 0, timp_overhead = TIMP_MEASURE_AUX((void) 0) ) #endif /* __TIMP__H__ */ |