OpenCL Solar System

Discussion in 'GPGPU Technology & Programming' started by moozoo, May 18, 2013.

  1. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    14,849
    Likes Received:
    2,268
    I dont think i did
    Q6600 + 6950
    [​IMG]
    Wouldnt that be
    INTEL CPU opencl + AMD opengl

    ps:
    Cpu usage 70%
    Gpu usage 0%

    pps: whats the difference between opencl platform and opencl device ?
     
  2. pcchen

    pcchen Moderator
    Moderator Veteran Subscriber

    Joined:
    Feb 6, 2002
    Messages:
    2,743
    Likes Received:
    106
    Location:
    Taiwan
    OpenCL platform means the implementation of OpenCL. For example, in your case, you are using AMD's OpenCL software implementation for x86 CPU, but it's running on an Intel CPU (an OpenCL device). Similarly, it may also be possible (though I'm not sure about this) to run Intel's CPU OpenCL platform on an AMD x86 CPU.

    The difference is less important for GPU because it's very unlikely to run an OpenCL platform on another vendor's GPU as GPU's internal architecture are generally proprietary.
     
  3. moozoo

    Newcomer

    Joined:
    Jul 23, 2010
    Messages:
    109
    Likes Received:
    1
    "Wouldnt that be
    INTEL CPU opencl + AMD opengl"

    Sorry, Perhaps I over abbreviated.
    AMD make an openCL library (driver) that runs on both Intel CPUs and AMD CPU's
    Intel also makes an openCL library (driver) that runs on Intel CPU's (maybe AMD CPU's, I don't know)
    I was trying to say the AMD openCL library for CPU's running on your CPU (which happens to be Intel made CPU)

    AMD also make an openCL library (driver) that runs on their graphics cards.
    Its installed with the graphics card drivers.
    Thats the one I want to get going since its performance is vastly better than any others except perhaps the Nvidia Titan cards.

    >whats the difference between opencl platform and opencl device
    A system can have a large number of opencl devices.
    These are grouped together under a platform for each vendor.

    On my machine I have three platforms
    Nvidia,Intel and AMD
    Under Nvidia there is the GTX260 device (using code written by Nvidia)
    Under Intel there is my CPU device (using code written by Intel)
    Under AMD these is also my CPU device (but using code written by AMD)

    I only have once device under each platform.
    However in your case you will have two devices under the AMD platform
    Your CPU and your graphic card.

    If you leave off the -cpu and comment out the #pragmas it shoud run but not work (as you and others have discovered for me).
    Then check the about box and you should see your graphics device as the opencl device.

    In my experience the Intel CPU opencl driver is faster than the AMD CPU opencl driver. However I wouldn't recommend installing it given almost all your opencl programs (bar broken ones like mine..) will usually be running on your graphics card.
     
  4. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    14,849
    Likes Received:
    2,268
    Is it possible its a cayman problem since both myself and alexo have 6950's
    have you tried a cgn card ?

    ps: just to make sure it isnt an error my end I downloaded gpu caps viewer and ran the opencl demo's and they all work fine
     
  5. Lightman

    Veteran Subscriber

    Joined:
    Jun 9, 2008
    Messages:
    1,802
    Likes Received:
    473
    Location:
    Torquay, UK
    GCN here and it's static picture on OpenCL device - Tahiti.
     
  6. moozoo

    Newcomer

    Joined:
    Jul 23, 2010
    Messages:
    109
    Likes Received:
    1
    Apparently amd graphics drivers require the objects to be shared to be created after both the gl and cl contexts have been made.
    I've done this in v1.02 but can not test it.
     
  7. Alexko

    Veteran Subscriber

    Joined:
    Aug 31, 2009
    Messages:
    4,491
    Likes Received:
    909
    Sorry, no difference with my HD 6950.
     
  8. moozoo

    Newcomer

    Joined:
    Jul 23, 2010
    Messages:
    109
    Likes Received:
    1
    :(
    Thanks Alexko
     
  9. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    14,849
    Likes Received:
    2,268
    "Apparently amd graphics drivers require the objects to be shared to be created after both the gl and cl contexts have been made"

    But other opencl drivers dont ?
    whats the correct behaviour ?
    have you submitted a bug report
     
  10. moozoo

    Newcomer

    Joined:
    Jul 23, 2010
    Messages:
    109
    Likes Received:
    1
    AMD APP SDK Release Notes

    It is in the AMD APP SDK Release Notes for 2.8

    From those notes
    -------------
    For OpenGL interoperability with OpenCL, there currently is a requirement on when the
    OpenCL context is created and when texture/buffer shared allocations can be made. To use
    shared resources, the OpenGL application must create an OpenGL context and then an
    OpenCL context. All resources (GL buffers and textures) created after creation of the OpenCL
    context can be shared between OpenGL and OpenCL. If resources are allocated before the
    OpenCL context creation, they cannot be shared between OpenGL and OpenCL.
    --------------------

    I've only been reading the opencl spec , looking at other example code and debugging against the platforms I have access to till now.

    I believe the 1.02 version of my program is now doing this as per AMD's requirement. So there must be something else going wrong.

    The opencl compile error related to
    #pragma OPENCL EXTENSION cl_khr_gl_sharing : enable
    is a bug
    http://devgurus.amd.com/thread/155539
     
  11. moozoo

    Newcomer

    Joined:
    Jul 23, 2010
    Messages:
    109
    Likes Received:
    1
    uploaded v1.03

    More stumbing in the dark to get amd cards working.
     
  12. Lightman

    Veteran Subscriber

    Joined:
    Jun 9, 2008
    Messages:
    1,802
    Likes Received:
    473
    Location:
    Torquay, UK
    It's better as it shows all the asteroids straight after opening, but still is not updating screen when running simulation.
     
  13. moozoo

    Newcomer

    Joined:
    Jul 23, 2010
    Messages:
    109
    Likes Received:
    1
    1.04

    version 1.04

    Lots of changes
    1) converts double4 to glfloat4 for display (calculations are still all in double)
    2) rewrote device selection logic
    3) cleaned up error handling
    4) added frames per second
    5) turned off vsync and runs during idle as well as per interval time
    6) changed relevant kernels to use fma instruction
    7) might work with cl_amd_fp64 only devices (Again I have no access to one)
    It is much faster now
    I'm getting 220fps on the default options.

    Lightman, shoudl you try again, could you check the device being used in the about box.
    With apu systems with a discrete gpu I don't have a way of selecting between the gpu's at the moment.
    It does save and read the last device vendor id to the registry. So if you have the device vendor id you can try directly updating it under HKEY_CURRENT_USER\Software\OpenCLSolarSystem
     
  14. fellix

    fellix Hey, You!
    Veteran

    Joined:
    Dec 4, 2004
    Messages:
    3,486
    Likes Received:
    397
    Location:
    Varna, Bulgaria
    GTX580 @ 825MHz GPU clock: ~250 FPS with the default settings, except for the # of bodies with mass set at maximum.
     
  15. Alexko

    Veteran Subscriber

    Joined:
    Aug 31, 2009
    Messages:
    4,491
    Likes Received:
    909
    Same settings as Fellix, about 160FPS* with my HD 6950: works like a charm this time.

    I'm going to have some very nerdy fun with this.


    *With a whole bunch of stuff running in the background.
     
  16. Lightman

    Veteran Subscriber

    Joined:
    Jun 9, 2008
    Messages:
    1,802
    Likes Received:
    473
    Location:
    Torquay, UK
    Works! :grin:

    If it wasn't clear, my HD 7970 is in i5 2500K rig without active HD2000, so only CPU CL and Tahiti CL devices are present.

    Anyway here are my findings using HD 7970 1050/1425:

    1. Default setting produces 652FPS and only 31% GPU utilization
    2. Maximum body setting produces 68FPS and 80% GPU utilization
    3. Maximum body and maximum Number with Mass produces 8FPS and 97% GPU utilization
    4. Default settings except Number with Mass set to maximum produced 199FPS and 59% GPU utilization

    Note: all other options were not changed and default view used.

    Tahiti is a bit quicker in DP match than my CPU ...

    PS. AMD CPU option doesn't work, still uses GPU.
     
    #36 Lightman, Jun 6, 2013
    Last edited by a moderator: Jun 6, 2013
  17. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    14,849
    Likes Received:
    2,268
    so what was the problem ?
     
  18. moozoo

    Newcomer

    Joined:
    Jul 23, 2010
    Messages:
    109
    Likes Received:
    1
    Thank you, everyone for helping me.

    It would be best not to benchmark with maximum Number with Mass since bodies with mass are put into __constant memory and the amount of constant memory varies between graphics cards.

    The maximum number of bodies in the initial.bin file might change. i.e. more asteroids are being found.

    So.. I'd recommend benchmarking with defaults + number of bodies 309760 and number with mass 384. on my GTX 260 I get ~5.25 fps
    I will look at adding a Benchmark option to the Menu that use these settings.

    Only 350ish of the asteroids have realistic masses for them. Most are educated guesses based on their type and estimated size (as per JPL's DE405). With the rest I assigned a small mass to them.
    The total mass of the asteroid belt is only about 4% of the mass of the moon. Think of all those asteroids as the talcum powder of the solar system compared to the sun and planets.

    >so what was the problem ?
    no way of working that out. I made lots of changes and couldn't test as I went.

    I realised that 1.04 still won't attempt to run on devices that only have cl_amd_fp64. I'll fix that in the next version.

    >PS. AMD CPU option doesn't work, still uses GPU.
    Thanks I'll look though the code for that again.

    >I'm going to have some very nerdy fun with this.

    Export to a SLF, edit it with a text editor and Import it (takes ages).
    If you are happy with it , use Saved Inital to save it to a .bin file.
    It is much faster to load it from a .bin file.
    The file format is documented in the Solex readme.
    I only implemented importing the format Solex outputs.

    You can set the Time Delta to 1 day and the Intergrator to "Adams Bashforth Moulton 8" and time will past faster but the accurary of the simulation will be lower.
    Note some combinations are unstable (bodies bounce about and then fly off), This isn't a bug as such, but a limitation of the intergration algorithm.
     
  19. Lightman

    Veteran Subscriber

    Joined:
    Jun 9, 2008
    Messages:
    1,802
    Likes Received:
    473
    Location:
    Torquay, UK
    With your benchmark settings of 384 bodies with mass and 309760 number of bodies I'm getting 50FPS with 84% GPU utilization. There are moments when it jumps to 52-53FPS and GPU utilization to 87% but I can't pin point why this is happening.
     
  20. Alexko

    Veteran Subscriber

    Joined:
    Aug 31, 2009
    Messages:
    4,491
    Likes Received:
    909
    24~25 FPS on my HD 6950.

    I'll try that, thanks.
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...