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
[Feature Request] Make lammps_extract_fix consistent with lammps_extract_compute for global arrays #4118
Comments
I understand that there are historic and performance reasons to return a copy of the data and there may be significant impact in performance if the function were to copy the whole vector/array from all CPUs in a parallel run, yet in the case for many fixes, such as histograms, the API user would implement the looping through the vector/array and call the API to gather all values anyway, adding overhead to allocate/free all values. |
@eltonfc The basic reason that extract_fix() returns global data (scalar, vector, array) differently than extract_compute() is However, I can see the utility for users to just make a single call to extract an entire global vector or array, similar to computes. How about if we enhanced the syntax for the function call, using the nrow and ncol args. If nrow = -1 for a global vector, then |
@sjplimp I have a more radical approach in mind. But that is difficult to describe here. We need to talk about this offline. |
That's a good solution, which doesn't break the API, which was something I was worried about.
That sounds, good. |
Summary
While
lammps_extract_compute
returns a pointer to a scalar, vector or array, consistent with theLMP_TYPE_*
argument given to it,lammps_extract_fix
always returns a pointer to a single value, which is inconsistent with the referenced data structure and withnthe behavior oflammps_extract_compute
.I propose making the behavior consistent by
lammps_extract_compute
returning a pointer to a [copy of a] data structure described by the Type constant.Detailed Description
The C API
lammps_extract_compute
function, when called with style constantLMP_STYLE_GLOBAL
returns a pointer to a scalar, a vector or an array, depending on the Type constant.On the other hand,
lammps_extract_fix
, when called with the same constants, returns a pointer to a single value, regardless whether it was called withLMP_TYPE_SCALAR
,LMP_TYPE_VECTOR
orLMP_TYPE_ARRAY
. This is done by copying the value and returning a pointer to it.Even though it is explictly warned in the documentation for the C interface and @akohlmey added that info to the Python API documentation, the behavior is inconsistent with
lammps_extract_compute
and with the underlying referenced data structure.Since
lammps_extract_fix
already allocates memory and returns the pointer to it, it may be possible to allocate memory for the whole fix data structure (vector, array) and return a pointer to it.Further Information, Files, and Links
This issue was discussed in the forums and this feature request suggested there.
Thank you!
The text was updated successfully, but these errors were encountered: