Commit 6c3b985
fix(api_cc): size remapped atomic parameters by stride (#5790)
## Summary
- allocate remapped atomic-parameter buffers for every frame, retained
atom, and daparam component;
- keep the allocation count aligned with the stride passed to
select_map;
- add typed C++ regressions for float and double, two frames, local and
ghost virtual atoms, and both local-only and all-atom aparam layouts.
## Impact
The previous allocation omitted the daparam factor. For models with
dim_aparam greater than one, select_map wrote more scalar components
than the vector contained, causing undefined behavior and potential heap
memory corruption in shared neighbor-list API paths.
## Why existing tests missed this
Existing multiframe and neighbor-list API tests use models whose daparam
is one. The aparam_nall=true fixtures also use one component per atom,
so the missing multiplier was numerically hidden.
The new direct helper tests exercise the exact missing combination:
daparam=2 with virtual-atom remapping, multiple frames, local
parameters, and local-plus-ghost parameters.
## Validation
- backend-neutral C++ unit-test target compiled and linked successfully;
- TestSelectMap typed suite: 12 passed;
- the four new cases fail with the pre-fix allocation and pass with the
corrected size;
- clang-format applied to changed C++ files;
- ruff format .;
- ruff check .;
- git diff --check.
Closes #5618.
Coding agent: Codex
Codex version: codex-cli 0.144.1
Model: gpt-5.6-sol
Reasoning effort: xhigh
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Fixed handling of multi-component atom parameters when filtering
virtual atoms.
* Ensured remapped parameter data maintains the correct size and values
for local and ghost atoms.
* **Tests**
* Added coverage for multi-frame data and virtual-atom filtering
scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: njzjz-bot <njzjz-bot@users.noreply.github.com>1 parent e4acf98 commit 6c3b985
2 files changed
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
192 | 195 | | |
193 | 196 | | |
194 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
0 commit comments