Questions tagged [intrinsics]

Intrinsics are functions used in compiled languages to trigger the execution specific processor instructions, typically those outside the scope of the compiled language itself.

Intrinsic functions are pseudo-functions used by compilers to represent functionality that is outside the current scope of the language; often times, they may later be incorporated into a language. Some examples are simd and atomic instructions. The compiler has knowledge of the operations of the intrinsics and is able to optimize register use to take advantage of them.

A compiler library usually has actual implementations of the functions, which are used if a lower class CPU (or completely different) is detected at run-time or compile time.

Compiler intrinsics are very similar to inline-assembly. Inline assembler has notations to denote permissible input and output registers as well as clobber values; unless the compiler implicitly parses the inline assembly. With a compiler intrinsic, the register use is already built into the compiler and a developer doesn't need to know as many low level details; although it is often helpful to have some low level assembler knowledge to guide profiling and optimization.

Related tags:

1314 questions
171
votes
5 answers

Header files for x86 SIMD intrinsics

Which header files provide the intrinsics for the different x86 SIMD instruction set extensions (MMX, SSE, AVX, ...)? It seems impossible to find such a list online. Correct me if I'm wrong.
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
88
votes
4 answers

What are intrinsics?

Can anyone explain what they are and why I would need them? What kind of applications am I building if I need to use intrinsics?
Scott J
  • 3,402
  • 4
  • 22
  • 14
81
votes
3 answers

Incrementing 'masked' bitsets

I'm currently in the process of writing a tree enumerator where I've come across the following problem: I'm looking at masked bitsets, i.e. bitsets where the set bits are a subset of a mask, i.e. 0000101 with mask 1010101. What I want to accomplish…
Tobias Ribizel
  • 5,331
  • 1
  • 18
  • 33
36
votes
7 answers

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

I'm involved in one of those challenges where you try to produce the smallest possible binary, so I'm building my program without the C or C++ run-time libraries (RTL). I don't link to the DLL version or the static version. I don't even #include…
Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
31
votes
1 answer

What are _mm_prefetch() locality hints?

The intrinsics guide says only this much about void _mm_prefetch (char const* p, int i) : Fetch the line of data from memory that contains address p to a location in the cache heirarchy specified by the locality hint i. Could you list the…
Serge Rogatch
  • 13,865
  • 7
  • 86
  • 158
31
votes
4 answers

print a __m128i variable

I'm trying to learn to code using intrinsics and below is a code which does addition compiler used: icc #include #include int main() { __m128i a = _mm_set_epi32(1,2,3,4); __m128i b = _mm_set_epi32(1,2,3,4); …
arunmoezhi
  • 3,082
  • 6
  • 35
  • 54
29
votes
4 answers

Is there a good reference for ARM Neon intrinsics?

The ARM reference manual doesn't go into too much detail into the individual instructions ( http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0348b/BABIIBBG.html ). Is there something that's a little more detailed?
Vineeth
  • 473
  • 1
  • 6
  • 8
29
votes
5 answers

Get member of __m128 by index?

I've got some code, originally given to me by someone working with MSVC, and I'm trying to get it to work on Clang. Here's the function that I'm having trouble with: float vectorGetByIndex( __m128 V, unsigned int i ) { assert( i <= 3 ); …
benwad
  • 6,414
  • 10
  • 59
  • 93
28
votes
3 answers

SSE, intrinsics, and alignment

I've written a 3D vector class using a lot of SSE compiler intrinsics. Everything worked fine until I started to instatiate classes having the 3D vector as a member with new. I experienced odd crashes in release mode but not in debug mode and the…
Jan Deinhard
  • 19,645
  • 24
  • 81
  • 137
27
votes
2 answers

SIMD and difference between packed and scalar double precision

I am reading Intel's intrinsics guide while implementing SIMD support. I have a few confusions and my questions are as below. __m128 _mm_cmpeq_ps (__m128 a, __m128 b) documentation says it is used to compare packed single precision floating points.…
user1461001
  • 693
  • 1
  • 7
  • 17
26
votes
2 answers

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

A quick Google search for "instrinsic attribute c#" only returns articles about other attributes, such as [Serializable]. Apparently these are called "intrinsic attributes". However, there is also an attribute in C# that is itself called…
Aaron Franke
  • 3,268
  • 4
  • 31
  • 51
26
votes
1 answer

Equivalent of InterlockedIncrement in Linux/gcc

It would be a very simple question (could be duplicated), but I was unable to find it. Win32 API provides a very handy set of atomic operations (as intrinsics) such as InterlockedIncrement which emits lock add x86 code. Also,…
minjang
  • 8,860
  • 9
  • 42
  • 61
22
votes
8 answers

c++ SSE SIMD framework

Does anyone know an open-source C++ x86 SIMD intrinsics library? Intel supplies exactly what I need in their integrated performance primitives library, but I can't use that because of the copyrights all over the place. EDIT I already know the…
user283145
21
votes
4 answers

When should I use _mm_sfence _mm_lfence and _mm_mfence

I read the "Intel Optimization guide Guide For Intel Architecture". However, I still have no idea about when should I use _mm_sfence() _mm_lfence() _mm_mfence() Could anyone explain when these should be used when writing multi-threaded code?
prgbenz
  • 1,129
  • 4
  • 13
  • 27
21
votes
2 answers

When will JVM use intrinsics

Why certain code patterns when present within JVM internal classes are turned into an intrinsic function, whereas the same patterns when called from my own class are not. Example: bitCount function, when called from within Integer.bitCount(i) will…
Mark
  • 821
  • 7
  • 14
1
2 3
87 88