Skip to content

Generalize GenerateGhosts for Periodic<Hypercuboid<_>> on N#338

Draft
janbridley wants to merge 8 commits into
trunkfrom
feat/generalize-hypercuboid-ghosts
Draft

Generalize GenerateGhosts for Periodic<Hypercuboid<_>> on N#338
janbridley wants to merge 8 commits into
trunkfrom
feat/generalize-hypercuboid-ghosts

Conversation

@janbridley

@janbridley janbridley commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

Previous code used a fixed list of checks for N=2 and 3 when generating ghosts across a periodic cubic boundary. This change builds up the required list of checks for general dimension, using a bitset to avoid keeping too much data in memory. The result is comparable performance to the original code, but a dimension-agnostic approach. HOWEVER: this changes the ordering of neighbors, which does not appear to have performance or correctness implications but I could be wrong on that.

Motivation and context

HOOMD_MAX_GHOSTS=1 (N match: 1d)
Timer precision: 41 ns
cuboid             fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ trait_method                  │               │               │               │         │
   ├─ corner_1d    1.592 ns      │ 1.928 ns      │ 1.612 ns      │ 1.64 ns       │ 100     │ 409600
   ╰─ interior_1d  0.951 ns      │ 4.664 ns      │ 1.002 ns      │ 1.076 ns      │ 100     │ 409600


HOOMD_MAX_GHOSTS=3 (N match: 2d)
Timer precision: 41 ns
cuboid             fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ specific                      │               │               │               │         │
│  ├─ corner_2d    4.793 ns      │ 25.3 ns       │ 4.875 ns      │ 5.245 ns      │ 100     │ 102400
│  ╰─ interior_2d  3.227 ns      │ 3.695 ns      │ 3.349 ns      │ 3.37 ns       │ 100     │ 204800
╰─ trait_method                  │               │               │               │         │
   ├─ corner_2d    4 ns          │ 4.549 ns      │ 4.142 ns      │ 4.148 ns      │ 100     │ 204800
   ╰─ interior_2d  2.515 ns      │ 3.309 ns      │ 2.616 ns      │ 2.626 ns      │ 100     │ 204800


HOOMD_MAX_GHOSTS=7 (N match: 3d)
Timer precision: 41 ns
cuboid             fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ specific                      │               │               │               │         │
│  ├─ corner_3d    12.2 ns       │ 13.58 ns      │ 12.69 ns      │ 12.7 ns       │ 100     │ 51200
│  ╰─ interior_3d  7.565 ns      │ 8.704 ns      │ 7.891 ns      │ 7.898 ns      │ 100     │ 51200
╰─ trait_method                  │               │               │               │         │
   ├─ corner_3d    40.67 ns      │ 14.62 µs      │ 40.67 ns      │ 187.2 ns      │ 100     │ 100
   ╰─ interior_3d  7.564 ns      │ 10.08 ns      │ 7.971 ns      │ 7.982 ns      │ 100     │ 102400



HOOMD_MAX_GHOSTS=15 (N match: 4d)
Timer precision: 41 ns
cuboid             fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ trait_method                  │               │               │               │         │
   ├─ corner_4d    31.41 ns      │ 38.08 ns      │ 32.71 ns      │ 32.7 ns       │ 100     │ 25600
   ╰─ interior_4d  16.84 ns      │ 19.2 ns       │ 17.41 ns      │ 17.47 ns      │ 100     │ 51200


HOOMD_MAX_GHOSTS=31 (N match: 5d)
Timer precision: 41 ns
cuboid             fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ trait_method                  │               │               │               │         │
   ├─ corner_5d    62.18 ns      │ 77.8 ns       │ 64.77 ns      │ 64.97 ns      │ 100     │ 6400
   ╰─ interior_5d  42.97 ns      │ 53.39 ns      │ 43.62 ns      │ 43.84 ns      │ 100     │ 12800



How has this been tested?

Regression tests against the old code

Checklist:

  • I have reviewed the Contributor Guidelines.
  • I agree with the terms of the hoomd-rs Contributor Agreement.
  • My name is on the list of contributors (doc/src/credits.md) in the pull request source branch.
  • I have summarized these changes in release-notes.md following the established format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant