Fix wrong output size in SplineC2ROMPTarget::mw_evaluateVGLandDetRatioGrads#4408
Conversation
Fix SplineC2R. When the requested size is smaller than what can be supplied, only output the requested size. What is the right way of selecting a subset of orbitals in an already built SplineC2R remains a big question. The trucation is subject to the sorting of orbitals in C2R which puts all the "complex" orbitals first. "complex" orbitals produce two real orbitals.
| offload_scratch_iw_ptr + spline_padded_size * 4 + first, | ||
| spline_padded_size, first, index); | ||
| const size_t first_cplx = first / 2; | ||
| const size_t last_cplx = omptarget::min(last / 2, orb_size); |
There was a problem hiding this comment.
The min() here is wrong. orb_size refers to output real orbitals.
| ValueType* restrict out_d2phi = out_dphi_z + phi_vgl_stride; | ||
|
|
||
| const size_t first_real = first_cplx + omptarget::min(nComplexBands_local, first_cplx); | ||
| const size_t last_real = last_cplx + omptarget::min(nComplexBands_local, last_cplx); |
There was a problem hiding this comment.
last_real can be larger than requested_orb_size and caused overflow.
|
Test this please |
prckent
left a comment
There was a problem hiding this comment.
Thanks Ye. We discussed this a bit last week, but so we have a record here: why didn't asan catch this?
Because we don't have a test case exposing this bug. The added test triggers asan failure when I backported it to develop. |
|
Test this please |
|
I also noticed that asan runs on the github actions without QMC_DATA. We probably need to update the image to include NiO a4(S1) and a16(S4) h5 files. |
Proposed changes
There is bug when using offload real build.
This caused writing to undesired memory locations and wrong numbers (crazy high variance/energy >>1)
What type(s) of changes does this code introduce?
Does this introduce a breaking change?
What systems has this change been tested on?
epyc-server
Checklist