What does the [Intrinsic] attribute in C# do?

Here’s what I’ve managed to find after a very limited search through dotnet/corefx repository on github. [Intrinsic] marks methods, properties and fields that can be potentially replaced/optimized by JIT. Source code comments say something similar (IntrinsicAttribute.cs): Calls to methods or references to fields marked with this attribute may be replaced at some call sites with … Read more

What are _mm_prefetch() locality hints?

Sometimes intrinsics are better understood in terms of the instruction they represent rather than as the abstract semantic given in their descriptions. The full set of the locality constants, as today, is #define _MM_HINT_T0 1 #define _MM_HINT_T1 2 #define _MM_HINT_T2 3 #define _MM_HINT_NTA 0 #define _MM_HINT_ENTA 4 #define _MM_HINT_ET0 5 #define _MM_HINT_ET1 6 #define _MM_HINT_ET2 … Read more

print a __m128i variable

Use this function to print them: #include <stdint.h> #include <string.h> void print128_num(__m128i var) { uint16_t val[8]; memcpy(val, &var, sizeof(val)); printf(“Numerical: %i %i %i %i %i %i %i %i \n”, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]); } You split 128bits into 16-bits(or 32-bits) before printing them. This is a way of 64-bit splitting and … Read more

How to use VC++ intrinsic functions w/o run-time library

I think I finally found a solution: First, in a header file, declare memset() with a pragma, like so: extern “C” void * __cdecl memset(void *, int, size_t); #pragma intrinsic(memset) That allows your code to call memset(). In most cases, the compiler will inline the intrinsic version. Second, in a separate implementation file, provide an … Read more

What are intrinsics?

An intrinsic function is a function which the compiler implements directly when possible, rather than linking to a library-provided implementation of the function. A common example is strncpy(). For short strings, making a function call to strncpy(), which involves setting up a ‘stack frame’ with a return address, will consume more time than the actual … Read more