4 ms·
> A question I have wrt memory access for CSR: is the access pattern suboptimal still? While there is less pointer chasing, I believe you are not guaranteed for
by VHRanger 3y ago
> A question I have wrt memory access for CSR: is the access pattern suboptimal still? While there is less pointer chasing, I believe you are not guaranteed for the edge data of adjacent nodes to be adjacent in memory, thus there is still potential for many cache misses.
Yes, you still get cache misses, but much much fewer.
You can also lay the graph array order out to minimize cache misses. This is something I've been looking into, but haven't implemented personally.
For example, the Eytzinger layout makes binary search much faster than a sorted array order [1]. Similarly for graphs, depending on the usecase you have Reverse Cuthill-McKee:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.reverse_cuthill_mckee.html#scipy.sparse.csgraph.reverse_cuthill_mckee https://docs.scipy.org/doc/scipy/reference/generated/scipy.s...
You can also just embed the graph into 1d, then take the sorted (or Eytzinger) order of the 1d embedding values, which should minimize average traversal cache miss.
> Another open question is whether you can further compress the CSR representation. For float-based edge data I think quantization works well, and I believe you can further compress the ROW/COL indices (delta encoding for the former). Compression potentially helps here because you can fit more in cache and can shove more edges into the CPU.
Yes, that's fairly well studied.
[1] https://algorithmica.org/en/eytzinger https://algorithmica.org/en/eytzinger
- pgera 3y ago>You can also lay the graph array order out to minimize cache misses. This is something I've been looking into, but haven't implemented personally. The issue with RCM is that it only works for undirected graphs, from what I remember. I'm less familiar with GNNs, but if you are trying to optimize for arbitrary BFS type traversals, an easy trick is to just do a few traversals from random sources and average the results. This can be used to reorder the graph and works pretty well in practice.
- VHRanger 3y agoRight, RCM assumes a symmetric matrix. Doing something like a single pass of 1d embedding algos like GGVec [1] (note: I wrote the algo, but it's effectively just the GLoVe algo for general graphs) or ProNE (if you have enough RAM) are also very cheap computationally [1] https://github.com/VHRanger/nodevectors https://github.com/VHRanger/nodevectors