qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/14] softfloat: Use POSIX integer types - benchmarked
@ 2012-01-16  0:46 Andreas Färber
  2012-01-16  0:46 ` [Qemu-devel] [PATCH 01/14] lm32: Fix mixup of uint32 and uint32_t Andreas Färber
                   ` (15 more replies)
  0 siblings, 16 replies; 40+ messages in thread
From: Andreas Färber @ 2012-01-16  0:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Rui Carmo, Peter Maydell, Pavel Borzenkov, Alexander Graf,
	Eric Sunshine, Blue Swirl, Christophe Lyon, malc, Juan Pineda,
	Andreas Färber, Aurélien Jarno

Hello,

Based on a suggestion from Alex earlier this week, I managed to run a
simple benchmark of softfloat performance with qemu-arm, as requested by
Peter.

I went for the Whetstone floating point benchmark:
http://en.wikipedia.org/wiki/Whetstone_%28benchmark%29

For a loop count of 100,000 and 5 runs I got the following results:

  current:        138.9-204.1 Whetstone-MIPS
  [u]int*_t:      185.2-188.7 Whetstone-MIPS
  [u]int_fast*_t: 285.7-294.1 Whetstone-MIPS

  Toshiba AC100:  833.3-909.1 Whetstone-MIPS

These results seem to indicate that the "fast" POSIX types are indeed
somewhat faster, both compared to exact-size POSIX types and to the
current state.

As a short summary of previous discussions, softfloat had these typedefs:
  [s]bits{8,16,32,64} - exact-size semantics, => [u]int{8,16,32,64}_t
  [u]int{8,16,32,64}  - minimum-width semantics, host-independent
AIX, Mac OS X and BeOS/Haiku have some or all of the latter already,
leading to type conflicts.
I had originally suggested the POSIX [u]int_least*_t types but we
rather preferred [u]int_fast*_t, worried about performance, to get the
fastest least-width types. For either of these the actual width depends
on system headers. On the other hand it would be futile to try to
performance-optimize integer types for every possible host inside QEMU.
If we don't mind performance or dislike host-dependencies, we could just
use [u]int*_t, but then with everything [u]int*_t we can't easily change
this in case it bites us in the future.

Personally I prefer those 'fast' types, because that way we get to
keep the distinction between what was formerly [s]bits* and [u]int* types.
The clear name distinction would even allow to do conversions by regex.

However, I noticed that target-mips/cpu.h had typedefs for
uint_fast{8,16}_t for Solaris <= 9. So I moved these to osdep.h and
added typedefs for the newly needed types.

Coccinelle needed some tweaking for the macros and only did the uint16
conversion fully. For the others I was too impatient, so I hand-converted
the remaining occurrences that Coccinelle did not catch.

