-
Notifications
You must be signed in to change notification settings - Fork 6
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
[ENH] Coiteration with hashed level #25
Conversation
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
My current thinking is the following:
|
In all but the third point, you would do the calculation exactly as-is, just only with the ordered levels. Just the deference would take into account the locate-capable unordered levels. The reason is that we ensure a conjunctive merge with unordered levels so the minimum/advance (the last of which is the same as operator++) etc will work exactly as with just the ordered levels. |
06/14/23 NotesToday, @bharath2438 and I met briefly. Here are a few notes that I am currently implementing:
Once this is done, co-iteration with arbitrary tuple of levels is supported. Now, we have been discussing adding optimizations to the co-iteration when a conjunctive merge takes place. However, Bharath and I couldn't come to a consensus here... When some levels are unordered, and the conjunctive merge criterion is met, then the current proposal was to iterate entirely through the ordered levels. However, it seems like it could also be highly inefficient(?) because we do not know if an unordered level has reached its end. For example, say we have |
Signed-off-by: Adam Li <[email protected]>
A few issues on commit 78d5cbc
It's possible |
I would be happy to hear about generalised solutions to this issue but sadly I do not immediately see any with unordered levels. One thing I just thought of is that in |
Would it be too brute-force to have the MergeLattice convert all unordered levels to ordered? Alternatively, is there a cheap way to inspect the "size" of each level that is co-iterated? So we can then either co-iterate by advancing all iterators, or doing this advance-and-locate strategy?
Why? If one is null opt, we're good to move on? Is this assuming we have a conjunction over only unordered levels?
I think the error arose from the fact that it checked for member, not a member function with possible arguments. I changed the signature of the However, w/ this change, I get the following errors in 5fc8476:
It's problematic because I think it is looking for
|
Signed-off-by: Adam Li <[email protected]>
Yeah, that would be asymptotically worse.
The merging strategy only works if iterators are ordered, therefore, advancing all iterators won't work. We have to locate into unordered levels.
Ah, no. Advance iterator would advance only the ordered levels, but use the function |
Signed-off-by: Adam Li <[email protected]>
NOTES 6/16/23:
|
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Few comments:
The code correctly co-iterates when there is a valid value at indices 0, 1, and 2, but as soon as it reaches index 3, there is a segfault. My guess is that there is a segfault when doing |
I'd do that for all types and template parameters.
|
Okay will do that in a separate PR.
So after some digging, it turns out this is because the Update: On further investigation, I think it could be because we are advancing the iterator regardless of hashed, or ordered every time. The iterator advances in an unordered fashion for the hashed level, so it results in some weird behavior. I suppose the fix would be to not advance iterators corresponding to hashed level. I will add this since this is required anyways for the advance-and-locate iteration scheme (we just eat the cost of certain conjunctive merges e.g. in #25 (comment)) |
Signed-off-by: Adam Li <[email protected]>
Leaving notes for the call on Sunday. My blocker for this is some compiler error that I'm trying to understand: b5d0960. Basically, I am trying to apply a function to a tuple of iterators given a bool condition specified by mask. The mask is the tuple of same length as the tuple of iterators. I thought I got it working on a sample function that just prints out something, but now there's an error, so I need to re-analyze if this is the right approach. By doing [Update]: I guess I am unsure how to best tackle this. I want to basically use template meta-programming to apply |
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Hey @adam2392, in
This should compile. I guess static_assert(false) always results in a static assertion failed? Does removing it results in successful compilation? |
Thanks! This + a few minor fixes made it work and I am back to the runtime segfault, but all other tests pass, so we're good. I will refactor the calc min ik now.
Yes this is true. I changed it to |
@hameerabbasi and @bharath2438 the main issue now is that the The issue is that it continues iterating. My guess is that the coiterator does not realized it's "finished". How should we address this? |
Just to clarify - since this is a conjunctive merge, it should stop after printing |
Yes that is a good point that I missed. It seems that the current coiteration code supports disjunction over ordered levels only? So then I guess there needs to be some if/else on whether or not the coiteration ended depending on the function F? |
The immediate problem I see here is, we are never really advancing hashed, since it is unordered. Hence, hashed stays in the beginning and the whole |
One solution that I can think of is -
|
Or... Just don't check the unordered levels at all when checking for the end condition. |
Then this would imply us altering the |
It would imply altering the compare function. Otherwise everything else would break. 😉 |
Maybe this will help: We can do the filtering just before the comparison. |
Signed-off-by: Adam Li <[email protected]>
I tried a similar solution that was more in-line w/ the rest of the code's design: dc1b236 So the comparison basically outputs:
This tuple of booleans are then fed into the |
Ouch... We need to feed in |
Heh yeah it's kinda janky, but assuming the Coiterator is used with levels that have at least one ordered always and no disjunction containing unordered, this is fine? I can clean up the PR if so, and make the unit-test pass now. I think everything works as it should. |
SGTM |
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Kay this is good to review @hameerabbasi @bharath2438 |
I plan on handling the compiler-time check for valid conjunctive merge using the |
Signed-off-by: Adam Li <[email protected]>
@adam2392, in the test case, why are we checking if |
Since we don't advance unordered iterators, this is not the case. Since there's no universally optimal way of advancing the ordered and unordered simultaneously, I just support the advance-and-locate strategy |
Signed-off-by: Adam Li <[email protected]>
Okay all the CIs pass now |
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.
This looks excellent to me, thanks @adam2392.
Supersedes: #24 and #19