Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add back support for ppc64le #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ configure_file(
"${PROJECT_SOURCE_DIR}/src/qcdloop.pc.in"
"${PROJECT_SOURCE_DIR}/src/qcdloop.pc"
)
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, Something like

IF(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "x86_64|i686|ppc64|ppc64le|ppc|ppcle" )

would be better.
But it is important to list supported architectures explicitly, and not "everything but...".

Copy link
Contributor Author

@matthewfeickert matthewfeickert Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andriish Can you explain more on why? How is this different or better? Is there another architecture that supports float128 that you know of? Or do you mean that there could be other architectures not considered here that also don't support libquadmath and these would get picked up erroneously here?

# Only enable quadmath for non-aarch64 as aarch64 supports float128 and so
# doesn't have libquadmath
IF(NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henryiii is there a more preferred way to do this? Or is just checking for aarch64 somewhere good enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. From conda-forge/qcdloop-feedstock#7 it seems like maybe ${CMAKE_SYSTEM_PROCESSOR} isn't what is desired when cross-compiling, as when cross-compiling for aarch64 on x86 it is attempting to link against libquadmath.

set(QUADMATH_NAMES ${QUADMATH_NAMES} libquadmath.so quadmath)
find_library(QUADMATH_LIBRARY
NAMES ${QUADMATH_NAMES}
Expand Down
2 changes: 1 addition & 1 deletion src/cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace std {
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}

#if defined(__x86_64__) || defined(__i386__)
Copy link

@andriish andriish Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would limit it here just to

__ppc64__

and

__ppc__

for the sake of consistency, see https://sourceforge.net/p/predef/wiki/Architectures/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andriish Can you elaborate on what you mean by "consistency"? I'm not sure what you're trying to communicate and the link isn't informative. I'm sure to you it is clear, but I'm going to need you to write out your point.

#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
template <>
struct hash<ql::qdouble> : public __hash_base<size_t, ql::qdouble>
{
Expand Down
14 changes: 7 additions & 7 deletions src/qcdloop/maths.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace ql
{
// Logarithms
inline double Log(double const& x) { return std::log(x); }
#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
inline qdouble Log(qdouble const& x) { return logq(x); }
inline qcomplex Log(qcomplex const& x) { return clogq(x); }
#endif
Expand All @@ -33,7 +33,7 @@ namespace ql

// Power
inline double Pow(double const& x, int const& a) { return std::pow(x, a); }
#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
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); }
#endif
Expand All @@ -45,7 +45,7 @@ namespace ql

// Root
inline double Sqrt(double const& x) { return std::sqrt(x); }
#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
inline qdouble Sqrt(qdouble const& x) { return sqrtq(x); }
inline qcomplex Sqrt(qcomplex const& x){ return csqrtq(x); }
#endif
Expand All @@ -57,7 +57,7 @@ namespace ql

// Absolute value
inline double Abs(double const& x) { return std::abs(x); }
#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
inline qdouble Abs(qdouble const& x) { return fabsq(x);}
inline qdouble Abs(qcomplex const& x) { return cabsq(x); }
#endif
Expand All @@ -71,7 +71,7 @@ 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(); }
#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
inline qdouble Imag(qcomplex const& x){ return cimagq(x);}
#endif
#if defined(__aarch64__)
Expand All @@ -81,15 +81,15 @@ namespace ql
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__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
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__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
inline qcomplex Conjg(qcomplex const& x){ return conjq(x); }
#endif
#if defined(__aarch64__)
Expand Down
4 changes: 2 additions & 2 deletions src/qcdloop/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
extern "C" { // for gcc4.7 compatibility
#include <quadmath.h>
}
Expand Down Expand Up @@ -49,7 +49,7 @@ namespace ql
namespace std
{

#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
//! implementation of operator<< for qdouble
ostream& operator<<(std::ostream& out, ql::qdouble f);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace ql {
template<typename TOutput, typename TMass, typename TScale>
Tools<TOutput,TMass,TScale>::Tools():
_qlonshellcutoff(is_same<TScale,double>::value ? 1e-10 : 1e-20q),
#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
_pi(is_same<TScale,double>::value ? M_PI : M_PIq),
#endif
#if defined(__aarch64__)
Expand Down
2 changes: 1 addition & 1 deletion src/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace std
{
#if defined(__x86_64__) || defined(__i386__)
#if defined(__x86_64__) || defined(__i386__) || defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
ostream& operator<<(std::ostream& out, ql::qdouble f)
{
char buf[200];
Expand Down
Loading