Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    4x to 5x speed boost for data processing

    Advanced
    4
    7
    381
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Doriphor
      Doriphor last edited by Doriphor

      So, I was investigating if Fuze supports some kind of parallel processing, and while I couldn't find much, there IS this:

      x = 12345
      vector x2 = {12345, 12346, 12347, 12348}
      vector y2
      
      start = time()
      for i = 0 to 1000000 loop
          y = x*x
      repeat
      end = time()
      
      start2 = time()
      for i = 0 to 1000000/4 loop
          y2 = x2*x2
      repeat
      end2 = time()
      
      print("First: ", end - start, "\nSecond: ", end2 - start2)
      update()
      
      loop
      repeat
      

      The second way of doing things takes roughly 4 to 5 times less time than the first. Now I know this is a very simplistic way of doing things, but this could be pretty exciting in situations where a large number of repetitive calculations is required!

      Tell me what you think!

      Caveats: this doesn't work with built-in functions, it also requires y2 in this situation to be declared beforehand.

      1 Reply Last reply Reply Quote 2
      • Doriphor
        Doriphor last edited by

        Oh, and more testing could be required because it's possible that optimizations cause the multiplications to be run only once and the time is used up by the loops alone.

        1 Reply Last reply Reply Quote 0
        • spikey
          spikey F last edited by spikey

          @Doriphor probably my day was already too long, but is this a typo? 1000000/4 or why not using the same as in the first loop? Nevertheless it could be that the second loop does not need to allocate new memory, thats why its quicker, but probably this what you discovered already. I am just guessing.

          1 Reply Last reply Reply Quote 0
          • vinicity
            vinicity F last edited by

            What is the resulting vector? Is it the the dot product? Or...

            If it is {x2.x * x2.x, x2.y * x2.y, etc} then, yes, that does seem to be a more efficient way of doing lots of multiplication operations.

            An interesting find...

            Doriphor 1 Reply Last reply Reply Quote 1
            • Doriphor
              Doriphor @vinicity last edited by

              @vinicity from what I can tell it actually did a square on each element independently.

              @spikey because if each vector has 4 elements you only need 1/4th of the loops.

              1 Reply Last reply Reply Quote 1
              • Willpowered
                Willpowered Fuze Team last edited by

                Neat idea! The second works faster because FUZE is an interpreted language. While it's still performing the same number of multiplications, it's passing data more efficiently to the native code since you're giving it 4 numbers at a time instead of 1 number. That means less interpreted instructions overall, which are slower than equivalent native code.

                Doriphor 1 Reply Last reply Reply Quote 4
                • Doriphor
                  Doriphor @Willpowered last edited by

                  @Willpowered I figured it was either that or conditional jumps take a lot of time 🤔

                  1 Reply Last reply Reply Quote 2
                  • First post
                    Last post