Re:KolibriOS – operating system written entirely in assembly...
by Someone on Wednesday April 15, 2020 @08:28AM
(#22876901)
When using Clang org CC (possibly other compilers, too), you don’t need to use intrinsics. These compilers have some support for vector types (https://clang.llvm.org/docs/LanguageExtensions.html#vectors-..., https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html)
One can, for example, write:
typedef int v4si __attribute__ ((vector_size (16)));
v4si a, b, c;
[…]
b += 3; // add 3 to each of b’s elements
c = a + b; // pairwise addition
Using this gives up some control over assembly; it doesn’t guarantee vector instructions get used, but it makes it easier for the compiler to generate them.Also, I’m fairly sure there are vector instructions not covered by this extension.
Re:KolibriOS – operating system written entirely in assembly...
by pjmlp on Wednesday April 15, 2020 @04:41AM
(#22875715)
CPU intrinsics are just another way of doing inline Assembly.
Re:KolibriOS – operating system written entirely in assembly...
by throwaway_pdp09 on Wednesday April 15, 2020 @04:58AM
(#22875789)
IANA C/C++/ASM expert, but one thing I've been thinking of would greatly benefit from type-punning (overlaying 2 kinds of data and interpreting one as the other) because it can use a 64-bit register to parallelise 4 ops at once where speed really, really matters.
That's trivial in ASM I believe, but don't know how well it's possible in C/C++, if at all.
Re:KolibriOS – operating system written entirely in assembly...
by pjmlp on Wednesday April 15, 2020 @05:31AM
(#22875934)
I fail to see why not just use a __m64 variable and do the conversion.
https://software.intel.com/sites/landingpage/IntrinsicsGuide...
You can also try to make a union whose one field is a __m64, but beware not to trigger UB conditions.
Re:KolibriOS – operating system written entirely in assembly...
by saagarjha on Wednesday April 15, 2020 @05:27AM
(#22875911)
Type punning in general would be somewhat difficult to do here in a way that vectorized but was still defined by the standard. You’d need to put a branch with undefined behavior in it when alignment wasn’t satisfied, then do a memcpy into a vector type, and hope that the compiler understands what you’re doing and doesn’t deoptimize it.
Re:KolibriOS – operating system written entirely in assembly...
by dhhwrongagain on Wednesday April 15, 2020 @04:56AM
(#22875776)
False or vacuously true
I would expect a much smaller gap as AVX2 is also available through intrinsics on C ?!