File simdlib_avx2.h¶
-
namespace faiss
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
Throughout the library, vectors are provided as float * pointers. Most algorithms can be optimized when several vectors are processed (added/searched) together in a batch. In this case, they are passed in as a matrix. When n vectors of size d are provided as float * x, component j of vector i is
x[ i * d + j ]
where 0 <= i < n and 0 <= j < d. In other words, matrices are always compact. When specifying the size of the matrix, we call it an n*d matrix, which implies a row-major storage.
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. I/O functions can read/write to a filename, a file handle or to an object that abstracts the medium.
The read functions return objects that should be deallocated with delete. All references within these objectes are owned by the object.
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. Definition of inverted lists + a few common classes that implement the interface.
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. Since IVF (inverted file) indexes are of so much use for large-scale use cases, we group a few functions related to them in this small library. Most functions work both on IndexIVFs and IndexIVFs embedded within an IndexPreTransform.
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. In this file are the implementations of extra metrics beyond L2 and inner product
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. Defines a few objects that apply transformations to a set of vectors Often these are pre-processing steps.
Functions
-
inline simd16uint16 min(simd16uint16 a, simd16uint16 b)¶
-
inline simd16uint16 max(simd16uint16 a, simd16uint16 b)¶
-
inline simd16uint16 combine2x2(simd16uint16 a, simd16uint16 b)¶
-
inline uint32_t cmp_ge32(simd16uint16 d0, simd16uint16 d1, simd16uint16 thr)¶
-
inline uint32_t cmp_le32(simd16uint16 d0, simd16uint16 d1, simd16uint16 thr)¶
-
inline simd32uint8 uint16_to_uint8_saturate(simd16uint16 a, simd16uint16 b)¶
-
inline uint32_t get_MSBs(simd32uint8 a)¶
get most significant bit of each byte
-
inline simd32uint8 blendv(simd32uint8 a, simd32uint8 b, simd32uint8 mask)¶
use MSB of each byte of mask to select a byte between a and b
-
inline simd8float32 hadd(simd8float32 a, simd8float32 b)¶
-
inline simd8float32 unpacklo(simd8float32 a, simd8float32 b)¶
-
inline simd8float32 unpackhi(simd8float32 a, simd8float32 b)¶
-
inline simd8float32 fmadd(simd8float32 a, simd8float32 b, simd8float32 c)¶
-
inline void cmplt_and_blend_inplace(const simd8float32 candidateValues, const simd8uint32 candidateIndices, simd8float32 &lowestValues, simd8uint32 &lowestIndices)¶
-
struct simd256bit¶
- #include <simdlib_avx2.h>
256-bit representation without interpretation as a vector
Simple wrapper around the AVX 256-bit registers
The objective is to separate the different interpretations of the same registers (as a vector of uint8, uint16 or uint32), to provide printing functions, and to give more readable names to the AVX intrinsics. It does not pretend to be exhausitve, functions are added as needed.
Subclassed by faiss::simd16uint16, faiss::simd16uint16, faiss::simd32uint8, faiss::simd32uint8, faiss::simd8float32, faiss::simd8float32, faiss::simd8uint32, faiss::simd8uint32
Public Functions
-
inline simd256bit()¶
-
inline explicit simd256bit(__m256i i)¶
-
inline explicit simd256bit(__m256 f)¶
-
inline explicit simd256bit(const void *x)¶
-
inline void clear()¶
-
inline void storeu(void *ptr) const¶
-
inline void loadu(const void *ptr)¶
-
inline void store(void *ptr) const¶
-
inline void bin(char bits[257]) const¶
-
inline simd256bit()¶
-
struct simd16uint16 : public faiss::simd256bit, public faiss::simd256bit¶
- #include <simdlib_avx2.h>
vector of 16 elements in uint16
Public Functions
-
inline simd16uint16()¶
-
inline explicit simd16uint16(__m256i i)¶
-
inline explicit simd16uint16(int x)¶
-
inline explicit simd16uint16(uint16_t x)¶
-
inline explicit simd16uint16(simd256bit x)¶
-
inline explicit simd16uint16(const uint16_t *x)¶
-
inline void set1(uint16_t x)¶
-
inline simd16uint16 operator*(const simd16uint16 &other) const¶
-
inline simd16uint16 operator>>(const int shift) const¶
-
inline simd16uint16 operator<<(const int shift) const¶
-
inline simd16uint16 operator+=(simd16uint16 other)¶
-
inline simd16uint16 operator-=(simd16uint16 other)¶
-
inline simd16uint16 operator+(simd16uint16 other) const¶
-
inline simd16uint16 operator-(simd16uint16 other) const¶
-
inline simd16uint16 operator&(simd256bit other) const¶
-
inline simd16uint16 operator|(simd256bit other) const¶
-
inline simd16uint16 operator==(simd256bit other) const¶
-
inline simd16uint16 operator~() const¶
-
inline uint16_t get_scalar_0() const¶
-
inline uint32_t ge_mask(simd16uint16 thresh) const¶
-
inline uint32_t le_mask(simd16uint16 thresh) const¶
-
inline uint32_t gt_mask(simd16uint16 thresh) const¶
-
inline bool all_gt(simd16uint16 thresh) const¶
-
inline uint16_t operator[](int i) const¶
-
inline void accu_min(simd16uint16 incoming)¶
-
inline void accu_max(simd16uint16 incoming)¶
-
inline void storeu(void *ptr) const¶
-
inline void loadu(const void *ptr)¶
-
inline void store(void *ptr) const¶
-
inline simd16uint16()¶
-
struct simd32uint8 : public faiss::simd256bit, public faiss::simd256bit¶
Public Functions
-
inline simd32uint8()¶
-
inline explicit simd32uint8(__m256i i)¶
-
inline explicit simd32uint8(int x)¶
-
inline explicit simd32uint8(uint8_t x)¶
-
inline explicit simd32uint8(simd256bit x)¶
-
inline explicit simd32uint8(const uint8_t *x)¶
-
inline void set1(uint8_t x)¶
-
inline simd32uint8 operator&(simd256bit other) const¶
-
inline simd32uint8 operator+(simd32uint8 other) const¶
-
inline simd32uint8 lookup_2_lanes(simd32uint8 idx) const¶
-
inline simd16uint16 lane0_as_uint16() const¶
-
inline simd16uint16 lane1_as_uint16() const¶
-
inline simd32uint8 operator+=(simd32uint8 other)¶
-
inline uint8_t operator[](int i) const¶
-
inline void storeu(void *ptr) const¶
-
inline void loadu(const void *ptr)¶
-
inline void store(void *ptr) const¶
-
inline simd32uint8()¶
-
struct simd8uint32 : public faiss::simd256bit, public faiss::simd256bit¶
- #include <simdlib_avx2.h>
vector of 8 unsigned 32-bit integers
Public Functions
-
inline simd8uint32()¶
-
inline explicit simd8uint32(__m256i i)¶
-
inline explicit simd8uint32(uint32_t x)¶
-
inline explicit simd8uint32(simd256bit x)¶
-
inline explicit simd8uint32(const uint8_t *x)¶
-
inline explicit simd8uint32(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5, uint32_t u6, uint32_t u7)¶
-
inline simd8uint32 operator+(simd8uint32 other) const¶
-
inline simd8uint32 operator-(simd8uint32 other) const¶
-
inline bool operator==(simd8uint32 other) const¶
-
inline bool operator!=(simd8uint32 other) const¶
-
inline void set1(uint32_t x)¶
-
inline void storeu(void *ptr) const¶
-
inline void loadu(const void *ptr)¶
-
inline void store(void *ptr) const¶
-
inline simd8uint32()¶
-
struct simd8float32 : public faiss::simd256bit, public faiss::simd256bit¶
Public Functions
-
inline simd8float32()¶
-
inline explicit simd8float32(simd256bit x)¶
-
inline explicit simd8float32(__m256 x)¶
-
inline explicit simd8float32(float x)¶
-
inline explicit simd8float32(const float *x)¶
-
inline explicit simd8float32(float f0, float f1, float f2, float f3, float f4, float f5, float f6, float f7)¶
-
inline simd8float32 operator*(simd8float32 other) const¶
-
inline simd8float32 operator+(simd8float32 other) const¶
-
inline simd8float32 operator-(simd8float32 other) const¶
-
inline simd8float32 &operator+=(const simd8float32 &other)¶
-
inline bool operator==(simd8float32 other) const¶
-
inline bool operator!=(simd8float32 other) const¶
-
inline void storeu(void *ptr) const¶
-
inline void loadu(const void *ptr)¶
-
inline void store(void *ptr) const¶
-
inline simd8float32()¶
-
inline simd16uint16 min(simd16uint16 a, simd16uint16 b)¶