sse

What is the difference between _mm512_load_epi32 and _mm512_load_si512?

浪子不回头ぞ 提交于 2020-01-03 18:18:06
问题 The Intel intrinsics guide states simply that _mm512_load_epi32 : Load[s] 512-bits (composed of 16 packed 32-bit integers) from memory into dst and that _mm512_load_si512 : Load[s] 512-bits of integer data from memory into dst What is the difference between these two? The documentation isn't clear. 回答1: There's no difference, it's just silly redundant naming. Use _mm512_load_si512 for clarity. Thanks, Intel. As usual, it's easier to understand the underlying asm for AVX512, and then you can

Uses of the monitor/mwait instructions

我们两清 提交于 2020-01-03 17:01:11
问题 I happened to stumble upon these two instructions - mwait and monitor https://www.felixcloutier.com/x86/mwait. The intel manual says these are used to wait for writes in a concurrent multi-processor system, and it made me curious what types of usecases were in mind when these instructions were added to the ISA. What are the semantics of these instructions? Is this integrated through linux into the threading libraries provided by posix (eg. does the thread yield while monitoring a word)? Or

Is there a more direct method to convert float to int with rounding than adding 0.5f and converting with truncation?

▼魔方 西西 提交于 2020-01-03 15:33:13
问题 Conversion from float to int with rounding happens fairly often in C++ code that works with floating point data. One use, for example, is in generating conversion tables. Consider this snippet of code: // Convert a positive float value and round to the nearest integer int RoundedIntValue = (int) (FloatValue + 0.5f); The C/C++ language defines the (int) cast as truncating, so the 0.5f must be added to ensure rounding up to the nearest positive integer (when the input is positive). For the

ZeroMemory in SSE

孤街醉人 提交于 2020-01-02 09:19:32
问题 I need simple ZeroMemory implementation with SSE (SSE2 prefered) Can someone help with that. I was serching thru SO and net but not found direct answer to that. 回答1: Is ZeroMemory() or memset() not good enough? Disclaimer: Some of the following may be SSE3. Fill any unaligned leading bytes by looping until the address is a multiple of 16 push to save an xmm reg pxor to zero the xmm reg While the remaining length >= 16, movdqa or movntdq to do the write pop to restore the xmm reg. Fill any

Extract set bytes position from SIMD vector

。_饼干妹妹 提交于 2020-01-02 04:49:06
问题 I run a bench of computations using SIMD intructions. These instructions return a vector of 16 bytes as result, named compare , with each byte being 0x00 or 0xff : 0 1 2 3 4 5 6 7 15 16 compare : 0x00 0x00 0x00 0x00 0xff 0x00 0x00 0x00 ... 0xff 0x00 Bytes set to 0xff mean I need to run the function do_operation(i) with i being the position of the byte . For instance, the above compare vector mean, I need to run this sequence of operations : do_operation(4); do_operation(15); Here is the

initialize a union array at declaration

女生的网名这么多〃 提交于 2020-01-02 03:45:08
问题 I'm trying to initialize the following union array at declaration: typedef union { __m128d m; float f[4]; } mat; mat m[2] = { {{30467.14153,5910.1427,15846.23837,7271.22705}, {30467.14153,5910.1427,15846.23837,7271.22705}}}; But I'getting the following error: matrix.c: In function ‘main’: matrix.c:21: error: incompatible types in initialization matrix.c:21: warning: excess elements in union initializer matrix.c:21: warning: (near initialization for ‘m[0]’) matrix.c:21: warning: excess

SSE2: How To Load Data From Non-Contiguous Memory Locations?

▼魔方 西西 提交于 2020-01-02 03:26:10
问题 I'm trying to vectorize some extremely performance critical code. At a high level, each loop iteration reads six floats from non-contiguous positions in a small array, then converts these values to double precision and adds them to six different double precision accumulators. These accumulators are the same across iterations, so they can live in registers. Due to the nature of the algorithm, it's not feasible to make the memory access pattern contiguous. The array is small enough to fit in L1

Improve SSE (SSSE3) YUV to RGB code

懵懂的女人 提交于 2020-01-01 12:00:35
问题 I am looking to optimise some SSE code I wrote for converting YUV to RGB (both planar and packed YUV functions). I am using SSSE3 at the moment, but if there are useful functions from later SSE versions that's ok. I am mainly interested in how I would work out processor stalls and the like. Anyone know of any tools that do static analysis of SSE code? ; ; Copyright (C) 2009-2010 David McPaul ; ; All rights reserved. Distributed under the terms of the MIT License. ; ; A rather unoptimised set

SSE: reciprocal if not zero

ⅰ亾dé卋堺 提交于 2020-01-01 09:28:53
问题 How can I take the reciprocal (inverse) of floats with SSE instructions, but only for non-zero values? Background bellow: I want to normalize an array of vectors so that each dimension has the same average. In C this can be coded as: float vectors[num * dim]; // input data // step 1. compute the sum on each dimension float norm[dim]; memset(norm, 0, dim * sizeof(float)); for(int i = 0; i < num; i++) for(int j = 0; j < dims; j++) norm[j] += vectors[i * dims + j]; // step 2. convert sums to

SSE Instructions: Byte+Short

一曲冷凌霜 提交于 2020-01-01 05:34:06
问题 I have very long byte arrays that need to be added to a destination array of type short (or int ). Does such SSE instruction exist? Or maybe their set ? 回答1: You need to unpack each vector of 8 bit values to two vectors of 16 bit values and then add those. __m128i v = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); __m128i vl = _mm_unpacklo_epi8(v, _mm_set1_epi8(0)); // vl = { 7, 6, 5, 4, 3, 2, 1, 0 } __m128i vh = _mm_unpackhi_epi8(v, _mm_set1_epi8(0)); // vh = { 15, 14,