Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand grid concepts to n dimensions #396

Merged
merged 11 commits into from
Jun 12, 2024

Conversation

serraramiro1
Copy link
Contributor

@serraramiro1 serraramiro1 commented Jun 4, 2024

Proposed changes

Adds support for N dimensional data structures in some grid types.
Partially addresses #341

Type of change

  • 🐛 Bugfix (change which fixes an issue)
  • 🚀 Feature (change which adds functionality)
  • 📚 Documentation (change which fixes or extends documentation)

💥 Breaking change! Explain why a non-backwards compatible change is necessary or remove this line entirely if not applicable.

Checklist

Put an x in the boxes that apply. This is simply a reminder of what we will require before merging your code.

  • Lint and unit tests (if any) pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All commits have been signed for DCO

@serraramiro1 serraramiro1 changed the title Ramiro/expand grid concepts to n dimensions Expand grid concepts to n dimensions Jun 4, 2024
Signed-off-by: Ramiro Serra <[email protected]>
@serraramiro1 serraramiro1 marked this pull request as ready for review June 5, 2024 16:02
@serraramiro1 serraramiro1 requested a review from hidmic June 5, 2024 16:20
@serraramiro1
Copy link
Contributor Author

@hidmic ready for a first pass. Still missing the benchmarking we talked about for the std::floor operation

@serraramiro1 serraramiro1 added enhancement New feature or request cpp Related to C++ code labels Jun 5, 2024
@serraramiro1
Copy link
Contributor Author

Raycasting benchmarking results:
BEFORE:

/ws/build/beluga/test/benchmark/benchmark_beluga --benchmark_filter=BM_RayCasting*
2024-06-05T16:58:41+00:00
Running /ws/build/beluga/test/benchmark/benchmark_beluga
Run on (16 X 4463 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x8)
  L1 Instruction 32 KiB (x8)
  L2 Unified 512 KiB (x8)
  L3 Unified 16384 KiB (x1)
Load Average: 0.64, 1.43, 1.22
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
------------------------------------------------------------------------------------------------------
Benchmark                                                            Time             CPU   Iterations
------------------------------------------------------------------------------------------------------
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/128                128 ns          128 ns      5265119 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/256                247 ns          247 ns      2836238 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/512                487 ns          487 ns      1447736 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/1024               970 ns          970 ns       717916 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/128                105 ns          105 ns      6756903 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/256                223 ns          223 ns      3169508 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/512                483 ns          483 ns      1471145 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/1024              1140 ns         1140 ns       628619 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/128                133 ns          133 ns      5314413 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/256                290 ns          289 ns      2454922 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/512                578 ns          578 ns      1212812 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/1024              1216 ns         1216 ns       575774 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>_BigO                0.11 NlgN       0.11 NlgN  Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>_RMS                   12 %            12 %     Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/128         116 ns          116 ns      6004666 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/256         205 ns          205 ns      3364014 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/512         387 ns          387 ns      1805948 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/1024        748 ns          748 ns       918389 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/128         116 ns          116 ns      5931622 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/256         237 ns          237 ns      2974539 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/512         453 ns          453 ns      1547181 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/1024        916 ns          916 ns       750888 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/128         116 ns          116 ns      6027575 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/256         248 ns          248 ns      2841370 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/512         478 ns          478 ns      1478262 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/1024        978 ns          977 ns       713467 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>_BigO         0.86 N          0.86 N     Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>_RMS            13 %            13 %     Horizontal
BM_RayCasting2d<BaselineGrid>/0/128                                170 ns          169 ns      4099756 Horizontal
BM_RayCasting2d<BaselineGrid>/0/256                                325 ns          325 ns      2155318 Horizontal
BM_RayCasting2d<BaselineGrid>/0/512                                629 ns          629 ns      1113598 Horizontal
BM_RayCasting2d<BaselineGrid>/0/1024                              1236 ns         1236 ns       567080 Horizontal
BM_RayCasting2d<BaselineGrid>/1/128                                171 ns          171 ns      4068096 Vertical
BM_RayCasting2d<BaselineGrid>/1/256                                326 ns          326 ns      2134319 Vertical
BM_RayCasting2d<BaselineGrid>/1/512                                639 ns          639 ns      1088590 Vertical
BM_RayCasting2d<BaselineGrid>/1/1024                              1385 ns         1385 ns       503818 Vertical
BM_RayCasting2d<BaselineGrid>/2/128                                202 ns          202 ns      3452096 Diagonal
BM_RayCasting2d<BaselineGrid>/2/256                                387 ns          386 ns      1813444 Diagonal
BM_RayCasting2d<BaselineGrid>/2/512                                756 ns          755 ns       909484 Diagonal
BM_RayCasting2d<BaselineGrid>/2/1024                              1485 ns         1484 ns       467665 Diagonal
BM_RayCasting2d<BaselineGrid>_BigO                                1.33 N          1.33 N     Horizontal
BM_RayCasting2d<BaselineGrid>_RMS                                   10 %             9 %     Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/128                         166 ns          166 ns      4199064 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/256                         314 ns          314 ns      2206226 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/512                         614 ns          614 ns      1110526 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/1024                       1210 ns         1210 ns       571440 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/1/128                         168 ns          168 ns      4148368 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/1/256                         319 ns          319 ns      2191651 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/1/512                         621 ns          621 ns      1098089 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/1/1024                       1293 ns         1293 ns       544885 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/2/128                         186 ns          186 ns      3746960 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>/2/256                         354 ns          354 ns      2008056 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>/2/512                         693 ns          693 ns      1000062 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>/2/1024                       1367 ns         1366 ns       514448 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>_BigO                         1.26 N          1.26 N     Horizontal
BM_RayCasting2d<StaticOccupancyGrid>_RMS                             6 %             6 %     Horizontal

