Skip to content
Snippets Groups Projects

Aparapi Mandelbrot Explorer

Closed Marco Stefanetti requested to merge stefanettim/aparapi-examples:b4 into master

mouse handling : recenter, zoom, drag
kernel uses double
zoom limits
dynamic iterations
window resizing

author Marco Stefanetti

Edited by Marco Stefanetti

Merge request reports

Approval is optional

Closed by Marco StefanettiMarco Stefanetti 4 years ago (Nov 10, 2020 8:26pm UTC)

Merge details

  • The changes were not merged into master.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Marco Stefanetti changed the description

    changed the description

  • Looks good to me. I will run it one last time locally to make sure it still works then approve it if its good.

  • Jeffrey Phillips Freeman approved this merge request

    approved this merge request

  • When I run this it seems to produce an error, then claim it is falling back to an AMD GPU (one of my graphics cards) but when running is very slow and appears to not put any load on my graphics card and all the load on my CPU.. GPU stays near 1% utilization where CPU quickly spikes to 100% as I drill down.

    I think it would help if we added the ability to select the computer source...

    Enter your selection, or q/Q to quit: 37
    Aparapi Fractals - canvas : 768x768 - max_iterations : 512 
    
    Aparapi Fractals - canvas : 1210x1480 - max_iterations : 512 
    Aparapi Fractals - canvas : 1210x1480 - max_iterations : 512 
    AfKernel, devices={AMD<GPU>|AMD<GPU>|AMD<GPU>|AMD<GPU>|Java Alternative Algorithm|Java Thread Pool}
    Device 139860715622976
      vendor = Advanced Micro Devices, Inc.
      type:GPU
      maxComputeUnits=64
      maxWorkItemDimensions=3
      maxWorkItemSizes={1024, 1024, 1024}
      maxWorkWorkGroupSize=256
      globalMemSize=17163091968
      localMemSize=65536
    
    double-click : recenter
    mouse wheel  : zoom
    mouse drag   : move
    
    Nov 03, 2020 6:15:34 PM com.aparapi.internal.kernel.KernelRunner fallBackToNextDevice
    WARNING: Device failed for AfKernel, devices={AMD<GPU>|AMD<GPU>|AMD<GPU>|AMD<GPU>|Java Alternative Algorithm|Java Thread Pool}: goto -> 0059
    com.aparapi.internal.exception.CodeGenException: goto -> 0059
    	at com.aparapi.internal.writer.BlockWriter.writeInstruction(BlockWriter.java:751)
    	at com.aparapi.internal.writer.KernelWriter.writeInstruction(KernelWriter.java:780)
    	at com.aparapi.internal.writer.BlockWriter.writeSequence(BlockWriter.java:299)
    	at com.aparapi.internal.writer.BlockWriter.writeBlock(BlockWriter.java:323)
    	at com.aparapi.internal.writer.BlockWriter.writeMethodBody(BlockWriter.java:873)
    	at com.aparapi.internal.writer.KernelWriter.write(KernelWriter.java:738)
    	at com.aparapi.internal.writer.KernelWriter.writeToString(KernelWriter.java:792)
    	at com.aparapi.internal.kernel.KernelRunner.executeInternalInner(KernelRunner.java:1535)
    	at com.aparapi.internal.kernel.KernelRunner.executeInternalOuter(KernelRunner.java:1383)
    	at com.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:1374)
    	at com.aparapi.Kernel.execute(Kernel.java:2897)
    	at com.aparapi.Kernel.execute(Kernel.java:2854)
    	at com.aparapi.Kernel.execute(Kernel.java:2794)
    	at com.aparapi.examples.mandel.AfMain.refresh(AfMain.java:128)
    	at com.aparapi.examples.mandel.AfGUI$2.componentResized(AfGUI.java:107)
    	at java.desktop/java.awt.AWTEventMulticaster.componentResized(AWTEventMulticaster.java:167)
    	at java.desktop/java.awt.Component.processComponentEvent(Component.java:6462)
    	at java.desktop/java.awt.Component.processEvent(Component.java:6416)
    	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
    	at java.desktop/java.awt.Window.processEvent(Window.java:2041)
    	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012)
    	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2764)
    	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
    	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
    	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
    	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
    	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
    	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
    	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
    Nov 03, 2020 6:15:34 PM com.aparapi.internal.kernel.KernelRunner fallBackToNextDevice
    WARNING: Trying next device: AMD<GPU>
    Mandelbrot -2.000000000000,-2.446280991736 2.000000000000,2.446280991736 - Iterations :        512 - Elapsed : 402 ms 
    Mandelbrot -2.000000000000,-2.446280991736 2.000000000000,2.446280991736 - Iterations :        512 - Elapsed : 345 ms 
    
    Enter your selection, or q/Q to quit: Invalid selection.
    
    Enter your selection, or q/Q to quit: Aparapi Fractals - canvas : 1210x1480 - max_iterations : 512 
    Mandelbrot -2.000000000000,-2.446280991736 2.000000000000,2.446280991736 - Iterations :        512 - Elapsed : 14 ms 
    Mandelbrot -1.970247933884,-2.436363636364 2.029752066116,2.456198347107 - Iterations :        512 - Elapsed : 15 ms 
    Mandelbrot -1.771900826446,-2.314049586777 2.228099173554,2.578512396694 - Iterations :        512 - Elapsed : 17 ms 
    Mandelbrot -1.755371900826,-2.208264462810 2.244628099174,2.684297520661 - Iterations :        512 - Elapsed : 15 ms

    Truncated log...

    Mandelbrot -0.087937055231,0.871903102316 -0.087913118739,0.871932380008 - Iterations :       3235 - Elapsed : 337 ms 
    Mandelbrot -0.087937173924,0.871903023187 -0.087913237433,0.871932300879 - Iterations :       3235 - Elapsed : 337 ms 
    ^C
    Profiles by Kernel Subclass (mean elapsed times in milliseconds)
    
    Device               Count    CLASS_MODEL_BUILT          INIT_JNI  OPENCL_GENERATED   OPENCL_COMPILED   PREPARE_EXECUTE          EXECUTED  Total
    ----------------- [[ AfKernel ]] ---------------------------------------------------------------------------------------------------
    AMD<GPU>             1                  256.458             0.184             9.508             0.000             0.000           175.781  441.931
    AMD<GPU>             1                    0.000             0.050             0.091             0.000             0.000           154.417  154.559
    AMD<GPU>             1                    0.000             0.018             0.048             0.000             0.000           154.247  154.312
    AMD<GPU>             1                    0.000             0.019             0.064             0.000             0.000           154.071  154.154
    Java Alternative Alg 1                    0.000             0.000             0.000             0.000             0.028           153.944  153.972
    Java Thread Pool     224                  0.000             0.000             0.000             0.000             0.007            95.996  96.003
  • Jeffrey Phillips Freeman unapproved this merge request

    unapproved this merge request

  • Hi, I never had this kind of exception. I'm still working on the code and added some functionalities, I run It hundreds of times, but I never had that problem. So, It's not easy for me to reproduce the error.
    Also, I'm empirically absolute sure It's only on GPU. It's very very fast and the final log is only on GPU usage. The Aparapi code is very simple. What can It be?
    I'm on windows10 1 GPU Nvidia 1650 SUPER, CPU AMD 3700x
    Shoul I try to add my old AMD GPU to my PC?

    I will show you the new version with a small benchmark test.

    For sure, we can not merge this one.

    thx, BR

    Edited by Marco Stefanetti
  • and that's my log :

    Aparapi Fractals - canvas : 768x768 - max_iterations : 512 
    Aparapi Fractals - canvas : 768x768 - max_iterations : 512 
    Aparapi Fractals - canvas : 768x768 - max_iterations : 512 
    AfKernel, devices={NVIDIA<GPU>|Java Alternative Algorithm|Java Thread Pool}
    Device 1157773856
      vendor = NVIDIA Corporation
      type:GPU
      maxComputeUnits=20
      maxWorkItemDimensions=3
      maxWorkItemSizes={1024, 1024, 64}
      maxWorkWorkGroupSize=1024
      globalMemSize=4294967296
      localMemSize=49152
    
    double-click : recenter
    mouse wheel  : zoom
    mouse drag   : move
    
    Mandelbrot -2.000000000000,-2.000000000000 2.000000000000,2.000000000000 - Iterations :        512 - Elapsed : 414 ms 
    Mandelbrot -2.005208333333,-2.000000000000 1.994791666667,2.000000000000 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.067708333333,-2.000000000000 1.932291666667,2.000000000000 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.145833333333,-2.015625000000 1.854166666667,1.984375000000 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.208333333333,-2.031250000000 1.791666666667,1.968750000000 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.250000000000,-2.041666666667 1.750000000000,1.958333333333 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.265625000000,-2.052083333333 1.734375000000,1.947916666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.276041666667,-2.057291666667 1.723958333333,1.942708333333 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.312500000000,-2.067708333333 1.687500000000,1.932291666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.354166666667,-2.083333333333 1.645833333333,1.916666666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.359375000000,-2.083333333333 1.640625000000,1.916666666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.369791666667,-2.083333333333 1.630208333333,1.916666666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.375000000000,-2.083333333333 1.625000000000,1.916666666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.380208333333,-2.083333333333 1.619791666667,1.916666666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.385416666667,-2.083333333333 1.614583333333,1.916666666667 - Iterations :        512 - Elapsed : 7 ms 
    Mandelbrot -2.390625000000,-2.083333333333 1.609375000000,1.916666666667 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.395833333333,-2.088541666667 1.604166666667,1.911458333333 - Iterations :        512 - Elapsed : 5 ms 
    Mandelbrot -2.401041666667,-2.088541666667 1.598958333333,1.911458333333 - Iterations :        512 - Elapsed : 5 ms 
    
    Profiles by Kernel Subclass (mean elapsed times in milliseconds)
    
    Device               Count    CLASS_MODEL_BUILT          INIT_JNI  OPENCL_GENERATED   OPENCL_COMPILED   PREPARE_EXECUTE          EXECUTED  Total
    ----------------- [[ AfKernel ]] ---------------------------------------------------------------------------------------------------
    NVIDIA<GPU>          18                  13,216             7,677             0,370             0,151             0,016             5,803  27,233
    
  • I think your problem can be here :

    Aparapi Fractals - canvas : 768x768 - max_iterations : 512 
    Aparapi Fractals - canvas : 1210x1480 - max_iterations : 512 
    Aparapi Fractals - canvas : 1210x1480 - max_iterations : 512 

    you had a resize of the canvas before starting, I'm investigating the code.

    I'll let you know, but probably I'll show a new version.

    thx

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • 34da37d9 - additional chek before writing in the result array

    Compare with previous version

  • added 1 commit

    • fae184b8 - kernel : inverted conditional to avoid early 'returns'

    Compare with previous version

  • added 1 commit

    • a55f4817 - modified t++ in the kernel loop

    Compare with previous version

  • added 1 commit

    • 56b6f121 - device selector and benchmark mode

    Compare with previous version

  • Marco Stefanetti added 2 commits

    added 2 commits

    • 9dc5800f - fixed setExecutionModeWithoutFallback
    • ebadac82 - fixed setExecutionModeWithoutFallback, changed java package

    Compare with previous version

  • added 1 commit

    • 04acb715 - Range2D and CPU benchmark fix

    Compare with previous version

  • I'm working on a benchmark that loops over all devices available and better formatting the code.

    Edited by Marco Stefanetti
Please register or sign in to reply
Loading