-
Notifications
You must be signed in to change notification settings - Fork 15
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
Field alignment problem in struct? #137
Comments
In general we don't zero buffers. If a type leaves some bytes not declared, it should be expected that this portion of the data can contain random bytes. Where do we use bit wise identity? |
I don't think we ever do it in production code, the error I saw happens in the test xtrack/tests/test_elements.py::test_constructors. I circumvented the problem by using a I mean you're right bitwise comparison is not the right way of checking the structs are the same if we allow them to be a non-contiguous type. However, in that test we assert the memory layout since we test json dumping, so we don't have much else to go of off. Do you think zeroing the padding by default (on OpenCL, since the rest seem to be doing it already) would be a significant overhead? |
Do you mean initialize the opencl buffer with zeros? I don't it will cost much. |
I defined a Quadrupole element with some
uint8
fields (see https://github.com/xsuite/xtrack/blob/e7ac347130b09ae1208061ba34b58e5e6d62f19f/xtrack/beam_elements/elements.py#L1194) andxtrack/tests/test_elements.py::test_constructors
fails when dumping and reloading the xobject (on OpenCL).From inspecting the buffers all the meaningful data seems to actually be in the right place (bytes at 144 and 152 are zero). However, it's not clear to me if this is by chance (and we have an alignment problem) or if it's simply the fact that the buffer is not being zeroed by default on OpenCL (then we have less of a problem but we cannot assume anymore that two identical xobjects are bitwise equal).
This is the exact difference and layout:
The text was updated successfully, but these errors were encountered: