I've rewritten some functions to reduce code duplication. The refactoring removed 1300 lines of code.
There are also some performance improvements. The biggest one is related to the last commit. After the latest code refactoring, it is no more necessary to relay the AUX bit for 2:1 balance. Moreover, that bit was not properly reset and 2:1 balance was check on many more octants than actually needed. This leads to a speed improvement of 25x for the function that perform load balance. All tests pass, however a thorough code review and some more test are needed to make sure the changes are fine.
I've rewritten some functions to reduce code duplication. The refactoring removed 1300 lines of code.
There are also some performance improvements. The biggest one is related to the last commit. After the latest code refactoring, it is no more necessary to relay the AUX bit for 2:1 balance. Moreover, that bit was not properly reset and 2:1 balance was check on many more octants than actually needed. This leads to a speed improvement of 25x for the function that perform load balance. All tests pass, however a thorough code review and some more test are needed to make sure the changes are fine.
Original profile of localBalance:![original](https://user-images.githubusercontent.com/7443174/187064504-9c3621d2-d98c-4b21-ad65-b636a7e92ac1.png)
Updated profile of localBalance:![updated](https://user-images.githubusercontent.com/7443174/187064528-1109327f-c280-41fc-a85c-b89bf28d7798.png)