diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 31f43b1..ebc7719 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,3 +20,33 @@ 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: | + set -e + set -x + 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 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") diff --git a/src/cache.cc b/src/cache.cc index 4974297..57a80d6 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -17,6 +17,7 @@ namespace std { seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } +#if defined(__x86_64__) || defined(__i386__) 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 b66cb24..b52ccf6 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. @@ -17,41 +21,81 @@ namespace ql { // Logarithms inline double Log(double const& x) { return std::log(x); } +#if defined(__x86_64__) || defined(__i386__) 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); } +#endif +#if defined(__aarch64__) + inline qdouble Log(qdouble 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); } // Power inline double Pow(double const& x, int const& a) { return std::pow(x, a); } +#if defined(__x86_64__) || defined(__i386__) 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); } +#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 + 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); } +#if defined(__x86_64__) || defined(__i386__) 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); } +#endif +#if defined(__aarch64__) + inline qdouble Sqrt(qdouble 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); } // Absolute value inline double Abs(double const& x) { return std::abs(x); } +#if defined(__x86_64__) || defined(__i386__) 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); } +#endif +#if defined(__aarch64__) + inline qdouble Abs(qdouble 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);} // 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(); } +#if defined(__x86_64__) || defined(__i386__) inline qdouble Imag(qcomplex const& x){ return cimagq(x);} +#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(); } +#if defined(__x86_64__) || defined(__i386__) inline qdouble Real(qcomplex const& x) { return crealq(x); } +#endif +#if defined(__aarch64__) + inline qdouble Real(qcomplex const& x) { return creall(x); } +#endif inline complex Conjg(complex const& x) { return std::conj(x); } +#if defined(__x86_64__) || defined(__i386__) inline qcomplex Conjg(qcomplex const& x){ return conjq(x); } +#endif +#if defined(__aarch64__) + inline qcomplex Conjg(qcomplex const& x){ return conjl(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 8a832dd..0294bcd 100644 --- a/src/qcdloop/types.h +++ b/src/qcdloop/types.h @@ -7,9 +7,28 @@ #pragma once +#if defined(__x86_64__) || defined(__i386__) extern "C" { // for gcc4.7 compatibility #include } +#endif +#if defined(__aarch64__) +#include +#include +#include +#include +using __float128 = long double; +using __complex128 = long double _Complex; +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 #define UNUSED(expr) (void)(expr) @@ -29,8 +48,11 @@ namespace ql namespace std { + +#if defined(__x86_64__) || defined(__i386__) //! 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..bb24b76 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -20,7 +20,12 @@ namespace ql { template Tools::Tools(): _qlonshellcutoff(is_same::value ? 1e-10 : 1e-20q), +#if defined(__x86_64__) || defined(__i386__) _pi(is_same::value ? M_PI : M_PIq), +#endif +#if defined(__aarch64__) + _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 9e90a47..19ac110 100644 --- a/src/types.cc +++ b/src/types.cc @@ -9,6 +9,7 @@ namespace std { +#if defined(__x86_64__) || defined(__i386__) ostream& operator<<(std::ostream& out, ql::qdouble f) { char buf[200]; @@ -24,6 +25,14 @@ namespace std out << "(" << crealq(f) << "," << cimagq(f) << ")"; return out; } +#endif +#if defined(__aarch64__) + ostream& operator<<(std::ostream& out, ql::qcomplex f) + { + out << "(" << creall(f) << "," << cimagl(f) << ")"; + return out; + } +#endif ostream& operator<<(std::ostream& os, ql::Code code) {