Package com.jogamp.opencl.util

Examples of com.jogamp.opencl.util.MultiQueueBarrier


            out.println(queue2);

            fillBuffer(clBufferC.buffer, 12345);


            final MultiQueueBarrier barrier = new MultiQueueBarrier(2);

            Thread thread1 = new Thread("C") {

                @Override
                public void run() {

                    int groupSize = queue1.getDevice().getMaxWorkItemSizes()[0];

                    fillBuffer(clBufferA1.buffer, 12345);
                    fillBuffer(clBufferB1.buffer, 67890);

    //                System.out.println("C buffer");
                    queue1.putWriteBuffer(clBufferA1, false// write A
                          .putWriteBuffer(clBufferB1, false); // write B

    //                System.out.println("C args");
                    vectorAddKernel1.setArgs(clBufferA1, clBufferB1, clBufferC); // C = A+B

    //                System.out.println("C kernels");
                    CLEventList events1 = new CLEventList(2);
                    queue1.put1DRangeKernel(vectorAddKernel1, 0, elements, groupSize, events1)
                          .putReadBuffer(clBufferC, false, events1);

                    barrier.waitFor(queue1, events1);

                }
            };

            Thread thread2 = new Thread("D") {

                @Override
                public void run() {

                    int groupSize = queue2.getDevice().getMaxWorkItemSizes()[0];

                    fillBuffer(clBufferA2.buffer, 12345);
                    fillBuffer(clBufferB2.buffer, 67890);

    //                System.out.println("D buffer");
                    queue2.putWriteBuffer(clBufferA2, false// write A
                          .putWriteBuffer(clBufferB2, false); // write B

    //                System.out.println("D args");
                    vectorAddKernel2.setArgs(clBufferA2, clBufferB2, clBufferD); // D = A+B

    //                System.out.println("D kernels");
                    CLEventList events2 = new CLEventList(2);
                    queue2.put1DRangeKernel(vectorAddKernel2, 0, elements, groupSize, events2);
                    queue2.putReadBuffer(clBufferD, false, events2);

                    barrier.waitFor(queue2, events2);

                }
            };

            out.println("starting threads");
            thread1.start();
            thread2.start();
            assertTrue(barrier.await(5, TimeUnit.SECONDS));
            out.println("done");

            checkIfEqual(clBufferC.buffer, clBufferD.buffer, elements);
            out.println("results are valid");
View Full Code Here

TOP

Related Classes of com.jogamp.opencl.util.MultiQueueBarrier

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.