News for hackers. Stuff that matters.
Re:C Is Not Suited to SIMD by nitwit005 on Monday January 27, 2025 @04:28PM (#42845829)
When I tested this before (some years ago), adding "restrict" to the C pointers resulted in the same behavior, so the aliasing default seem to be the key issue.
Re:C Is Not Suited to SIMD by AlotOfReading on Monday January 27, 2025 @07:14PM (#42847422)
Your compiler very likely assumes strict aliasing at whatever optimization level you're already using, so restrict usually won't do much. GCC does at O2, keil (and clang?) at O1.
Re:C Is Not Suited to SIMD by legobmw99 on Monday January 27, 2025 @07:45PM (#42847627)
“strict aliasing” refers to disallowing pointers of different types to alias. In the context of a function that accepts two arrays of floats, for example, it doesn’t apply
Re:C Is Not Suited to SIMD by nitwit005 on Tuesday January 28, 2025 @03:56PM (#42857879)
That looks correct from playing around in godbolt.
Re:C Is Not Suited to SIMD by kazinator on Tuesday January 28, 2025 @12:17AM (#42849088)
But restrict says "I promise that these things don't overlap, on penalty of my program going to hell". Is that what's going on in Fortran?
Re:C Is Not Suited to SIMD by cozzyd on Tuesday January 28, 2025 @01:14AM (#42849390)
yes, Fortran forbids referring to the same memory location by multiple names.
Re:C Is Not Suited to SIMD by pklausler on Tuesday January 28, 2025 @01:51AM (#42849586)
Nope. There’s lots of ways to alias storage in Fortran.
Re:C Is Not Suited to SIMD by cozzyd on Tuesday January 28, 2025 @11:06AM (#42853910)
sorry, I meant in the case of function parameters, though I'm far from a fortran expert so there may be exceptions.