simd

Compare and swap with SIMD intrinsics

自作多情 提交于 2019-12-11 08:34:31
问题 Is it possible to compare in SIMD instruction and swap the values if some condition happened. In other words, I have 4 integers: (100 5) (1 42) And I want to receive: (5 100) (1 42) i.e. I want to compare pairwise (first value with second and third with fourth) and in case left operand is greater - swap the values. Is it possible to do with only 1 SIMD? P.S.: it's the first time I'm trying SIMD and probably I'm using wrong terminology - please fix me if I'm wrong. 回答1: It seems that you want

Optimize 128x128 to 256-bit multiply for Intel AVX[SIMD] [duplicate]

你说的曾经没有我的故事 提交于 2019-12-11 07:47:59
问题 This question already has answers here : Why _umul128 works slower than scalar code for mul128x64x2 function? (1 answer) SIMD signed with unsigned multiplication for 64-bit * 64-bit to 128-bit (2 answers) Is there hardware support for 128bit integers in modern processors? (3 answers) Is there a 128 bit integer in gcc? (3 answers) Closed 3 months ago . I'm trying to implement multiplication of 128 unsigned int on two 64 unsigned integers by Intel AVX. The problem is that non vectorised version

How to use AVX/SIMD with nested loops and += format?

為{幸葍}努か 提交于 2019-12-11 05:27:08
问题 I am writing a page rank program. I am writing a method for updating the rankings. I have successful got it working with nested for loops and also a threaded version. However I would like to instead use SIMD/AVX. This is the code I would like to change into a SIMD/AVX implementation. #define IDX(a, b) ((a * npages) + b) // 2D matrix indexing for (size_t i = 0; i < npages; i++) { temp[i] = 0.0; for (size_t j = 0; j < npages; j++) { temp[i] += P[j] * matrix_cap[IDX(i,j)]; } } For this code P[]

Dispatching SIMD instructions + SIMDPP + qmake

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 05:18:01
问题 I'm developing a QT widget that makes use of SIMD instruction sets. I've compiled 3 versions: SSE3, AVX, and AVX2(simdpp allows to switch between them by a single #define). Now, what I want is for my widget to switch automatically between these implementations, according to best supported instruction set. Guide that is provided with simdpp makes use of some makefile magic: CXXFLAGS="" test: main.o test_sse2.o test_sse3.o test_sse4_1.o test_null.o g++ $^ -o test main.o: main.cc g++ main.cc $

Intrinsics Neon Swap elements in vector

给你一囗甜甜゛ 提交于 2019-12-11 05:07:55
问题 I would like to optimize such code with Neon Intrinsics. Basically with given input of 0 1 2 3 4 5 6 7 8 will produce the output, 2 1 0 5 4 3 8 7 6 void func(uint8_t* src, uint8_t* dst, int size){ for (int i = 0; i < size; i++){ dst[0] = src[2]; dst[1] = src[1]; dst[2] = src[0] dst = dst+3; src = src+3; } } The only way I can think of is to use uint8x8x3_t src = vld3_u8(src); to get 3 vectors and then access every single element from src[2], src[1], src[0] and write to the memory. Can someone

Testing NEON SIMD registers for equality over all lanes

巧了我就是萌 提交于 2019-12-11 04:34:54
问题 I'm using Neon Instrinics with clang. I want to test two uint32x4_t SIMD values for equality over all lanes. So not 4 test results, but one single result that tells me if A and B are equal for all lanes. On Intel AVX, I would use something like: _mm256_testz_si256( _mm256_xor_si256( A, B ), _mm256_set1_epi64x( -1 ) ) What would be a good way to perform an all-lane equality test for NEON SIMD? I am assuming I will need intrinsics that operate across lanes. Does ARM Neon have those features?

efficiency of CUDA Scalar and SIMD video instructions

﹥>﹥吖頭↗ 提交于 2019-12-11 04:15:21
问题 The throughput of SIMD instruction is lower that 32-bits integer arithmetic. In case of SM2.0 (Scalar instruction only versions) is 2 time lower. In case of SM3.0 is 6 time lower. What is a cases when suitable to use them ? 回答1: If your data is already packed in a format that is handled natively by a SIMD video instruction, then it would require multiple steps to unpack it so that it can be handled by an ordinary instruction. Furthermore, the throughput of a SIMD video instruction should also

Integer SIMD Instruction AVX in C

允我心安 提交于 2019-12-11 04:09:26
问题 I am trying to run SIMD instruction over data types int , float and double . I need multiply, add and load operation. For float and double I successfully managed to make those instructions work: _mm256_add_ps , _mm256_mul_ps and _mm256_load_ps (ending *pd for double). (Direct FMADD operation isn't supported) But for integer I couldn't find a working instruction. All of those showed at intel AVX manual give similar error by GCC 4.7 like "‘_mm256_mul_epu32’ was not declared in this scope". For

Dot Product of Vectors with SIMD

老子叫甜甜 提交于 2019-12-11 04:06:30
问题 I am attempting to use SIMD instructions to speed up a dot product calculation in my C code. However, the run times of my functions are approximately equal. It'd be great if someone could explain why and how to speed up the calculation. Specifically, I'm attempting to calculate the dot product of two arrays with about 10,000 elements in them. My regular C function is as follows: float my_dotProd( float const * const x, float const * const y, size_t const N ){ // N is the number of elements in

Linker errors when using intrinsic function via function pointer

痴心易碎 提交于 2019-12-11 04:04:49
问题 The code below doesn't compile with visual studio 2013. I get linker Error unresolved external symbol(LNK 2019) for the mm functions. If i use the functions directly, it all links fine. Why it doesn't compile? And is there a work-around #include "emmintrin.h" #include <smmintrin.h> #include <intrin.h> __m128i (*load)(const __m128i*) = NULL; if (it::isAligned<16>(ucpSrc, iXOffset * sizeof(unsigned char)) ) load = &_mm_load_si128; else load = &_mm_lddqu_si128; 回答1: Where some compilers such as