-
Notifications
You must be signed in to change notification settings - Fork 36
Hilbert order method for load balancing #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good! It's more complex than what I did with Enzo's Hilbert curve because you considered the octree structure in its calculation. I had one question for my own curiosity about the block weighting as an inline comment and another question about testing. But I can approve it because those are just minor items.
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
|
||
# Load Balance | ||
#setup_test_parallel(LoadBalance-1 LoadBalance/morton-1 input/LoadBalance/test_balance-on-bcg.in) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to still test the Morton curve in addition to the Hilbert curve? From the other files, it seems like it's not being removed, so I think it might be a good idea to keep this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test for the Morton method was actually already removed before I added the Hilbert method. My guess is the original test was removed because it was a lengthy cosmological simulation. I added it back in temporarily while I was putting together the Hilbert test and then commented it out. I didn't want to reintroduce a test which was removed and I probably should have removed it entirely instead of commenting it out.
|
||
*pindex_(block) = 0; | ||
*pcount_(block) = 0; | ||
*pweight_(block) = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all blocks equally weighted? If so, this is fine. It's just for my curiosity. If we were to have performance timing for each block or some proxy, would this be where the associated weight would be assigned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the weighting is the same as in the Morton method as @jobordner said. So all the blocks initially have equal weight and by the end of the method all leaf blocks should have weight 1 and all non-leaf blocks should have a weight = 1 + (the number of its descendant blocks)
Looks good to me, and works great! (out-performs Morton as expected) In PR #350 I made some structural changes to ordering (e.g. replaced (@jwise77 the weighting is the same as in Morton (the same for all blocks), but the variable "weight" is available so different blocks can be assigned different weights later as needed.) |
A
MethodOrderHilbert
class was added which uses a Hilbert curve to order blocks in a simulation.The class is largely based on the MethodOrderMorton class but with some key logic/functions replaced with Hilbert versions. Namely, the logic for iterating over child blocks in a Morton order was replaced with a Hilbert version (facilitated by a
hilbert_children
function) and theIndex.next
method was replaced withMethodOrderHilbert::hilbert_next
.The algorithms for determining the Hilbert order are based on those presented in "Mengjuan Li et al 2023 (Efficient entry point encoding and decoding algorithms on 2D Hilbert space filling curve)" and "Lianyin Jia et al 2022 (Efficient 3D Hilbert curve encoding and decoding algorithms)" which are iterative and use look-up tables rather than recursive. Note, there are typos in the tables presented in these papers, the tables used by the
MethodOrderHilbert
class should be the correct ones.