News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Dot Particle Optimizations

Started by kevin, September 22, 2020, 09:20:49 PM

Previous topic - Next topic

kevin

   Dot Particle Optimizations V2.0

     While getting back to work on the PBMath64 library, I was wondering if we could use that to help with this type of brute force processing.  So  decided to knock up the following particle demo.  

    The initial particle example is written how most people (i think) would approach this problem, we'd create and manage the logic for many individual particles.  The up side is it's easy, then down side it puts a lot of work for the PlayBASIC runtime to do..   So then I decided to optimize the initial example a few different ways, mainly to remove the dynamic creation and roll our own.   Using different logic to replace built in functionality, which in this case returns around a 2.5 times the performance of the demo.    


  Video

 



  Links

  * 64 Bit Floating Point Math Library for PlayBASIC
  * Using Shapes For Dot Particles
   * Alpha Particles (Project pack example)


  Downloads

     Attached bellow.  

     We have two versions of the demos attached bellow. The first file is the original (as seen in the video) and contains four examples,  while the second includes the tweaked versions of the original four demos plus another one.  Which handles the particles in groups..  


BigDan256

Hi Kevin,

You got me interested and I played with the code a bit. Tried a full pre-allocate without keeping free and bucket lists.

There's a logic error that bugged me:
When particle y# < 0, it doesn't update yv#, x# or y# so the particle just stays off screen and never dies.

Just bugged me because the particle count doesn't drop, but the fps increases because those particles aren't drawn.

kevin

Hey Dan,

Quote
There's a logic error that bugged me:
When particle y# < 0, it doesn't update yv#, x# or y# so the particle just stays off screen and never dies.

   shhh..  yeah, I only noticed it when putting the video together..    but ya get that :)

kevin


Updated the download (in first post) and have included another optimization example that rearranges the code to handle the particles in groups/batches.  In the version we gain a few more FPS,  as concept reduces the cost per pixel.  We can take this further,  but where's the fun in that ?

kevin


PlayBASIC LIVE -  Performance testing V165C2 vs V164L - (2020/10/02)


   Today we'll compare the performance of the PlayBASIC V1. 65 runtime with older edition of PlayBASIC V1.64L (The FREE learning Edition) .  For our comparison we'll use the particle demos from last week.   

   The results are about what I expected,  being there's a big performance gap running the un-optimized particle code, but that gap narrows when running the faster version.  This shows that we've not only being making the runtime instruction sets faster but key functions behind the command sets are faster in the newer editions.   It's not a magic bullet mind you, but the increase ranges between 8/9 times faster than V1.64L through to as narrow as only twice as fast.   


  Still the winner is PB1.65


Video:


   






Downloads:


Particle Optimization Source Code + More Info
https://www.underwaredesign.com/forums/index.php?topic=4543.0



PlayBASIC Math64 Library

https://www.underwaredesign.com/forums/index.php?topic=4535.0


Credits:


      Video By:
   Kevin Picone
   http://PlayBASIC.com 
   https://underwaredesign.com

   Music:
  Spirit of Fire by  Jesse Gallagher
  Venkatesananda  by   Jesse Gallagher



                 

PlayBASIC LIVE PLAYLIST
https://www.youtube.com/playlist?list=PL_dvm0gvzzIVGlAhx34N6z2ce0ffMMOZ8

PlayBASIC BLOG PLAYLIST
https://www.youtube.com/playlist?list=PL_dvm0gvzzIU0Hnr6veV5UvwkSapHCo1J

PlayBASIC on FACEBOOK
http://www.facebook.com/pages/PlayBasic/127905400584274   (Facebook Page)

PlayBASIC on TWITTER
https://twitter.com/PlayBasic



#PlayBASIC #particles #basic #coding #programming #sourcecode