News for hackers. Stuff that matters.
Re:C Is Not Suited to SIMD by Gibbon1 on Monday January 27, 2025 @04:45PM (#42846017)
The C language spec isn't what important here it's the ABI doesn't know the difference.
Re:C Is Not Suited to SIMD by jjmarr on Monday January 27, 2025 @05:52PM (#42846708)
if using an int* over an int[] changes the memory layout of a struct, that necessarily implies a difference in the ABI.

As an example, C++'s std::array can be implemented as a struct containing a fixed-size C-style array. This can be passed-by-value. This means that returning a std::array can be more performant than returning a std::vector (which might be implemented as an int* that is reallocated when you add too many elements), because a std::array is returned on the stack while a std::vector is returned on the heap.

I was bit by this once when returning a std::unordered_map because I was doing a heap-allocation in a performance-critical section.

Re:C Is Not Suited to SIMD by Gibbon1 on Tuesday January 28, 2025 @03:13PM (#42857353)
The memory layout is the ABI not the language spec.
Re:C Is Not Suited to SIMD by jjmarr on Wednesday January 29, 2025 @11:21AM (#42866941)
The language spec for C constrains the memory layout of a struct. From 6.7.3.2.7 of the draft spec:

> a structure is a type consisting of a sequence of members, whose storage is allocated in an ordered sequence, (emphasis added)

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf