Files
263-0007-00L-Advanced-Syste…/docs/optimization_symmetry.md
T
salijagic ef67c7e5c0 Ilp
2026-05-21 19:09:24 +02:00

3.2 KiB

Optimization: Inlining

  • Author: Smail
  • Predecessor: variant_inlining_7_symmetry_1.cpp
  • File(s): variants/variant_inlining_7_symmetry_2.cpp
  • Status: TBA

What this changes

Instead of calculating the distance and norm vector between two pedestrians everytime, we created a LUT that only calculates the distances once and r_a_b_norm (with expensive sqrt flop dx, dy, norm). The forces are somewhat symmetric, however it would still require a lot of calculations, maybe this second symmetry optimization can be done at a later stage.

When i > j we need the opposite vector which is curr * -1.

Code (relevant snippet)

TBD - see variants/variant_inlining_7_symmetry_1.cpp for the final version, and the individual file headers for the incremental steps.

Benchmark

Conditions: single run (TODO: switch to min-of-N), N_ITER=1000, -O3 -march=native -flto. Predecessor reference for the same config is the baseline row.

x86

Machine:

Processors: 16 x AMD Ryzen AI 7 350 w/ Radeon 860M
Memory: 32 GiB of RAM (30.6 GiB usable)
Graphics Processor: AMD Radeon 860M Graphics
Manufacturer: LENOVO
Product Name: 83HX
System Version: IdeaPad Slim 5 14AKP10

Frequency: 2 GHz

Existing single-point measurement (N unspecified, kept from the previous OPTIMIZATIONS.md; W matches roughly N=120 at N_ITER=1000):

Variant W(n) [Flops] T(n) [Cycles] Performance [Flops/Cycle]
Baseline 1'058'400'000.00 850'352'900.00 1.24
Inlining 1'058'400'000.00 756'088'260.00 1.40
Symmetry

Inlining is about 12.9% faster on this point. A full N sweep with min-of-3 is TODO.

Full sweep (TODO):

N W(n) [Flops] T(n) [Cycles] Performance [Flops/Cycle] Diff vs Predecessor
50
100
200
500
1000

ARM (Apple)

Machine:

TBD

Frequency: TBD

N W(n) [Flops] T(n) [Cycles] Performance [Flops/Cycle] Diff vs Predecessor
50
100
200
500
1000

Analysis

Speedup likely comes mainly from halving the number of sqrt flops.

Takeaway

TBD