[llvm-commits] Patch: SparseMultiSet

Michael Ilseman milseman at apple.com
Wed Jan 16 14:18:11 PST 2013


Looking at how the LeaderTable is used, it's not cleared frequently and it's pretty dense. I think the correct solution would be to change the DenseMap to be a std::vector and grow it as needed.

On Jan 16, 2013, at 2:08 PM, Michael Ilseman <milseman at apple.com> wrote:

> GVN's LeaderTable could possibly benefit, but it would need a growable key universe. I had reused the sparse array design from SparseSet, which did not allow a growable universe, but I think it should be possible to grow by adding a growUniverse() method. That would give you close to what's already here, but rather than have it be a hash table of numbers from 0...N pointing to lists (containing pointers), it would be a small array of indices into a vector in which all the lists (with indices rather than pointers) are inlined. It seems like you could net memory savings, and even have a configurable memory-to-lookup-speed tradeoff. Though, for uint_16, I would suspect lookup to be faster through the SparseMultiSet than a DenseMap. If you had less than 100% density, then you'd get even more memory savings.
> 
> If it seems that GVN could be sped up, or at least cleaned up, then I can certainly look into that further.
> 
> On Jan 16, 2013, at 1:49 PM, Owen Anderson <resistor at mac.com> wrote:
> 
>> FWIW,  this could also be useful for GVN's value table struct, which is currently a hashtable-to-linked-list.
>> 
>> --Owen
>> 
>> On Jan 16, 2013, at 10:39 AM, Michael Ilseman <milseman at apple.com> wrote:
>> 
>>> Attached is a patch introducing a new data structure, the SparseMultiSet, and changes to the MI scheduler to use it.
>>> 
>>> A SparseMultiSet adds multiset behavior to SparseSet, while retaining SparseSet's desirable properties. Essentially, SparseMultiSet provides multiset behavior by storing its dense data in doubly linked lists that are inlined into the dense vector. This allows it to provide good data locality as well as vector-like constant-time clear() and fast constant time find(), insert(), and erase(). It also allows SparseMultiSet to have a builtin recycler rather than keeping SparseSet's behavior of always swapping upon removal, which allows it to preserve more iterators. It's often a better alternative to a SparseSet of a growable container or vector-of-vector.
>>> 
>>> Unit tests included in patch.
>>> 
>>> <sparseMultiSet.patch>_______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list