[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some comments relating to ICFP contest

This page is part of the web mail archives of SRFI 77 from before July 7th, 2015. The new archives for SRFI 77 contain all messages, not just those from before July 7th, 2015.

On Wed, 26 Jul 2006, Michael Sperber wrote:

Andre van Tonder <andre@xxxxxxxxxxxxxxxxx> writes:

Conceded.  But the context of my comment was efficiency.  How likely
is it that implementations will compile the expression (exact-and (* x
y) #xFFFFFFFF) to the single machine instruction available on many

I would think it's about as likely as a "32-bit type" doing the same
thing.  On a 32-bit architecture, if your values are tagged, ...

I had backed off from the initial suggestion of separate types, instead suggesting only additional procedures on the existing exact integer type. Even if values are tagged, it seems that

  (exact-u32* x y)

may provide more control over efficiency than the above compound expression, involving a lesser number of machine instructions. When ranges can be inferred, as in

  (let ((x (blob-u32-ref (endianness big) blob 0))
    (exact-u32* x 5))

one would be in even better shape, since x and the result are known to fit in a single register and no tags are involved. In the absence of such procedures, on a 32 bit architecture, one would need to involve at least two registers for the result of the multiplication, which would presumably take more machine cycles, then apply the and, etc.

For arithmetic, perhaps multiples of 8 bits are not so important. However, is this specification is supposed to also be usable for fast operations on blobs, where multiples of 8 are inherent? If not, perhaps a parallel set of operations for the blob-inherent types would be useful as a separate library.