AFTER:

/ws/build/beluga/test/benchmark/benchmark_beluga --benchmark_filter=BM_RayCasting*
2024-06-05T16:51:00+00:00
Running /ws/build/beluga/test/benchmark/benchmark_beluga
Run on (16 X 4463 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x8)
  L1 Instruction 32 KiB (x8)
  L2 Unified 512 KiB (x8)
  L3 Unified 16384 KiB (x1)
Load Average: 0.67, 0.96, 0.97
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
------------------------------------------------------------------------------------------------------
Benchmark                                                            Time             CPU   Iterations
------------------------------------------------------------------------------------------------------
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/128                130 ns          130 ns      5325143 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/256                248 ns          248 ns      2799482 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/512                487 ns          487 ns      1436251 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/0/1024               963 ns          963 ns       718293 Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/128                104 ns          104 ns      6609707 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/256                225 ns          225 ns      2991287 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/512                479 ns          479 ns      1456837 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/1/1024              1004 ns         1004 ns       677292 Vertical
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/128                130 ns          130 ns      5287251 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/256                289 ns          289 ns      2405722 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/512                562 ns          562 ns      1223773 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>/2/1024              1181 ns         1181 ns       607516 Diagonal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>_BigO                1.02 N          1.02 N     Horizontal
BM_RayCasting2d_BaselineRaycast<BaselineGrid>_RMS                   11 %            11 %     Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/128         112 ns          112 ns      6158191 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/256         203 ns          203 ns      3432731 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/512         383 ns          383 ns      1830013 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/0/1024        743 ns          743 ns       922079 Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/128         120 ns          120 ns      5730959 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/256         223 ns          223 ns      3028873 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/512         427 ns          427 ns      1381905 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/1/1024        888 ns          888 ns       758725 Vertical
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/128         114 ns          114 ns      6067103 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/256         241 ns          241 ns      2891901 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/512         471 ns          471 ns      1481508 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>/2/1024        975 ns          975 ns       696995 Diagonal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>_BigO         0.85 N          0.85 N     Horizontal
BM_RayCasting2d_BaselineRaycast<StaticOccupancyGrid>_RMS            13 %            13 %     Horizontal
BM_RayCasting2d<BaselineGrid>/0/128                                170 ns          170 ns      4081695 Horizontal
BM_RayCasting2d<BaselineGrid>/0/256                                320 ns          320 ns      2179661 Horizontal
BM_RayCasting2d<BaselineGrid>/0/512                                621 ns          621 ns      1101291 Horizontal
BM_RayCasting2d<BaselineGrid>/0/1024                              1224 ns         1224 ns       566991 Horizontal
BM_RayCasting2d<BaselineGrid>/1/128                                143 ns          143 ns      4849137 Vertical
BM_RayCasting2d<BaselineGrid>/1/256                                285 ns          285 ns      2499762 Vertical
BM_RayCasting2d<BaselineGrid>/1/512                                567 ns          567 ns      1182680 Vertical
BM_RayCasting2d<BaselineGrid>/1/1024                              1228 ns         1228 ns       551757 Vertical
BM_RayCasting2d<BaselineGrid>/2/128                                173 ns          173 ns      4021495 Diagonal
BM_RayCasting2d<BaselineGrid>/2/256                                325 ns          325 ns      2120534 Diagonal
BM_RayCasting2d<BaselineGrid>/2/512                                631 ns          631 ns      1087549 Diagonal
BM_RayCasting2d<BaselineGrid>/2/1024                              1287 ns         1287 ns       540009 Diagonal
BM_RayCasting2d<BaselineGrid>_BigO                                1.21 N          1.21 N     Horizontal
BM_RayCasting2d<BaselineGrid>_RMS                                    4 %             4 %     Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/128                         141 ns          141 ns      4953015 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/256                         263 ns          263 ns      2651616 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/512                         502 ns          502 ns      1342838 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/0/1024                        990 ns          990 ns       700428 Horizontal
BM_RayCasting2d<StaticOccupancyGrid>/1/128                         144 ns          144 ns      4771063 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/1/256                         276 ns          276 ns      2532897 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/1/512                         527 ns          527 ns      1289750 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/1/1024                       1130 ns         1130 ns       606373 Vertical
BM_RayCasting2d<StaticOccupancyGrid>/2/128                         171 ns          171 ns      4081638 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>/2/256                         324 ns          324 ns      2147395 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>/2/512                         631 ns          631 ns      1082137 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>/2/1024                       1256 ns         1256 ns       546671 Diagonal
BM_RayCasting2d<StaticOccupancyGrid>_BigO                         1.10 N          1.10 N     Horizontal
BM_RayCasting2d<StaticOccupancyGrid>_RMS                            12 %            12 %     Horizontal

@serraramiro1 serraramiro1 force-pushed the ramiro/expand-grid-concepts-to-n-dimensions branch from 625a6e4 to d787873 Compare June 5, 2024 17:07
Signed-off-by: Ramiro Serra <[email protected]>
Signed-off-by: Ramiro Serra <[email protected]>
serraramiro1 and others added 2 commits June 6, 2024 09:46
Co-authored-by: Michel Hidalgo <[email protected]>
Signed-off-by: serraramiro1 <[email protected]>
@serraramiro1 serraramiro1 requested a review from hidmic June 6, 2024 13:48
@serraramiro1
Copy link
Contributor Author

@glpuga Could you TAL and see if this might be harming performance in any way? We don't seem to experience regressions in the raycasting benchmark, but that might not be completely representative either.

How did you come up with the slowness of std::floor?

Copy link
Collaborator

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, pending @glpuga's reply.

Signed-off-by: Ramiro Serra <[email protected]>
@serraramiro1
Copy link
Contributor Author

flamegraph
Flamegraph is not showing any hot spot wrt the floor operation. We seem to be safe.

@hidmic Shall we proceed?

@serraramiro1 serraramiro1 requested a review from hidmic June 12, 2024 12:51
@hidmic
Copy link
Collaborator

hidmic commented Jun 12, 2024

@serraramiro1 what did we run to get this flame graph? A full example or a microbenchmark?

@serraramiro1
Copy link
Contributor Author

serraramiro1 commented Jun 12, 2024

@serraramiro1 what did we run to get this flame graph? A full example or a microbenchmark?

@hidmic I followed PROFILING.md instructions to generate this flamegraph

@serraramiro1 serraramiro1 merged commit 45c4e9c into main Jun 12, 2024
10 checks passed
@serraramiro1 serraramiro1 deleted the ramiro/expand-grid-concepts-to-n-dimensions branch June 12, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp Related to C++ code enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants