[Mono-bugs] [Bug 472506] New: Mono.Simd doesn't contain Hamming weight function which is in the SSE4.2/4a

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 4 12:34:02 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=472506


           Summary: Mono.Simd doesn't contain Hamming weight function
                    which is in the SSE4.2/4a
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.2.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: michal.kovac.develop at centrum.cz
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; cs; rv:1.9.0.5)
Gecko/2009012717 Gentoo Firefox/3.0.5

I haven't found function for counting of number of bits in the VectorXX (we can
call it BitCount, HammingWeight,...). In the SSE4.2 and SSE4a is the POPCNT
operation which does it. It would speed up our software for data mining Ferda
Data Miner (http://ferda.sourceforge.net/). For architectures which does not
have the SSE4.2 or SSE4a I would prefer to use this kind of counting of bits on
architectures without SSE (it is on the amd64 architectures the quickest):


    const ulong m1  = 0x5555555555555555; //binary: 0101...
    const ulong m2  = 0x3333333333333333; //binary: 00110011..
    const ulong m4  = 0x0f0f0f0f0f0f0f0f; //binary:  4 zeros,  4 ones ...
    const ulong h01 = 0x0101010101010101; //the sum of 256 to the power of
0,1,2,3...

static unsafe ulong QuickSum(ulong x) {
    x -= (x >> 1) & m1;//put count of each 2 bits into those 2 bits
    x = (x & m2) + ((x >> 2) & m2); //put count of each 4 bits into those 4
bits
    x = (x + (x >> 4)) & m4;        //put count of each 8 bits into those 8
bits
    return ((x * h01)>>56);  //returns left 8 bits of x + (x<<8) + (x<<16) +
(x<<24) + ...
}

For those architectures which doesn't have SSE 4.2/4a but has a SEE support I
think it can be also speed up.

thanks
Michal Kovac

Reproducible: Always

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list