From f22500f23efe2a702085c4e9c4b6bb0c050d0e62 Mon Sep 17 00:00:00 2001 From: "se.gorbunov" <se.gorbunov@gsi.de> Date: Mon, 5 Sep 2022 09:54:11 +0000 Subject: [PATCH] L1: update of pseudo SSE vectors --- reco/L1/vectors/L1vecPseudo.h | 298 +++++++++++++++++++++++++++++++ reco/L1/vectors/PSEUDO_F32vec1.h | 165 ----------------- reco/L1/vectors/PSEUDO_F32vec4.h | 262 --------------------------- reco/L1/vectors/PSEUDO_F64vec1.h | 103 ----------- reco/L1/vectors/vec_arithmetic.h | 30 ---- 5 files changed, 298 insertions(+), 560 deletions(-) create mode 100644 reco/L1/vectors/L1vecPseudo.h delete mode 100644 reco/L1/vectors/PSEUDO_F32vec1.h delete mode 100644 reco/L1/vectors/PSEUDO_F32vec4.h delete mode 100644 reco/L1/vectors/PSEUDO_F64vec1.h delete mode 100644 reco/L1/vectors/vec_arithmetic.h diff --git a/reco/L1/vectors/L1vecPseudo.h b/reco/L1/vectors/L1vecPseudo.h new file mode 100644 index 0000000000..f9d21411f9 --- /dev/null +++ b/reco/L1/vectors/L1vecPseudo.h @@ -0,0 +1,298 @@ +/* Copyright (C) 2010 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt + SPDX-License-Identifier: GPL-3.0-only + Authors: Igor Kulakov [committer] */ + +#ifndef L1vecPseudo_H +#define L1vecPseudo_H + +#include <iomanip> +#include <iostream> + +#include <cmath> + +typedef float fscal; +const int fvecLen = 4; + +/********************************** + * + * Pseudo SIMD vector + * + **********************************/ + +fscal min(fscal x, fscal y); +fscal max(fscal x, fscal y); +fscal asgnb(fscal x, fscal y); +fscal sgn(fscal x); + + +class fmask { + +public: + static constexpr int Size {4}; + + bool v[Size]; + + bool& operator[](int i) { return v[i]; } + bool operator[](int i) const { return v[i]; } + + fmask() : fmask(0.f) {} + + fmask(const fmask& a) + { + for (int i = 0; i < Size; i++) { + v[i] = a.v[i]; + } + } + + fmask(bool a) + { + for (int i = 0; i < Size; i++) { + v[i] = a; + } + } + + static fmask One() { return fmask(true); } + + static fmask Zero() { return fmask(false); } + +#define _op(A, B, F) \ + fmask z; \ + for (int i = 0; i < Size; i++) { \ + z[i] = (A[i] F B[i]); \ + } \ + return z; + + /* Logic */ + friend fmask operator&&(const fmask& a, const fmask& b) { _op(a, b, &&) } + friend fmask operator||(const fmask& a, const fmask& b) { _op(a, b, ||) } + friend fmask operator&(const fmask& a, const fmask& b) { _op(a, b, &) } + friend fmask operator|(const fmask& a, const fmask& b) { _op(a, b, |) } + friend fmask operator^(const fmask& a, const fmask& b) { _op(a, b, ^) } + +#undef _op + + friend fmask operator!(const fmask& a) + { + fmask z; + for (int i = 0; i < Size; i++) { + z[i] = !a[i]; + } + return z; + } + + friend std::ostream& operator<<(std::ostream& strm, const fmask& a) + { + strm << '['; + for (int i = 0; i < Size; i++) { + strm << std::setw(12) << std::setfill(' ') << a[i] << ' '; + } + return strm; + } + + friend std::istream& operator>>(std::istream& strm, fmask& a) + { + for (int i = 0; i < Size; i++) { + strm >> a[i]; + } + return strm; + } +}; + + +class fvec { + +public: + static constexpr int Size {fmask::Size}; + + fscal v[Size]; + + fvec() : fvec(0.f) {} + + fvec(const fvec& a) + { + for (int i = 0; i < Size; i++) { + v[i] = a.v[i]; + } + } + + fvec(fscal a) + { + for (int i = 0; i < Size; i++) { + v[i] = a; + } + } + + static fvec One() { return fvec(1.); } + + static fvec Zero() { return fvec(0.); } + + fscal& operator[](int i) { return v[i]; } + + fscal operator[](int i) const { return v[i]; } + +#define _f1(A, F) \ + fvec z; \ + for (int i = 0; i < Size; i++) { \ + z[i] = F(A[i]); \ + } \ + return z; + +#define _f2(A, B, F) \ + fvec z; \ + for (int i = 0; i < Size; i++) { \ + z[i] = F(A[i], B[i]); \ + } \ + return z; + +#define _op(A, B, F) \ + fvec z; \ + for (int i = 0; i < Size; i++) { \ + z[i] = (A[i] F B[i]); \ + } \ + return z; + +#define _opComp(A, B, F) \ + fmask z; \ + for (int i = 0; i < Size; i++) { \ + z[i] = (A[i] F B[i]); \ + } \ + return z; + + + /* Arithmetic Operators */ + friend fvec operator+(const fvec& a, const fvec& b) { _op(a, b, +) } + friend fvec operator-(const fvec& a, const fvec& b) { _op(a, b, -) } + friend fvec operator*(const fvec& a, const fvec& b) { _op(a, b, *) } + friend fvec operator/(const fvec& a, const fvec& b) { _op(a, b, /) } + + /* Comparison */ + friend fmask operator<(const fvec& a, const fvec& b) { _opComp(a, b, <) } + friend fmask operator<=(const fvec& a, const fvec& b) { _opComp(a, b, <=) } + friend fmask operator>(const fvec& a, const fvec& b) { _opComp(a, b, >) } + friend fmask operator>=(const fvec& a, const fvec& b) { _opComp(a, b, >=) } + friend fmask operator==(const fvec& a, const fvec& b) { _opComp(a, b, ==) } + + friend fvec if3(fmask a, fvec b, fvec c) + { + fvec z; + for (int i = 0; i < Size; i++) { + z[i] = a[i] ? b[i] : c[i]; + } + return z; + } + + /* Functions */ + friend fscal min(fscal x, fscal y) { return x < y ? x : y; } + friend fscal max(fscal x, fscal y) { return x < y ? y : x; } + friend fscal asgnb(fscal x, fscal y) { return y >= 0.f ? fabs(x) : -fabs(x); } + friend fscal sgn(fscal x) { return x >= 0.f ? 1.f : -1.f; } + + friend fvec min(const fvec& a, const fvec& b) { _f2(a, b, min) } + friend fvec max(const fvec& a, const fvec& b) { _f2(a, b, max) } + friend fvec asgnb(const fvec& a, const fvec& b) { _f2(a, b, asgnb) } + friend fvec sqrt(const fvec& a) { _f1(a, sqrt) } + friend fvec abs(const fvec& a) { _f1(a, fabs) } + friend fvec sgn(const fvec& a) { _f1(a, sgn) } + friend fvec exp(const fvec& a) { _f1(a, exp) } + friend fvec log(const fvec& a) { _f1(a, log) } + friend fvec sin(const fvec& a) { _f1(a, sin) } + friend fvec cos(const fvec& a) { _f1(a, cos) } +#undef _f1 +#undef _f2 +#undef _op +#undef _opComp + + /* Define all operators for consistensy */ + + friend fvec operator-(const fvec& a) { return fvec(0) - a; } + friend fvec operator+(const fvec& a) { return a; } + friend fvec operator+(const fvec& a, const fscal& b) { return a + fvec(b); } + friend fvec operator-(const fvec& a, const fscal& b) { return a - fvec(b); } + friend fvec operator*(const fvec& a, const fscal& b) { return a * fvec(b); } + friend fvec operator/(const fvec& a, const fscal& b) { return a / fvec(b); } + friend fvec operator+(const fscal& a, const fvec& b) { return fvec(a) + b; } + friend fvec operator-(const fscal& a, const fvec& b) { return fvec(a) - b; } + friend fvec operator*(const fscal& a, const fvec& b) { return fvec(a) * b; } + friend fvec operator/(const fscal& a, const fvec& b) { return fvec(a) / b; } + friend void operator+=(fvec& a, const fvec& b) { a = a + b; } + friend void operator-=(fvec& a, const fvec& b) { a = a - b; } + friend void operator*=(fvec& a, const fvec& b) { a = a * b; } + friend void operator/=(fvec& a, const fvec& b) { a = a / b; } + friend void operator+=(fvec& a, const fscal& b) { a = a + b; } + friend void operator-=(fvec& a, const fscal& b) { a = a - b; } + friend void operator*=(fvec& a, const fscal& b) { a = a * b; } + friend void operator/=(fvec& a, const fscal& b) { a = a / b; } + + friend std::ostream& operator<<(std::ostream& strm, const fvec& a) + { + //strm << "[" << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << "]"; + strm << '['; + for (int i = 0; i < Size; i++) { + strm << std::setw(12) << std::setfill(' ') << a[i] << ' '; + } + return strm; + } + + friend std::istream& operator>>(std::istream& strm, fvec& a) + { + for (int i = 0; i < Size; i++) { + strm >> a[i]; + } + return strm; + } + +} __attribute__((aligned(16))); + + +#define _fvecalignment __attribute__((aligned(fvec::Size * sizeof(fscal)))) + + +inline fmask MaskOne() { return fmask::One(); } +inline fmask MaskZero() { return fmask::One(); } + +inline fvec fabs(const fvec& a) { return abs(a); } + +inline fvec masked(const fvec& a, const fmask& mask) { return if3(mask, a, fvec::Zero()); } + +inline fvec mask2int(const fmask& mask) +{ // mask returned + return if3(mask, fvec::One(), fvec::Zero()); +} + +/// Checks, if all bands are equal +/// NOTE: two values defined as signaling_NaN() are not equal, thus if there are all or one +/// of the words are kNaN, the function returns false +inline bool IsHorizontallyEqual(const fvec& v) +{ + fscal s = v[0]; + bool ret = true; + for (int i = 1; i < fvecLen; i++) { + ret = ret && (v[i] == s); + } + return ret; +} + +/// Checks, if any of the bands is NaN +inline bool IsNanAny(const fvec& v) +{ + bool ret = false; + for (int i = 0; i < fvecLen; i++) { + ret = ret || std::isnan(v[i]); + } + return ret; +} + +inline bool EmptyFmask(const fmask& a) +{ + bool ret = true; + for (int i = 0; i < fvecLen; i++) { + ret = ret && (!bool(a[i])); + } + return ret; +} + +inline bool NotEmptyFmask(const fmask& a) { return !EmptyFmask(a); } + +#include "std_alloc.h" + +#endif diff --git a/reco/L1/vectors/PSEUDO_F32vec1.h b/reco/L1/vectors/PSEUDO_F32vec1.h deleted file mode 100644 index 2a8b37f34d..0000000000 --- a/reco/L1/vectors/PSEUDO_F32vec1.h +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2010 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer] */ - -#ifndef CBM_KF_F32vec1_H -#define CBM_KF_F32vec1_H - -#include <iostream> - -#include <cmath> - -/********************************** - * - * Vector of one single float - * - **********************************/ - -// const union -// { -// int i[1]; -// float m; -// } -// __f32vec1_true_cheat = {0xFFFFFFFF}, -// __f32vec1_false_cheat = {0x00000000}; - -// #define _f32vec1_true ((F32vec1)__f32vec1_true_cheat.m) -// #define _f32vec1_false ((F32vec1)__f32vec1_false_cheat.m) - -class F32vec1 { -public: - float v; - - float& operator[](int i) { return v; } - float operator[](int i) const { return v; } - - F32vec1() {} - F32vec1(const float& v0) { v = v0; } - - /* Conversion function */ - operator float() const { return v; } /* Convert to __m128 */ - - /* Arithmetic Operators */ - - /* Functions */ - //friend F32vec1 min( const F32vec1 &a, const F32vec1 &b ){ return a<b ?a :b; } - //friend F32vec1 max( const F32vec1 &a, const F32vec1 &b ){ return a>b ?a :b; } - - /* Square Root */ - - /* Reciprocal( inverse) Square Root */ - //friend F32vec1 rsqrt( const F32vec1 &a ){ return 1./sqrt(a); } - - /* Reciprocal (inversion) */ - friend F32vec1 rcp(const F32vec1& a) { return 1. / a; } - - /* Absolute value */ - //friend F32vec1 fabs(const F32vec1 &a){ return fabs(a); } - - /* Sign */ - //friend F32vec1 sgn(const F32vec1 &a){ return a<0 ?-1 :(a>0 ?1 :0); } - - /* Logical */ - /* - friend F32vec1 operator&( const F32vec1 &a, const F32vec1 &b ){ // mask returned - F32vec1 tmp; - int *x = (int*)&tmp; - int *y = (int*)&a; - int *z = (int*)&b; - x[0] = y[0] & z[0]; - x[1] = y[1] & z[1]; - return tmp; - } - */ - /* Non intrinsic functions */ - - /* Define all operators for consistensy */ - - friend void operator+=(F32vec1& a, const F32vec1& b) { a = a + b; } - friend void operator-=(F32vec1& a, const F32vec1& b) { a = a - b; } - friend void operator*=(F32vec1& a, const F32vec1& b) { a = a * b; } - friend void operator/=(F32vec1& a, const F32vec1& b) { a = a / b; } - -#define _op(A, B, O) \ - F32vec1 z; \ - z.v = A.v O B.v; \ - return z; - - // /* Comparison */ - friend F32vec1 operator<(const F32vec1& a, const F32vec1& b) { _op(a, b, <) } - friend F32vec1 operator<=(const F32vec1& a, const F32vec1& b) { _op(a, b, <=) } - friend F32vec1 operator>(const F32vec1& a, const F32vec1& b) { _op(a, b, >) } - friend F32vec1 operator>=(const F32vec1& a, const F32vec1& b) { _op(a, b, >=) } - - // /* Logic */ - friend F32vec1 operator&(const F32vec1& a, const F32vec1& b) { _op(a, b, &&) } - friend F32vec1 operator|(const F32vec1& a, const F32vec1& b) { _op(a, b, ||) } - friend F32vec1 operator||(const F32vec1& a, const F32vec1& b) { _op(a, b, ||) } -#undef _op - - friend F32vec1 operator!(const F32vec1& a) - { - F32vec1 z; - z[0] = !a[0]; - - return z; - } - - friend F32vec1 if3(const F32vec1& a, const F32vec1& b, const F32vec1& c) - { - F32vec1 z; - z[0] = (a[0]) ? b[0] : c[0]; - - return z; - } - -#define NotEmptyFvec(a) bool((a)[0]) -#define EmptyFvec(a) !(bool((a)[0])) - friend F32vec1 bool2int(const F32vec1& a) - { // mask returned - return if3(a, 1, 0); - } - - - friend ostream& operator<<(ostream& strm, const F32vec1& a) - { - strm << a[0]; - return strm; - } - - friend istream& operator>>(istream& strm, F32vec1& a) - { - float tmp; - strm >> tmp; - a = tmp; - return strm; - } - -} __attribute__((aligned(4))); -; - -typedef F32vec1 fvec; -const int fvecLen = 1; -// #define fvec_true _f32vec1_true -// #define fvec_false _f32vec1_false -#define _fvecalignment - - -namespace nsL1 -{ - template<typename T> - struct vector { - typedef std::vector<T> TStd; - typedef std::vector<T> TSimd; - }; - - typedef nsL1::vector<fvec>::TSimd vector_fvec; -}; // namespace nsL1 - -template<typename T> -struct nsL1vector : - public nsL1::vector<T> // just for use std::vector simultaniosly -{ -}; - -#endif diff --git a/reco/L1/vectors/PSEUDO_F32vec4.h b/reco/L1/vectors/PSEUDO_F32vec4.h deleted file mode 100644 index fa985d9e60..0000000000 --- a/reco/L1/vectors/PSEUDO_F32vec4.h +++ /dev/null @@ -1,262 +0,0 @@ -/* Copyright (C) 2010 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer] */ - -#ifndef L1Algo_PSEUDO_F32vec4_H -#define L1Algo_PSEUDO_F32vec4_H - -#include <iomanip> -#include <iostream> - -#include <cmath> - -#include "vec_arithmetic.h" - -/********************************** - * - * Vector of four floats - * - **********************************/ - - -float min(float x, float y); -float max(float x, float y); -float asgnb(float x, float y); -float rsqrt(float x); -float rcp(float x); -float sgn(float x); - - -union F32scalUnion { - float f; - int i; - F32scalUnion() : f(0.f) {} - F32scalUnion(int j) : i(j) {} - F32scalUnion(float g) : f(g) {} -}; - -//const F32scalUnion __f32scal_abs_mask {static_cast<int>(0x7fffffff)}; -//const F32scalUnion __f32scal_sgn_mask {static_cast<int>(0x80000000)}; -const F32scalUnion __f32scal_true {static_cast<int>(0xFFFFFFFF)}; -const F32scalUnion __f32scal_false {static_cast<int>(0x00000000)}; - - -class F32vec4 { - -public: - F32scalUnion v[4]; - - float& operator[](int i) { return v[i].f; } - float operator[](int i) const { return v[i].f; } - - F32vec4() : F32vec4(0.f) {} - - F32vec4(const F32vec4& a) - { - v[0] = a.v[0]; - v[1] = a.v[1]; - v[2] = a.v[2]; - v[3] = a.v[3]; - } - - F32vec4(float a) - { - v[0].f = a; - v[1].f = a; - v[2].f = a; - v[3].f = a; - } - - F32vec4(float f0, float f1, float f2, float f3) - { - v[0].f = f0; - v[1].f = f1; - v[2].f = f2; - v[3].f = f3; - } - -#define _f1(A, F) \ - F32vec4 z; \ - z[0] = F(A[0]); \ - z[1] = F(A[1]); \ - z[2] = F(A[2]); \ - z[3] = F(A[3]); \ - return z; - -#define _f2(A, B, F) \ - F32vec4 z; \ - z[0] = F(A[0], B[0]); \ - z[1] = F(A[1], B[1]); \ - z[2] = F(A[2], B[2]); \ - z[3] = F(A[3], B[3]); \ - return z; - -#define _op(A, B, F) \ - F32vec4 z; \ - z[0] = (A[0] F B[0]); \ - z[1] = (A[1] F B[1]); \ - z[2] = (A[2] F B[2]); \ - z[3] = (A[3] F B[3]); \ - return z; - -#define _opBit(A, B, F) \ - F32vec4 z; \ - z.v[0].i = (A.v[0].i F B.v[0].i); \ - z.v[1].i = (A.v[1].i F B.v[1].i); \ - z.v[2].i = (A.v[2].i F B.v[2].i); \ - z.v[3].i = (A.v[3].i F B.v[3].i); \ - return z; - -#define _opComp(A, B, F) \ - F32vec4 z; \ - z[0] = (A[0] F B[0]) ? __f32scal_true.f : __f32scal_false.f; \ - z[1] = (A[1] F B[1]) ? __f32scal_true.f : __f32scal_false.f; \ - z[2] = (A[2] F B[2]) ? __f32scal_true.f : __f32scal_false.f; \ - z[3] = (A[3] F B[3]) ? __f32scal_true.f : __f32scal_false.f; \ - return z; - - - /* Arithmetic Operators */ - friend F32vec4 operator+(const F32vec4& a, const F32vec4& b) { _op(a, b, +) } - friend F32vec4 operator-(const F32vec4& a, const F32vec4& b) { _op(a, b, -) } - friend F32vec4 operator*(const F32vec4& a, const F32vec4& b) { _op(a, b, *) } - friend F32vec4 operator/(const F32vec4& a, const F32vec4& b) { _op(a, b, /) } - - /* Comparison */ - friend F32vec4 operator<(const F32vec4& a, const F32vec4& b) { _opComp(a, b, <) } - friend F32vec4 operator<=(const F32vec4& a, const F32vec4& b) { _opComp(a, b, <=) } - friend F32vec4 operator>(const F32vec4& a, const F32vec4& b) { _opComp(a, b, >) } - friend F32vec4 operator>=(const F32vec4& a, const F32vec4& b) { _opComp(a, b, >=) } - friend F32vec4 operator==(const F32vec4& a, const F32vec4& b) { _opComp(a, b, ==) } - - /* Logic */ - friend F32vec4 operator&(const F32vec4& a, const F32vec4& b) { _opBit(a, b, &) } - friend F32vec4 operator|(const F32vec4& a, const F32vec4& b) { _opBit(a, b, |) } - friend F32vec4 operator^(const F32vec4& a, const F32vec4& b) { _opBit(a, b, ^) } - - friend F32vec4 operator!(const F32vec4& a) - { - F32vec4 z; - z.v[0].i = ~a.v[0].i; - z.v[1].i = ~a.v[1].i; - z.v[2].i = ~a.v[2].i; - z.v[3].i = ~a.v[3].i; - return z; - } - - friend F32vec4 if3(F32vec4 a, F32vec4 b, F32vec4 c) { return ((a) & (b)) | ((!(a)) & (c)); } // analog (a) ? b : c - - /* - friend F32vec4 if3(const F32vec4& a, const F32vec4& b, const F32vec4& c) - { - F32vec4 z; - z[0] = (a.v[0].i) ? b[0] : c[0]; - z[1] = (a.v[1].i) ? b[1] : c[1]; - z[2] = (a.v[2].i) ? b[2] : c[2]; - z[3] = (a.v[3].i) ? b[3] : c[3]; - return z; - }*/ - - friend bool NotEmptyFvec(F32vec4 a) { return bool(a.v[0].i) || bool(a.v[1].i) || bool(a.v[2].i) || bool(a.v[3].i); } - friend bool EmptyFvec(F32vec4 a) { return !NotEmptyFvec(a); } - - // bool NotEmpty(const F32vec4 &a) { return a[0]||a[1]||a[2]||a[3]; } - // bool Empty(const F32vec4 &a) { return !(a[0]||a[1]||a[2]||a[3]); } // optimize - - friend F32vec4 bool2int(const F32vec4& a) - { // mask returned - return if3(a, 1, 0); - } - - - /* Functions */ - friend float min(float x, float y) { return x < y ? x : y; } - friend float max(float x, float y) { return x < y ? y : x; } - friend float asgnb(float x, float y) { return y >= 0.f ? fabs(x) : -fabs(x); } - friend float rsqrt(float x) { return 1. / sqrt(x); } - friend float rcp(float x) { return 1. / x; } - friend float sgn(float x) { return x >= 0.f ? 1.f : -1.f; } - - friend F32vec4 min(const F32vec4& a, const F32vec4& b) { _f2(a, b, min) } - friend F32vec4 max(const F32vec4& a, const F32vec4& b) { _f2(a, b, max) } - friend F32vec4 asgnb(const F32vec4& a, const F32vec4& b) { _f2(a, b, asgnb) } - friend F32vec4 sqrt(const F32vec4& a) { _f1(a, sqrt) } - friend F32vec4 rsqrt(const F32vec4& a) { _f1(a, rsqrt) } - friend F32vec4 rcp(const F32vec4& a) { _f1(a, rcp) } - friend F32vec4 fabs(const F32vec4& a) { _f1(a, fabs) } - friend F32vec4 sgn(const F32vec4& a) { _f1(a, sgn) } - friend F32vec4 exp(const F32vec4& a) { _f1(a, exp) } - friend F32vec4 log(const F32vec4& a) { _f1(a, log) } - friend F32vec4 sin(const F32vec4& a) { _f1(a, sin) } - friend F32vec4 cos(const F32vec4& a) { _f1(a, cos) } -#undef _f1 -#undef _f2 -#undef _op -#undef _opBit -#undef _opComp - - /* Define all operators for consistensy */ - - vec_arithmetic(F32vec4, float); - - friend std::ostream& operator<<(std::ostream& strm, const F32vec4& a) - { - //strm << "[" << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << "]"; - strm << '['; - strm << std::setw(12) << std::setfill(' ') << a[0] << ' '; - strm << std::setw(12) << std::setfill(' ') << a[1] << ' '; - strm << std::setw(12) << std::setfill(' ') << a[2] << ' '; - strm << std::setw(12) << std::setfill(' ') << a[3] << ']'; - return strm; - } - - friend std::istream& operator>>(std::istream& strm, F32vec4& a) - { - float tmp; - strm >> tmp; - a = tmp; - return strm; - } - - /// Checks, if all bands are equal - /// NOTE: two values defined as signaling_NaN() are not equal, thus if there are all or one - /// of the words are kNaN, the function returns false - bool IsHorizontallyEqual() const { return (v[0].f == v[1].f) && (v[1].f == v[2].f) && (v[2].f == v[3].f); } - - /// Checks, if any of the bands is NaN - bool IsNanAny() const { return std::isnan(v[0].f) || std::isnan(v[1].f) || std::isnan(v[2].f) || std::isnan(v[3].f); } - - -} __attribute__((aligned(16))); - - -typedef F32vec4 fvec; -typedef float fscal; -const int fvecLen = 4; - -const F32vec4 fvec_zero(0.f); -const F32vec4 fvec_one(1.f); -const F32vec4 fvec_true(__f32scal_true.f); -const F32vec4 fvec_false(__f32scal_false.f); - -#define _fvecalignment - - -namespace nsL1 -{ - template<typename T> - struct vector { - typedef std::vector<T> TStd; - typedef std::vector<T> TSimd; - }; - - typedef nsL1::vector<fvec>::TSimd vector_fvec; -}; // namespace nsL1 - -template<typename T> -struct nsL1vector : - public nsL1::vector<T> // just for use std::vector simultaniosly -{ -}; - -#endif diff --git a/reco/L1/vectors/PSEUDO_F64vec1.h b/reco/L1/vectors/PSEUDO_F64vec1.h deleted file mode 100644 index 409abf45e4..0000000000 --- a/reco/L1/vectors/PSEUDO_F64vec1.h +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (C) 2010 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer] */ - -#ifndef L1Algo_PSEUDO_F64vec1_H -#define L1Algo_PSEUDO_F64vec1_H - -#include <iostream> - -#include <cmath> - -#include "vec_arithmetic.h" - -/********************************** - * - * Vector of four doubles - * - **********************************/ - -class F64vec1 { -public: - double v[1]; - - double& operator[](int i) { return ((double*) &v)[i]; } - double operator[](int i) const { return ((double*) &v)[i]; } - - F64vec1() {} - F64vec1(const F64vec1& a) { v[0] = a.v[0]; } - F64vec1(const double& a) { v[0] = a; } - - friend double min(double x, double y) { return x < y ? x : y; } - friend double max(double x, double y) { return x < y ? y : x; } - friend double asgnb(double x, double y) { return y >= 0 ? fabs(x) : -fabs(x); } - friend double rsqrt(double x) { return 1. / sqrt(x); } - friend double rcp(double x) { return 1. / x; } - friend double sgn(double x) { return x >= 0 ? 1 : -1; } - -#define _f2(A, B, F) \ - F64vec1 z; \ - z.v[0] = F(A.v[0], B.v[0]); \ - return z; -#define _f1(A, F) \ - F64vec1 z; \ - z.v[0] = F(A.v[0]); \ - return z; -#define _op(A, B, O) \ - F64vec1 z; \ - z.v[0] = A.v[0] O B.v[0]; \ - return z; - - /* Arithmetic Operators */ - friend F64vec1 operator+(const F64vec1& a, const F64vec1& b) { _op(a, b, +) } - friend F64vec1 operator-(const F64vec1& a, const F64vec1& b) { _op(a, b, -) } - friend F64vec1 operator*(const F64vec1& a, const F64vec1& b) { _op(a, b, *) } - friend F64vec1 operator/(const F64vec1& a, const F64vec1& b) { _op(a, b, /) } - - /* Functions */ - friend F64vec1 min(const F64vec1& a, const F64vec1& b) { _f2(a, b, min) } - friend F64vec1 max(const F64vec1& a, const F64vec1& b) { _f2(a, b, max) } - friend F64vec1 asgnb(const F64vec1& a, const F64vec1& b) { _f2(a, b, asgnb) } - friend F64vec1 sqrt(const F64vec1& a) { _f1(a, sqrt) } - friend F64vec1 rsqrt(const F64vec1& a) { _f1(a, rsqrt) } - friend F64vec1 rcp(const F64vec1& a) { _f1(a, rcp) } - friend F64vec1 fabs(const F64vec1& a) { _f1(a, fabs) } - friend F64vec1 sgn(const F64vec1& a) { _f1(a, sgn) } - friend F64vec1 exp(const F64vec1& a) { _f1(a, exp) } - friend F64vec1 log(const F64vec1& a) { _f1(a, log) } - friend F64vec1 sin(const F64vec1& a) { _f1(a, sin) } - friend F64vec1 cos(const F64vec1& a) { _f1(a, cos) } -#undef _f1 -#undef _f2 -#undef _op - - /* Define all operators for consistensy */ - - vec_arithmetic(F64vec1, double); - - friend std::ostream& operator<<(std::ostream& strm, const F64vec1& a) - { - strm << a[0]; - return strm; - } - - friend std::istream& operator>>(std::istream& strm, F64vec1& a) - { - double tmp; - strm >> tmp; - a = tmp; - return strm; - } - -}; // __attribute__ ((aligned(16)));; - -typedef F64vec1 fvec; -const int fvecLen = 1; -typedef double fscal; - -//#define fvec_true _f32vec1_true -//#define fvec_false _f32vec1_false -#define _fvecalignment - - -#endif diff --git a/reco/L1/vectors/vec_arithmetic.h b/reco/L1/vectors/vec_arithmetic.h deleted file mode 100644 index 8afeeb57b3..0000000000 --- a/reco/L1/vectors/vec_arithmetic.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2010-2014 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer] */ - -#ifndef _vec_arithmetic_H -#define _vec_arithmetic_H - -/* Define all operators after definition of basic operators */ - -#define vec_arithmetic(V, S) \ - friend V operator-(const V& a) { return V(0) - a; } \ - friend V operator+(const V& a) { return a; } \ - friend V operator+(const V& a, const S& b) { return a + V(b); } \ - friend V operator-(const V& a, const S& b) { return a - V(b); } \ - friend V operator*(const V& a, const S& b) { return a * V(b); } \ - friend V operator/(const V& a, const S& b) { return a / V(b); } \ - friend V operator+(const S& a, const V& b) { return V(a) + b; } \ - friend V operator-(const S& a, const V& b) { return V(a) - b; } \ - friend V operator*(const S& a, const V& b) { return V(a) * b; } \ - friend V operator/(const S& a, const V& b) { return V(a) / b; } \ - friend void operator+=(V& a, const V& b) { a = a + b; } \ - friend void operator-=(V& a, const V& b) { a = a - b; } \ - friend void operator*=(V& a, const V& b) { a = a * b; } \ - friend void operator/=(V& a, const V& b) { a = a / b; } \ - friend void operator+=(V& a, const S& b) { a = a + b; } \ - friend void operator-=(V& a, const S& b) { a = a - b; } \ - friend void operator*=(V& a, const S& b) { a = a * b; } \ - friend void operator/=(V& a, const S& b) { a = a / b; } - -#endif -- GitLab