synchronized Reductor<Double> getAddReductorDouble() { if (addReductorDouble == null) { try { addReductorDouble = ReductionUtils.createReductor(getContext(), ReductionUtils.Operation.Add, OpenCLType.Double, 1); } catch (CLBuildException ex) { Logger.getLogger(LinearAlgebraUtils.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Failed to create an addition reductor !", ex); } } return addReductorDouble; }
return new Pair<String, Map<String, Object>>(getSource(), macros);
Pair<String, Map<String, Object>> codeAndMacros = getReductionCodeAndMacros(op, valueType, valueChannels); CLProgram program = context.createProgram(codeAndMacros.getFirst()); program.defineMacros(codeAndMacros.getValue());
return new Pair<String, Map<String, Object>>(getSource(), macros);
Pair<String, Map<String, Object>> codeAndMacros = getReductionCodeAndMacros(op, valueType, valueChannels); CLProgram program = context.createProgram(codeAndMacros.getFirst()); program.defineMacros(codeAndMacros.getValue());
synchronized Reductor<Float> getAddReductorFloat() { if (addReductorFloat == null) { try { addReductorFloat = ReductionUtils.createReductor(getContext(), ReductionUtils.Operation.Add, OpenCLType.Float, 1); } catch (CLBuildException ex) { Logger.getLogger(LinearAlgebraUtils.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Failed to create an addition reductor !", ex); } } return addReductorFloat; }
synchronized Reductor<Double> getAddReductorDouble() { if (addReductorDouble == null) { try { addReductorDouble = ReductionUtils.createReductor(getContext(), ReductionUtils.Operation.Add, OpenCLType.Double, 1); } catch (CLBuildException ex) { Logger.getLogger(LinearAlgebraUtils.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Failed to create an addition reductor !", ex); } } return addReductorDouble; }
synchronized Reductor<Float> getAddReductorFloat() { if (addReductorFloat == null) { try { addReductorFloat = ReductionUtils.createReductor(getContext(), ReductionUtils.Operation.Add, OpenCLType.Float, 1); } catch (CLBuildException ex) { Logger.getLogger(LinearAlgebraUtils.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Failed to create an addition reductor !", ex); } } return addReductorFloat; }
public SobelFilterDemo() throws IOException, CLBuildException { context = JavaCL.createBestContext(); queue = context.createDefaultQueue(); sobel = new SimpleSobel(context); floatMinReductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Max, OpenCLType.Float, 1); }
public SobelFilterDemo() throws IOException, CLBuildException { context = JavaCL.createBestContext(); queue = context.createDefaultQueue(); sobel = new SimpleSobel(context); floatMinReductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Max, OpenCLType.Float, 1); }
public SobelFilterDemo() throws IOException, CLBuildException { context = JavaCL.createBestContext(); queue = context.createDefaultQueue(); sobel = new SimpleSobel(context); floatMinReductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Max, OpenCLType.Float, 1); }
public CLDenseMatrix2DImpl<V> max() throws CLBuildException { synchronized (this) { if (maxReductor == null) maxReductor = ReductionUtils.createReductor(getMatrix().getContext(), ReductionUtils.Operation.Max, getMatrix().getPrimitive().oclType, 1); } CLMatrix2D<V> in = getMatrix(), out = in.blankMatrix(1, 1); CLMatrixUtils.reduce(in, out, minReductor); return new CLDenseMatrix2DImpl<V>(out); }
public CLDenseMatrix2DImpl<V> min() throws CLBuildException { synchronized (this) { if (minReductor == null) minReductor = ReductionUtils.createReductor(getMatrix().getContext(), ReductionUtils.Operation.Min, getMatrix().getPrimitive().oclType, 1); } CLMatrix2D<V> out = getMatrix().blankMatrix(1, 1); CLMatrixUtils.reduce(getMatrix(), out, minReductor); return new CLDenseMatrix2DImpl<V>(out); } volatile Reductor<V> maxReductor;
@Test public void testIssue26() { try { float[] array = new float[4097]; for (int i = 0; i < array.length; i++) array[i] = 1; CLBuffer<Float> clBufferInput = context.createBuffer(CLMem.Usage.Input, pointerToFloats(array), true); ReductionUtils.Reductor<Float> reductor = ReductionUtils.createReductor( context, ReductionUtils.Operation.Add, OpenCLType.Float, 1 ); Pointer<Float> result = reductor.reduce(queue, clBufferInput, 4097, 64); float sum = result.get(0); float expected = 4097; System.err.println("[Test of issue 26] Expected " + expected + ", got " + sum); assertEquals(expected, sum, 0); } catch (Exception ex) { ex.printStackTrace(); assertTrue(ex.toString(), false); } } @Test
@Test public void testMinMax() { try { CLBuffer<Integer> input = context.createBuffer(CLMem.Usage.Input, pointerToInts( 1110, 22, 35535, 3, 1 ), true); int maxReductionSize = 2; Pointer<Integer> result = allocateInt().order(context.getByteOrder()); Reductor<Integer> reductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Min, OpenCLType.Int, 1); reductor.reduce(queue, input, input.getElementCount(), result, maxReductionSize); queue.finish(); assertEquals(1, (int)result.get()); reductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Max, OpenCLType.Int, 1); reductor.reduce(queue, input, input.getElementCount(), result, maxReductionSize); queue.finish(); assertEquals(35535, (int)result.get()); } catch (Exception ex) { ex.printStackTrace(); assertTrue(ex.toString(), false); } }
Reductor<Integer> reductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Add, OpenCLType.Int, channels);