Since Coccinelle stripped leading whitespace before types replaced anyway,
I hand-edited (and git-am'ed) the patches to make lines touched adhere to
Coding Style.

Patches 1-3 fix misuses of softfloat types that were introduced since the
last series of fixes. These could be cherry-picked.

Patch 4 fixes a misuse of int inside softfloat. This could be cherry-picked.

Patch 5 moves the Solaris typedefs to a central header, resolving an XXX
present since their introduction in r1979.

Patches 6-13 convert the softfloat integer types.

Patch 14 converts the 'flag' type to bool, removing the last softfloat type.

Please test that this doesn't break / unbreaks Your Favorite Host:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/softfloat

Regards,
Andreas

Cc: Alexander Graf <agraf@suse.de>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Aurélien Jarno <aurelien@aurel32.net>
Cc: malc <av1474@comtv.ru>
Cc: Ben Taylor <bentaylor.solx86@gmail.com>

Cc: Rui Carmo <rui.carmo@gmail.com>
Cc: Eric Sunshine <sunshine@sunshineco.com>
Cc: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Cc: Juan Pineda <juan@logician.com>

Host: HP Envy w/ Intel Core i7-2630QM 2.0 GHz (openSUSE 12.1)
QEMU: 2be276242135eac6e86be2a8259545e620c94107 plus + 2 patches
Configuration: --prefix=/usr/local
Command: arm-linux-user/qemu-arm path/to/whetstone -c 100000

Source: http://www.netlib.org/benchmark/whetstone.c
Compiler: gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Compilation: gcc -O -s whetstone.c -o whetstone -lm -static

[u]int*_t:
---
diff --git a/fpu/softfloat.h b/fpu/softfloat.h
index 07c2929..6fe19d7 100644
--- a/fpu/softfloat.h
+++ b/fpu/softfloat.h
@@ -57,11 +57,11 @@ typedef uint8_t flag;
 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX
-typedef int uint16;
-typedef int int16;
+typedef uint16_t uint16;
+typedef int16_t int16;
 #endif
-typedef unsigned int uint32;
-typedef signed int int32;
+typedef uint32_t uint32;
+typedef int32_t int32;
 typedef uint64_t uint64;
 typedef int64_t int64;

---

[u]int_fast*_t:
---
diff --git a/fpu/softfloat.h b/fpu/softfloat.h
index 07c2929..43486aa 100644
--- a/fpu/softfloat.h
+++ b/fpu/softfloat.h
@@ -54,16 +54,16 @@ these four paragraphs for those parts of this code
that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef uint8_t uint8;
-typedef int8_t int8;
+typedef uint_fast8_t uint8;
+typedef int_fast8_t int8;
 #ifndef _AIX
-typedef int uint16;
-typedef int int16;
+typedef uint_fast16_t uint16;
+typedef int_fast16_t int16;
 #endif
-typedef unsigned int uint32;
-typedef signed int int32;
-typedef uint64_t uint64;
-typedef int64_t int64;
+typedef uint_fast32_t uint32;
+typedef int_fast32_t int32;
+typedef uint_fast64_t uint64;
+typedef int_fast64_t int64;

 #define LIT64( a ) a##LL
 #define INLINE static inline
---

spatch(1) -macro_file_builtins:
---
#define STATUS_PARAM
#define STATUS_VAR

#define INLINE static inline

#define MINMAX
---

Andreas Färber (13):
  lm32: Fix mixup of uint32 and uint32_t
  target-sparc: Fix mixup of uint64 and uint64_t
  qemu-tool: Fix mixup of int64 and int64_t
  softfloat: Fix mixups of int and int16
  softfloat: Replace uint16 type with uint_fast16_t
  softfloat: Replace int16 type with int_fast16_t
  softfloat: Remove unused uint8 type
  softfloat: Replace int8 type with int_fast8_t
  softfloat: Replace uint32 type with uint_fast32_t
  softfloat: Replace int32 type with int_fast32_t
  softfloat: Replace uint64 type with uint_fast64_t
  softfloat: Replace int64 type with int_fast64_t
  softfloat: Replace flag type with bool

 fpu/softfloat-macros.h        |   52 ++--
 fpu/softfloat-specialize.h    |   56 ++--
 fpu/softfloat.c               |  626 ++++++++++++++++++++--------------------
 fpu/softfloat.h               |  115 ++++-----
 hw/milkymist-vgafb_template.h |    2 +-
 qemu-tool.c                   |    4 +-
 target-sparc/vis_helper.c     |    2 +-
 7 files changed, 419 insertions(+), 438 deletions(-)

-- 
1.7.7

^ permalink raw reply related	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2012-01-23 17:43 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16  0:46 [Qemu-devel] [PATCH 00/14] softfloat: Use POSIX integer types - benchmarked Andreas Färber
2012-01-16  0:46 ` [Qemu-devel] [PATCH 01/14] lm32: Fix mixup of uint32 and uint32_t Andreas Färber
2012-01-16 11:27   ` Peter Maydell
2012-01-16 12:18     ` Andreas Färber
2012-01-16 21:39     ` Michael Walle
2012-01-17  9:44   ` [Qemu-devel] [PATCH v2] " Andreas Färber
2012-01-19  8:17     ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2012-01-16  0:46 ` [Qemu-devel] [PATCH 02/14] target-sparc: Fix mixup of uint64 and uint64_t Andreas Färber
2012-01-21 18:51   ` Blue Swirl
2012-01-22  2:03     ` Andreas Färber
2012-01-22  8:09       ` Blue Swirl
2012-01-22 10:02   ` Blue Swirl
2012-01-16  0:46 ` [Qemu-devel] [PATCH 03/14] qemu-tool: Fix mixup of int64 and int64_t Andreas Färber
2012-01-16  8:11   ` Stefan Hajnoczi
2012-01-16  0:46 ` [Qemu-devel] [PATCH 04/14] softfloat: Fix mixups of int and int16 Andreas Färber
2012-01-16 17:51   ` Peter Maydell
2012-01-16  0:46 ` [Qemu-devel] [PATCH 05/14] target-mips: Move definition of uint_fast{8, 16}_t to osdep.h Andreas Färber
2012-01-16 11:38   ` Peter Maydell
2012-01-16 12:13     ` Andreas Färber
2012-01-16 12:21       ` Peter Maydell
2012-01-16 12:24         ` Andreas Färber
2012-01-16  0:46 ` [Qemu-devel] [PATCH 06/14] softfloat: Replace uint16 type with uint_fast16_t Andreas Färber
2012-01-16 18:43   ` Peter Maydell
2012-01-16  0:46 ` [Qemu-devel] [PATCH 07/14] softfloat: Replace int16 type with int_fast16_t Andreas Färber
2012-01-16  0:46 ` [Qemu-devel] [PATCH 08/14] softfloat: Remove unused uint8 type Andreas Färber
2012-01-16  0:46 ` [Qemu-devel] [PATCH 09/14] softfloat: Replace int8 type with int_fast8_t Andreas Färber
2012-01-16 18:48   ` Peter Maydell
2012-01-16  0:46 ` [Qemu-devel] [PATCH 10/14] softfloat: Replace uint32 type with uint_fast32_t Andreas Färber
2012-01-16  0:47 ` [Qemu-devel] [PATCH 11/14] softfloat: Replace int32 type with int_fast32_t Andreas Färber
2012-01-16  0:47 ` [Qemu-devel] [PATCH 12/14] softfloat: Replace uint64 type with uint_fast64_t Andreas Färber
2012-01-16  0:47 ` [Qemu-devel] [PATCH 13/14] softfloat: Replace int64 type with int_fast64_t Andreas Färber
2012-01-16  0:47 ` [Qemu-devel] [PATCH 14/14] softfloat: Replace flag type with bool Andreas Färber
2012-01-16 19:02 ` [Qemu-devel] [PATCH 00/14] softfloat: Use POSIX integer types - benchmarked Peter Maydell
2012-01-16 19:12   ` Alexander Graf
2012-01-16 19:17     ` Peter Maydell
2012-01-16 19:18       ` Alexander Graf
2012-01-16 23:52         ` Peter Maydell
2012-01-17  0:05           ` Alexander Graf
2012-01-20 13:05 ` Peter Maydell
2012-01-23 17:41   ` Andreas Färber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).