Single Precision Support - #458
Conversation
Control for pip builds from env var.
And annotate harder issues in AoS.
SP has some detailed padding before `idcpu` and at the end of each particle, if they do not align with the size of `double`.
Importing into pandas does not support binary fields, but there is no quick way to remove them.
| # print('particle 2 from aos:\n',aos[1]) | ||
| # print('array interface\n', aos.__array_interface__) | ||
| arr = aos.to_numpy() | ||
| int_arg = 7 if arr[0][0].dtype == "float32" else 6 # padding |
There was a problem hiding this comment.
Is this something that users will have to know, that there might be this extra padding element so the indices for the integers might be shifted?
There was a problem hiding this comment.
I fear so... I have not found a way to kick out numpy struct elements (in the SP case: the paddings) without doing a copy yet.
That said, nobody should use AoS anymore in AMReX. I am inclined to drop all support for it in pyAMReX to stop wasting time :)
| }/* | ||
| if constexpr (ParticleType::NInt % 2 != 0) { // alignas | ||
| descr.append(py::make_tuple("", "|V4")); // empty space due to alignment | ||
| }*/ |
There was a problem hiding this comment.
Adding this end-of-particle padding after the int (32bit) array fails both the double precision tests o.0
|
There seems to be a follow-up issue in SP in ImpactX (which uses pure SoA particle layout) for Note the PR here just works around AoS stuff (legacy). |
For AoS and SoA `.to_numpy()` and dependent logic like `.to_df()`, the lifetime of the temporary copied variable is only handled by NumPy if we first create a named variable. The `to_host()` returned object is a temporary, and `np.array` using the `__array_interface__` protocol does not keep it alive automatically unless it is stored in an actual variable (eg., `tmp`). X-ref: - conda-forge/impactx-feedstock#56 (comment) - #458 (comment)
setup.pyAs a follow-up, one could add support for SP
.to_df()by removing binary columns (members) from the AoS before passing it into Pandas. But this legacy layout is not our need or focus, nor worth spending more time on.