From c58e3ed4593f03afd535b9e483a82a4d951bdeb8 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 13:16:49 +0100 Subject: [PATCH 01/11] Add ARN to CI --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ CMakeLists.txt | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 31f43b1..6f41601 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,3 +20,29 @@ jobs: uses: ./.github/workflows/fedora35 - name: Get the output status run: exit ${{ steps.compileindocker.outputs.out }} + + + compilejobRocky9_ARM: + if: "!contains(github.event.head_commit.message, 'skip ci')" + name: Rocky9aarch64_ARM + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: QEMU + run: | + set -x + sudo apt update + sudo apt install --yes binfmt-support qemu-user-static wget + - name: Compile_with_arm + continue-on-error: true + uses: addnab/docker-run-action@v3 + with: + image: arm64v8/rockylinux:9 + options: -v ${{ github.workspace }}:/work --platform=linux/arm64/v8 + run: | + dnf -y install epel-release wget + dnf -y install gcc gcc-c++ gcc-gfortran make which cmake cmake-data cmake-filesystem + cmake -S . -B BUILD -DCMAKE_INSTALL_PREFIX=$(pwd)/INSTALL + cmake --build BUILD + cmake --install BUILD diff --git a/CMakeLists.txt b/CMakeLists.txt index 64bd4c3..0bc4e74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ configure_file( "${PROJECT_SOURCE_DIR}/src/qcdloop.pc.in" "${PROJECT_SOURCE_DIR}/src/qcdloop.pc" ) - +IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") set(QUADMATH_NAMES ${QUADMATH_NAMES} libquadmath.so quadmath) find_library(QUADMATH_LIBRARY NAMES ${QUADMATH_NAMES} @@ -95,7 +95,7 @@ else(QUADMATH_FOUND) message(FATAL_ERROR "Could not find QuadMath") endif(QUADMATH_FIND_REQUIRED) endif(QUADMATH_FOUND) - +endif() # libqcdloop configuration include_directories(src/qcdloop src) FILE(GLOB_RECURSE Headers "src/qcdloop/*.h") From 9c464e46f48e8e66bc3276cc188b5233f7589252 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 13:22:25 +0100 Subject: [PATCH 02/11] Add ARM to CI --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f41601..f342276 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,8 +41,10 @@ jobs: image: arm64v8/rockylinux:9 options: -v ${{ github.workspace }}:/work --platform=linux/arm64/v8 run: | - dnf -y install epel-release wget dnf -y install gcc gcc-c++ gcc-gfortran make which cmake cmake-data cmake-filesystem + cd work + pwd + ls cmake -S . -B BUILD -DCMAKE_INSTALL_PREFIX=$(pwd)/INSTALL cmake --build BUILD cmake --install BUILD From 7834e0589c0a8e212bc3080f999749290e0c5da9 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 13:24:13 +0100 Subject: [PATCH 03/11] Add ARM to CI --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f342276..ebc7719 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,6 +41,8 @@ jobs: image: arm64v8/rockylinux:9 options: -v ${{ github.workspace }}:/work --platform=linux/arm64/v8 run: | + set -e + set -x dnf -y install gcc gcc-c++ gcc-gfortran make which cmake cmake-data cmake-filesystem cd work pwd From 5d04f36bd5bf122648c0b38b62873400285b3b55 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 13:28:20 +0100 Subject: [PATCH 04/11] Add ARM to CI --- src/qcdloop/types.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qcdloop/types.h b/src/qcdloop/types.h index 8a832dd..51dffed 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -7,9 +7,19 @@ #pragma once +#ifdef __x86_64__ extern "C" { // for gcc4.7 compatibility #include } +#endif +#ifdef __aarch64__ +#include +#include +#include +#include +typedef long double __float128; +using __complex128 = long double _Complex ; +#endif #include #define UNUSED(expr) (void)(expr) From ff2179a0da8eadc8e3e0ff82d15b71645a933059 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 13:34:08 +0100 Subject: [PATCH 05/11] Add ARM to CI --- src/qcdloop/types.h | 63 +++++++++++++++++++++++++++++++++++++++++++++ src/types.cc | 6 +++++ 2 files changed, 69 insertions(+) diff --git a/src/qcdloop/types.h b/src/qcdloop/types.h index 51dffed..fa09940 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -19,6 +19,69 @@ extern "C" { // for gcc4.7 compatibility #include typedef long double __float128; using __complex128 = long double _Complex ; +#define acosq acosl +#define acoshq acoshl +#define asinq asinl +#define asinhq asinhl +#define atanq atanl +#define atanhq atanhl +#define cbrtq cbrtl +#define ceilq ceill +#define coshq coshl +#define cosq cosl +#define erfq erfl +#define erfcq erfcl +#define expq expl +#define expm1q expm1l +#define fabsq fabsl +#define floorq floorl +#define lgammaq lgammal +#define logq logl +#define log10q log10l +#define log2q log2l +#define log1pq log1pl +#define nearbyintq nearbyintl +#define rintq rintl +#define roundq roundl +#define sinhq sinhl +#define sinq sinl +#define sqrtq sqrtl +#define tanq tanl +#define tanhq tanhl +#define tgammaq tgammal +#define truncq truncl + +#define atan2q atan2l +#define copysignq copysignl +#define hypotq hypotl +#define ldexpq ldexpl +#define nextafterq nextafterl +#define powq powl +#define remainderq remainderl + + +#define cabsq cabsl +#define crealq creall +#define cimagq cimagl +#define cargq cargl +#define conjq conjl +#define cacosq cacosl +#define cacoshq cacoshl +#define casinq casinl +#define casinhq casinhl +#define catanq catanl +#define catanhq catanhl +#define ccosq ccosl +#define ccoshq ccoshl +#define cexpq cexpl +#define clogq clogl +#define clog10q clog10l +#define csinq csinl +#define csinhq csinhl +#define csqrtq csqrtl +#define ctanq ctanl +#define ctanhq ctanhl +#define cpowq cpowl #endif #include diff --git a/src/types.cc b/src/types.cc index 9e90a47..311846c 100644 --- a/src/types.cc +++ b/src/types.cc @@ -13,8 +13,14 @@ namespace std { char buf[200]; std::ostringstream format; +#ifdef __x86_64__ format << "%." << (std::min)(190L, out.precision()) << "Qe"; quadmath_snprintf(buf, 200, format.str().c_str(), f); +#endif +#ifdef __aarch64__ + format << "%." << (std::min)(190L, out.precision()) << "Le"; + snprintf(buf, 200, format.str().c_str(), f); +#endif out << buf; return out; } From 4198e351139f8d2202aef6722daa59e2eb6ae0ff Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 13:47:05 +0100 Subject: [PATCH 06/11] Add ARM to CI --- src/qcdloop/types.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qcdloop/types.h b/src/qcdloop/types.h index fa09940..89e6dc3 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -11,8 +11,9 @@ extern "C" { // for gcc4.7 compatibility #include } -#endif -#ifdef __aarch64__ +#else +//#endif +//#ifdef __aarch64__ #include #include #include From e7f910f31ca37190761f454c30492420bfff6ea2 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 13:54:38 +0100 Subject: [PATCH 07/11] Add ARM to CI --- src/qcdloop/types.h | 120 ++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/qcdloop/types.h b/src/qcdloop/types.h index 89e6dc3..ff5186a 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -20,69 +20,69 @@ extern "C" { // for gcc4.7 compatibility #include typedef long double __float128; using __complex128 = long double _Complex ; -#define acosq acosl -#define acoshq acoshl -#define asinq asinl -#define asinhq asinhl -#define atanq atanl -#define atanhq atanhl -#define cbrtq cbrtl -#define ceilq ceill -#define coshq coshl -#define cosq cosl -#define erfq erfl -#define erfcq erfcl -#define expq expl -#define expm1q expm1l -#define fabsq fabsl -#define floorq floorl -#define lgammaq lgammal -#define logq logl -#define log10q log10l -#define log2q log2l -#define log1pq log1pl -#define nearbyintq nearbyintl -#define rintq rintl -#define roundq roundl -#define sinhq sinhl -#define sinq sinl -#define sqrtq sqrtl -#define tanq tanl -#define tanhq tanhl -#define tgammaq tgammal -#define truncq truncl +#define acos std::acos +#define acosh std::acoshl +#define asin std::asin +#define asinh std::asinhl +#define atan std::atan +#define atanh std::atanhl +#define cbrt std::cbrt +#define ceil std::ceil +#define cosh std::cosh +#define cos std::cos +#define erf std::erf +#define erfc std::erfc +#define exp std::exp +#define expm1 std::expm1 +#define fabs std::fabs +#define floor std::floor +#define lgamma std::lgamma +#define log std::log +#define log10 std::log10 +#define log2 std::log2 +#define log1p std::log1p +#define nearbyint std::nearbyint +#define rint std::rint +#define round std::round +#define sinh std::sinh +#define sin std::sin +#define sqrt std::sqrt +#define tan std::tan +#define tanh std::tanh +#define tgamma std::tgamma +#define trunc std::trunc -#define atan2q atan2l -#define copysignq copysignl -#define hypotq hypotl -#define ldexpq ldexpl -#define nextafterq nextafterl -#define powq powl -#define remainderq remainderl +#define atan2 std::atan2 +#define copysign std::copysign +#define hypot std::hypot +#define ldexp std::ldexp +#define nextafter std::nextafter +#define pow std::pow +#define remainder std::remainder -#define cabsq cabsl -#define crealq creall -#define cimagq cimagl -#define cargq cargl -#define conjq conjl -#define cacosq cacosl -#define cacoshq cacoshl -#define casinq casinl -#define casinhq casinhl -#define catanq catanl -#define catanhq catanhl -#define ccosq ccosl -#define ccoshq ccoshl -#define cexpq cexpl -#define clogq clogl -#define clog10q clog10l -#define csinq csinl -#define csinhq csinhl -#define csqrtq csqrtl -#define ctanq ctanl -#define ctanhq ctanhl -#define cpowq cpowl +#define cabsq std::abs +#define crealq std::real +#define cimagq std::imag +#define cargq std::arg +#define conjq std::conj +#define cacosq std::acos +#define cacoshq std::acosh +#define casinq std::asin +#define casinhq std::asinh +#define catanq std::atan +#define catanhq std::atanh +#define ccosq std::cos +#define ccoshq std::cosh +#define cexpq std::exp +#define clogq std::log +#define clog10q std::log10 +#define csinq std::sin +#define csinhq std::sinh +#define csqrtq std::sqrt +#define ctanq std::tan +#define ctanhq std::tanh +#define cpowq std::powl #endif #include From 7f8082980d14b2810db3a2dbeaf8b6c1d8f953a0 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 14:10:00 +0100 Subject: [PATCH 08/11] Add ARM to CI --- src/qcdloop/maths.h | 41 +++++++++++++++++++++++++++++++++++++---- src/qcdloop/types.h | 7 ++++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/qcdloop/maths.h b/src/qcdloop/maths.h index b66cb24..c727726 100644 --- a/src/qcdloop/maths.h +++ b/src/qcdloop/maths.h @@ -17,41 +17,74 @@ namespace ql { // Logarithms inline double Log(double const& x) { return std::log(x); } +#ifdef __x86_64__ inline qdouble Log(qdouble const& x) { return logq(x); } - inline complex Log(complex const& x) { return std::log(x); } inline qcomplex Log(qcomplex const& x) { return clogq(x); } +#else + inline qdouble Log(qdouble const& x) { return std::log(x); } + inline qcomplex Log(qcomplex const& x) { return std::logq(x); } +#endif + inline complex Log(complex const& x) { return std::log(x); } // Power inline double Pow(double const& x, int const& a) { return std::pow(x, a); } +#ifdef __x86_64__ inline qdouble Pow(qdouble const& x, int const& a) { return powq(x,a); } - inline complex Pow(complex const& x, int const& a) { return std::pow(x,a); } inline qcomplex Pow(qcomplex const& x, int const& a){ return cpowq(x,a); } +#else + inline qdouble Pow(qdouble const& x, int const& a) { return std::pow(x,a); } + inline qcomplex Pow(qcomplex const& x, int const& a){ return std::pow(x,a); } +#endif + inline complex Pow(complex const& x, int const& a) { return std::pow(x,a); } // Root inline double Sqrt(double const& x) { return std::sqrt(x); } +#ifdef __x86_64__ inline qdouble Sqrt(qdouble const& x) { return sqrtq(x); } - inline complex Sqrt(complex const& x) { return std::sqrt(x); } inline qcomplex Sqrt(qcomplex const& x){ return csqrtq(x); } +#else + inline qdouble Sqrt(qdouble const& x) { return std::sqrt(x); } + inline qcomplex Sqrt(qcomplex const& x){ return std::sqrt(x); } +#endif + inline complex Sqrt(complex const& x) { return std::sqrt(x); } // Absolute value inline double Abs(double const& x) { return std::abs(x); } +#ifdef __x86_64__ inline qdouble Abs(qdouble const& x) { return fabsq(x);} - inline double Abs(complex const& x) { return std::abs(x);} inline qdouble Abs(qcomplex const& x) { return cabsq(x); } +#else + inline qdouble Abs(qdouble const& x) { return std::abs(x);} + inline qdouble Abs(qcomplex const& x) { return std::abs(x); } +#endif + inline double Abs(complex const& x) { return std::abs(x);} // Complex tools, imag, real and conj. inline double Imag(double const& x) { UNUSED(x); return 0; } inline qdouble Imag(qdouble const& x) { UNUSED(x); return qdouble(0); } inline double Imag(complex const& x) { return x.imag(); } +#ifdef __x86_64__ inline qdouble Imag(qcomplex const& x){ return cimagq(x);} +#else + inline qdouble Imag(qcomplex const& x){ return std::imag(x);} +#endif inline double Real(double const& x) { return x; } inline qdouble Real(qdouble const& x) { return x; } inline double Real(complex const& x) { return x.real(); } +#ifdef __x86_64__ inline qdouble Real(qcomplex const& x) { return crealq(x); } +#else + inline qdouble Real(qcomplex const& x) { return std::real(x); } +#endif inline complex Conjg(complex const& x) { return std::conj(x); } +#ifdef __x86_64__ inline qcomplex Conjg(qcomplex const& x){ return conjq(x); } +#else + inline qcomplex Conjg(qcomplex const& x){ return std::conj(x); } +#endif + // Comparison and sign operations inline int Sign(double const& x) { return (double(0) < x) - (x < double(0)); } diff --git a/src/qcdloop/types.h b/src/qcdloop/types.h index ff5186a..88a5ffe 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -12,14 +12,15 @@ extern "C" { // for gcc4.7 compatibility #include } #else -//#endif -//#ifdef __aarch64__ +#endif +#ifdef __aarch64__ #include #include #include #include typedef long double __float128; using __complex128 = long double _Complex ; +/* #define acos std::acos #define acosh std::acoshl #define asin std::asin @@ -82,7 +83,7 @@ using __complex128 = long double _Complex ; #define csqrtq std::sqrt #define ctanq std::tan #define ctanhq std::tanh -#define cpowq std::powl +#define cpowq std::powl*/ #endif #include From c97e40ab6d2341de0d034bcdcc2f471d0722e3e5 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 14:15:31 +0100 Subject: [PATCH 09/11] OK --- src/qcdloop/maths.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qcdloop/maths.h b/src/qcdloop/maths.h index c727726..4774b46 100644 --- a/src/qcdloop/maths.h +++ b/src/qcdloop/maths.h @@ -22,7 +22,7 @@ namespace ql inline qcomplex Log(qcomplex const& x) { return clogq(x); } #else inline qdouble Log(qdouble const& x) { return std::log(x); } - inline qcomplex Log(qcomplex const& x) { return std::logq(x); } + inline qcomplex Log(qcomplex const& x) { return std::log(x); } #endif inline complex Log(complex const& x) { return std::log(x); } @@ -33,7 +33,7 @@ namespace ql inline qcomplex Pow(qcomplex const& x, int const& a){ return cpowq(x,a); } #else inline qdouble Pow(qdouble const& x, int const& a) { return std::pow(x,a); } - inline qcomplex Pow(qcomplex const& x, int const& a){ return std::pow(x,a); } + inline qcomplex Pow(qcomplex const& x, int const& a){ return cpowl(x,a); } #endif inline complex Pow(complex const& x, int const& a) { return std::pow(x,a); } @@ -44,7 +44,7 @@ namespace ql inline qcomplex Sqrt(qcomplex const& x){ return csqrtq(x); } #else inline qdouble Sqrt(qdouble const& x) { return std::sqrt(x); } - inline qcomplex Sqrt(qcomplex const& x){ return std::sqrt(x); } + inline qcomplex Sqrt(qcomplex const& x){ return csqrtl(x); } #endif inline complex Sqrt(complex const& x) { return std::sqrt(x); } @@ -55,7 +55,7 @@ namespace ql inline qdouble Abs(qcomplex const& x) { return cabsq(x); } #else inline qdouble Abs(qdouble const& x) { return std::abs(x);} - inline qdouble Abs(qcomplex const& x) { return std::abs(x); } + inline qdouble Abs(qcomplex const& x) { return cabsl(x); } #endif inline double Abs(complex const& x) { return std::abs(x);} @@ -75,7 +75,7 @@ namespace ql #ifdef __x86_64__ inline qdouble Real(qcomplex const& x) { return crealq(x); } #else - inline qdouble Real(qcomplex const& x) { return std::real(x); } + inline qdouble Real(qcomplex const& x) { return creall(x); } #endif inline complex Conjg(complex const& x) { return std::conj(x); } From 6aed397d35e685759321b3aeb441132c7fb021f3 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 14:54:57 +0100 Subject: [PATCH 10/11] OK --- src/cache.cc | 2 ++ src/qcdloop/maths.h | 12 ++++--- src/qcdloop/types.h | 76 +++++++-------------------------------------- src/tools.cc | 4 +++ src/types.cc | 14 +++++---- 5 files changed, 34 insertions(+), 74 deletions(-) diff --git a/src/cache.cc b/src/cache.cc index 4974297..ac88f4a 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -17,6 +17,7 @@ namespace std { seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } +#ifdef __x86_64__ template <> struct hash : public __hash_base { @@ -25,6 +26,7 @@ namespace std { return x != 0.0q ? std::_Hash_impl::hash(x) : 0; } }; +#endif template <> struct hash : public __hash_base { diff --git a/src/qcdloop/maths.h b/src/qcdloop/maths.h index 4774b46..eb8dcc4 100644 --- a/src/qcdloop/maths.h +++ b/src/qcdloop/maths.h @@ -8,7 +8,11 @@ #pragma once #include "types.h" - +#include +#include +#include +#include +#include /*! * Some basic math functions with inline (performance) * for double and quadruple precision. @@ -22,7 +26,7 @@ namespace ql inline qcomplex Log(qcomplex const& x) { return clogq(x); } #else inline qdouble Log(qdouble const& x) { return std::log(x); } - inline qcomplex Log(qcomplex const& x) { return std::log(x); } + inline qcomplex Log(qcomplex const& x) { return clogl(x); } #endif inline complex Log(complex const& x) { return std::log(x); } @@ -66,7 +70,7 @@ namespace ql #ifdef __x86_64__ inline qdouble Imag(qcomplex const& x){ return cimagq(x);} #else - inline qdouble Imag(qcomplex const& x){ return std::imag(x);} + inline qdouble Imag(qcomplex const& x){ return cimagl(x);} #endif inline double Real(double const& x) { return x; } @@ -82,7 +86,7 @@ namespace ql #ifdef __x86_64__ inline qcomplex Conjg(qcomplex const& x){ return conjq(x); } #else - inline qcomplex Conjg(qcomplex const& x){ return std::conj(x); } + inline qcomplex Conjg(qcomplex const& x){ return conjl(x); } #endif diff --git a/src/qcdloop/types.h b/src/qcdloop/types.h index 88a5ffe..1b2132c 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -20,70 +20,15 @@ extern "C" { // for gcc4.7 compatibility #include typedef long double __float128; using __complex128 = long double _Complex ; -/* -#define acos std::acos -#define acosh std::acoshl -#define asin std::asin -#define asinh std::asinhl -#define atan std::atan -#define atanh std::atanhl -#define cbrt std::cbrt -#define ceil std::ceil -#define cosh std::cosh -#define cos std::cos -#define erf std::erf -#define erfc std::erfc -#define exp std::exp -#define expm1 std::expm1 -#define fabs std::fabs -#define floor std::floor -#define lgamma std::lgamma -#define log std::log -#define log10 std::log10 -#define log2 std::log2 -#define log1p std::log1p -#define nearbyint std::nearbyint -#define rint std::rint -#define round std::round -#define sinh std::sinh -#define sin std::sin -#define sqrt std::sqrt -#define tan std::tan -#define tanh std::tanh -#define tgamma std::tgamma -#define trunc std::trunc - -#define atan2 std::atan2 -#define copysign std::copysign -#define hypot std::hypot -#define ldexp std::ldexp -#define nextafter std::nextafter -#define pow std::pow -#define remainder std::remainder - - -#define cabsq std::abs -#define crealq std::real -#define cimagq std::imag -#define cargq std::arg -#define conjq std::conj -#define cacosq std::acos -#define cacoshq std::acosh -#define casinq std::asin -#define casinhq std::asinh -#define catanq std::atan -#define catanhq std::atanh -#define ccosq std::cos -#define ccoshq std::cosh -#define cexpq std::exp -#define clogq std::log -#define clog10q std::log10 -#define csinq std::sin -#define csinhq std::sinh -#define csqrtq std::sqrt -#define ctanq std::tan -#define ctanhq std::tanh -#define cpowq std::powl*/ +extern "C" { +__complex128 conjl(__complex128); +__float128 cimagl(__complex128); +__float128 creall(__complex128); +__complex128 csqrtl(__complex128); +__complex128 clogl(__complex128); +__float128 cabsl(__complex128); +__complex128 cpowl(__complex128,__complex128); +} #endif #include @@ -104,8 +49,11 @@ namespace ql namespace std { + +#ifdef __x86_64__ //! implementation of operator<< for qdouble ostream& operator<<(std::ostream& out, ql::qdouble f); +#endif //! implementation of operator<< for qcomplex ostream& operator<<(std::ostream& out, ql::qcomplex f); diff --git a/src/tools.cc b/src/tools.cc index e553eb0..8f205f6 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -20,7 +20,11 @@ namespace ql { template Tools::Tools(): _qlonshellcutoff(is_same::value ? 1e-10 : 1e-20q), +#ifdef __x86_64__ _pi(is_same::value ? M_PI : M_PIq), +#else + _pi(is_same::value ? M_PI : M_PIl), +#endif _pi2 (_pi*_pi), _pio3 (_pi/TScale(3)), _pio6 (_pi/TScale(6)), diff --git a/src/types.cc b/src/types.cc index 311846c..d8dd705 100644 --- a/src/types.cc +++ b/src/types.cc @@ -9,18 +9,13 @@ namespace std { +#ifdef __x86_64__ ostream& operator<<(std::ostream& out, ql::qdouble f) { char buf[200]; std::ostringstream format; -#ifdef __x86_64__ format << "%." << (std::min)(190L, out.precision()) << "Qe"; quadmath_snprintf(buf, 200, format.str().c_str(), f); -#endif -#ifdef __aarch64__ - format << "%." << (std::min)(190L, out.precision()) << "Le"; - snprintf(buf, 200, format.str().c_str(), f); -#endif out << buf; return out; } @@ -30,6 +25,13 @@ namespace std out << "(" << crealq(f) << "," << cimagq(f) << ")"; return out; } +#else + ostream& operator<<(std::ostream& out, ql::qcomplex f) + { + out << "(" << creall(f) << "," << cimagl(f) << ")"; + return out; + } +#endif ostream& operator<<(std::ostream& os, ql::Code code) { From 3163999c0ec5099ae98c6f6db090293e21abfc5c Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sat, 14 Dec 2024 15:05:17 +0100 Subject: [PATCH 11/11] OK --- src/cache.cc | 2 +- src/qcdloop/maths.h | 35 +++++++++++++++++++++-------------- src/qcdloop/types.h | 11 +++++------ src/tools.cc | 5 +++-- src/types.cc | 5 +++-- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/cache.cc b/src/cache.cc index ac88f4a..57a80d6 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -17,7 +17,7 @@ namespace std { seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) template <> struct hash : public __hash_base { diff --git a/src/qcdloop/maths.h b/src/qcdloop/maths.h index eb8dcc4..b52ccf6 100644 --- a/src/qcdloop/maths.h +++ b/src/qcdloop/maths.h @@ -21,10 +21,11 @@ namespace ql { // Logarithms inline double Log(double const& x) { return std::log(x); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) inline qdouble Log(qdouble const& x) { return logq(x); } inline qcomplex Log(qcomplex const& x) { return clogq(x); } -#else +#endif +#if defined(__aarch64__) inline qdouble Log(qdouble const& x) { return std::log(x); } inline qcomplex Log(qcomplex const& x) { return clogl(x); } #endif @@ -32,10 +33,11 @@ namespace ql // Power inline double Pow(double const& x, int const& a) { return std::pow(x, a); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) inline qdouble Pow(qdouble const& x, int const& a) { return powq(x,a); } inline qcomplex Pow(qcomplex const& x, int const& a){ return cpowq(x,a); } -#else +#endif +#if defined(__aarch64__) inline qdouble Pow(qdouble const& x, int const& a) { return std::pow(x,a); } inline qcomplex Pow(qcomplex const& x, int const& a){ return cpowl(x,a); } #endif @@ -43,10 +45,11 @@ namespace ql // Root inline double Sqrt(double const& x) { return std::sqrt(x); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) inline qdouble Sqrt(qdouble const& x) { return sqrtq(x); } inline qcomplex Sqrt(qcomplex const& x){ return csqrtq(x); } -#else +#endif +#if defined(__aarch64__) inline qdouble Sqrt(qdouble const& x) { return std::sqrt(x); } inline qcomplex Sqrt(qcomplex const& x){ return csqrtl(x); } #endif @@ -54,10 +57,11 @@ namespace ql // Absolute value inline double Abs(double const& x) { return std::abs(x); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) inline qdouble Abs(qdouble const& x) { return fabsq(x);} inline qdouble Abs(qcomplex const& x) { return cabsq(x); } -#else +#endif +#if defined(__aarch64__) inline qdouble Abs(qdouble const& x) { return std::abs(x);} inline qdouble Abs(qcomplex const& x) { return cabsl(x); } #endif @@ -67,25 +71,28 @@ namespace ql inline double Imag(double const& x) { UNUSED(x); return 0; } inline qdouble Imag(qdouble const& x) { UNUSED(x); return qdouble(0); } inline double Imag(complex const& x) { return x.imag(); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) inline qdouble Imag(qcomplex const& x){ return cimagq(x);} -#else +#endif +#if defined(__aarch64__) inline qdouble Imag(qcomplex const& x){ return cimagl(x);} #endif inline double Real(double const& x) { return x; } inline qdouble Real(qdouble const& x) { return x; } inline double Real(complex const& x) { return x.real(); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) inline qdouble Real(qcomplex const& x) { return crealq(x); } -#else +#endif +#if defined(__aarch64__) inline qdouble Real(qcomplex const& x) { return creall(x); } #endif inline complex Conjg(complex const& x) { return std::conj(x); } -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) inline qcomplex Conjg(qcomplex const& x){ return conjq(x); } -#else +#endif +#if defined(__aarch64__) inline qcomplex Conjg(qcomplex const& x){ return conjl(x); } #endif diff --git a/src/qcdloop/types.h b/src/qcdloop/types.h index 1b2132c..0294bcd 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -7,19 +7,18 @@ #pragma once -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) extern "C" { // for gcc4.7 compatibility #include } -#else #endif -#ifdef __aarch64__ +#if defined(__aarch64__) #include #include #include #include -typedef long double __float128; -using __complex128 = long double _Complex ; +using __float128 = long double; +using __complex128 = long double _Complex; extern "C" { __complex128 conjl(__complex128); __float128 cimagl(__complex128); @@ -50,7 +49,7 @@ namespace ql namespace std { -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) //! implementation of operator<< for qdouble ostream& operator<<(std::ostream& out, ql::qdouble f); #endif diff --git a/src/tools.cc b/src/tools.cc index 8f205f6..bb24b76 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -20,9 +20,10 @@ namespace ql { template Tools::Tools(): _qlonshellcutoff(is_same::value ? 1e-10 : 1e-20q), -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) _pi(is_same::value ? M_PI : M_PIq), -#else +#endif +#if defined(__aarch64__) _pi(is_same::value ? M_PI : M_PIl), #endif _pi2 (_pi*_pi), diff --git a/src/types.cc b/src/types.cc index d8dd705..19ac110 100644 --- a/src/types.cc +++ b/src/types.cc @@ -9,7 +9,7 @@ namespace std { -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(__i386__) ostream& operator<<(std::ostream& out, ql::qdouble f) { char buf[200]; @@ -25,7 +25,8 @@ namespace std out << "(" << crealq(f) << "," << cimagq(f) << ")"; return out; } -#else +#endif +#if defined(__aarch64__) ostream& operator<<(std::ostream& out, ql::qcomplex f) { out << "(" << creall(f) << "," << cimagl(f) << ")";