How to know if cpu supports unaligned memory accesses ?
Laurent Bourgès
bourges.laurent at gmail.com
Sat Apr 17 18:02:02 UTC 2021
Hi,
In the Marlin renderer & in other Unsafe use cases (pixel tile processing)
for java2d pipelines, I do use putInt()/putLong() primitives even if the
address is not aligned (to 4 or 8 bytes) to get faster processing of byte
buffer or arrays...
Is it possible in java (jdk internals) to query cpu capabilities like
endianness, unaligned support ?
For x86-64: unaligned ~ aligned, so it is not necessary to add padding in
the data layout and then it is better to have smaller buffers.
I would like write code like:
if (cpu_supports_unaligned) {
...
Use int/long to pack bytes...
} else {
Use byte (fallback)
}
Laurent
More information about the core-libs-dev
mailing list