Skip to content

Commit

Permalink
Merge pull request OpenMathLib#4320 from ChipKerchner/fixOldGCCPower
Browse files Browse the repository at this point in the history
Fix older versions of gcc - missing __has_builtin, cpuid and no support of P10.
  • Loading branch information
martin-frbg committed Nov 15, 2023
2 parents 46440a0 + d99aad8 commit d36b86a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
12 changes: 12 additions & 0 deletions Makefile.power
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ endif

ifeq ($(CORE), POWER10)
ifneq ($(C_COMPILER), PGI)
ifeq ($(C_COMPILER), GCC))
ifeq ($(GCCVERSIONGTEQ10), 1)
CCOMMON_OPT += -Ofast -mcpu=power10 -mtune=power10 -mvsx -fno-fast-math
else ifneq ($(GCCVERSIONGT4), 1)
$(warning your compiler is too old to fully support POWER9, getting a newer version of gcc is recommended)
CCOMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -fno-fast-math
else
$(warning your compiler is too old to fully support POWER10, getting a newer version of gcc is recommended)
CCOMMON_OPT += -Ofast -mcpu=power9 -mtune=power9 -mvsx -fno-fast-math
endif
else
CCOMMON_OPT += -Ofast -mcpu=power10 -mtune=power10 -mvsx -fno-fast-math
endif
ifeq ($(F_COMPILER), IBM)
FCOMMON_OPT += -O2 -qrecur -qnosave -qarch=pwr10 -qtune=pwr10 -qfloat=nomaf -qzerosize
else
Expand Down
17 changes: 12 additions & 5 deletions driver/others/dynamic_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ static int cpuid(void)
#endif
return CPU_UNKNOWN;
}
#else
#if defined(C_PGI) || defined(__clang__)
#elif defined(C_PGI) || defined(__clang__)
/*
* NV HPC compilers do not yet implement __builtin_cpu_is().
* Fake a version here for use in the CPU detection code below.
Expand Down Expand Up @@ -196,13 +195,21 @@ static int cpuid(void)
cpu_type = pvrPOWER[i].cpu_type;
return (int)(cpu_type);
}
#endif /* C_PGI */
#elif !defined(__BUILTIN_CPU_SUPPORTS__)
static int cpuid(void)
{
return CPU_UNKNOWN;
}
#endif /* _AIX */

#ifndef __BUILTIN_CPU_SUPPORTS__
#include <string.h>

#if defined(_AIX) || (defined(__has_builtin) && !__has_builtin(__builtin_cpu_is))
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif

#if defined(_AIX) || !__has_builtin(__builtin_cpu_is)
static int __builtin_cpu_is(const char *arg)
{
static int ipinfo = -1;
Expand All @@ -227,7 +234,7 @@ static int __builtin_cpu_is(const char *arg)
}
#endif

#if defined(_AIX) || (defined(__has_builtin) && !__has_builtin(__builtin_cpu_supports))
#if defined(_AIX) || !__has_builtin(__builtin_cpu_supports)
static int __builtin_cpu_supports(const char *arg)
{
return 0;
Expand Down

0 comments on commit d36b86a

Please sign in to comment.