SARITH: Safe ARITHmetic - A Progress Report
5 Feb 2000 18:56:30 -0500

          From comp.compilers

Related articles
SARITH: Safe ARITHmetic - A Progress Report (2000-02-05)
Re: SARITH: Safe ARITHmetic - A Progress Report (Robert A Duff) (2000-02-19)
| List of all articles for this month |

Newsgroups: comp.compilers
Date: 5 Feb 2000 18:56:30 -0500
Keywords: Eiffel, arithmetic

SARITH (Safe/Saturating ARITHmetic) is an open-source project to
provide new handling in Eiffel for 8-, 16-, 32-bit integer types, both
signed and unsigned. Combinations of modulo- and
saturation-arithmetic, as well as execution-halting behaviour on
overflow/out-of-boundary assignment via require clauses, and
exception-raising behaviours on both -debug and -boost compilation
modes will be provided via class-types.

The project is open-source'd (Eiffel Forum Freeware License, version
1), and although it is presently intended for an upcoming elj-win32
test-release, use of the sources by other Eiffel compiler vendors, or
ports to other languages, are hereby formally granted and welcome.

Saturation ARITHmetic is applicable in any area of the problem domain
where the size of numerical representation is critical, the limit of
numerical representation is conceivably within reach, and where a
closest representable value in the result is preferable to a
"wrap-around" result. It is certainly not new: Ada is an example of a
high-level language that implements saturation; and a good example of
saturation support in hardware comes with MMX.

SARITH, however, goes far beyond Ada or MMX, in that, probably for the
first time in CS history, arbitrary mixtures of signed and unsigned
types in both inputs and outputs are allowed, defined, and working
correctly. Adding a signed and an unsigned, and saturating the result
to an unsigned is permitted, for example. Mixed signed and unsigned
types are allowed in all operations: addition and subtraction,
assignments, relational comparators, etc.

If, say, for an 8-bit example, p is signed 0x99 (a negative hex value)
and q is unsigned 0x99 (a larger, positive hex value), p = q returns
False, and p < q returns True.

Safe ARITHmetic is the natural complement to saturation arithmetic.
It is applicable most typically (though not always) to situations of
the problem domain where "an overflow IS a bug"; --i.e.: where we want
to *detect* rather than "adjust for" overflows.

A future goal of SARITH is to bring MMX support to the Eiffel
language. Unlike previous (inelegant) attempts to bring SIMD support
to high level languages, SARITH aims to first support saturation and
other behaviours with non-SIMD types, so as to "pave a road" to MMX in
particular, and to SIMD more generally.

The current status of SARITH is:

  * 8, 16, 32-bit signed and unsigned base types have been implemented
      at compiler level (these have been integrated into the -0.77beta6

Not yet integrated in the compiler mods:

  * Inter-type casting/saturating assignments, mixed types and sizes
      (C macros).

  * Relational comparisions, mixed types allowed (C macros).

  * Addition/subtraction, mixed types, saturating and modulo (inline
      assembly, x86).

Everything so far is 100% tested (for all possible input value

Please note that SARITH is optimized for speed, by inlining, and by
minimizing of register usage and branch prediction cache pollution;
--code size concerns were last in the list.

We are looking for support for the SARITH project and would welcome
people with expertise in areas to help progress SARITH.

SARITH related links:

  * Homepage:

  * elj-search:

  * Mailing List:

  * Latest News:

  * History:

  * Downloads:

  * ETL3: Conformance and Conversion

  * SmallEiffel upgrade patch instructions and results

Enjoy, from the Sarith Team.

Daniel Watkins - Guus Leeuw - Geoff Eldridge - -

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.