diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Life.java b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Life.java index e68fbf4c2ec4acfbddd3a4f80b8a12d05a9043a0..8653873a668fc861e46854cfb09c67d70c70a2bf 100644 --- a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Life.java +++ b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Life.java @@ -39,6 +39,7 @@ under those regulations, please refer to the U.S. Bureau of Industry and Securit package com.amd.aparapi.examples.javaonedemo; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; @@ -190,9 +191,9 @@ public class Life{ public static void main(String[] _args) { JFrame frame = new JFrame("Game of Life"); - final int width = Integer.getInteger("width", 1024 + 512); + final int width = Integer.getInteger("width", 1024 + 256); - final int height = Integer.getInteger("height", 768); + final int height = Integer.getInteger("height", 768 - 64); // Buffer is twice the size as the screen. We will alternate between mutating data from top to bottom // and bottom to top in alternate generation passses. The LifeKernel will track which pass is which @@ -206,6 +207,7 @@ public class Life{ @SuppressWarnings("serial") JComponent viewer = new JComponent(){ @Override public void paintComponent(Graphics g) { g.setFont(font); + g.setColor(Color.WHITE); // if (lifeKernel != null) { if (lifeKernel.isExplicit()) { lifeKernel.get(lifeKernel.imageData); // We only pull the imageData when we intend to use it. diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Mandel.java b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Mandel.java index 35ee3e59adee1302e9c3933c68f8db270547a19f..5348073ad49b2634a6a67e951facf5182dbcdfc4 100644 --- a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Mandel.java +++ b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Mandel.java @@ -45,8 +45,6 @@ import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; @@ -57,7 +55,6 @@ import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.util.List; -import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFrame; @@ -172,7 +169,7 @@ public class Mandel{ /** User selected zoom-in point on the Mandelbrot view. */ public static volatile Point to = null; - public static int frames = 0; + public static int frameCount = 0; public static long start = 0; @@ -198,7 +195,7 @@ public class Mandel{ final int[] imageRgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); // Create a Kernel passing the size, RGB buffer and the palette. final MandelKernel kernel = new MandelKernel(width, height, rgb); - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); + final Font font = new Font("Garamond", Font.BOLD, 100); // Draw Mandelbrot image JComponent viewer = new JComponent(){ @@ -206,13 +203,14 @@ public class Mandel{ g.drawImage(image, 0, 0, width, height, this); g.setFont(font); + g.setColor(Color.WHITE); long now = System.currentTimeMillis(); // if (now - start > 1000) { - double framesPerSecond = (frames * 1000.0) / (now - start); + double framesPerSecond = (frameCount * 1000.0) / (now - start); g.drawString(String.format("%5.2f", framesPerSecond), 20, 100); // generationsPerSecond.setText(String.format("%5.2f", generationsPerSecondField)); - frames++; + // frames++; // } } }; @@ -237,13 +235,13 @@ public class Mandel{ // } else if (item.equals(choices[0])) { kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - frames = 0; + frameCount = 0; start = System.currentTimeMillis(); // modeButton = javaMandelBrot; } else if (item.equals(choices[1])) { kernel.setExecutionMode(Kernel.EXECUTION_MODE.GPU); - frames = 0; + frameCount = 0; start = System.currentTimeMillis(); // modeButton = javaMandelBrotMultiThread; } @@ -278,7 +276,7 @@ public class Mandel{ // Set the default scale and offset, execute the kernel and force a repaint of the viewer. kernel.setScaleAndOffset(defaultScale, -1f, 0f); kernel.execute(range); - + kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); System.arraycopy(rgb, 0, imageRgb, 0, rgb.length); viewer.repaint(); @@ -306,8 +304,7 @@ public class Mandel{ } } } - frames = 0; - start = System.currentTimeMillis(); + float x = -1f; float y = 0f; float scale = defaultScale; @@ -316,9 +313,11 @@ public class Mandel{ // This is how many frames we will display as we zoom in and out. int frames = 128; - long startMillis = System.currentTimeMillis(); + frameCount = 0; + start = System.currentTimeMillis(); for (int sign = -1; sign < 2; sign += 2) { for (int i = 0; i < frames - 4; i++) { + frameCount++; scale = scale + sign * defaultScale / frames; x = x - sign * (tox / frames); y = y - sign * (toy / frames); @@ -340,9 +339,6 @@ public class Mandel{ } } - long elapsedMillis = System.currentTimeMillis() - startMillis; - System.out.println("FPS = " + frames * 1000 / elapsedMillis); - // Reset zoom-in point. to = null; diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/NBody.java b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/NBody.java index 5260a94648e7ad47e989ae3419e114448b0ec948..a6aa782d514132f57612d08e5a732cbd07ef3de6 100644 --- a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/NBody.java +++ b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/NBody.java @@ -200,7 +200,7 @@ public class NBody{ public static void main(String _args[]) { - final NBodyKernel kernel = new NBodyKernel(Range.create(Integer.getInteger("bodies", 12288))); + final NBodyKernel kernel = new NBodyKernel(Range.create(Integer.getInteger("bodies", 12288 - 256 - 32))); kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); JFrame frame = new JFrame("NBody"); @@ -259,7 +259,8 @@ public class NBody{ final GLCanvas canvas = new GLCanvas(caps); final GLUT glut = new GLUT(); - Dimension dimension = new Dimension(Integer.getInteger("width", 742 - 64), Integer.getInteger("height", 742 - 64)); + + Dimension dimension = new Dimension(Integer.getInteger("width", 1024 + 256), Integer.getInteger("height", 768 - 64)); canvas.setPreferredSize(dimension); canvas.addGLEventListener(new GLEventListener(){