Examples of CLProgram


Examples of com.jogamp.opencl.CLProgram

            int elementCount = 1444477;                                  // Length of arrays to process
            int localWorkSize = min(device.getMaxWorkGroupSize(), 256)// Local work size dimensions
            int globalWorkSize = roundUp(localWorkSize, elementCount);   // rounded up to the nearest multiple of the localWorkSize

            // load sources, create and build program
            CLProgram program = context.createProgram(HelloJOCL.class.getResourceAsStream("VectorAdd.cl")).build();

            // A, B are input buffers, C is for the result
            CLBuffer<FloatBuffer> clBufferA = context.createFloatBuffer(globalWorkSize, READ_ONLY);
            CLBuffer<FloatBuffer> clBufferB = context.createFloatBuffer(globalWorkSize, READ_ONLY);
            CLBuffer<FloatBuffer> clBufferC = context.createFloatBuffer(globalWorkSize, WRITE_ONLY);

            out.println("used device memory: "
                + (clBufferA.getCLSize()+clBufferB.getCLSize()+clBufferC.getCLSize())/1000000 +"MB");

            // fill input buffers with random numbers
            // (just to have test data; seed is fixed -> results will not change between runs).
            fillBuffer(clBufferA.getBuffer(), 12345);
            fillBuffer(clBufferB.getBuffer(), 67890);

            // get a reference to the kernel function with the name 'VectorAdd'
            // and map the buffers to its input parameters.
            CLKernel kernel = program.createCLKernel("VectorAdd");
            kernel.putArgs(clBufferA, clBufferB, clBufferC).putArg(elementCount);

            // asynchronous write of data to GPU device,
            // followed by blocking read to get the computed results back.
            long time = nanoTime();
View Full Code Here

Examples of com.jogamp.opencl.CLProgram

       
        CLContext context = CLContext.create(platform.getMaxFlopsDevice());
       
        try{
            //load and compile program for the chosen device
            CLProgram program = context.createProgram(getStreamFor("Gamma.cl"));
            program.build(CompilerOptions.FAST_RELAXED_MATH);
            assert program.isExecutable();
           
            // load image
            BufferedImage image = readImage("lena.png");
            assert image.getColorModel().getNumComponents() == 3;
           
            float[] pixels = image.getRaster().getPixels(0, 0, image.getWidth(), image.getHeight(), (float[])null);
           
            // copy to direct float buffer
            FloatBuffer fb = Buffers.newDirectFloatBuffer(pixels);
           
            // allocate a OpenCL buffer using the direct fb as working copy
            CLBuffer<FloatBuffer> buffer = context.createBuffer(fb, CLBuffer.Mem.READ_WRITE);
           
            // creade a command queue with benchmarking flag set
            CLCommandQueue queue = context.getDevices()[0].createCommandQueue(Mode.PROFILING_MODE);
           
            int localWorkSize = queue.getDevice().getMaxWorkGroupSize(); // Local work size dimensions
            int globalWorkSize = roundUp(localWorkSize, fb.capacity())// rounded up to the nearest multiple of the localWorkSize
           
            // create kernel and set function parameters
            CLKernel kernel = program.createCLKernel("gamma");
           
            // original lenna
            show(image, 0, 50, "reference");
           
            // a few gamma corrected versions
View Full Code Here

Examples of com.jogamp.opencl.CLProgram

       
        CLContext context = CLContext.create(platform.getMaxFlopsDevice());
       
        try{
            //load and compile program for the chosen device
            CLProgram program = context.createProgram(getStreamFor("Gamma.cl"));
            program.build(CompilerOptions.FAST_RELAXED_MATH);
            assert program.isExecutable();
           
            // load image
            BufferedImage image = readImage("lena.png");
            assert image.getColorModel().getNumComponents() == 3;
           
            float[] pixels = image.getRaster().getPixels(0, 0, image.getWidth(), image.getHeight(), (float[])null);
           
            // copy to direct float buffer
            FloatBuffer fb = Buffers.newDirectFloatBuffer(pixels);
           
            // allocate a OpenCL buffer using the direct fb as working copy
            CLBuffer<FloatBuffer> buffer = context.createBuffer(fb, CLBuffer.Mem.READ_WRITE);
           
            // creade a command queue with benchmarking flag set
            CLCommandQueue queue = context.getDevices()[0].createCommandQueue(Mode.PROFILING_MODE);
           
            int localWorkSize = queue.getDevice().getMaxWorkGroupSize(); // Local work size dimensions
            int globalWorkSize = roundUp(localWorkSize, fb.capacity())// rounded up to the nearest multiple of the localWorkSize
           
            // create kernel and set function parameters
            CLKernel kernel = program.createCLKernel("gamma");
           
            // original lenna
            show(image, 0, 50, "reference");
           
            // a few gamma corrected versions
View Full Code Here

Examples of com.jogamp.opencl.CLProgram

        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");
        //Check for work group size
        CLDevice device = queue.getDevice();
        long szBitonicSortLocal  = kernelMap.get(BITONIC_SORT_LOCAL).getWorkGroupSize(device);
View Full Code Here

Examples of com.jogamp.opencl.CLProgram

        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");
        //Check for work group size
        CLDevice device = queue.getDevice();
        long szBitonicSortLocal  = kernelMap.get(BITONIC_SORT_LOCAL).getWorkGroupSize(device);
View Full Code Here

Examples of com.jogamp.opencl.CLProgram

        }
    }

    private void initCL() {

        CLProgram program;
        try {
            program = clContext.createProgram(getClass().getResourceAsStream("JoglInterop.cl"));
            program.build();
            System.out.println(program.getBuildStatus());
            System.out.println(program.isExecutable());
            System.out.println(program.getBuildLog());
        } catch (IOException ex) {
            throw new RuntimeException("can not handle exception", ex);
        }

        commandQueue = clContext.getMaxFlopsDevice().createCommandQueue();

        clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES], BUFFER_SIZE, CLGLBuffer.Mem.WRITE_ONLY);
        System.out.println("clsize: "+clBuffer.getCLSize());

        System.out.println("cl buffer type: " + clBuffer.getGLObjectType());
        System.out.println("shared with gl buffer: " + clBuffer.getGLObjectID());

        kernel = program.createCLKernel("sineWave")
                        .putArg(clBuffer)
                        .putArg(MESH_SIZE)
                        .rewind();

        System.out.println("cl initialised");
