Code Documentation 3.6
Social Network Visualizer
Loading...
Searching...
No Matches
thread_local_state.h File Reference

Per-thread state for the parallel SSSP source loop in DistanceEngine. More...

#include "engine/per_source_scratch.h"
#include <QVector>
#include <QtGlobal>
Include dependency graph for thread_local_state.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ThreadLocalState

Detailed Description

Per-thread state for the parallel SSSP source loop in DistanceEngine.

During Phase 2 parallelisation (QtConcurrent::blockingMap over source vertices), each worker thread owns one ThreadLocalState. It holds:

  • A PerSourceScratch (reused across all sources the thread processes).
  • Partial BC and SC accumulator arrays — intermediate vertices are shared across sources, so BC/SC are NOT written to GraphVertex directly inside the loop. Instead each thread accumulates into partialBC / partialSC, and a single-threaded reduction step at the end writes the totals to the vertex objects.
  • Running totals for graph-wide aggregates (distance sum, geodesics count, diameter, PC/SPC sums) that would otherwise require a mutex around every graph call.

Lifecycle: allocate(totalV) — called once per thread before the parallel loop (partialBC / partialSC are zeroed at allocation; pss is reset per source) Post-loop reduction reads totalDistanceSum, totalGeodesicsCount, maxDiameter, totalSumPC, totalSumSPC, partialBC[*], partialSC[*] and merges into graph state.