SciProgCentre/kmath

Inconsistent endianness on different KMath platforms

Closed this issue · 5 comments

In kmath-memory module, different platform implementations provide different endianness, so they can't be used for persistent serialization.

  1. JS - Big Endian.
  2. JVM - platform byte order.
  3. Native - Littel Endian.

The solution is to make all the memory implementations use Little Endian byte order, since Kotlin/Native can only use it.

It is a good question.

On JVM it always uses Big Endian, see allocate documentation. Why do you think that native uses Little Endian?

The Memory interface does not specify the layout of the memory, so the byte order could be different on different platforms. Actually, I was thinking about using Apache Arrow as an alternative memory representation for communication between platforms.

It is a good question.

On JVM it always uses Big Endian, see allocate documentation. Why do you think that native uses Little Endian?

Since it is documented
image

Indeed. This is from ByteArray native extensions. Still, I do not think that we need to change that. We can provide alternative platform-consistent memory.

Should be shipped within #432