Package com.jogamp.opencl

Examples of com.jogamp.opencl.CLContext


   
    private Map<String, CLKernel> initBitonicSort(CLCommandQueue queue) throws IOException {

        out.println("    creating bitonic sort program");

        CLContext context = queue.getContext();

        CLProgram program = context.createProgram(getClass().getResourceAsStream("BitonicSort.cl"))
                                   .build(define("LOCAL_SIZE_LIMIT", LOCAL_SIZE_LIMIT));

        Map<String, CLKernel> kernelMap = program.createCLKernels();

        out.println("    checking minimum supported workgroup size");
View Full Code Here


*/
public class RadixSortDemo {

    public RadixSortDemo() throws IOException {

        CLContext context = null;
        try{
            CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.type(GPU));
            if (platform == null) {
                throw new RuntimeException("this demo requires a GPU OpenCL implementation");
            }
           
            //single GPU setup
            context = CLContext.create(platform.getMaxFlopsDevice());
            CLCommandQueue queue = context.getDevices()[0].createCommandQueue();

            int maxValue = Integer.MAX_VALUE;
            int samples  = 10;

            int[] workgroupSizes = new int[] {128, 256};

            int[] runs = new int[] {   32768,
                                       65536,
                                      131072,
                                      262144,
                                      524288,
                                     1048576,
                                     2097152,
                                     4194304,
                                     8388608 };

            for (int i = 0; i < workgroupSizes.length; i++) {

                int workgroupSize = workgroupSizes[i];

                out.println("\n = = = workgroup size: "+workgroupSize+" = = = ");

                for(int run = 0; run < runs.length; run++) {

                    ifworkgroupSize==128 && runs[run] >= 8388608
                      || workgroupSize==256 && runs[run] <= 32768) {
                        continue; // we can only sort up to 4MB with wg size of 128
                    }

                    int numElements = runs[run];

                    CLBuffer<IntBuffer> array = context.createIntBuffer(numElements, READ_WRITE);
                    out.print("array size: " + array.getCLSize()/1000000.0f+"MB; ");
                    out.println("elements: " + array.getCLCapacity()/1000+"K");

                    fillBuffer(array, maxValue);

                    RadixSort radixSort = new RadixSort(queue, numElements, workgroupSize);
                    for(int a = 0; a < samples; a++) {

                        queue.finish();

                        long time = nanoTime();

                        queue.putWriteBuffer(array, false);
                        radixSort.sort(array, numElements, 32);
                        queue.putReadBuffer(array, true);

                        out.println("time: " + (nanoTime() - time)/1000000.0f+"ms");
                    }

                    out.print("snapshot: ");
                    printSnapshot(array.getBuffer(), 20);

                    out.println("validating...");
                    checkIfSorted(array.getBuffer());
                    out.println("values sorted");

                    array.release();
                    radixSort.release();
                }
            }

        }finally{
            if(context != null) {
                context.release();
            }
        }

    }
View Full Code Here

        int numBlocks = ((maxElements % (CTA_SIZE * 4)) == 0)
                ? (maxElements / (CTA_SIZE * 4)) : (maxElements / (CTA_SIZE * 4) + 1);

        this.queue = queue;

        CLContext context  = queue.getContext();
        this.tempKeys      = context.createBuffer(4 * maxElements,           READ_WRITE);
        this.mCounters     = context.createBuffer(4 * WARP_SIZE * numBlocks, READ_WRITE);
        this.mCountersSum  = context.createBuffer(4 * WARP_SIZE * numBlocks, READ_WRITE);
        this.mBlockOffsets = context.createBuffer(4 * WARP_SIZE * numBlocks, READ_WRITE);

        program = context.createProgram(getClass().getResourceAsStream("RadixSort.cl"))
                         .build(ENABLE_MAD, define("WARP_SIZE", WARP_SIZE));

//        out.println(program.getBuildLog());

        ckRadixSortBlocksKeysOnly  = program.createCLKernel("radixSortBlocksKeysOnly");
View Full Code Here

    public Scan(CLCommandQueue queue, int numElements) throws IOException {

        this.queue = queue;

        CLContext context = queue.getContext();
        if (numElements > MAX_WORKGROUP_INCLUSIVE_SCAN_SIZE) {
            buffer = context.createBuffer(numElements / MAX_WORKGROUP_INCLUSIVE_SCAN_SIZE * 4, READ_WRITE);
        }
        program = context.createProgram(getClass().getResourceAsStream("Scan_b.cl"))
                         .build(ENABLE_MAD);

        ckScanExclusiveLocal1 = program.createCLKernel("scanExclusiveLocal1");
        ckScanExclusiveLocal2 = program.createCLKernel("scanExclusiveLocal2");
        ckUniformUpdate       = program.createCLKernel("uniformUpdate");
View Full Code Here

TOP

Related Classes of com.jogamp.opencl.CLContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.