Repository navigation
Closed
Description
22cf13b was left out of TravelMapping#404 because while it's easier on the CPU, it needs more RAM bandwidth. Above ~7 threads, this becomes a bottleneck, and this alternative performs worse.
This solution avoids the pointer-chasing, and allocates far less memory, all in one block.
After calling all_waypoints.graph_points, we know how many vertices there will be. This will come in handy.
-
char* vbitfield = new char[ceil(hi_priority_points.size()+lo_priority_points.size()/8)*args::numthreads];
Organize it so as to keep all of each thread's bits contiguous. - Reserve this much space in the
HighwayGraph::verticesvector -- or just use a C array?
The address of each HGVertex minus the start of the array forms the basis of the index intovbitfield. - Default constructed. Change the existing ctor to a setup function for existing objects.
-
HighwayGraph::simplifyprototype will need aconst size_t offset. - Nix sublists;
offset+wwill be the index into theverticesarray for in-place setup.
- Similar trick (using ints, not bits) may let us get rid of
HGVertex::foo_vertex_num
This gets its own rabbit hole
If this works well,
- the concept may be adaptable to TravelerLists. Nix
traveler_num.
Err... I probably meantin_subgraph(t4 /a5d4b2d), but hey, try that too!in_subgraphnixed in 634da8b.traveler_numwill be at TMBitset leftovers #252.
- Edges are another matter. They're not stored in contiguous memory, and really kinda can't be. Getting a bitfield index = messy and/or expensive.
Activity
yakra commentedon Mar 24, 2022
yakra commentedon Mar 25, 2022
yakra commentedon Mar 25, 2022
yakra commentedon Mar 27, 2022
Results are... hmm.
Some thoughts upon digesting BiggaTomato's data, with lab1 & lab2's fresh in...
Subgraph performance is slower.
Not better because...?
vbitsis that the whole thing can fit in cache, with the same bytes accessed multiple times.Sure, this is still allocating less than the existing method, because no pointers from each
HGVertex. But still.Actually worse because...?
v...•
v->unique_namejust before first assigning numbers• in the case of the master graph,
v.incident_*_edgesintrefs is comparable to subgraph membership functions introduced per the OP. We have an added call tovertices.size()but lose a couple bitwise operators. That may cost more than one dereference and a quick array index._7g/_7gs: Is it dereferencingginfoo_tmg_line? What ifgwere passed as a reference? Shouldn't the compiler optimize this stuff away? 🤣 This does compile differently.There are construction/destruction gains, but...
They fail to offset the hit to subgraphs on BiggaTomato, and only barely do so on lab1 & lab2. Most likely a loss overall, as:
This leads to...
A better solution?
_8/_8s: Allocate just one array per vertex:vnums= new int[3*Args::numthreads]Sequential locality?
_7s/_7gs/_8s: This can be applied to either solution. Will it do anything?Seems an unclear winner fr higher-cache machines.
TravelerListelements, then come back to this.check10.sh -vHighwayGraph::clear()to its own thread. Meh, may need to measure effects on datacheckfps?yakra commentedon Apr 7, 2022
manual "rebase"
All changes were either implemented in the linked commits or made unnecessary by other commits in the meantime.
8f28a2c contiguous vertices
cc9da66 vbits
6c97b69 faster PlaceRadius vertex search
cc9da66 subgraph vertex bit field
cc9da66 (redone via a
switch)cc9da66 v2 (bugfix in ec6238e)
cc9da66 v2
33183f2
V1-> V0cc9da66 v2
8f28a2c v1
8f28a2c v1
12beccd
cc9da66 v2
t1 branchless nibbleDrop. Less efficient.8f28a2c v1
8f28a2c v1
12beccd
cc9da66 v2
cc9da66 v2
f0d618a
9dcf0a5 #include in TravelerList.h
d5d8c03 compute stats_t: std::unordered_map::operator[]
af9d017 TMArray
Done in 634da8b, much differently. Instead of the HGVertex-style iterate-check-add approach,
|=s together loads of TMBitsets instead.The only similarity is the removal of
TravelerList::in_subgraph.As of this writing our
TMBitset<TravelerList*,uint32_t>s allocate 48 B. If they're magically allocated in adjacent memory that could be a 2/3 cache line overlap. But I'm not convinced this is a problem; it performs well in Linux. FreeBSD has to have something else going on. It seems to have memory bandwidth issues in a few areas; this is just siteupdate's most extreme manifestation of them. Continue to pursue solutions targeting memory locality,HGEdgealignment & size, cache hits, etc.v7 & v8 have their own issue now.
Yes. Outperforms t2 a majority of the time on BT, lab1 & lab2.
OTOH, on lab5, only outperforms t2 @ 8 threads.
Be interesting to see how this scales on lab4.
Slight lead on lab2. Other machines appear slightly slower, but may just be noise. Shouldn't do any harm.
HighwaySegment::clinched_byto a bit field #221Bring in changes from
e7d8dda(fcg full custom graphs branch):HighwayGraphobject; slim down graph_generation.cppor a new
add_triooradd_groupfunction, whatever's clever.yakra commentedon Apr 20, 2022
yakra commentedon Jul 16, 2023
Updated comments above & added links.
Everything is either:
TMBitset<TravelerList*>) or