3 ms·
So very fast code in C is not actually C code, but written in a non-standard extended C dialect that is also platform specific - thanks for clarifying. I'm cur
by the_why_of_y 10y ago
So very fast code in C is not actually C code, but written in a non-standard extended C dialect that is also platform specific - thanks for clarifying.
I'm curious if there is a way to limit the entries in the Benchmark Game to just those that actually use only the language standards, where those exist...
- burntsushi 10y agoTo be clear, using SIMD doesn't require some "non-standard extended C dialect." We very much want a better SIMD story on Rust, and the benchmark game entries should definitely be allowed to use SIMD. SIMD will get you into platform specific woes unfortunately, but that shouldn't stop us. :-)
- Const-me 10y agoWhat are you talking about? Intrinsics are perfectly valid C99 code. __int64i is a union with 8 different arrays in it, and intrinsics are library functions.
- the_why_of_y 10y agoThe words "SIMD", "intrinsic", "__m64", "__m128" do not occur in the C11 draft text; the word "vector" occurs once in example code for an array-with-length struct. http://www.iso-9899.info/n1570.html http://www.iso-9899.info/n1570.html Intrinsics are not library functions - they would hardly provide the desired performance benefit if they were. Intrinsics are "magic" functions that the compiler has built-in support for, and thus I would call them language extensions. For example from GCC header avxintrin.h: extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm256_permute2f128_pd (__m256d __X, __m256d __Y, const int __C) { return (__m256d) __builtin_ia32_vperm2f128_pd256 ((__v4df)__X, (__v4df)__Y, __C); } Over here the word "__builtin_ia32_vperm2f128_pd256" occurs in the "cc1" and "cc1plus" binaries and "avxintrin.h", but nowhere else. Notably there is no externally visible definition.
- Const-me 10y agoI don’t know why authors of GCC invented that non-standard extended C dialect, you better ask them. In Visual C++, the prototype of that intrinsic is valid C99 code: extern __m256d __cdecl _mm256_permute2f128_pd(__m256d, __m256d, int);
- the_why_of_y 10y agoWhich library contains the definition of "_mm256_permute2f128_pd"? The likely answer is "none", as these are built-in to Visual C++ in a similar way to GCC, with only superficial differences such as an apparent lack of indirection to some __builtin_foo. https://msdn.microsoft.com/en-us/library/26td21ds(v=vs.100).aspx https://msdn.microsoft.com/en-us/library/26td21ds(v=vs.100).... "An intrinsic is a function known by the compiler that directly maps to a sequence of one or more assembly language instructions. Intrinsic functions are inherently more efficient than called functions because no calling linkage is required." https://msdn.microsoft.com/en-us/library/y0dh78ez(v=vs.100).aspx https://msdn.microsoft.com/en-us/library/y0dh78ez(v=vs.100).... "The use of intrinsics affects the portability of code, because intrinsics that are available in Visual C++ might not be available if the code is compiled with other compilers and some intrinsics that might be available for some target architectures are not available for all architectures."
- Const-me 10y agoI know how intrinsic work, thanks. Use them a lot in C++. C99 language spec says nothing about the things you’re talking about. It only specifies the language, not how C compilers implement various features. From the programmer’s point of view (except when the programmer works on the compiler itself), intrinsics are just C library functions, only inline, and very performant if done right. Fully compliant with C99 and C++ language specs.