jordan30001 / aparapi

Automatically exported from code.google.com/p/aparapi
Other
0 stars 0 forks source link

Support OpenCL 1.2 popCount functionality #51

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We implemented a popCount method in code, but popCount is apparently now 
available in OpenCL 1.2

http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/popcount.html

This could potentially be a very nice performance improvement for our kernels.

Original issue reported on code.google.com by ryan.lam...@gmail.com on 22 May 2012 at 5:06

GoogleCodeExporter commented 9 years ago
Ryan so this would be just providing a mapping to the OpenCL 1.2 popcount 
function/method.  I assume you already have a Java implementation.

Ideally we can also add a synthetic OpenCL solution for OpenCL 1.1 users.  i.e 
just redirect to a canned implementation. 

Can I assign this enhancement to you? ;)

Original comment by frost.g...@gmail.com on 22 May 2012 at 2:14

GoogleCodeExporter commented 9 years ago
Yes, I'm just requesting a direct mapping, exactly like the other direct 
mappings Aparapi provides.

We already have a Java implementation, I'll post it and give attribution so 
that we can determine if the license matches Aparapi's licensing requirements.

/**
 * Returns the number of bits set in the long
 */
private int pop(long x) {

    /*
     * http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/3.1.0/org/apache/lucene/util/BitUtil.java
     */

    /*
     * Hacker's Delight 32 bit pop function:
     * http://www.hackersdelight.org/HDcode/newCode/pop_arrayHS.c.txt
     * 
     * int pop(unsigned x) {
     * x = x - ((x >> 1) & 0x55555555);
     * x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
     * x = (x + (x >> 4)) & 0x0F0F0F0F;
     * x = x + (x >> 8);
     * x = x + (x >> 16);
     * return x & 0x0000003F;
     * }
     * *
     */

    // 64 bit java version of the C function from above
    x = x - (x >>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x >>> 2 & 0x3333333333333333L);
    x = x + (x >>> 4) & 0x0F0F0F0F0F0F0F0FL;
    x = x + (x >>> 8);
    x = x + (x >>> 16);
    x = x + (x >>> 32);
    return (int) x & 0x7F;
}

Original comment by ryan.lam...@gmail.com on 24 May 2012 at 2:51

GoogleCodeExporter commented 9 years ago
After we determine the licensing acceptance, I can work on implementing this 
feature. Is the trunk in a state where we can start implementing new features 
again or are we waiting until after 2012 AFDS?

Original comment by ryan.lam...@gmail.com on 24 May 2012 at 2:54

GoogleCodeExporter commented 9 years ago
Do we have any clarification on Aparapi license compatibility with the above 
code?

http://www.apache.org/licenses/LICENSE-2.0.html
http://www.hackersdelight.org/permissions.htm

Original comment by ryan.lam...@gmail.com on 11 Aug 2012 at 7:51

GoogleCodeExporter commented 9 years ago
Please reference the following link to see how much a hardware PopCount() 
function could improve performance over a software-only solution:

http://java.dzone.com/articles/java-intrinsics-and?mz=110215-high-perf

Original comment by ryan.lam...@gmail.com on 21 Nov 2012 at 9:45