library/fatter_sparse_bitset.m:
Add this version of fat_sparse_bitset.m, which stores *two* words
worth of bits in each cell, not one. This word would otherwise be unused,
because the Boehm-Demers-Weiser allocator rounds up requests for three
word cells to four.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of library modules.
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
library/tree_bitset.m:
Update the documentation of all these other bitset modules. Copy
the same basic introduction to all the relevant modules. Add documentation
of the differences to tree_bitset.m and fatter_sparse_bitset.m, with
a pointer in fat_sparse_bitset.m to fatter_sparse_bitset.m.
library/test_bitset.m:
Test the new module as well as the others.
tests/hard_coded/speedtest_bitset.m:
Extend the benchmarking of list_to_set operations to the new module.
To allow the benchmarking to be tough enough to be informative, comment
out the benchmarking of the old_list_to_set operations.
... by using the algorithm now in sparse_bitset.list_to_set.
Keep the old list_to_set algorithm around in both modules for a short while
to allow comparative benchmarking.
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
As above.
tests/hard_coded/speedtest_bitset.m:
A benchmark program to compare the old and new list_to_set algorithms,
both versus each other, and between sparse_bitset and fat_sparse_bitset.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Speed up the remove_leq and remove_gt operations by moving a
loop invariant computation, the conversion of the boundary item's index
into an <offset,bitposn> pair, out of the loop.
Eliminate some unnecessary differences between the two modules,
e.g. clear_bit being a predicate rather than a function.
library/test_bitset.m:
Add facilities to test the remove_leq and remove_gt operations
of sparse_bitset.m, fat_sparse_bitset.m, and tree_bitset.m
against the same operations on plain old set_ordlists.
Bring this module up to date by requiring set elements to be
members of the uenum typeclass, not the enum typeclass.
Make the test_bitset type a bespoke type.
library/tree_bitset.m:
Add predicate versions of the remove_leq and remove_gt operations
alongside the existing function versions, to allow the new code
in test_bitset.m to work the same way regardless of which bitset module
it is testing.
For uniformity with the other bitset modules, require set elements to be
members of the uenum typeclass, not the enum typeclass.
Change the other integers, such as level numbers, to be unsigned
as well, to avoid the need for casts.
NEWS:
Announce the new additions and changes.
tests/hard_coded/test_tree_bitset.{m,exp}:
Use those new facilities to test those operations, and add some
test sets designed for that purpose.
Add a comment about the limitations of this testing strategy.
tests/hard_coded/bitset_tester.m:
Delete this long-unused module. (It was the original basis of
the test_bitset.m module in the library directory, but it became unused
when test_tree_bitset.m switched to using that module a long time ago.)
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
Replace shifts by ints (most cast from uints) with shifts where
the number of bits to shift is specified as a uint.
NEWS:
Mention all the user-visible changes below.
library/enum.m:
Add the typeclass uenum, which is a version of the existing enum typeclass
that maps items to uints, not ints. It also uses a semidet predicate,
not a semidet function, to get back to the item from the uint.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Make these modules operate on uints, which means requiring the items
in the sets to be instances of uenum, not enum.
If a few places, improve loops by doing previously-repeated conversions
of [u]ints into <offset, bit-to-set> pairs just once.
library/counter.m:
Define ucounters, which allocate uints. Improve documentation.
library/digraph.m:
Change digraph_keys from ints to uints, since we put them into
sparse_bitsets.
library/int.m:
Make int an instance of the uenum typeclass. This can help users
who currently put ints into sparse_bitsets.
library/pprint.m:
Prettyprint sparse_bitsets as lists of uints.
library/term.m:
Make vars instances of uenum as well as enum.
library/uint.m:
Make uint an instance of the uenum typeclass.
Add the ubits_per_uint function, which allows some casts to be avoided.
compiler/make.deps_set.m:
Change the indexes we put into sparse_bitsets from ints to uints.
compiler/make.make_info.m:
Change the source of those indexes from ints to uints.
compiler/make.top_level.m:
compiler/make.util.m:
Conform to the changes above.
compiler/pre_quantification.m:
Change zones from ints to uints, since we put them into sparse_bitsets.
tests/hard_coded/int_uenum.{m,exp}:
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/valid/use_import_only_for_instance.m:
Update this extract from library/digraph.m the same way as
library/digraph.m itself.
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
Change the auxiliary functions of these modules into predicates,
since their main job is to update the bitset_elems data structure.
Make the converted predicates use state variable notation
where this is useful.
When an operation has two versions, a function and a predicate,
the predicate used to be implemented in terms of the function.
Switch this: implement the functions in terms of the predicates.
Use a consistent naming scheme for variables: ItemX for the things
stored in the sparse bitset; SetX for representing whole sparse bitsets,
and ElemsX for repreresenting bitset_elems.
Fix some minor problems in the comments describing the exported operations.
Note opportunities for improvement.
library/diet.m:
library/fat_sparse_bitset.m:
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
library/sparse_bitset.m:
library/tree_bitset.m:
Delete predicates and functions that have been marked as obsolete
since at least 2019.
Adjust documentation as required.
NEWS:
Announce the deletions.
In the Mercury standard library, every exported predicate or function
has (or at least *should* have) a comment that documents it, including
the meanings of its arguments. About 35-40% of these modules put `'s
(left and right quotes) around the names of the variable representing
those arguments. Some tried to do it consistently (though there were spots
with unquoted or half quoted names), while some did it only a few places.
This is inconsistent: we should either do it everywhere, or nowhere.
This diff makes it nowhere, because
- this is what the majority of the standard library modules do;
- this is what virtually all of the modules in the compiler, profiler,
deep_profiler etc directories do;
- typing all those quotes when adding new predicates in modules that
follow this convention is a pain in the ass; and because
- on many modern terminals, `' looks non-symmetrical and weird.
Likewise, the comment explaining a predicate often started with
% `predname(arguments)' returns ...
This diff deletes these quotes as well, since they add nothing useful.
This diff does leave in place quotes around code fragments, both terms
and goals, where this helps delineate the boundaries of that fragment.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Improve these modules in several ways.
Provide more detailed documentation for the main data structures
and for several predicates.
Give some internal predicates more meaningful names.
Make union_list and intersect_list merge four sets per pass instead of two,
and encode the pass's main invariant (that both the input and output lists
of sets are nonempty) in the types.
Provide distinct low_to_high and high_to_low versions of both fold_bits
and fold2_bits, in order to avoid having to make repeated switches
based on the direction.
Use predmode declarations when possible.
Use variable names in a more consistent manner.
Move initial det computations out of the conditions of if-then-elses.
Eliminate negated tests in the conditions of if-then-elses.
Use det_from_int where relevant.
Eliminate nil/cons switches where both arms do the same thing.
Eliminate unnecessary differences between the two modules.
library/diet.m:
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
library/test_bitset.m:
library/tree_bitset.m:
As above. Also, mark as obsolete the same predicates as were marked obsolete
in the other set modules recently.
compiler/mode_robdd.equiv_vars.m:
compiler/mode_robdd.implications.m:
compiler/mode_robdd.tfeirn.m:
library/robdd.m:
library/digraph.m:
Avoid using predicates that are now marked obsolete.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Add modes for folds with unique and mostly-unique accumulators.
library/diet.m:
Fix some formatting.
Estimated hours taken: 3
Branches: main
Avoid some redundant work during determinism analysis. This diff speeds up
tools/speedtest by just shy of 0.7%.
compiler/det_analysis.m:
Instead of (a) getting a list of procedures in the module and then
(b) classifying them into three categories, do both jobs at once.
This avoids some redundant traversals and map lookups, and avoids
the creation of an intermediate data structure.
compiler/instmap.m:
Instead of converting a set into a list and iterating over that list
to check that elements of the set have a given property, iterate over
the set elements directly.
Put the arguments of a predicate in a more logical order.
compiler/det_util.m:
Conform to the change in instmap.m.
compiler/set_of_var.m:
Provide the all_true predicate needed by det_util.
library/*set*.m:
In every module that implements sets, provide an all_true predicate.
NEWS:
Mention the new predicates in the library.
Estimated hours taken: 8
Branches: main
compiler/inst_match.m:
Instead of first testing whether an inst exists in a set
and then inserting it if does not, use a single predicate
that does both the membership test and the insertion (if
the membership test failed) in one pass.
This speeds up compilation of one version of the rcpsp_cpx
stress test by about 9%, with negligible effect on tools/speedtest.
Some cleanups that should have been committed before this diff follow.
Change the structure of many of the predicates in this module from
containing multiple clauses, to a single clause with an explicit
disjunction, which (where relevant) now gets a require_comple_switch
wrapper. In several cases, this change has shown that we were
missing code for handling some kinds of insts. For example, some
predicates handled free/0 but not free/1, even though there was
no reason for the difference. This diff fixes such oversights
in places where the right action seems obvious to me, and adds
XXXs in places where I see no obvious fix.
Rename several predicates and function symbols to avoid ambiguities.
Add some XXXs on potential problems.
library/*set*.m:
Implement this insert_new predicate for all the implementations
of sets we have. The code in each case is copied from the code
of insert, with code to return a set unchanged replaced with `fail'.
NEWS:
Mention the new predicates.
Estimated hours taken: 6
Branches: main
library/sparse_bitset.m:
Add the predicates and functions needed to allow this module
to replace tree_bitset.m in implementing the operations of
set_of_var.m.
Convert the module to call unexpected instead of error.
library/fat_sparse_bitset.m:
A new module. It is a copy of the updated version of sparse_bitset.m
modified to use fat lists instead of plain lists. This means that
instead of representations such as
[bitset_elem(Offset1, Bits1), bitset_elem(Offset2, Bits2)]
it has representations such as
node(Offset1, Bits1, node(Offset2, Bits2, empty))
These have half the number of nodes and thus half the number of
allocations. In theory, they could also need only 75% of the space
(one three-word cell instead of two two-word cells), but the Boehm
collector rounds up three words to four.
library/library.m:
Add the new module.