diff --git a/.gitignore b/.gitignore index b44b95d6339932e40a637ca96666d85f39b9c11a..40cff2ac4d55c23c40b1b5fa5577894a66457f3b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ hs_err_pid* **/include/ **/nbproject/ target/ + +# IntelliJ config files +.idea +*.iml \ No newline at end of file diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index fb3247c7a4ac6709d63442973e16560e4e8a27db..50e4421c9e6d13a89987b518002082df310f6337 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -8,6 +8,7 @@ * Steven Libby * Paul Miner * Lorenzo Gallucci +* Subhomoy Haldar (HungryBlueDev) # Details @@ -24,4 +25,5 @@ Below are some of the specific details of various contributions. * Steven Libby provided patch for #6 (Allow finer control over fallback mode selection) Aug 21th 2012 * Steven Libby and Ryan Lamothe for #10 (Support for OpenMP, major refactoring cleanup and support for multidim arrays) March 28th 2013 * Paul Miner issue #61 and #115 (JTP Speed up and fixes to explicit puts) June 13th 2013 -& lgalluci for his fix for issue #121 (incorrect toString for 3D ranges) July 6th 2013 \ No newline at end of file +& lgalluci for his fix for issue #121 (incorrect toString for 3D ranges) July 6th 2013 +* HungryBlueDev fixed the JavaDoc errors and warnings. July 8th 2019 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 70c3afddb73cc318a279e1dd7d99dc849630b7a2..ee501eb7452ef7ff3a203fe16f606839c21108b8 100644 --- a/pom.xml +++ b/pom.xml @@ -145,7 +145,7 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <configuration> - <additionalparam>-Xdoclint:none</additionalparam> + <source>8</source> </configuration> </plugin> <plugin> diff --git a/src/main/java/com/aparapi/examples/javaonedemo/Mandel.java b/src/main/java/com/aparapi/examples/javaonedemo/Mandel.java index 02755c27e89c355d2abd32be6f2197335f9367f8..7041ecac27f47d5f035aacb4dffc30b85a52bcd4 100644 --- a/src/main/java/com/aparapi/examples/javaonedemo/Mandel.java +++ b/src/main/java/com/aparapi/examples/javaonedemo/Mandel.java @@ -140,7 +140,6 @@ public class Mandel{ * @param _width Mandelbrot image width * @param _height Mandelbrot image height * @param _rgb Mandelbrot image RGB buffer - * @param _pallette Mandelbrot image palette */ public MandelKernel(int _width, int _height, int[] _rgb) { //Initialize palette values diff --git a/src/main/java/com/aparapi/examples/javaonedemo/NBody.java b/src/main/java/com/aparapi/examples/javaonedemo/NBody.java index 5b5be0746bcb5174bc6f1bb085de350724a76705..70f05b455cb4c503e15c8b52abb1d0834faf6d0e 100644 --- a/src/main/java/com/aparapi/examples/javaonedemo/NBody.java +++ b/src/main/java/com/aparapi/examples/javaonedemo/NBody.java @@ -83,6 +83,7 @@ import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.awt.GLCanvas; import com.jogamp.opengl.fixedfunc.GLLightingFunc; import com.jogamp.opengl.glu.GLU; + import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; @@ -100,295 +101,303 @@ import com.jogamp.opengl.util.texture.TextureIO; /** * NBody implementing demonstrating Aparapi kernels. - * - * For a description of the NBody problem. - * @see http://en.wikipedia.org/wiki/N-body_problem - * - * We use JOGL to render the bodies. - * @see http://jogamp.org/jogl/www/ - * - * @author gfrost * + * For a description of the NBody problem, see + * <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * + * We use JOGL to render the bodies. <a href="http://jogamp.org/jogl/www/">JOGL</a> + * + * @see <a href="http://jogamp.org/jogl/www/">JOGL</a> + * @see <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * + * @author gfrost */ -public class NBody{ +public class NBody { - public static class NBodyKernel extends Kernel{ - protected final float delT = .005f; + public static class NBodyKernel extends Kernel { + protected final float delT = .005f; - protected final float espSqr = 1.0f; + protected final float espSqr = 1.0f; - protected final float mass = 5f; + protected final float mass = 5f; - private final Range range; + private final Range range; - private final float[] xyz; // positions xy and z of bodies + private final float[] xyz; // positions xy and z of bodies - private final float[] vxyz; // velocity component of x,y and z of bodies + private final float[] vxyz; // velocity component of x,y and z of bodies - public NBodyKernel(Range _range) { - range = _range; - // range = Range.create(bodies); - xyz = new float[range.getGlobalSize(0) * 3]; - vxyz = new float[range.getGlobalSize(0) * 3]; - final float maxDist = 20f; - for (int body = 0; body < (range.getGlobalSize(0) * 3); body += 3) { + public NBodyKernel(Range _range) { + range = _range; + // range = Range.create(bodies); + xyz = new float[range.getGlobalSize(0) * 3]; + vxyz = new float[range.getGlobalSize(0) * 3]; + final float maxDist = 20f; + for (int body = 0; body < (range.getGlobalSize(0) * 3); body += 3) { - final float theta = (float) (Math.random() * Math.PI * 2); - final float phi = (float) (Math.random() * Math.PI * 2); - final float radius = (float) (Math.random() * maxDist); + final float theta = (float) (Math.random() * Math.PI * 2); + final float phi = (float) (Math.random() * Math.PI * 2); + final float radius = (float) (Math.random() * maxDist); - // get the 3D dimensional coordinates - xyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)); - xyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)); - xyz[body + 2] = (float) (radius * Math.cos(phi)); + // get the 3D dimensional coordinates + xyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)); + xyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)); + xyz[body + 2] = (float) (radius * Math.cos(phi)); - // divide into two 'spheres of bodies' by adjusting x + // divide into two 'spheres of bodies' by adjusting x - if ((body % 2) == 0) { - xyz[body + 0] += maxDist * 1.5; - } else { - xyz[body + 0] -= maxDist * 1.5; + if ((body % 2) == 0) { + xyz[body + 0] += maxDist * 1.5; + } else { + xyz[body + 0] -= maxDist * 1.5; + } } - } - setExplicit(true); - } - - /** - * Here is the kernel entrypoint. Here is where we calculate the position of each body - */ - @Override public void run() { - final int body = getGlobalId(); - final int count = getGlobalSize(0) * 3; - final int globalId = body * 3; - - float accx = 0.f; - float accy = 0.f; - float accz = 0.f; - - final float myPosx = xyz[globalId + 0]; - final float myPosy = xyz[globalId + 1]; - final float myPosz = xyz[globalId + 2]; - for (int i = 0; i < count; i += 3) { - final float dx = xyz[i + 0] - myPosx; - final float dy = xyz[i + 1] - myPosy; - final float dz = xyz[i + 2] - myPosz; - final float invDist = rsqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr); - final float s = mass * invDist * invDist * invDist; - accx = accx + (s * dx); - accy = accy + (s * dy); - accz = accz + (s * dz); - } - accx = accx * delT; - accy = accy * delT; - accz = accz * delT; - xyz[globalId + 0] = myPosx + (vxyz[globalId + 0] * delT) + (accx * .5f * delT); - xyz[globalId + 1] = myPosy + (vxyz[globalId + 1] * delT) + (accy * .5f * delT); - xyz[globalId + 2] = myPosz + (vxyz[globalId + 2] * delT) + (accz * .5f * delT); - - vxyz[globalId + 0] = vxyz[globalId + 0] + accx; - vxyz[globalId + 1] = vxyz[globalId + 1] + accy; - vxyz[globalId + 2] = vxyz[globalId + 2] + accz; - } - - /** - * Render all particles to the OpenGL context - * @param gl - */ - - protected void render(GL2 gl) { - gl.glBegin(GL2.GL_QUADS); - - for (int i = 0; i < (range.getGlobalSize(0) * 3); i += 3) { - gl.glTexCoord2f(0, 1); - gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]); - gl.glTexCoord2f(0, 0); - gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 0); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 1); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]); - } - gl.glEnd(); - } - - } - - public static int width; - - public static int height; - - public static boolean running; - - public static Texture texture; - - public static void main(String _args[]) { - - final NBodyKernel kernel = new NBodyKernel(Range.create(Integer.getInteger("bodies", 10000))); - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - final JFrame frame = new JFrame("NBody"); - - final JPanel panel = new JPanel(new BorderLayout()); - final JPanel controlPanel = new JPanel(new FlowLayout()); - panel.add(controlPanel, BorderLayout.SOUTH); - - final JButton startButton = new JButton("Start"); - - startButton.addActionListener(new ActionListener(){ - @Override public void actionPerformed(ActionEvent e) { - running = true; - startButton.setEnabled(false); - } - }); - controlPanel.add(startButton); - - final String[] choices = new String[] { - // "Java Sequential", - "Java Threads", - "GPU OpenCL" - }; - - final JComboBox modeButton = new JComboBox(choices); - - modeButton.addItemListener(new ItemListener(){ - @Override public void itemStateChanged(ItemEvent e) { - final String item = (String) modeButton.getSelectedItem(); - - if (item.equals(choices[0])) { - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - - } else if (item.equals(choices[1])) { - kernel.setExecutionMode(Kernel.EXECUTION_MODE.GPU); + setExplicit(true); + } + + /** + * Here is the kernel entrypoint. Here is where we calculate the position of each body + */ + @Override + public void run() { + final int body = getGlobalId(); + final int count = getGlobalSize(0) * 3; + final int globalId = body * 3; + + float accx = 0.f; + float accy = 0.f; + float accz = 0.f; + + final float myPosx = xyz[globalId + 0]; + final float myPosy = xyz[globalId + 1]; + final float myPosz = xyz[globalId + 2]; + for (int i = 0; i < count; i += 3) { + final float dx = xyz[i + 0] - myPosx; + final float dy = xyz[i + 1] - myPosy; + final float dz = xyz[i + 2] - myPosz; + final float invDist = rsqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr); + final float s = mass * invDist * invDist * invDist; + accx = accx + (s * dx); + accy = accy + (s * dy); + accz = accz + (s * dz); } - } + accx = accx * delT; + accy = accy * delT; + accz = accz * delT; + xyz[globalId + 0] = myPosx + (vxyz[globalId + 0] * delT) + (accx * .5f * delT); + xyz[globalId + 1] = myPosy + (vxyz[globalId + 1] * delT) + (accy * .5f * delT); + xyz[globalId + 2] = myPosz + (vxyz[globalId + 2] * delT) + (accz * .5f * delT); + + vxyz[globalId + 0] = vxyz[globalId + 0] + accx; + vxyz[globalId + 1] = vxyz[globalId + 1] + accy; + vxyz[globalId + 2] = vxyz[globalId + 2] + accz; + } + + /** + * Render all particles to the OpenGL context + * @param gl + */ + + protected void render(GL2 gl) { + gl.glBegin(GL2.GL_QUADS); + + for (int i = 0; i < (range.getGlobalSize(0) * 3); i += 3) { + gl.glTexCoord2f(0, 1); + gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]); + gl.glTexCoord2f(0, 0); + gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]); + gl.glTexCoord2f(1, 0); + gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]); + gl.glTexCoord2f(1, 1); + gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]); + } + gl.glEnd(); + } - }); - controlPanel.add(modeButton); + } - controlPanel.add(new JLabel(" " + kernel.range.getGlobalSize(0) + " Particles")); + public static int width; - final GLCapabilities caps = new GLCapabilities(null); - final GLProfile profile = caps.getGLProfile(); - caps.setDoubleBuffered(true); - caps.setHardwareAccelerated(true); - final GLCanvas canvas = new GLCanvas(caps); + public static int height; - final GLUT glut = new GLUT(); + public static boolean running; - final Dimension dimension = new Dimension(Integer.getInteger("width", 1024 + 256), - Integer.getInteger("height", 768 - 64 - 32)); - canvas.setPreferredSize(dimension); + public static Texture texture; - canvas.addGLEventListener(new GLEventListener(){ - private double ratio; + public static void main(String _args[]) { - private final float xeye = 0f; + final NBodyKernel kernel = new NBodyKernel(Range.create(Integer.getInteger("bodies", 10000))); + kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); + final JFrame frame = new JFrame("NBody"); - private final float yeye = 0f; + final JPanel panel = new JPanel(new BorderLayout()); + final JPanel controlPanel = new JPanel(new FlowLayout()); + panel.add(controlPanel, BorderLayout.SOUTH); - private final float zeye = 100f; + final JButton startButton = new JButton("Start"); - private final float xat = 0f; + startButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + running = true; + startButton.setEnabled(false); + } + }); + controlPanel.add(startButton); - private final float yat = 0f; + final String[] choices = new String[]{ + // "Java Sequential", + "Java Threads", + "GPU OpenCL" + }; - private final float zat = 0f; + final JComboBox modeButton = new JComboBox(choices); - public final float zoomFactor = 1.0f; + modeButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + final String item = (String) modeButton.getSelectedItem(); - private int frames; + if (item.equals(choices[0])) { + kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - private long last = System.currentTimeMillis(); + } else if (item.equals(choices[1])) { + kernel.setExecutionMode(Kernel.EXECUTION_MODE.GPU); + } + } - @Override public void dispose(GLAutoDrawable drawable) { + }); + controlPanel.add(modeButton); - } + controlPanel.add(new JLabel(" " + kernel.range.getGlobalSize(0) + " Particles")); - @Override public void display(GLAutoDrawable drawable) { + final GLCapabilities caps = new GLCapabilities(null); + final GLProfile profile = caps.getGLProfile(); + caps.setDoubleBuffered(true); + caps.setHardwareAccelerated(true); + final GLCanvas canvas = new GLCanvas(caps); - final GL2 gl = drawable.getGL().getGL2(); - texture.enable(gl); - texture.bind(gl); + final GLUT glut = new GLUT(); - gl.glLoadIdentity(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glColor3f(1f, 1f, 1f); + final Dimension dimension = new Dimension(Integer.getInteger("width", 1024 + 256), + Integer.getInteger("height", 768 - 64 - 32)); + canvas.setPreferredSize(dimension); - final GLU glu = new GLU(); - glu.gluPerspective(45f, ratio, 1f, 1000f); + canvas.addGLEventListener(new GLEventListener() { + private double ratio; - glu.gluLookAt(xeye, yeye, zeye * zoomFactor, xat, yat, zat, 0f, 1f, 0f); - if (running) { - kernel.execute(kernel.range); - if (kernel.isExplicit()) { - kernel.get(kernel.xyz); - } - final List<ProfileInfo> profileInfo = kernel.getProfileInfo(); - if ((profileInfo != null) && (profileInfo.size() > 0)) { - for (final ProfileInfo p : profileInfo) { - System.out.print(" " + p.getType() + " " + p.getLabel() + ((p.getEnd() - p.getStart()) / 1000) + "us"); - } - System.out.println(); - } - } - kernel.render(gl); + private final float xeye = 0f; + + private final float yeye = 0f; - final long now = System.currentTimeMillis(); - final long time = now - last; - frames++; + private final float zeye = 100f; - if (running) { - final float framesPerSecond = (frames * 1000.0f) / time; + private final float xat = 0f; + + private final float yat = 0f; + + private final float zat = 0f; + + public final float zoomFactor = 1.0f; + + private int frames; + + private long last = System.currentTimeMillis(); + + @Override + public void dispose(GLAutoDrawable drawable) { - gl.glColor3f(.5f, .5f, .5f); - gl.glRasterPos2i(-40, 38); - glut.glutBitmapString(8, String.format("%5.2f fps", framesPerSecond)); - gl.glFlush(); } - frames = 0; - last = now; - - } - - @Override public void init(GLAutoDrawable drawable) { - final GL2 gl = drawable.getGL().getGL2(); - - gl.glShadeModel(GLLightingFunc.GL_SMOOTH); - gl.glEnable(GL.GL_BLEND); - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); - try { - final InputStream textureStream = NBody.class.getResourceAsStream("/particle.jpg"); - if( textureStream == null ) - throw new IllegalStateException("Could not access particle.jpg resource"); - texture = TextureIO.newTexture(textureStream, false, null); - } catch (final IOException | GLException e) { - throw new IllegalStateException("Could not create texture", e); + + @Override + public void display(GLAutoDrawable drawable) { + + final GL2 gl = drawable.getGL().getGL2(); + texture.enable(gl); + texture.bind(gl); + + gl.glLoadIdentity(); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glColor3f(1f, 1f, 1f); + + final GLU glu = new GLU(); + glu.gluPerspective(45f, ratio, 1f, 1000f); + + glu.gluLookAt(xeye, yeye, zeye * zoomFactor, xat, yat, zat, 0f, 1f, 0f); + if (running) { + kernel.execute(kernel.range); + if (kernel.isExplicit()) { + kernel.get(kernel.xyz); + } + final List<ProfileInfo> profileInfo = kernel.getProfileInfo(); + if ((profileInfo != null) && (profileInfo.size() > 0)) { + for (final ProfileInfo p : profileInfo) { + System.out.print(" " + p.getType() + " " + p.getLabel() + ((p.getEnd() - p.getStart()) / 1000) + "us"); + } + System.out.println(); + } + } + kernel.render(gl); + + final long now = System.currentTimeMillis(); + final long time = now - last; + frames++; + + if (running) { + final float framesPerSecond = (frames * 1000.0f) / time; + + gl.glColor3f(.5f, .5f, .5f); + gl.glRasterPos2i(-40, 38); + glut.glutBitmapString(8, String.format("%5.2f fps", framesPerSecond)); + gl.glFlush(); + } + frames = 0; + last = now; + } - } + @Override + public void init(GLAutoDrawable drawable) { + final GL2 gl = drawable.getGL().getGL2(); + + gl.glShadeModel(GLLightingFunc.GL_SMOOTH); + gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); + try { + final InputStream textureStream = NBody.class.getResourceAsStream("/particle.jpg"); + if (textureStream == null) + throw new IllegalStateException("Could not access particle.jpg resource"); + texture = TextureIO.newTexture(textureStream, false, null); + } catch (final IOException | GLException e) { + throw new IllegalStateException("Could not create texture", e); + } - @Override public void reshape(GLAutoDrawable drawable, int x, int y, int _width, int _height) { - width = _width; - height = _height; + } - final GL2 gl = drawable.getGL().getGL2(); - gl.glViewport(0, 0, width, height); + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int _width, int _height) { + width = _width; + height = _height; - ratio = (double) width / (double) height; + final GL2 gl = drawable.getGL().getGL2(); + gl.glViewport(0, 0, width, height); - } + ratio = (double) width / (double) height; + + } - }); + }); - panel.add(canvas, BorderLayout.CENTER); - frame.getContentPane().add(panel, BorderLayout.CENTER); - final FPSAnimator animator = new FPSAnimator(canvas, 100); + panel.add(canvas, BorderLayout.CENTER); + frame.getContentPane().add(panel, BorderLayout.CENTER); + final FPSAnimator animator = new FPSAnimator(canvas, 100); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.pack(); - frame.setVisible(true); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); - animator.start(); + animator.start(); - } + } } diff --git a/src/main/java/com/aparapi/examples/matrix/CorrMatrixHost.java b/src/main/java/com/aparapi/examples/matrix/CorrMatrixHost.java index 1fe5637bb8e945e09b61d2e11c3caa88c9473520..c445fddcc4564339bc4f692cb4b0f44ed2dd3308 100644 --- a/src/main/java/com/aparapi/examples/matrix/CorrMatrixHost.java +++ b/src/main/java/com/aparapi/examples/matrix/CorrMatrixHost.java @@ -34,8 +34,8 @@ import com.aparapi.device.OpenCLDevice; /** * GPU calculations using OpenBitSet Intersection for OpenBitSets * - * Based on code from: <br/> - * {@link http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/3.1.0/org/apache/lucene/util/BitUtil.java} + * Based on code from: + * <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/3.1.0/org/apache/lucene/util/BitUtil.java">apache.lucene.util.BitUtil.java</a> * * @author ryan.lamothe at gmail.com * @author sedillard at gmail.com @@ -51,9 +51,8 @@ public class CorrMatrixHost { * The first term-document matrix * @param matrixB * The second term-document matrix - * @param Aparapi EXECUTION_MODE + * @param executionMode EXECUTION_MODE * @return result Matrix - * @throws Exception */ public static int[][] intersectionMatrix(final long[][] matrixA, final long[][] matrixB, final EXECUTION_MODE executionMode) { diff --git a/src/main/java/com/aparapi/examples/matrix/CorrMatrixKernel.java b/src/main/java/com/aparapi/examples/matrix/CorrMatrixKernel.java index 90de1ae86a7fd6b02da429aba6bd308c53786894..45ffd74491045b6d2290e7a618651014bd271bdc 100644 --- a/src/main/java/com/aparapi/examples/matrix/CorrMatrixKernel.java +++ b/src/main/java/com/aparapi/examples/matrix/CorrMatrixKernel.java @@ -27,10 +27,10 @@ import com.aparapi.Kernel; /** * This kernel attempts to re-implement the Lucene OpenBitSet functionality on a GPU - * - * Based on code from: <br/> - * {@link http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/3.1.0/org/apache/lucene/util/BitUtil.java} - * + * + * Based on code from: + * <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/3.1.0/org/apache/lucene/util/BitUtil.java">apache.lucene.util.BitUtil.java</a> + * * @author ryan.lamothe at gmail.com * @author sedillard at gmail.com */ @@ -50,6 +50,13 @@ public class CorrMatrixKernel extends Kernel { /** * Default constructor + * + * @param matrixA Matrix A. + * @param matrixB Matrix B. + * @param matrixA_NumTerms Number of terms in Matrix A. + * @param matrixB_NumTerms Number of terms in Matrix B. + * @param numLongs Number of longs. + * @param resultMatrix The matrix to store the results in. */ public CorrMatrixKernel(final long[] matrixA, final int matrixA_NumTerms, final long[] matrixB, final int matrixB_NumTerms, final int numLongs, final int[] resultMatrix) { @@ -78,6 +85,12 @@ public class CorrMatrixKernel extends Kernel { /** * A naive implementation of the pop_array code below + * + * @param matrixA Matrix A. + * @param matrixB Matrix B. + * @param aStart Offset for Matrix A. + * @param bStart Offset for Matrix B. + * @param numWords The number of words to operate on. */ private int naive_pop_intersect(final long matrixA[], final int aStart, final long matrixB[], final int bStart, final int numWords) { int sum = 0; @@ -92,8 +105,14 @@ public class CorrMatrixKernel extends Kernel { /** * Returns the popcount or cardinality of the two sets after an intersection. * Neither array is modified. - * + * * Modified for the purposes of this kernel from its original version + * + * @param matrixA Matrix A. + * @param matrixB Matrix B. + * @param aStart Offset for Matrix A. + * @param bStart Offset for Matrix B. + * @param numWords The number of words to operate on. */ private int pop_intersect(final long matrixA[], final int aStart, final long matrixB[], final int bStart, final int numWords) { @@ -242,6 +261,8 @@ public class CorrMatrixKernel extends Kernel { /** * Returns the number of bits set in the long + * + * @param x The long whose bit count is needed. */ private int pop(long x) { @@ -252,7 +273,7 @@ public class CorrMatrixKernel extends Kernel { /* * Hacker's Delight 32 bit pop function: * http://www.hackersdelight.org/HDcode/newCode/pop_arrayHS.c.txt - * + * * int pop(unsigned x) { * x = x - ((x >> 1) & 0x55555555); * x = (x & 0x33333333) + ((x >> 2) & 0x33333333); diff --git a/src/main/java/com/aparapi/examples/matrix/Main.java b/src/main/java/com/aparapi/examples/matrix/Main.java index 70075076a33957596ce18bb487b45ac36866e0dd..4b99136bfc1fd630fbc3131cc9f503ab8841f727 100644 --- a/src/main/java/com/aparapi/examples/matrix/Main.java +++ b/src/main/java/com/aparapi/examples/matrix/Main.java @@ -50,6 +50,8 @@ import java.util.Random; public class Main { /** * NumTerms and NumLongs (documents) need to be adjusted manually right now to force 'striping' to occur (see Host code for details) + * + * @param _args The command-line arguments. */ public static void main(String[] _args) { final List<Pair<OpenBitSet, OpenBitSet>> obsPairs = new ArrayList<Pair<OpenBitSet, OpenBitSet>>(); @@ -59,9 +61,9 @@ public class Main { int[][] obsResultMatrix; - /* - * Populate test data - */ + /* + * Populate test data + */ System.out.println("----------"); System.out.println("Populating test matrix data using settings from build.xml..."); System.out.println("----------"); @@ -79,9 +81,9 @@ public class Main { obsPairs.add(i, new ImmutablePair<OpenBitSet, OpenBitSet>(new OpenBitSet(bits, numLongs), new OpenBitSet(bits, numLongs))); } - /* - * OpenBitSet calculations - */ + /* + * OpenBitSet calculations + */ System.out.println("Executing OpenBitSet intersectionCount"); final long startTime = System.currentTimeMillis(); @@ -107,9 +109,9 @@ public class Main { System.out.println("OpenBitSet Gross Execution Time: " + endTime + " ms <------OpenBitSet"); System.out.println("----------"); - /* - * GPU calculations - */ + /* + * GPU calculations + */ System.out.println("Executing Aparapi intersectionCount"); final long[][] matrixA = new long[obsPairs.size()][]; @@ -137,7 +139,7 @@ public class Main { for (int j = 0; j < obsResultMatrix[i].length; j++) if (obsResultMatrix[i][j] != gpuResultMatrix[i][j]) { System.out.println("[" + i + "][" + j + "] -> " + obsResultMatrix[i][j] + " : " + gpuResultMatrix[i][j]); - } + } } System.out.println("Any elements not listed matched!"); } diff --git a/src/main/java/com/aparapi/examples/median/MedianKernel7x7.java b/src/main/java/com/aparapi/examples/median/MedianKernel7x7.java index 1df96dd60f103aa288bb503986efc77f02eafd94..29201750c1b7a057b174cc69c7ad4ab022bcc762 100644 --- a/src/main/java/com/aparapi/examples/median/MedianKernel7x7.java +++ b/src/main/java/com/aparapi/examples/median/MedianKernel7x7.java @@ -29,7 +29,7 @@ import com.aparapi.*; /** * Provides support for pixel windows of size no greater than 49 (e.g. 7x7). - * <p/> + * * <p>Demonstrates use of __private array for (partial) sorting, also demonstrates @NoCl annotation for specialised use of ThreadLocal in JTP execution. */ public class MedianKernel7x7 extends Kernel { @@ -155,6 +155,8 @@ public class MedianKernel7x7 extends Kernel { * Title: Algorithms + data structures = programs * Publisher: Englewood Cliffs: Prentice-Hall, 1976 * </pre> + * + * @param actualPixelCount The actual pixel count. */ protected final int median(int actualPixelCount) { int i, j, L, m; diff --git a/src/main/java/com/aparapi/examples/nbody/Main.java b/src/main/java/com/aparapi/examples/nbody/Main.java index adf1a241e536c409cc24eb68c643e179843d5bdf..d178b0b43684e05154ace11e8451fdb0406edeb6 100644 --- a/src/main/java/com/aparapi/examples/nbody/Main.java +++ b/src/main/java/com/aparapi/examples/nbody/Main.java @@ -98,16 +98,16 @@ import com.jogamp.opengl.util.texture.TextureIO; /** * NBody implementing demonstrating Aparapi kernels. - * - * For a description of the NBody problem. - * - * @see http://en.wikipedia.org/wiki/N-body_problem - * - * We use JOGL to render the bodies. - * @see http://jogamp.org/jogl/www/ - * + * + * For a description of the NBody problem, see + * <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * + * We use JOGL to render the bodies. <a href="http://jogamp.org/jogl/www/">JOGL</a> + * + * @see <a href="http://jogamp.org/jogl/www/">JOGL</a> + * @see <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * * @author gfrost - * */ public class Main{ @@ -127,7 +127,7 @@ public class Main{ /** * Constructor initializes xyz and vxyz arrays. * - * @param _bodies + * @param _range The execution range provided. */ public NBodyKernel(Range _range) { range = _range; @@ -197,7 +197,7 @@ public class Main{ /** * Render all particles to the OpenGL context * - * @param gl + * @param gl The OpenGL context to render to. */ protected void render(GL2 gl) { diff --git a/src/main/java/com/aparapi/examples/nbody/Seq.java b/src/main/java/com/aparapi/examples/nbody/Seq.java index 2d1dbdaa9dafe48159c67df9e935bd6efc2e663a..e6382803bbd161d95424bf54349fb28b0b4e24d8 100644 --- a/src/main/java/com/aparapi/examples/nbody/Seq.java +++ b/src/main/java/com/aparapi/examples/nbody/Seq.java @@ -98,16 +98,16 @@ import com.jogamp.opengl.util.texture.TextureIO; /** * NBody implemented sequentially - * - * For a description of the NBody problem. - * - * @see http://en.wikipedia.org/wiki/N-body_problem - * - * We use JOGL to render the bodies. - * @see http://jogamp.org/jogl/www/ - * + * + * For a description of the NBody problem, see + * <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * + * We use JOGL to render the bodies. <a href="http://jogamp.org/jogl/www/">JOGL</a> + * + * @see <a href="http://jogamp.org/jogl/www/">JOGL</a> + * @see <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * * @author gfrost - * */ public class Seq{ @@ -127,7 +127,7 @@ public class Seq{ /** * Constructor initializes xyz and vxyz arrays. * - * @param _bodies + * @param _bodies The number of bodies to be simulated. */ public NBodyKernel(int _bodies) { bodies = _bodies; @@ -196,7 +196,7 @@ public class Seq{ /** * Render all particles to the OpenGL context * - * @param gl + * @param gl The OpenGL context to render to. */ protected void render(GL2 gl) { diff --git a/src/main/java/com/aparapi/examples/oopnbody/Main.java b/src/main/java/com/aparapi/examples/oopnbody/Main.java index 4ac096689e9a3824a2a35c0afa44dda521d1ffb7..7b41147f13b345a45ead88c1b10fe78dd8bb8765 100644 --- a/src/main/java/com/aparapi/examples/oopnbody/Main.java +++ b/src/main/java/com/aparapi/examples/oopnbody/Main.java @@ -95,16 +95,16 @@ import com.jogamp.opengl.util.texture.TextureIO; /** * NBody implementing demonstrating Aparapi kernels. - * - * For a description of the NBody problem. - * - * @see http://en.wikipedia.org/wiki/N-body_problem - * - * We use JOGL to render the bodies. - * @see http://jogamp.org/jogl/www/ - * + * + * For a description of the NBody problem, see + * <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * + * We use JOGL to render the bodies. <a href="http://jogamp.org/jogl/www/">JOGL</a> + * + * @see <a href="http://jogamp.org/jogl/www/">JOGL</a> + * @see <a href="https://en.wikipedia.org/wiki/N-body_problem">n-body problem</a> + * * @author gfrost - * */ public class Main{ @@ -121,7 +121,7 @@ public class Main{ /** * Constructor initializes xyz and vxyz arrays. * - * @param _bodies + * @param _range The execution range provided. */ public NBodyKernel(Range _range) { range = _range;