GPGPU(OpenCL/CUDA)+Multithreading Support

  • plypencil
    6th Dec 2012 Member 0 Permalink

    Bekas:

    I have little knowledge about the TPT architecture, i just pointed out the drawbacks of the openCL.

    However if there is a pratical solution probably multithreading.
    But like Simon said

     

     The main issue with multithreading the simulation is memory access

     

     

    What I meant by double buffering, is creating an inmemory copy of the frame after its processed, which the drawing routine can access. Creating a copy uses less time than to synchronise the logic and draw with each other.

  • Bekas
    13th Dec 2012 Member 0 Permalink

    @plypencil (View Post)

    plypencil:

     

     What I meant by double buffering, is creating an inmemory copy of the frame after its processed, which the drawing routine can access. Creating a copy uses less time than to synchronise the logic and draw with each other.

     

    I tried creating a copy of the data and updating the particles based on that data.
    The data that i duplicated was the parts array.
    Still i got particles beeing 'randomly' killed

  • Rawrkanos
    14th Dec 2012 Member 0 Permalink

    Bekas:

    @plypencil (View Post)

    plypencil:

     

     What I meant by double buffering, is creating an inmemory copy of the frame after its processed, which the drawing routine can access. Creating a copy uses less time than to synchronise the logic and draw with each other.

     

    I tried creating a copy of the data and updating the particles based on that data.
    The data that i duplicated was the parts array.
    Still i got particles beeing 'randomly' killed

     Is there anyway you can protect against that, or double-check? Take an average of two copies? That is two say, if it says there is a pixel there even once, put the pixel there?

  • MiningMarsh
    13th Jan 2013 Member 0 Permalink

    @plypencil (View Post)

     I don't know if you really get double buffering. Double buffering is actually holding two memory buffers, and then only drawing to one, while the offer is being displayed. The advantage is that you only swap buffers when you are finished drawing, so the screen doesnt display the updates until they are finished. Nothing to do with copying.

    If you have each thread modifying a separate buffer, well, you have accomplished nothing, as you have to sync the buffers. If each modifies the same buffer and they are flipped, what does this accomplish? You still have shared memory issues.

     

  • Bekas
    13th Jan 2013 Member 0 Permalink

    I think what @plypencil was trying to say is to use an array with the data before the update. And let the threads acess that array to update the 'original' one.
    While this does work for some applications ( like CA ), it cant be applied to PT.

  • MiningMarsh
    15th Jan 2013 Member 0 Permalink

    Really, after profiling powder, and looking at the relevant code, TPT was just not designed from the ground up to be multithreaded. The simulation update code takes 40% of all cpu time, and the biggest issue I saw looking at the code (if I understood it correctly), is that particles are updated in a very specific order. Threading this so that multiple particles are updated at once (the only real way multithreading could help) could create all sorts of obscure changes in certain saves, if they worked due to particles updating in a sequential order. I do plan on trying it anyway in my free time just to see what happens, but there is not really much hope that it won't break terribly at this point.

  • Rawrkanos
    17th Jan 2013 Member 0 Permalink

    MiningMarsh:

    Really, after profiling powder, and looking at the relevant code, TPT was just not designed from the ground up to be multithreaded. The simulation update code takes 40% of all cpu time, and the biggest issue I saw looking at the code (if I understood it correctly), is that particles are updated in a very specific order. Threading this so that multiple particles are updated at once (the only real way multithreading could help) could create all sorts of obscure changes in certain saves, if they worked due to particles updating in a sequential order. I do plan on trying it anyway in my free time just to see what happens, but there is not really much hope that it won't break terribly at this point.

     Any chance you could look into OpenCL, as well?

  • kroq-gar78
    12th Feb 2013 Member 0 Permalink

    mniip:

    heat simulation works on a proprietary engine which was optimised in all possible ways, the most lagging part is update functions, which are called tons of times, you can't do anything with it

     Wait, proprietary? I thought it was based on FFTW, unless I have absolutely no idea what I'm talking about :(

  • jacksonmj
    12th Feb 2013 Developer 0 Permalink

    It's newtonian gravity that's based on FFTW.

     

    Also, I suspect heat simulation isn't really optimised in all possible ways...

  • The-Fall
    12th Feb 2013 Member 0 Permalink

    So, Optimizations are possible, but not quite to the extent of multi-threading. Ok, This is fine.