-
Notifications
You must be signed in to change notification settings - Fork 161
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
Add Flip/SetAll/ClearAllBlist #3385
Conversation
caaa42c
to
a5035b6
Compare
The kernel documentation for blister.c says that if there are unused bits in the last word they will be set to zero. This is required for blists to work properly. This means handling the last word in flip and set will require a special case. |
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.
These new functions don't really fit into the existing blist interface at all: Just look at chapter 22 of the manual, and what functions there, and compare this with what's added in this PR: The PR exposes (already in the names of the functions) a view of blists as "lists of bits", while the rest of the documentation (and names) expose them as "list of booleans".
Thus, when regarding blists as per the documentation, the new function names make little sense. I guess ClearAllBitsBlist
could be renamed to SetAllEntriesToTrue
, but that would still be a rather odd function, if you think about it (at least I can't think of any similar function for other list types). The function IMHO only makes sense when one is thinking about these things in terms of bitfields. And even then: a bitfield would usually always have a size which is a multiple of 8, but more likely of 32 or 64 on modern machines (and the actual, buggy implementation in this PR, suggests to me that this is also how @james-d-mitchell is thinking about them).
I'd be somewhat less confused by a function SetBlistEntries(blist, num, bool)
which sets num
many entries of blist
to the value given in bool
. It'd still be somewhat odd, but at least would not be completely against the grain.
That said, I never liked the whole blist API. It seems to artificially cram bitfields into a GAP "list" API, but the abstraction is leaky and creaky all over the place; and we get weird functions like IntersectionBlist
which has nothing to do with Intersection
, but rather is a way to hide that we really want to do an "and" operation on a bitfield. The worst of them all is SizeBlist
, IMHO.
Out of scope, but: Personally, what I'd really want, but probably will never get, is an actual "proper" bitfield type, which standard terminology, and always has an internal size which is a multiple of 8 or 64; and possibly even has a variant with static size. It could even internally share most of the code with blists.
Just to clarify: in general I support the idea of adding functions with the functionality described here. What I am objecting is putting "bits" into the function names; the names should "fit" with the existing blist API. |
As I said in my original PR I'm not particularly attached to the names, any specific suggestions? |
a5035b6
to
3eef771
Compare
I don't really agree with your comments @fingolfin regarding the "fit" of these functions, but I do agree that the names don't fit. I don't have the time to argue the point, nor do I think it will serve any purpose to do so. I've updated the PR to:
I would find these 3 functions useful, which is why I made this PR, if you decide that you don't want them in GAP, then that's ok with me, please feel free to close this PR. |
3eef771
to
fdca979
Compare
Codecov Report
@@ Coverage Diff @@
## master #3385 +/- ##
==========================================
- Coverage 85.16% 85.15% -0.01%
==========================================
Files 697 697
Lines 344056 344109 +53
==========================================
+ Hits 293003 293035 +32
- Misses 51053 51074 +21
|
I wrote some more tests, I have cut+pasted them here, as that's probably the easiest way to send them to you. These currently crash. The problem is lists of length 0.
|
Thanks @ChrisJefferson, I didn't account for the list of length 0 case. I don't think your tests are valid though, you flip |
Woops, yes, you are right :) That's what I was aiming for (I'm using the fact that I know that = compares the whole block of memory, to check we set/clear bits off the end correctly). |
fdca979
to
e3abb50
Compare
I've updated the PR to handle the 0 length blist case, and to add @ChrisJefferson tests. |
I'm going to close this because there are no comments, or further requests for changes in the past 7 days. |
Obviously, you can shut the PR (I won't force reopen it), but I did generally like the work. All my issues with it were fixed, but I know some other people had issues so I was waiting to see if they commented. If you reopen, I'll accept the PR and we can merge it (unless of course someone does still have an issue). |
I got the impression that this isn't a desirable feature in the end, I'll re-open if I got the wrong impression. If it's not though, I'll move it into one of our packages, rather than leaving it as an open PR for longer. |
The only person to say anything particularly critical was @fingolfin, and even then his clarification:
was pretty clear to me. I had the impression that this would be merged, so I think you've got the wrong impression. I know it's annoying to make changes and wait a week and hear nothing, but that's the nature of GAP, where most contributors have to fit their work on GAP around (usually) much more pressing work issues. |
@wilfwilson, I am not annoyed by waiting, nor by anything @fingolfin or @ChrisJefferson wrote. @fingolfin's first and second comments seem contradictory to me, so I wasn't sure what to think. |
Fair enough, glad you weren't annoyed. @fingolfin has started at a new university this week, so it might be a bit longer before he'll comment further on this, if he intends to. I'll reopen it to give it some more time for comments, I hope you don't mind. In particular I'll most likely give it an 'Approving' review, if and when I have time 🙂 |
I was indeed (and still am) super busy with the new job, where I also had to start teaching on the very first day, organize furniture, deal with tons of bureaucracy and more. And just to put things in perspective: I have plenty of examples where a PR of mine got no review at all for more than a month. Of course that's not ideal, but this is just what happens if all contributors essentially only can work on GAP as a side job. As such I am grateful that recently some more people started to help with reviews; before that, in the past year or so, it was mostly Chris and me who took care of the bulk of reviews. |
As to this:
I am not sure what to make of that: my second comment specifically stated that it was meant to clarify the first comment, in that I pointed out that I was objecting to the fit of the names, not the fit of functions (which I had indeed phrased a bit carelessly in my initial comment). So, to me, it's pretty clear that the second comment clarifies and hence supersedes the first. I really don't know how to make it more clear. |
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.
Looks good to me overall, though I have a small change request regarding whitespace.
src/blister.c
Outdated
|
||
UInt * ptr = BLOCKS_BLIST(list); | ||
for (UInt i = NUMBER_BLOCKS_BLIST(list); 0 < i; i--) { | ||
*ptr++ = (UInt)~0; |
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.
Very strictly and pedantically speaking, (UInt)~0
(also elsewhere in this PR) should be ~(UInt)0
for full portability, although I assume all machines built today and probably also in the future will be using two's complement, so it probably doesn't matter... (some of the code in this file also uses ~0UL
).
Anyway, I won't complain if this is left as-is, we probably rely on two's complement elsewhere anyway shrug
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.
Happy to change this also
It wasn't clear to me if the names changes were what you were aiming at, or if you would only accept a version of the method along the lines of the |
On this topic: At the GAP days in Halle, a group of us spoke about ways that we could manage issues and PRs more effectively. The aim was to make the job easier for those who review PRs and attempt to solve issues, rather than adding hoops for PR/issue creators to jump through. I've been writing up something about this to help contributors, but I'm not finished yet. The main thrust is to use labels more effectively, which seems to be going well in my opinion. There's no particular aim to close issues or PRs (beyond actually resolving them/merging them in the proper way), however we have introduced a small measure along these lines: Since #3366 was merged, issues/PRs that are given the label (In particular, it wouldn't apply in cases like this PR, where although nothing happened for a period of time, it wasn't because of a lack of information). |
Sorry to kick up one more problem! This isn't checking the blists are mutable. You could either fix this with some code a bit like:
Or, wait until (hopefully) #3391 is merged, at which point you will be able to write:
|
@ChrisJefferson good catch on the mutability -- but to be fair, most other functions in this file also lack this :-/, e.g. Here one of the instances of this bug in live action:
|
I agree, ignire the mutablely issue, we will do a general cleanup later. |
Just for clarity, I'm happy to merge this as soon as @james-d-mitchell tells me he's made any final changes he wants to make (no rush, and no requirement for changes, that's just why I'm not pressing merge now) |
e3abb50
to
eda9f39
Compare
I believe I've addressed all of the issues (except the mutability one), please let me know if there is anything else. |
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.
Looks great to me now, thank you! Once tests have completed, we can merge this. I'll then update my PR, which also adds the mutability checks.
Thanks @wilfwilson, @fingolfin and @ChrisJefferson for the comments, and apologies for the confusion! |
This PRs adds three functions for blists,
FlipBlist
,SetAllBitsBlist
, andClearAllBitsBlist
. I found that I wanted these three functions in various pieces of code, and so I thought I'd add them. I'm not particularly attached to these particular names.