Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #147296
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Bit field usage |
| Date | 2019-10-27 22:30 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <qp529j$eep$1@dont-email.me> (permalink) |
| References | (4 earlier) <0o49re9320b1b05s7v5l6tc4h6cionhnr7@4ax.com> <qp289j$b8j$1@dont-email.me> <cab3c91e-05d9-4b68-a9f9-5748b4c6d532@googlegroups.com> <qp40s8$pvs$1@dont-email.me> <95febac6-81a6-490b-9197-36c3b1ae5811@googlegroups.com> |
On 27/10/2019 15:19, already5chosen@yahoo.com wrote: > On Sunday, October 27, 2019 at 2:00:17 PM UTC+2, David Brown wrote: >> On 27/10/2019 11:46, already5chosen@yahoo.com wrote: >>> On Saturday, October 26, 2019 at 10:54:34 PM UTC+3, jacobnavia >>> wrote: >>>> Le 26/10/2019 à 20:41, Robert Wessel a écrit : >>>>> That is not true of all 64-bit implementations, of course. >>>>> Consider MSVC invoked with /Zp1. Of course it's true of >>>>> many implementations. >>>> >>>> Yes, packing fields would be possible in processors like the >>>> x86. It is not possible in RISC processors where alignment is >>>> much stricter. >>> >>> There are only 2 high-performance RISCs that are still relevant >>> for new development: ARM/ARM64 and POWER. ARM has no alignment >>> requirements on the integer side of the ISA. The same for Power >>> in Big Endian mode. As far as I remember, Power operating in >>> Little Endian mode used to have alignment requirements, but it >>> seems that since Power8 they have "pure little-endian" mode that >>> removes these limitations. >>> >> >> There are many, many other RISC ISA's that are in heavy use - the >> world does /not/ revolve around the fastest cores. And for lots of >> ISA's, alignment is strict. >> >> Even for ISA's that sometimes allow unaligned access, it can often >> depend on the implementation. Some ARM core implementations >> support unaligned access, others do not, others support it only for >> certain instructions. > > IIRC, under ARMv7 or later support for unaligned accesses is > mandatory. Of course, only for "normal' memory, I/O is different and > implementation-dependent, as it should be. > >> The same applies to PPC (I don't know the details of Power). >> Almost all ISA's (including x86) fail on unaligned access for >> certain kinds of accesses - typically atomic or lock instructions, >> vector instructions, load/store multiple instructions, etc. And >> for many devices, unaligned access can be very much slower than >> aligned access. > > Atomics can't remain atomic, that's obvious. They don't have to fail, > but as long as they don't do what they are intended to do it's of > little importance. As to vectors, the trend here is certainly toward > relaxation or removal of alignment restrictions. > I don't believe there is any such trend towards removing or relaxing alignment restrictions. I can't claim to have followed cpu details closely enough to be confident in that belief, but I certainly don't see any benefit in having that trend. There are rarely any advantages in having non-aligned data, and you usually have to go out of your way to create it in the first place (often invoking undefined behaviour) - while there are good hardware efficiency reasons for wanting alignment. For vector instructions, it is not always clear what is meant by "aligned" access. If you have a vector of 4 4-byte integers, for example, it can be convenient for the programmer if the alignment requirements are 4 byte alignment rather than 16 byte alignment. But there is little to be gained for the programmer by allowing 1 byte alignment access. It seems to me that regardless of whether or not a particular cpu implementation supports unaligned access or not, that it is almost always best to stick to the alignment specified by the ABI and handled automatically by the compiler.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-24 08:03 +0200
Re: Bit field usage Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-10-24 10:15 -0600
Re: Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-24 18:55 +0200
Re: Bit field usage Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-10-24 21:28 -0600
Re: Bit field usage scott@slp53.sl.home (Scott Lurndal) - 2019-10-24 17:22 +0000
Re: Bit field usage Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-24 19:45 +0200
Re: Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-24 19:59 +0200
Re: Bit field usage Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-24 20:02 +0200
Re: Bit field usage Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-10-24 21:29 -0600
Re: Bit field usage Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-25 07:51 +0200
Re: Bit field usage scott@slp53.sl.home (Scott Lurndal) - 2019-10-25 15:05 +0000
Re: Bit field usage Bart <bc@freeuk.com> - 2019-10-24 19:13 +0100
Re: Bit field usage Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-24 20:54 +0200
Re: Bit field usage Bart <bc@freeuk.com> - 2019-10-24 20:12 +0100
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-10-24 23:03 +0200
Re: Bit field usage Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-10-24 22:50 +0100
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-10-25 09:18 +0200
Re: Bit field usage Reinhardt Behm <rbehm@hushmail.com> - 2019-10-25 15:46 +0800
Re: Bit field usage Robert Wessel <robertwessel2@yahoo.com> - 2019-10-26 12:36 -0500
Re: Bit field usage scott@slp53.sl.home (Scott Lurndal) - 2019-10-25 15:04 +0000
Re: Bit field usage Robert Wessel <robertwessel2@yahoo.com> - 2019-10-26 12:40 -0500
Re: Bit field usage Philipp Klaus Krause <pkk@spth.de> - 2019-10-26 21:12 +0200
Re: Bit field usage Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-10-25 09:25 -0600
Re: Bit field usage Robert Wessel <robertwessel2@yahoo.com> - 2019-10-26 12:52 -0500
Re: Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-24 19:56 +0200
Re: Bit field usage already5chosen@yahoo.com - 2019-10-24 12:03 -0700
Re: Bit field usage scott@slp53.sl.home (Scott Lurndal) - 2019-10-24 19:40 +0000
Re: Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-24 22:15 +0200
Re: Bit field usage already5chosen@yahoo.com - 2019-10-24 14:16 -0700
Re: Bit field usage Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-10-24 17:50 -0700
Re: Bit field usage Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-10-25 09:36 -0600
Re: Bit field usage Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-10-27 04:54 -0700
Re: Bit field usage Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-10-27 10:05 -0600
Re: Bit field usage Philipp Klaus Krause <pkk@spth.de> - 2019-10-26 20:15 +0200
Re: Bit field usage Philipp Klaus Krause <pkk@spth.de> - 2019-10-26 20:16 +0200
Re: Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-26 20:37 +0200
Re: Bit field usage Robert Wessel <robertwessel2@yahoo.com> - 2019-10-26 13:41 -0500
Re: Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-26 21:54 +0200
Re: Bit field usage already5chosen@yahoo.com - 2019-10-27 03:46 -0700
Re: Bit field usage jacobnavia <jacob@jacob.remcomp.fr> - 2019-10-27 12:50 +0100
Re: Bit field usage already5chosen@yahoo.com - 2019-10-27 06:37 -0700
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-10-27 13:00 +0100
Re: Bit field usage already5chosen@yahoo.com - 2019-10-27 07:19 -0700
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-10-27 22:30 +0100
Re: Bit field usage Christopher Collins <ccollins476ad@gmail.com> - 2019-11-07 12:36 -0800
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-11-08 08:18 +0100
Re: Bit field usage Christopher Collins <ccollins476ad@gmail.com> - 2019-11-08 10:19 -0800
Re: Bit field usage Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-11-08 21:47 +0000
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-11-10 14:08 +0100
Re: Bit field usage Christopher Collins <ccollins476ad@gmail.com> - 2019-11-11 09:26 -0800
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-11-11 20:31 +0100
Re: Bit field usage Christopher Collins <ccollins476ad@gmail.com> - 2019-11-11 23:01 -0800
Re: Bit field usage Christopher Collins <ccollins476ad@gmail.com> - 2019-11-11 23:25 -0800
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-11-12 10:54 +0100
Re: Bit field usage Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-11-12 14:43 +0000
Re: Bit field usage James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-12 10:54 -0500
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-11-12 19:37 +0100
Re: Bit field usage Robert Wessel <robertwessel2@yahoo.com> - 2019-10-27 08:36 -0500
Re: Bit field usage already5chosen@yahoo.com - 2019-10-27 06:49 -0700
Re: Bit field usage Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-27 14:23 +0100
Re: Bit field usage Robert Wessel <robertwessel2@yahoo.com> - 2019-10-27 08:42 -0500
Re: Bit field usage Philipp Klaus Krause <pkk@spth.de> - 2019-10-26 21:06 +0200
Re: Bit field usage Bart <bc@freeuk.com> - 2019-10-26 20:41 +0100
Re: Bit field usage Philipp Klaus Krause <pkk@spth.de> - 2019-10-27 08:29 +0100
Re: Bit field usage David Brown <david.brown@hesbynett.no> - 2019-10-27 13:05 +0100
csiph-web