-
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] Augment coiteration algorithm to handle hashed level during conjunctive merge #19
Conversation
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
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.
A couple of changes.
Co-authored-by: Hameer Abbasi <[email protected]>
Co-authored-by: Hameer Abbasi <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Addressed changes in the unit-test. Now, I will re-visit the logic we discussed about implementation. |
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
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 file contains my initial attempt at: adding a constexpr check at compile time to determine if the coiteration is valid (this assumes that the user converts non-ordered, non-locatable formats to a correct format).
What I'm not sure on now is how to best implement the locate
logic. That is, we want to somehow given a tuple of levels, determine which of these have locate and instead of advancing the iterator on those levels, we locate into them given a index and pointer.
May 26th 2023I had a few clarifying questions as well:
Am I missing anything? |
…t implement the altered co-iteration logic assuming that some of the levels are unordered. Signed-off-by: Adam Li <[email protected]>
We would iterate through the first one and locate into all the other ones in this case; but the output will be marked unordered as well. This means only a level with an insert capability can be the output.
This is correct.
You'd have to check if it's a conjunction wrt the unordered levels. It can be somewhere in the middle, i.e. A simple algorithm to identify which functions are valid is as follows:
You wouldn't need to store anything, just test the function itself.
That sounds good to me, but one other place I can think of is the dereferencing operator, it must return the right |
Okay, this sounds like it is not handled by co-iteration, but at the merge lattice level, mapping inputs to outputs. Right?
So to clarify, this means that the function
Then, this means that we just assume that The next part is how to handle actually co-iterating. If we don't store which levels are unordered, then we just use |
Both have a component to them -- we'd handle it here by signalling to merge lattices whether the output is ordered.
This code looks roughly correct, except for two things:
|
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.
A couple of comments I hope will be helpful on how to proceed.
/* | ||
The class template for Coiteration of level formats. | ||
|
||
Uses a generic function object F to compare elements | ||
from different sequences at the same position and returns a tuple of the | ||
minimum index and the corresponding elements from each sequence. | ||
|
||
Parameters | ||
---------- | ||
F : class | ||
A function object that is used to compare two elements from different ranges. | ||
IK : class | ||
The type of the first element of each range. | ||
PK : class | ||
The type of the second element of each range. | ||
Levels : Tuple of class | ||
A tuple of level formats, where each level is itself a tuple of elements to be iterated. | ||
Is : Tuple of class | ||
A tuple of indices that is used to keep track of the current position in each level. | ||
|
||
Notes | ||
----- | ||
Coiteration is only allowed through tuples of levels if the following criterion is met: | ||
If: | ||
1. the levels are all ordered (i.e. has the `is_ordered == True` property) | ||
2. if any of the level are do not have the is_ordered property, it must have the locate | ||
function, else return False. Then do a check that `m_comparisonHelper` defines | ||
a conjunctive merge (i.e. AND operation). | ||
Otherwise, coiteration is not allowed. | ||
*/ |
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 is great! However, I'd recommend Doxygen-style docstrings.
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.
Okay, I changed the docstring to this style: https://www.doxygen.nl/manual/docblocks.html. Not as familiar w/ Doxygen, so lmk if you think I did anything wrong here.
Signed-off-by: Adam Li <[email protected]>
Notes from today's brief call: Let's take your example for instance: During initialization of the Coiterate, we would be able to know what levels are ordered during compile-time since these are properties of the levels. So say Say For storing what levels are formatted: have a constexpr function with tuple of levels input that spits out a tuple of true/false indicating ordered/unordered elements in For dereferencing: Have to modify the algorithm to only return the PKs for the ordered ones and then locate into all unordered levels. |
Signed-off-by: Adam Li <[email protected]>
@hameerabbasi quick few questions:
seems sensible, but upon further inspection does not work as I would want. |
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]>
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]>
Xref: co_iteration.hpp file
Nvm, we would just setup the iteration helpers for the |
Signed-off-by: Adam Li <[email protected]>
…le of ordered levels Signed-off-by: Adam Li <[email protected]>
@@ -30,6 +59,26 @@ namespace xsparse::level_capabilities | |||
} | |||
} | |||
|
|||
constexpr auto ordered_levels() const noexcept |
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.
@hameerabbasi and @bharath2438 does this look fine in your opinion to get tuple of booleans corresponding to ordered levels?
If so, my next step is to implement a function for checking whether or not an instantiation of Coiterate
satisfies the co-iteration criterion:
- all levels are ordered, or has_locate_v
- for levels that are unordered, check all True/False combinations as input to function
F
There is a total of 2**N combinations, where N is the number of unordered levels.
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.
Yes, looks fine. Is there any way to do away with decay_t
by passing in the right argument to std::apply
?
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.
I don't think so? What would "the right argument" to std::apply
be? We only have access to m_levelsTuple
and m_comparisonHelper
in this setting.
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.
IIRC, decay_t
is used for stripping off the reference (or const) from the type, so I was wondering if it was really necessary, or would std::make_tuple(decltype(levels)::LevelProperties::is_ordered...)
be sufficient.
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.
Ah I see, yeah I tried that before (and just now again), but the issue is that:
In file included from /Users/adam2392/Documents/xsparse/test/source/coiteration_test.cpp:17:
/Users/adam2392/Documents/xsparse/include/xsparse/level_capabilities/co_iteration.hpp:77:25: error: type 'decltype(levels)' (aka 'const xsparse::levels::dense<std::tuple<>, unsigned long, unsigned long> &') cannot be used prior to '::' because it has no members
decltype(levels)::LevelProperties::is_ordered...);
Signed-off-by: Adam Li <[email protected]>
Signed-off-by: Adam Li <[email protected]>
Some notes for discussion tomorrow: Perhaps it is my lack of knowledge/experience writing "compiler-time" functions vs "runtime" functions, but I think the next step is to essentially "filter" the So I would presume we need something like template recursion, kinda like this: https://godbolt.org. |
Ah so the issue I was discussing today about Currently for dense, compressed, offset, range and singleton, the
We want a similar design for hashed I think. I'm thinking of thus migrating the xsparse/include/xsparse/levels/hashed.hpp Line 51 in 9f47a2c
coordinate_iterate.hpp . How does that sound @hameerabbasi and @bharath2438?
|
Signed-off-by: Adam Li <[email protected]>
Actually, the main reason why We could however, move the helper code to |
Closed by #25 |
Closes: #20
Towards: #17
The CoIteration algorithm currently assumes all inputs are ordered. A hashed level format is unordered by definition, but we would like for it to work as is when one of the input levels is the "hashed" level.
Specifically, the coiteration works exactly as is, but if one of the levels is unordered, then will iterate through the other levels, and use
locate
into the hashed level. This will only work as expected during a conjunctive merge.Details
The unit-test currently highlights my current understanding of how the algorithm should be checked. Let me know if there are any issues you see?