Git Product home page Git Product logo

Comments (4)

jcuda avatar jcuda commented on September 27, 2024

As proposed in https://forum.byte-welt.net/t/pointer-buffer-should-have-byteorder-little-endian/19508/3 , the implementation could be thread-safe and safe regarding the offsets by implementing it as

ByteBuffer byteBuffer = ((ByteBuffer)buffer).slice();
byteBuffer.limit(Math.toIntExact(byteOffset + byteSize));
byteBuffer.position(Math.toIntExact(byteOffset));

from jcuda.

blueberry avatar blueberry commented on September 27, 2024

It is probably worth considering that Nvidia (and AMD) GPUs are LITTLE_ENDIAN, so IMHO native should be the default.

from jcuda.

jcuda avatar jcuda commented on September 27, 2024

Using the nativeOrder() certainly makes sense. In fact, I occasionally stumbled over the (nowadays somewhat unusual) BIG_ENDIAN being the default, and wondered why they did this...

(This was an attempt to blame the Sun/Oracle people ;-) )

It would have made even more sense to do this right in the beginning, when the method was implemented. As mentioned above (and in the forum thread ), changing this now might be incompatible.

But although I'm always hesitant do do changes like this, here, it may be justified: Most users probably already did set the byte order manually. And they did this (or should have done this) because until now, the byte order of the returned buffer was not specified.

The advantage of specifying it now to be the nativeOrder() seems to outweigh the slight possibility of an incompatibiliy, especially when it's pointed out in the change log.

from jcuda.

almson avatar almson commented on September 27, 2024

BIG_ENDIAN is the default probably because it is the "network" byte order used by many protocols such as TCP/IP.

File I/O defaults to whatever is the system's code page, while NIO standardizes on BIG_ENDIAN. The JDK guys made the wrong choice both times :)

from jcuda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.