views:

983

answers:

2

I've profiled my application with Ants and found out that > 10% is in CRC32 calculations. (The CRC32-calculation is done in plain C#)

I did some googling and learned about the following intrinsics in Visual Studio 2008 :

_mm_crc32_u8

_mm_crc32_u16

_mm_crc32_u32

_mm_crc32_u64

( http://msdn.microsoft.com/en-us/library/bb514036.aspx )

Can anyone tell me / show me how to use these to replace my homebrew CRC32 ?

+1  A: 

You can use PInvoke (and pure c#) or create C++/CLI project and write wrapper around this functions.

Did you saw example on msdn? To compute CRC of string you need just loop through it.

Well, they're Intrinsic functions. It means you have only one option: create C++/CLI wrapper.

Trickster
A: 

Some years ago I used one I found on codeproject. Now I can't find it again. But this one also look very fast:

CRC32 on CodeProject

Nerds Rule
That's the usual Single-table-lookup with 2 XOR's, one AND and a shift that I'm using at the moment ;)
Pygmy