View Full Code Here

Examples of com.jogamp.opencl.CLProgram

        rGBuffer = cl.createFloatBuffer(width * height * 2, Mem.READ_WRITE);
        gGBuffer = cl.createFloatBuffer(width * height * 2, Mem.READ_WRITE);
        bGBuffer = cl.createFloatBuffer(width * height * 2, Mem.READ_WRITE);
        if (false) {
            try {
                CLProgram p = cl.createProgram(new FileInputStream("/home/notzed/cl/fft-512.cl"));
                p.build();
                fft512 = p.createCLKernel("fft0");
            } catch (IOException ex) {
                Logger.getLogger(BlurTest.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            fft = new CLFFTPlan(cl, new int[]{width, height}, CLFFTPlan.CLFFTDataFormat.InterleavedComplexFormat);
View Full Code Here

Examples of com.nativelibs4java.opencl.CLProgram

   
    CLFloatBuffer b1 = context.createFloatBuffer(Usage.Input, array1, true);
    CLFloatBuffer b2 = context.createFloatBuffer(Usage.Input, array2, true);
    CLFloatBuffer b3 = context.createFloatBuffer(Usage.Output, resultArray, false);

    CLProgram program;
    try {
      program = context.createProgram(myKernelSource).build();
      CLKernel kernel = program.createKernel(
              "simpleKernel",
              b1,
              b2,
              b3
      );
View Full Code Here

Examples of com.nativelibs4java.opencl.CLProgram

        CLBuffer<Double> buffer_v1 = context.createDoubleBuffer(CLMem.Usage.Input,v1_b, true);
        CLBuffer<Double> buffer_v2 = context.createDoubleBuffer(CLMem.Usage.Input,v2_b, true);
        CLBuffer<Double> buffer_v3 = context.createDoubleBuffer(CLMem.Usage.Output, dataSize);
       
        String src = IOUtils.readText(new File("matvec.cl"));
        CLProgram program = context.createProgram(src);
        CLKernel prod_escalar = program.createKernel("prod_escalar");
        prod_escalar.setArgs(buffer_v1, buffer_v2, buffer_v3, dataSize, dataSize);
       
        CLEvent prodEvt = prod_escalar.enqueueNDRange(queue, new int[] { dataSize });

        DoubleBuffer buffer_v4 = buffer_v3.read(queue,prodEvt);
View Full Code Here

Examples of com.nativelibs4java.opencl.CLProgram

        CLBuffer<Double> clBufferEntrada = null;

        //leitura do arquivo cl e compilacao do programa
        String src = IOUtils.readText(new File("matvec.cl"));
        CLProgram program = context.createProgram(src);
        //CLKernel kernel = null;
        //CLEvent prodEvt = null;
        CLKernel kernelProdEscalar = program.createKernel("prod_escalar");
        CLKernel kernelS2 = program.createKernel("s2");
        CLKernel kernelS1 = program.createKernel("s1");
        CLKernel kernelAtualizaPesos3 = program.createKernel("atualiza_pesos_3");
        CLKernel kernelAtualizaPesos2 = program.createKernel("atualiza_pesos_2");
        CLKernel kernelAtualizaPesos1 = program.createKernel("atualiza_pesos_1");

        //----------------------------VARIAVEIS DA 1a CAMADA
        int qtdNeuronios_1 = 12;
        //gerado como vetor para facilitar o uso no kernel
        double[] pesos_1 = FuncoesCPU.gerarVetorAleatorio(qtdNeuronios_1 * qtdNeuronios_1, Param.min, Param.max);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.