Re: What exactly is our CRC algorithm? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: What exactly is our CRC algorithm?
Date
Msg-id 20141226155033.GB3763@momjian.us
Whole thread Raw
In response to Re: What exactly is our CRC algorithm?  (Abhijit Menon-Sen <ams@2ndQuadrant.com>)
Responses Re: What exactly is our CRC algorithm?  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
On Thu, Dec 25, 2014 at 11:57:29AM +0530, Abhijit Menon-Sen wrote:
> Hi.
> 
> Here's a proposed patch to use CPUID at startup to determine if the
> SSE4.2 CRC instructions are available, to use them instead of the
> slice-by-8 implementation (posted earlier).
> 
> A few notes:
> 
> 1. GCC has included cpuid.h since 4.3.0, so I figured it was safe to
>    use. It can be replaced with some inline assembly otherwise.
> 
> 2. I've also used the crc32b/crc32q instructions directly rather than
>    using ".bytes" to encode the instructions; bintuils versions since
>    2007 or so have supported them.
> 
> 3. I've included the MSVC implementation mostly as an example of how to
>    extend this to different compilers/platforms. It's written according
>    to the documentation for MSVC intrinsics, but I have not tested it.
>    Suggestions/improvements are welcome.

Uh, what happens if the system is compiled on a different CPU that it is
run on?  Seems we would need a run-time CPU test.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + Everyone has their own god. +



pgsql-hackers by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: BUG #12330: ACID is broken for unique constraints
Next
From: Tom Lane
Date:
Subject: Re: BUG #12330: ACID is broken for unique constraints