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
0
votes
1 answer

Consistency of projecting points onto an undistorted image

I want to project a point in 3D space into 2D image coordinates. I have the calibrated intrinsics and extrinsics of the camera I'm using. I have the camera matrix K and distortion coefficients D. However, I want the projected image coordinates to be…
Ashok
  • 1,079
  • 3
  • 10
  • 17
0
votes
1 answer

Is there separate intrinsic for bitset64 in Visual Studio C compiler?

I need to set nth bit of 64 bit integer to 1; There is an intrinsic (documented here http://msdn.microsoft.com/en-us/library/z56sc6y4(v=vs.90).aspx) : unsigned char _bittestandset64( __int64 *a, __int64 b ); which does the job. My question is if…
Piotr Lopusiewicz
  • 2,514
  • 2
  • 27
  • 38
0
votes
2 answers

Inconsistent MSDN documentation for InterlockedExchange() type functions/intrinsics?

First, we have InterlockedExchange64(); http://msdn.microsoft.com/en-us/library/windows/desktop/ms683593%28v=vs.85%29.aspx LONGLONG __cdecl InterlockedExchange64( __inout LONGLONG volatile *Target, __in LONGLONG Value ); Second, we have the…
user82238
0
votes
1 answer

How to use SSE intrinsics in MS Visual Studio?

I am trying to make some optimized code using SSE2 instructions. Currently, i have it written in inline assembly, like this: ... __m128 zero = {0}; __asm { ... LINE_LOOP_1: MOVQ xmm0, QWORD PTR [eax] ; no problem PUNPCKLBW …
anatolyg
  • 26,506
  • 9
  • 60
  • 134
0
votes
1 answer

How to get two strings char by char comparing table with SSE 4.2?

How to get two strings char by char comparing table with SSE 4.2 intrinsics in C? _mm_cmpistrm return mask of important bits, that is aggregating function on char by char comparing table processing result. __m128i _mm_cmpistrm ( __m128i a, …
udjin
  • 31
  • 2
-1
votes
0 answers

In RISC-V vector intrinsics in C, what is the tail policy?

When calling a C intrinsic like this for RISC-V extension "V" vectors: vint8m1_t temp = vmv_v_v_i8m1(vec_src1,5); What is the policy for the tail of the result vector? is it a don't care? Tried to debug the following line: vint8m1_t temp =…
Ron Cohen
  • 1
  • 3
-1
votes
0 answers

Usage of _mm_loadu_epi8 leads to error - ‘_mm_loadu_epi8’ was not declared in this scope

While trying to load _mm_loadu_epi8 instruction which is defined in AVX512 family of Intel Intrinsics instruction was getting error in c++ that - Usage of _mm_loadu_epi8 leads to error - ‘_mm_loadu_epi8’ was not declared in this scope. Tried to use…
Srihari S
  • 17
  • 4
-1
votes
1 answer

__m128i initializers and _mm_madd_epi16: What is the result?

I tried the following code: __m128i x = { 1,2,3,4,5,6,7,8 }; __m128i y = { 10,20,30,40,50,60,70,80}; __m128i z = _mm_madd_epi16(x, y); The result is: z = {6244, 201, -17692, 1006, 0,0,0,0} But the first element should be 1*10 + 2*20 = 50. Can you…
Zvi Vered
  • 459
  • 2
  • 8
  • 16
-1
votes
1 answer

Ideas to speeden up the given AVX512 code

mask_new1 = _mm512_set_epi32(0, 3, 0, 3, 0, 3, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2); s1 = _mm512_permutexvar_pd(mask_new1, r); out1 = _mm512_mul_pd(s1, _mm512_mul_pd(b1, c1)); Are there any ways/ideas to perform faster the permute operation…
Srihari S
  • 17
  • 4
-1
votes
1 answer

Intrinsics load matrix

Im learning Intrinsics. I dont know how to load a matrix correctly. I want to do matrix multiplication. This is my code: int i, j, k; __m128 mat2values = _mm_setzero_ps(); __m128 mat1values = _mm_setzero_ps(); __m128 r = _mm_setzero_ps(); for (i =…
Leon
  • 63
  • 7
-1
votes
2 answers

Can't use uint64_t with rdrand as it expects unsigned long long, but uint64_t is defined as unsigned long

I've run into the following annoyance when trying to use rdrand intrinsic. With my current compiler unsigned long and unsigned long long are both 64-bits. However, uint64_t is defined as unsigned long while _rdrand64_step expects a pointer to…
Chris_F
  • 4,991
  • 5
  • 33
  • 63
-1
votes
2 answers

Fastest way to sum array of float values

I have doing DSP coding using Visual Studio and C++. I have an array of floats, only 8 right now but may be changed later to more or less, I need to sum to a single float variable, and then average. I would like to use intrinsic instructions, which…
-1
votes
2 answers

Implementing C# hardware intrinsics wrapper issue

I am trying to use the power of hardware intrinsic and just for test create one function based on Avx2 instructions and compare it with my current Vector implementation with no intrinsic at all. When I did a benchmark of 2 functions doing the same,…
Denis
  • 334
  • 4
  • 17
-1
votes
1 answer

Intel intrinsic data type inside struct

I want to know how to properly use intel intrinsic data type in my program, the way I am currently using involve the use of _mm256_loadu_ps and _mm256_storeu_ps for loading and storing results. But the code runs slower than simple code and after…
-1
votes
3 answers

Illegal Instruction with mm_cmpeq_epi8_mask

Im trying to run code similar to the following #include void foo() { __m128i a = _mm_set_epi8 (0,0,6,5,4,3,2,1,8,7,6,5,4,3,2,1); __m128i b = _mm_set_epi8 (0,0,0,0,0,0,0,1,8,7,6,5,4,3,2,1); __mmask16 m =…