getWritableData() {
55 | return getData();
56 | }
57 |
58 | public long[] getSize() {
59 | return new long[] { rows, columns };
60 | }
61 |
62 | public double getDouble(long row, long column) {
63 | return data.getDoubleAtOffset((row * columns + column) << 3);
64 | }
65 |
66 | @Override
67 | public void setDouble(double value, long row, long column) {
68 | data.setDoubleAtOffset((row * columns + column) << 3, value);
69 | }
70 |
71 | @Override
72 | public double getDouble(int row, int column) {
73 | return getDouble((long)row, column);
74 | }
75 |
76 | @Override
77 | public void setDouble(double value, int row, int column) {
78 | setDouble(value, (long)row, column);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/DirectNIODenseDoubleMatrix2DFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this template, choose Tools | Templates
3 | * and open the template in the editor.
4 | */
5 |
6 | package com.nativelibs4java.opencl.blas.ujmp;
7 |
8 | import org.ujmp.core.doublematrix.DenseDoubleMatrix2D;
9 | import org.ujmp.core.doublematrix.factory.AbstractDoubleMatrix2DFactory;
10 | import org.ujmp.core.exceptions.MatrixException;
11 |
12 | /**
13 | *
14 | * @author ochafik
15 | */
16 | public class DirectNIODenseDoubleMatrix2DFactory extends
17 | AbstractDoubleMatrix2DFactory {
18 | private static final long serialVersionUID = 4390694808314618187L;
19 |
20 |
21 | public DenseDoubleMatrix2D dense(long rows, long columns)
22 | throws MatrixException {
23 | return new DirectNIODenseDoubleMatrix2D(rows, columns);
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JavaCL - Java API and utilities for OpenCL
3 | * http://javacl.googlecode.com/
4 | *
5 | * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/)
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | * * Neither the name of Olivier Chafik nor the
17 | * names of its contributors may be used to endorse or promote products
18 | * derived from this software without specific prior written permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY
21 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 | /**
32 | * OpenCL UJMP float/double dense matrix implementations with many asynchronous accelerated operations (multiplication, transpose, piece-wise unary or binary operations...).
33 | * To install these implementations, please use the following calls :
34 | * {@code
35 | * MatrixMapper.getInstance().setDenseDoubleMatrix2DClass(CLDenseDoubleMatrix2D.class);
36 | * MatrixMapper.getInstance().setDenseFloatMatrix2DClass(CLDenseFloatMatrix2D.class);
37 | * }
38 | */
39 | package com.nativelibs4java.opencl.blas.ujmp;
40 |
--------------------------------------------------------------------------------
/Blas/src/test/java/com/nativelibs4java/opencl/blas/CLMatrixUtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.nativelibs4java.opencl.blas;
2 |
3 | import static com.nativelibs4java.opencl.blas.CLMatrixUtils.roundUp;
4 | import static org.junit.Assert.*;
5 |
6 | import org.junit.Test;
7 | /**
8 | *
9 | * @author ochafik
10 | */
11 |
12 | public class CLMatrixUtilsTest {
13 |
14 | @Test
15 | public void testRoundUp() {
16 | assertEquals(0, roundUp(0, 16));
17 | assertEquals(16, roundUp(1, 16));
18 | assertEquals(16, roundUp(16, 16));
19 | assertEquals(32, roundUp(17, 16));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Contributions/Kazo Csaba/BinaryKernelTest - issue 30.java:
--------------------------------------------------------------------------------
1 | package com.nativelibs4java.opencl;
2 |
3 | import static com.nativelibs4java.util.NIOUtils.directBuffer;
4 | import java.util.Map;
5 | import static org.junit.Assert.assertEquals;
6 |
7 | import java.nio.IntBuffer;
8 |
9 | import org.junit.BeforeClass;
10 | import org.junit.Test;
11 |
12 | import com.nativelibs4java.test.MiscTestUtils;
13 |
14 | /**
15 | *
16 | * @author Kazó Csaba
17 | */
18 | @SuppressWarnings("unchecked")
19 | public class BinaryKernelTest extends AbstractCommon {
20 |
21 | @BeforeClass
22 | public static void setup() {
23 | MiscTestUtils.protectJNI();
24 | }
25 |
26 | @Test
27 | public void simpleTest() throws CLBuildException {
28 | CLProgram program = context.createProgram(
29 | "__kernel void copy(__global int* a, __global int* b) {\n" +
30 | " int i = get_global_id(0);\n" +
31 | " b[i]=a[i];\n" +
32 | "} ");
33 | program.build();
34 | Map binaries = program.getBinaries();
35 | program.release();
36 |
37 | CLProgram binaryProgram = context.createProgram(binaries);
38 | CLKernel kernel=binaryProgram.createKernel("copy");
39 |
40 | CLIntBuffer a=context.createIntBuffer(CLMem.Usage.Input, 4);
41 | CLIntBuffer b=context.createIntBuffer(CLMem.Usage.Output, 4);
42 |
43 | IntBuffer source = directBuffer(4, context.getByteOrder(), IntBuffer.class);
44 | for (int i=0; i<4; i++)
45 | source.put(i, 3*i+10);
46 |
47 | a.write(queue, source, true);
48 |
49 | kernel.setArgs(a, b);
50 | kernel.enqueueNDRange(queue, new int[]{4}, new int[]{1}).waitFor();
51 |
52 | IntBuffer target = b.read(queue);
53 |
54 | assertEquals(target.capacity(), source.capacity());
55 | for (int i=0; i<4; i++)
56 | assertEquals(source.get(i), target.get(i));
57 | }
58 | }
--------------------------------------------------------------------------------
/Contributions/Kazo Csaba/CreateBinaryProgram - issue 30.README:
--------------------------------------------------------------------------------
1 | See http://code.google.com/p/nativelibs4java/issues/detail?id=30
2 |
3 | kazocsaba's first comment :
4 | <<<
5 | Certainly, I'm happy to contribute the patch under LGPL and BSD.
6 |
7 | Csaba
8 | >>>
9 |
--------------------------------------------------------------------------------
/Core/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Core/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | project/boot
3 | project/target
4 | *~
5 |
--------------------------------------------------------------------------------
/Core/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Core
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.maven.ide.eclipse.maven2Builder
15 |
16 |
17 |
18 |
19 | org.eclipse.iam.jdt.core.mavenIncrementalBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.maven.ide.eclipse.maven2Nature
26 | org.eclipse.iam.jdt.core.mavenNature
27 | org.eclipse.jdt.core.javanature
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Core/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Thu Jan 28 23:48:18 CET 2010
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.compliance=1.6
5 | org.eclipse.jdt.core.compiler.source=1.6
6 |
--------------------------------------------------------------------------------
/Core/.settings/org.maven.ide.eclipse.prefs:
--------------------------------------------------------------------------------
1 | #Thu Jan 28 23:46:12 CET 2010
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | fullBuildGoals=process-test-resources
5 | includeModules=false
6 | resolveWorkspaceProjects=true
7 | resourceFilterGoals=process-resources resources\:testResources
8 | skipCompilerPlugin=true
9 | version=1
10 |
--------------------------------------------------------------------------------
/Core/javacl-core-bridj.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Core/javacl-core.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Core/nb-configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
16 | all
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Core/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Core/src/main/jnlp/HardwareReport.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | JavaCL-BridJ HardwareReport
8 | Olivier Chafik
9 |
10 | JavaCL-BridJ HardwareReport
11 | JavaCL-BridJ HardwareReport
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
35 |
36 |
--------------------------------------------------------------------------------
/Core/src/main/jnlp/InteractiveImageTransformDemo.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | JavaCL-BridJ Interactive Image Transform Demo
8 | Olivier Chafik
9 |
10 | Image Transform Kernel Editor + Demos for JavaCL-BridJ (Object-Oriented OpenCL Library for Java)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
--------------------------------------------------------------------------------
/Core/src/main/jnlp/JavaCL.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | JavaCL-BridJ
8 | Olivier Chafik
9 |
10 | Object-Oriented OpenCL-BridJ Library for Java
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Core/src/main/jnlp/MandelbrotDemo.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | JavaCL-BridJ Mandelbrot Demos
8 | Olivier Chafik (demo adapted from Bob Boothby's)
9 |
10 | Mandelbrot Demo for JavaCL-BridJ (Object-Oriented OpenCL Library for Java)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
33 |
34 |
--------------------------------------------------------------------------------
/Core/src/main/jnlp/OpenCL4Java.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | OpenCL4Java-BridJ
8 | Olivier Chafik
9 |
10 | OpenCL-BridJ bindings for Java
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Core/src/main/jnlp/ParticlesDemo.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | JavaCL-BridJ Particles Demos
8 | Olivier Chafik
9 |
10 | Demos for JavaCL (Object-Oriented OpenCL Library for Java)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
--------------------------------------------------------------------------------
/Core/src/main/jnlp/ScalaCL.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | ScalaCL
8 | Olivier Chafik
9 |
10 | OpenCL for Scala: natural DSL and Object-Oriented API
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuildException.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | package com.nativelibs4java.opencl;
3 |
4 | import com.ochafik.util.string.StringUtils;
5 | import java.util.Collection;
6 |
7 | /**
8 | * OpenCL program build exception
9 | * @author ochafik
10 | */
11 | @SuppressWarnings("serial")
12 | public class CLBuildException extends CLException {
13 | final CLProgram program;
14 | CLBuildException(CLProgram program, String string, Collection errors) {
15 | super(string + "\n" + StringUtils.implode(errors, "\n"), -1);
16 | this.program = program;
17 | }
18 | public CLProgram getProgram() {
19 | return program;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/CLUserEvent.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | package com.nativelibs4java.opencl;
3 |
4 |
5 | import static com.nativelibs4java.opencl.JavaCL.CL;
6 | import static com.nativelibs4java.opencl.CLException.error;
7 | import static com.nativelibs4java.opencl.library.OpenCLLibrary.*;
8 | import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*;
9 | import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event;
10 |
11 | public class CLUserEvent extends CLEvent {
12 | CLUserEvent(CLQueue queue, long evt) {
13 | super(queue, evt);
14 | }
15 | /**
16 | #documentCallsFunction("clSetUserEventStatus")
17 | * Sets the execution status of a this event object.
18 | * NOTE: Enqueued commands that specify user events in the event_wait_list argument of clEnqueue*** commands must ensure that the status of these user events being waited on are set using clSetUserEventStatus before any OpenCL APIs that release OpenCL objects except for event objects are called; otherwise the behavior is undefined. More details in the OpenCL specifications at section 5.9.
19 | * @param executionStatus specifies the new execution status to be set and can be CL_COMPLETE or a negative integer value to indicate an error. A negative integer value causes all enqueued commands that wait on this user event to be terminated. setStatus can only be called once to change the execution status of event.
20 | */
21 | public void setStatus(int executionStatus) {
22 | error(CL.clSetUserEventStatus(getEntity(), executionStatus));
23 | }
24 |
25 | /**
26 | * Calls setStatus(CL_COMPLETE)
27 | */
28 | public void setComplete() {
29 | setStatus(CL_COMPLETE);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/InfoName.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | package com.nativelibs4java.opencl;
3 |
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * Tagging annotation to indicate the name of an OpenCL information in the OpenCL specifications.
11 | * @author ochafik
12 | */
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target(ElementType.METHOD)
15 | public @interface InfoName {
16 | String value();
17 | }
18 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/LocalSize.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | package com.nativelibs4java.opencl;
3 | import org.bridj.*;
4 | import org.bridj.util.*;
5 | import java.lang.reflect.Type;
6 | /**
7 | * Size in bytes of a __local argument.
8 | */
9 | public class LocalSize {
10 | long size;
11 | public LocalSize(long size) {
12 | this.size = size;
13 | }
14 |
15 | #foreach ($prim in $primitivesNoBool)
16 |
17 | /**
18 | * Returns the size in bytes of an array of ${prim.Name} values of the specified length.
19 | * @return arrayLength * sizeof(${prim.Name}) = arrayLength * ${prim.Size}
20 | */
21 | public static LocalSize of${prim.CapName}Array(long arrayLength) {
22 | return new LocalSize(arrayLength * ${prim.Size});
23 | }
24 |
25 | #end
26 |
27 | /**
28 | * Returns the size in bytes of an array of T values of the specified length.
29 | */
30 | public static LocalSize ofArray(long arrayLength, Type componentType) {
31 | PointerIO io = PointerIO.getInstance(componentType);
32 | if (io == null)
33 | throw new RuntimeException("Unsupported type : " + Utils.toString(componentType));
34 | return new LocalSize(arrayLength * io.getTargetSize());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/PlatformUtils.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | package com.nativelibs4java.opencl;
3 |
4 | class PlatformUtils {
5 | public enum PlatformKind {
6 | AMDApp,
7 | NVIDIA,
8 | Apple,
9 | Intel
10 | }
11 | public static PlatformKind guessPlatformKind(CLPlatform p) {
12 | String name = p.getName();
13 | if (name != null) {
14 | if (name.equals("Apple"))
15 | return PlatformKind.Apple;
16 | else if (name.equals("ATI Stream") || name.equals("AMD Accelerated Parallel Processing"))
17 | return PlatformKind.AMDApp;
18 | else {
19 | String vendor = p.getVendor().toLowerCase();
20 | if (vendor.contains("nvidia"))
21 | return PlatformKind.NVIDIA;
22 | }
23 | }
24 | return null;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | package com.nativelibs4java.opencl;
3 | import org.bridj.*;
4 |
5 | /**
6 | *
7 | * @author ochafik
8 | */
9 | final class ReusablePointer {
10 | private final Pointer> pointer;
11 | private final long bytesCapacity;
12 |
13 | public ReusablePointer(long bytesCapacity) {
14 | this.bytesCapacity = bytesCapacity;
15 | this.pointer = allocateAlignedBytes(bytesCapacity).withoutValidityInformation();
16 | }
17 |
18 | static Pointer> allocateAlignedBytes(long count) {
19 | // Allocate memory aligned to 128 bytes to match alignment of cl_double16.
20 | return Pointer.allocateAlignedBytes(null /* io */, count, 128 /* alignment */, null /* beforeDeallocation */);
21 | }
22 |
23 | public Pointer pointerToInts(int... values) {
24 | if (values == null)
25 | return null;
26 | long needed = 4 * values.length;
27 | if (needed > bytesCapacity) {
28 | return Pointer.pointerToInts(values);
29 | } else {
30 | return (Pointer)pointer.setInts(values);
31 | }
32 | }
33 | public Pointer pointerToSizeTs(long... values) {
34 | if (values == null)
35 | return null;
36 | long needed = SizeT.SIZE * values.length;
37 | if (needed > bytesCapacity) {
38 | return Pointer.pointerToSizeTs(values);
39 | } else {
40 | return (Pointer)pointer.setSizeTs(values);
41 | }
42 | }
43 | public Pointer pointerToSizeTs(int... values) {
44 | if (values == null)
45 | return null;
46 | long needed = SizeT.SIZE * values.length;
47 | if (needed > bytesCapacity) {
48 | return Pointer.pointerToSizeTs(values);
49 | } else {
50 | return (Pointer)pointer.setSizeTs(values);
51 | }
52 | }
53 | public Pointer allocatedBytes(int needed) {
54 | if (needed == 0)
55 | return null;
56 | if (needed > bytesCapacity) {
57 | return (Pointer)allocateAlignedBytes(needed);
58 | } else {
59 | return (Pointer)pointer;
60 | }
61 | }
62 | public Pointer allocatedSizeTs(int needed) {
63 | return allocatedBytes(needed * SizeT.SIZE);
64 | }
65 | public Pointer allocatedInts(int needed) {
66 | return allocatedBytes(needed * 4);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointers.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | package com.nativelibs4java.opencl;
3 | import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event;
4 | import org.bridj.*;
5 | import static org.bridj.Pointer.*;
6 | /**
7 | *
8 | * @author ochafik
9 | */
10 | final class ReusablePointers {
11 | public final int[] int1Array = new int[1];
12 |
13 | public final ReusablePointer
14 | sizeT3_1 = new ReusablePointer(3 * SizeT.SIZE),
15 | sizeT3_2 = new ReusablePointer(3 * SizeT.SIZE),
16 | sizeT3_3 = new ReusablePointer(3 * SizeT.SIZE);
17 |
18 | public final Pointer
19 | int1 = allocateInt().withoutValidityInformation(),
20 | int2 = allocateInt().withoutValidityInformation();
21 |
22 | public final Pointer
23 | sizeT1 = allocateSizeT().withoutValidityInformation();
24 |
25 | public final Pointer
26 | long1 = allocateLong().withoutValidityInformation();
27 |
28 | public final Pointer>
29 | ptr1 = allocatePointer().withoutValidityInformation();
30 |
31 | public final ReusablePointer
32 | int3_1 = new ReusablePointer(4 * 3);
33 |
34 | public final ReusablePointer
35 | kernelArg = new ReusablePointer(8 * 16); // double16 arguments !
36 |
37 | public final Pointer event_out = allocateTypedPointer(cl_event.class).withoutValidityInformation();
38 |
39 | public final Pointer pErr = allocateInt().withoutValidityInformation();
40 |
41 | public final int[] event_count = new int[1];
42 | public final ReusablePointer events_in = new ReusablePointer(Pointer.SIZE * 10);
43 |
44 | private ReusablePointers() {}
45 |
46 | public static ReusablePointers get() {
47 | return local.get();
48 | }
49 | private static final ThreadLocal local = new ThreadLocal() {
50 |
51 | @Override
52 | protected ReusablePointers initialValue() {
53 | return new ReusablePointers();
54 | }
55 |
56 | };
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/Core/src/main/velocity/com/nativelibs4java/opencl/package-info.java:
--------------------------------------------------------------------------------
1 | #parse("main/Header.vm")
2 | /**
3 | * Object-oriented wrappers around the OpenCL API ({@link com.nativelibs4java.opencl.JavaCL}, {@link com.nativelibs4java.opencl.CLPlatform}, {@link com.nativelibs4java.opencl.CLContext}, {@link com.nativelibs4java.opencl.CLProgram}, {@link com.nativelibs4java.opencl.CLKernel}, {@link com.nativelibs4java.opencl.CLBuffer}...)
4 | * Also see the low-level bindings : {@link com.nativelibs4java.opencl.library.OpenCLLibrary}
5 | */
6 | package com.nativelibs4java.opencl;
7 |
--------------------------------------------------------------------------------
/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this template, choose Tools | Templates
3 | * and open the template in the editor.
4 | */
5 |
6 | package com.nativelibs4java.opencl;
7 |
8 | import org.junit.Before;
9 | import org.junit.BeforeClass;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | import org.junit.After;
14 | import org.junit.runner.RunWith;
15 | import org.junit.runners.Parameterized;
16 |
17 | /**
18 | *
19 | * @author ochafik
20 | */
21 | @RunWith(Parameterized.class)
22 | public abstract class AbstractCommon {
23 |
24 | CLPlatform platform;
25 | CLContext context;
26 | CLQueue queue;
27 | CLDevice device;
28 | CLImageFormat[] formatsRead2D, formatsRead3D, formatsWrite2D, formatsWrite3D, formatsReadWrite2D, formatsReadWrite3D;
29 |
30 | static boolean listedPlatforms;
31 |
32 | AbstractCommon(CLDevice device) {
33 | this.device = device;
34 | platform = device.getPlatform();
35 | context = platform.createContext(null, device);
36 | queue = context.createDefaultQueue();
37 | device = context.getDevices()[0];
38 | formatsRead2D = context.getSupportedImageFormats(CLMem.Flags.ReadOnly, CLMem.ObjectType.Image2D);
39 | formatsWrite2D = context.getSupportedImageFormats(CLMem.Flags.WriteOnly, CLMem.ObjectType.Image2D);
40 | formatsRead3D = context.getSupportedImageFormats(CLMem.Flags.ReadOnly, CLMem.ObjectType.Image3D);
41 | formatsWrite3D = context.getSupportedImageFormats(CLMem.Flags.WriteOnly, CLMem.ObjectType.Image3D);
42 | formatsReadWrite2D = context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image2D);
43 | formatsReadWrite3D = context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image3D);
44 | }
45 |
46 | @Parameterized.Parameters
47 | public static List