From ab00096d3f5b61d4d79748ef18d6c6178188d147 Mon Sep 17 00:00:00 2001
From: Gary Frost <frost.gary@gmail.com>
Date: Tue, 21 Feb 2012 23:26:48 +0000
Subject: [PATCH] Added ability to extract OpenCL profile information at
runtime
---
samples/mandel/mandel.bat | 1 +
.../src/com/amd/aparapi/sample/mandel/Main.java | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/samples/mandel/mandel.bat b/samples/mandel/mandel.bat
index daadd488..8e3babad 100644
--- a/samples/mandel/mandel.bat
+++ b/samples/mandel/mandel.bat
@@ -1,6 +1,7 @@
java ^
-Djava.library.path=../../com.amd.aparapi.jni/dist ^
-Dcom.amd.aparapi.executionMode=%1 ^
+ -Dcom.amd.aparapi.enableProfiling=true ^
-classpath ../../com.amd.aparapi/dist/aparapi.jar;mandel.jar ^
com.amd.aparapi.sample.mandel.Main
diff --git a/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java b/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java
index 99d3373c..2cd7dda2 100644
--- a/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java
+++ b/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java
@@ -48,11 +48,13 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
+import java.util.List;
import javax.swing.JComponent;
import javax.swing.JFrame;
import com.amd.aparapi.Kernel;
+import com.amd.aparapi.ProfileInfo;
import com.amd.aparapi.Range;
/**
@@ -225,6 +227,9 @@ public class Main{
// Set the default scale and offset, execute the kernel and force a repaint of the viewer.
kernel.setScaleAndOffset(defaultScale, -1f, 0f);
kernel.execute(range);
+
+
+
System.arraycopy(rgb, 0, imageRgb, 0, rgb.length);
viewer.repaint();
@@ -271,6 +276,15 @@ public class Main{
// Set the scale and offset, execute the kernel and force a repaint of the viewer.
kernel.setScaleAndOffset(scale, x, y);
kernel.execute(range);
+
+ /**
+
+ for (ProfileInfo p:kernel.getProfileInfo()){
+ System.out.print(" "+p.getType()+" "+p.getLabel()+" "+(p.getEnd()-p.getStart())/1000+"us");
+ }
+ System.out.println();
+ **/
+
System.arraycopy(rgb, 0, imageRgb, 0, rgb.length);
viewer.repaint();
}
--
GitLab