Dolphin, the GameCube and Wii emulator - Forums
Math routines - Printable Version

+- Dolphin, the GameCube and Wii emulator - Forums (https://forums.dolphin-emu.org)
+-- Forum: Dolphin Emulator Discussion and Support (https://forums.dolphin-emu.org/Forum-dolphin-emulator-discussion-and-support)
+--- Forum: Development Discussion (https://forums.dolphin-emu.org/Forum-development-discussion)
+--- Thread: Math routines (/Thread-math-routines)



Math routines - CyBoRg - 12-12-2015

Hello,I'm new here. Big Grin
I'm thinking about trying to optimize some math routines if this has not been done already.
Is there any operation which needs optimization ? For example,a factorization routine,a square root,matrix multiplications,divisions or something like that ? Tongue
Where should I look in the code ?
Also, did somebody think about a "distributed rendering" version of dolphin ? Cool
Regards Blush


RE: Math routines - degasus - 12-12-2015

Our "math" routines look a bit different. eg this is very high in profilation while running in interpreter mode. We also have no factorization or matrix multiplications. But there is a square root and a division, but I doubt you're talking about this kind of code.

Please keep in mind that we're emulating hardware, so all of our functions are done in custom hardware on the wii itself. There is no higher logic in hardware.

What do you mean about "distributed rendering"?


RE: Math routines - CyBoRg - 12-15-2015

(12-12-2015, 08:56 AM)degasus Wrote: Our "math" routines look a bit different. eg this is very high in profilation while running in interpreter mode. We also have no factorization or matrix multiplications. But there is a square root and a division, but I doubt you're talking about this kind of code.

Please keep in mind that we're emulating hardware, so all of our functions are done in custom hardware on the wii itself. There is no higher logic in hardware.
That's why I was asking about math.
There are also GPU implementations of math libraries.
But the idea was to understand if there was something that could have improved the performance with the aid of efficient math.
For example, I see a "// TODO: Optimize the below to be as fast as possible." in this.

degasus Wrote:What do you mean about "distributed rendering"?
Forgive me for that, it's a stupid thought... Tongue
I had in mind a master-slave option to share the load on more CPUs,via LAN/WiFi.


RE: Math routines - KHg8m3r - 12-15-2015

(12-15-2015, 01:11 AM)CyBoRg Wrote:
(12-12-2015, 08:56 AM)degasus Wrote: Our "math" routines look a bit different. eg this is very high in profilation while running in interpreter mode. We also have no factorization or matrix multiplications. But there is a square root and a division, but I doubt you're talking about this kind of code.

Please keep in mind that we're emulating hardware, so all of our functions are done in custom hardware on the wii itself. There is no higher logic in hardware.
That's why I was asking about math.
There are also GPU implementations of math libraries.
But the idea was to understand if there was something that could have improved the performance with the aid of efficient math.
For example, I see a "// TODO: Optimize the below to be as fast as possible." in this.

If you can find a way to code it so that math is faster, be our guest. If you can effectively push it to the GPU without it slowing down the GPU work already being done and getting a CPU boost out of it, even better.

(12-15-2015, 01:11 AM)CyBoRg Wrote:
degasus Wrote:What do you mean about "distributed rendering"?
Forgive me for that, it's a stupid thought... Tongue
I had in mind a master-slave option to share the load on more CPUs,via LAN/WiFi.

Spreading the CPU load over a network is probably not a good idea. If you take our current dual core Dolphin setup, and try to split those threads over multiple LAN/WiFi computers/CPUs, you would get so much lag from waiting for the different threads to all sync up together.


RE: Math routines - CyBoRg - 12-15-2015

(12-15-2015, 01:35 AM)KHg8m3r Wrote: If you can find a way to code it so that math is faster, be our guest. If you can effectively push it to the GPU without it slowing down the GPU work already being done and getting a CPU boost out of it, even better.

I wish I was that good Tongue I'm going to fork the code,we'll see what happens.  Big Grin

KHg8m3r Wrote:Spreading the CPU load over a network is probably not a good idea. If you take our current dual core Dolphin setup, and try to split those threads over multiple LAN/WiFi computers/CPUs, you would get so much lag from waiting for the different threads to all sync up together.
Not only that,it's even harder in that way.
But I had a different trick in mind.  Angel
The idea is to have both(or "n") machine(s) working on half(or 1/n ) the native resolution and to sync the results in one single frame to display.
It's some sort of "shared frame buffer" and the theory behind it is that (bare with me,it's an example,numbers are hypothetical) if we have two machines that can render 1M pixels at 10fps and 500K pixels at 20fps, if we sum our "job" together we effectively get 1M pixels at -+20/19fps(with the minimum lag possible,which is in the order of a few milliseconds on a LAN environment over miles;it's almost unnoticeable if the machines are within a meter).
It is not efficient space-wise because you need "n" copies of everything on the machines,unlike a general implementation of a parallel hypervisor,where the load is shared intelligently by passing messages through the switches; but with this trick in mind,if done right,you effectively multiply the fps by the number of machines(again,at the expense of space since a copy of all the software is needed on each machine).
Cool