5 Replies Latest reply on Jun 18, 2013 3:19 AM by dzhiga

    Is it possible to use CodeXL to profile Java OpenGL Program?

    bwroga

      Is it possible to profile an OpenGL program written in Java (JOGL)?

        • Re: Is it possible to use CodeXL to profile Java OpenGL Program?
          bwroga

          I have tried creating a new project with these settings:

           

          Executable Path:

          C:\Program Files (x86)\Java\jre7\bin\java.exe

           

          Working Directory:

          C:\Program Files (x86)\Java\jre7\bin

           

          Command Line Arguments:

          -cp E:\Projects\Scala\Projects\Rings\target\scala-2.9.2\classes;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-armv6.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-armv6hf.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-i586.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-macosx-universal.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-solaris-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-solaris-i586.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-windows-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-windows-i586.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-linux-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-linux-armv6.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-linux-armv6hf.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-linux-i586.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-macosx-universal.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-solaris-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-solaris-i586.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-windows-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\joal-natives-windows-i586.jar;E:\Projects\Scala\Projects\Rings\lib\joal-test.jar;E:\Projects\Scala\Projects\Rings\lib\joal.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-linux-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-linux-armv6.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-linux-armv6hf.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-linux-i586.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-macosx-universal.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-solaris-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-solaris-i586.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-windows-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\jocl-natives-windows-i586.jar;E:\Projects\Scala\Projects\Rings\lib\jocl.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-linux-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-linux-armv6.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-linux-armv6hf.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-linux-i586.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-macosx-universal.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-solaris-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-solaris-i586.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-windows-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-natives-windows-i586.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all-noawt.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-all.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-test-android.jar;E:\Projects\Scala\Projects\Rings\lib\jogl-test.jar;C:\Users\Ben\.sbt\boot\scala-2.9.2\lib\scala-library.jar Main

           

          When I click "Ok" CodeXL crashes

           

          If I limit the arguments to:

          -cp E:\Projects\Scala\Projects\Rings\target\scala-2.9.2\classes;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-amd64.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-armv6.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-armv6hf.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-linux-i586.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-macosx-universal.jar;E:\Projects\Scala\Projects\Rings\lib\gluegen-rt-natives-solaris-amd64.jar; Main

           

          CodeXL doesn't crash, but I can't run my project because I haven't included all the classes I need to in the classpath.

            • Re: Is it possible to use CodeXL to profile Java OpenGL Program?
              dorono

              Hi,

              Thanks for the report!

              This has been confirmed to be a bug in CodeXL 1.1. It is fixed in the upcoming CodeXL release.

              While AMD policy prohibits disclosure of release dates, I can say that CodeXL updates are released several times a year, so it should not be long now until the next release.

              • Re: Is it possible to use CodeXL to profile Java OpenGL Program?
                dzhiga

                I changed classpath settings in the project .cxl file (<ApplicationArguments>). But codeXL does not record calls to the kernels. I use JavaCL to call opencl kernels.

                  • Re: Is it possible to use CodeXL to profile Java OpenGL Program?
                    chesik

                    Hi dzhiga,

                     

                    Regarding your comment: "But codeXL does not record calls to the kernels.":  Are the kernels being dispatched to the GPU or CPU?  If the CPU, then as Doron stated, I think the upcoming version of CodeXL will have improvements in this area.  If GPU, then this is something we would like to investigate.  Can you share your Java application so that the GPU profiler team can take a look at the problem?

                     

                    Thanks,

                    Chris

                      • Re: Is it possible to use CodeXL to profile Java OpenGL Program?
                        dzhiga

                        JavaCLTutorial.java

                        -------------------------------------------------

                        package org.testcl;

                         

                         

                        import static java.lang.Math.cos;

                        import static java.lang.Math.sin;

                        import static org.bridj.Pointer.allocateFloats;

                         

                         

                        import java.io.IOException;

                        import java.nio.ByteOrder;

                         

                         

                        import org.bridj.Pointer;

                         

                         

                        import com.nativelibs4java.opencl.CLBuffer;

                        import com.nativelibs4java.opencl.CLContext;

                        import com.nativelibs4java.opencl.CLEvent;

                        import com.nativelibs4java.opencl.CLKernel;

                        import com.nativelibs4java.opencl.CLMem.Usage;

                        import com.nativelibs4java.opencl.CLProgram;

                        import com.nativelibs4java.opencl.CLQueue;

                        import com.nativelibs4java.opencl.JavaCL;

                        import com.nativelibs4java.util.IOUtils;

                         

                         

                        public class JavaCLTutorial {

                            public static void main(String[] args) throws IOException {

                                CLContext context = JavaCL.createBestContext();

                                CLQueue queue = context.createDefaultQueue();

                                ByteOrder byteOrder = context.getByteOrder();

                               

                                int n = 1024;

                                Pointer<Float>

                                    aPtr = allocateFloats(n).order(byteOrder),

                                    bPtr = allocateFloats(n).order(byteOrder);

                         

                         

                                for (int i = 0; i < n; i++) {

                                    aPtr.set(i, (float)cos(i));

                                    bPtr.set(i, (float)sin(i));

                                }

                         

                         

                                // Create OpenCL input buffers (using the native memory pointers aPtr and bPtr) :

                                CLBuffer<Float>

                                    a = context.createBuffer(Usage.Input, aPtr),

                                    b = context.createBuffer(Usage.Input, bPtr);

                         

                         

                                // Create an OpenCL output buffer :

                                CLBuffer<Float> out = context.createFloatBuffer(Usage.Output, n);

                         

                         

                                // Read the program sources and compile them :

                                String src = IOUtils.readText(JavaCLTutorial.class.getResource("TutorialKernels.cl"));

                                CLProgram program = context.createProgram(src);

                         

                         

                                // Get and call the kernel :

                                CLKernel addFloatsKernel = program.createKernel("add_floats");

                                addFloatsKernel.setArgs(a, b, out, n);

                                CLEvent addEvt = addFloatsKernel.enqueueNDRange(queue, new int[] { n });

                               

                                Pointer<Float> outPtr = out.read(queue, addEvt); // blocks until add_floats finished

                         

                         

                                // Print the first 10 output values :

                                for (int i = 0; i < 10 && i < n; i++)

                                    System.out.println("out[" + i + "] = " + outPtr.get(i));

                               

                            }

                        }

                        --------------------------

                        TutorialKernels.cl

                        __kernel void add_floats(__global const float* a, __global const float* b, __global float* out, int n)

                        {

                            int i = get_global_id(0);

                            if (i >= n)

                                return;

                            out[i] = a[i] + b[i];

                        }

                        ----------------------------------------

                         

                         

                        This is code from JavaCL tutorial. It uses javacl-1.0.0-RC3-shaded.jar library

                        CodeXL ignore all breakpoints and step/break button. I can see only Debugged process event list.

                        Kernel dispatched on GPU