Skip to content

Commit 1c935cf

Browse files
authored
Merge pull request #34 from andriish/arm
Add support for aarch64
2 parents c19b7b1 + 3163999 commit 1c935cf

File tree

7 files changed

+119
-7
lines changed

7 files changed

+119
-7
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,33 @@ jobs:
2020
uses: ./.github/workflows/fedora35
2121
- name: Get the output status
2222
run: exit ${{ steps.compileindocker.outputs.out }}
23+
24+
25+
compilejobRocky9_ARM:
26+
if: "!contains(github.event.head_commit.message, 'skip ci')"
27+
name: Rocky9aarch64_ARM
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
- name: QEMU
33+
run: |
34+
set -x
35+
sudo apt update
36+
sudo apt install --yes binfmt-support qemu-user-static wget
37+
- name: Compile_with_arm
38+
continue-on-error: true
39+
uses: addnab/docker-run-action@v3
40+
with:
41+
image: arm64v8/rockylinux:9
42+
options: -v ${{ github.workspace }}:/work --platform=linux/arm64/v8
43+
run: |
44+
set -e
45+
set -x
46+
dnf -y install gcc gcc-c++ gcc-gfortran make which cmake cmake-data cmake-filesystem
47+
cd work
48+
pwd
49+
ls
50+
cmake -S . -B BUILD -DCMAKE_INSTALL_PREFIX=$(pwd)/INSTALL
51+
cmake --build BUILD
52+
cmake --install BUILD

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ configure_file(
6666
"${PROJECT_SOURCE_DIR}/src/qcdloop.pc.in"
6767
"${PROJECT_SOURCE_DIR}/src/qcdloop.pc"
6868
)
69-
69+
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
7070
set(QUADMATH_NAMES ${QUADMATH_NAMES} libquadmath.so quadmath)
7171
find_library(QUADMATH_LIBRARY
7272
NAMES ${QUADMATH_NAMES}
@@ -95,7 +95,7 @@ else(QUADMATH_FOUND)
9595
message(FATAL_ERROR "Could not find QuadMath")
9696
endif(QUADMATH_FIND_REQUIRED)
9797
endif(QUADMATH_FOUND)
98-
98+
endif()
9999
# libqcdloop configuration
100100
include_directories(src/qcdloop src)
101101
FILE(GLOB_RECURSE Headers "src/qcdloop/*.h")

src/cache.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace std {
1717
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1818
}
1919

20+
#if defined(__x86_64__) || defined(__i386__)
2021
template <>
2122
struct hash<ql::qdouble> : public __hash_base<size_t, ql::qdouble>
2223
{
@@ -25,6 +26,7 @@ namespace std {
2526
return x != 0.0q ? std::_Hash_impl::hash(x) : 0;
2627
}
2728
};
29+
#endif
2830

2931
template <> struct hash<ql::complex> : public __hash_base<size_t, ql::complex>
3032
{

src/qcdloop/maths.h

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
#pragma once
99

1010
#include "types.h"
11-
11+
#include <stdlib.h>
12+
#include <complex.h>
13+
#include <tgmath.h>
14+
#include <float.h>
15+
#include <cmath>
1216
/*!
1317
* Some basic math functions with inline (performance)
1418
* for double and quadruple precision.
@@ -17,41 +21,81 @@ namespace ql
1721
{
1822
// Logarithms
1923
inline double Log(double const& x) { return std::log(x); }
24+
#if defined(__x86_64__) || defined(__i386__)
2025
inline qdouble Log(qdouble const& x) { return logq(x); }
21-
inline complex Log(complex const& x) { return std::log(x); }
2226
inline qcomplex Log(qcomplex const& x) { return clogq(x); }
27+
#endif
28+
#if defined(__aarch64__)
29+
inline qdouble Log(qdouble const& x) { return std::log(x); }
30+
inline qcomplex Log(qcomplex const& x) { return clogl(x); }
31+
#endif
32+
inline complex Log(complex const& x) { return std::log(x); }
2333

2434
// Power
2535
inline double Pow(double const& x, int const& a) { return std::pow(x, a); }
36+
#if defined(__x86_64__) || defined(__i386__)
2637
inline qdouble Pow(qdouble const& x, int const& a) { return powq(x,a); }
27-
inline complex Pow(complex const& x, int const& a) { return std::pow(x,a); }
2838
inline qcomplex Pow(qcomplex const& x, int const& a){ return cpowq(x,a); }
39+
#endif
40+
#if defined(__aarch64__)
41+
inline qdouble Pow(qdouble const& x, int const& a) { return std::pow(x,a); }
42+
inline qcomplex Pow(qcomplex const& x, int const& a){ return cpowl(x,a); }
43+
#endif
44+
inline complex Pow(complex const& x, int const& a) { return std::pow(x,a); }
2945

3046
// Root
3147
inline double Sqrt(double const& x) { return std::sqrt(x); }
48+
#if defined(__x86_64__) || defined(__i386__)
3249
inline qdouble Sqrt(qdouble const& x) { return sqrtq(x); }
33-
inline complex Sqrt(complex const& x) { return std::sqrt(x); }
3450
inline qcomplex Sqrt(qcomplex const& x){ return csqrtq(x); }
51+
#endif
52+
#if defined(__aarch64__)
53+
inline qdouble Sqrt(qdouble const& x) { return std::sqrt(x); }
54+
inline qcomplex Sqrt(qcomplex const& x){ return csqrtl(x); }
55+
#endif
56+
inline complex Sqrt(complex const& x) { return std::sqrt(x); }
3557

3658
// Absolute value
3759
inline double Abs(double const& x) { return std::abs(x); }
60+
#if defined(__x86_64__) || defined(__i386__)
3861
inline qdouble Abs(qdouble const& x) { return fabsq(x);}
39-
inline double Abs(complex const& x) { return std::abs(x);}
4062
inline qdouble Abs(qcomplex const& x) { return cabsq(x); }
63+
#endif
64+
#if defined(__aarch64__)
65+
inline qdouble Abs(qdouble const& x) { return std::abs(x);}
66+
inline qdouble Abs(qcomplex const& x) { return cabsl(x); }
67+
#endif
68+
inline double Abs(complex const& x) { return std::abs(x);}
4169

4270
// Complex tools, imag, real and conj.
4371
inline double Imag(double const& x) { UNUSED(x); return 0; }
4472
inline qdouble Imag(qdouble const& x) { UNUSED(x); return qdouble(0); }
4573
inline double Imag(complex const& x) { return x.imag(); }
74+
#if defined(__x86_64__) || defined(__i386__)
4675
inline qdouble Imag(qcomplex const& x){ return cimagq(x);}
76+
#endif
77+
#if defined(__aarch64__)
78+
inline qdouble Imag(qcomplex const& x){ return cimagl(x);}
79+
#endif
4780

4881
inline double Real(double const& x) { return x; }
4982
inline qdouble Real(qdouble const& x) { return x; }
5083
inline double Real(complex const& x) { return x.real(); }
84+
#if defined(__x86_64__) || defined(__i386__)
5185
inline qdouble Real(qcomplex const& x) { return crealq(x); }
86+
#endif
87+
#if defined(__aarch64__)
88+
inline qdouble Real(qcomplex const& x) { return creall(x); }
89+
#endif
5290

5391
inline complex Conjg(complex const& x) { return std::conj(x); }
92+
#if defined(__x86_64__) || defined(__i386__)
5493
inline qcomplex Conjg(qcomplex const& x){ return conjq(x); }
94+
#endif
95+
#if defined(__aarch64__)
96+
inline qcomplex Conjg(qcomplex const& x){ return conjl(x); }
97+
#endif
98+
5599

56100
// Comparison and sign operations
57101
inline int Sign(double const& x) { return (double(0) < x) - (x < double(0)); }

src/qcdloop/types.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,28 @@
77

88
#pragma once
99

10+
#if defined(__x86_64__) || defined(__i386__)
1011
extern "C" { // for gcc4.7 compatibility
1112
#include <quadmath.h>
1213
}
14+
#endif
15+
#if defined(__aarch64__)
16+
#include <stdlib.h>
17+
#include <complex.h>
18+
#include <tgmath.h>
19+
#include <float.h>
20+
using __float128 = long double;
21+
using __complex128 = long double _Complex;
22+
extern "C" {
23+
__complex128 conjl(__complex128);
24+
__float128 cimagl(__complex128);
25+
__float128 creall(__complex128);
26+
__complex128 csqrtl(__complex128);
27+
__complex128 clogl(__complex128);
28+
__float128 cabsl(__complex128);
29+
__complex128 cpowl(__complex128,__complex128);
30+
}
31+
#endif
1332
#include <complex>
1433

1534
#define UNUSED(expr) (void)(expr)
@@ -29,8 +48,11 @@ namespace ql
2948

3049
namespace std
3150
{
51+
52+
#if defined(__x86_64__) || defined(__i386__)
3253
//! implementation of operator<< for qdouble
3354
ostream& operator<<(std::ostream& out, ql::qdouble f);
55+
#endif
3456

3557
//! implementation of operator<< for qcomplex
3658
ostream& operator<<(std::ostream& out, ql::qcomplex f);

src/tools.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ namespace ql {
2020
template<typename TOutput, typename TMass, typename TScale>
2121
Tools<TOutput,TMass,TScale>::Tools():
2222
_qlonshellcutoff(is_same<TScale,double>::value ? 1e-10 : 1e-20q),
23+
#if defined(__x86_64__) || defined(__i386__)
2324
_pi(is_same<TScale,double>::value ? M_PI : M_PIq),
25+
#endif
26+
#if defined(__aarch64__)
27+
_pi(is_same<TScale,double>::value ? M_PI : M_PIl),
28+
#endif
2429
_pi2 (_pi*_pi),
2530
_pio3 (_pi/TScale(3)),
2631
_pio6 (_pi/TScale(6)),

src/types.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace std
1111
{
12+
#if defined(__x86_64__) || defined(__i386__)
1213
ostream& operator<<(std::ostream& out, ql::qdouble f)
1314
{
1415
char buf[200];
@@ -24,6 +25,14 @@ namespace std
2425
out << "(" << crealq(f) << "," << cimagq(f) << ")";
2526
return out;
2627
}
28+
#endif
29+
#if defined(__aarch64__)
30+
ostream& operator<<(std::ostream& out, ql::qcomplex f)
31+
{
32+
out << "(" << creall(f) << "," << cimagl(f) << ")";
33+
return out;
34+
}
35+
#endif
2736

2837
ostream& operator<<(std::ostream& os, ql::Code code)
2938
{

0 commit comments

Comments
 (0)