Skip to content

Commit

Permalink
Merge pull request #2682 from martin-frbg/aix
Browse files Browse the repository at this point in the history
[WIP] fix compilation on AIX
  • Loading branch information
martin-frbg authored Jul 13, 2020
2 parents 3ab15ff + 5865c7d commit 419b868
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 20 deletions.
10 changes: 8 additions & 2 deletions Makefile.power
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ ifeq ($(USE_OPENMP), 1)
COMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -malign-power -DUSE_OPENMP -fno-fast-math -fopenmp
FCOMMON_OPT += -O2 -frecursive -mcpu=power8 -mtune=power8 -malign-power -DUSE_OPENMP -fno-fast-math -fopenmp
else
COMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -malign-power -fno-fast-math
FCOMMON_OPT += -O2 -frecursive -mcpu=power8 -mtune=power8 -malign-power -fno-fast-math
COMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -malign-power -fno-fast-math
FCOMMON_OPT += -O2 -frecursive -mcpu=power8 -mtune=power8 -malign-power -fno-fast-math
ifeq ($(OSNAME), AIX)
FCOMMON_OPT += -O1 -frecursive -mcpu=power8 -mtune=power8 -malign-power -fno-fast-math
endif
endif
endif

Expand Down Expand Up @@ -78,6 +81,9 @@ CCOMMON_OPT += -mpowerpc64 -maix64
ifeq ($(COMPILER_F77), g77)
FCOMMON_OPT += -mpowerpc64 -maix64
endif
ifeq ($(F_COMPILER), GFORTRAN)
FCOMMON_OPT += -mpowerpc64 -maix64
endif
ifeq ($(COMPILER_F77), xlf)
FCOMMON_OPT += -q64
endif
Expand Down
3 changes: 3 additions & 0 deletions Makefile.system
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ endif
ifeq ($(TARGET), ARMV8)
GETARCH_FLAGS := -DFORCE_ARMV7
endif
ifeq ($(TARGET), POWER8)
GETARCH_FLAGS := -DFORCE_POWER6
endif
endif


Expand Down
1 change: 1 addition & 0 deletions c_check
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Checking cross compile
$hostos = `uname -s | sed -e s/\-.*//`; chop($hostos);
$hostarch = `uname -m | sed -e s/i.86/x86/`;chop($hostarch);
$hostarch = `uname -p` if ($hostos eq "AIX");
$hostarch = "x86_64" if ($hostarch eq "amd64");
$hostarch = "arm" if ($hostarch =~ /^arm.*/);
$hostarch = "arm64" if ($hostarch eq "aarch64");
Expand Down
32 changes: 16 additions & 16 deletions cpuid_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#define CPUTYPE_PPCG4 7
#define CPUTYPE_POWER8 8
#define CPUTYPE_POWER9 9
#define CPUTYPE_POWER10 10
#define CPUTYPE_POWER10 10

char *cpuname[] = {
"UNKNOWN",
Expand All @@ -83,8 +83,8 @@ char *lowercpuname[] = {
"cell",
"ppcg4",
"power8",
"power9",
"power10"
"power9",
"power10"
};

char *corename[] = {
Expand All @@ -97,8 +97,8 @@ char *corename[] = {
"CELL",
"PPCG4",
"POWER8",
"POWER9",
"POWER10"
"POWER9",
"POWER10"
};

int detect(void){
Expand Down Expand Up @@ -154,17 +154,17 @@ int detect(void){

pclose(infile);

if (!strncasecmp(p, "POWER3", 6)) return CPUTYPE_POWER3;
if (!strncasecmp(p, "POWER4", 6)) return CPUTYPE_POWER4;
if (!strncasecmp(p, "PPC970", 6)) return CPUTYPE_PPC970;
if (!strncasecmp(p, "POWER5", 6)) return CPUTYPE_POWER5;
if (!strncasecmp(p, "POWER6", 6)) return CPUTYPE_POWER6;
if (!strncasecmp(p, "POWER7", 6)) return CPUTYPE_POWER6;
if (!strncasecmp(p, "POWER8", 6)) return CPUTYPE_POWER8;
if (!strncasecmp(p, "POWER9", 6)) return CPUTYPE_POWER9;
if (!strncasecmp(p, "POWER10", 7)) return CPUTYPE_POWER10;
if (!strncasecmp(p, "Cell", 4)) return CPUTYPE_CELL;
if (!strncasecmp(p, "7447", 4)) return CPUTYPE_PPCG4;
if (strstr(p, "POWER3")) return CPUTYPE_POWER3;
if (strstr(p, "POWER4")) return CPUTYPE_POWER4;
if (strstr(p, "PPC970")) return CPUTYPE_PPC970;
if (strstr(p, "POWER5")) return CPUTYPE_POWER5;
if (strstr(p, "POWER6")) return CPUTYPE_POWER6;
if (strstr(p, "POWER7")) return CPUTYPE_POWER6;
if (strstr(p, "POWER8")) return CPUTYPE_POWER8;
if (strstr(p, "POWER9")) return CPUTYPE_POWER9;
if (strstr(p, "POWER10")) return CPUTYPE_POWER10;
if (strstr(p, "Cell")) return CPUTYPE_CELL;
if (strstr(p, "7447")) return CPUTYPE_PPCG4;
return CPUTYPE_POWER5;
#endif

Expand Down
10 changes: 10 additions & 0 deletions getarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/sysinfo.h>
#include <unistd.h>
#endif
#if defined(AIX)
#include <sys/sysinfo.h>
#endif

#if defined(__x86_64__) || defined(_M_X64)
#if (( defined(__GNUC__) && __GNUC__ > 6 && defined(__AVX2__)) || (defined(__clang__) && __clang_major__ >= 6))
#else
#define NO_AVX512
#endif
#endif
/* #define FORCE_P2 */
/* #define FORCE_KATMAI */
/* #define FORCE_COPPERMINE */
Expand Down Expand Up @@ -1297,6 +1302,11 @@ static int get_num_cores(void) {
sysctl(m, 2, &count, &len, NULL, 0);

return count;

#elif defined(AIX)
//returns the number of processors which are currently online
return sysconf(_SC_NPROCESSORS_ONLN);

#else
return 2;
#endif
Expand Down
4 changes: 2 additions & 2 deletions kernel/Makefile.L3
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ $(KDIR)$(SGEMMONCOPYOBJ) : $(KERNELDIR)/$(SGEMMONCOPY)

$(KDIR)$(SGEMMOTCOPYOBJ) : $(KERNELDIR)/$(SGEMMOTCOPY)
ifeq ($(OS), AIX)
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmotcopy.s
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmotcopy.s
m4 sgemmotcopy.s > sgemmotcopy_nomacros.s
$(CC) $(CFLAGS) -c -UDOUBLE -UCOMPLEX sgemmotcopy_nomacros.s -o $@
rm sgemmotcopy.s sgemmotcopy_nomacros.s
Expand All @@ -530,7 +530,7 @@ $(KDIR)$(SGEMMINCOPYOBJ) : $(KERNELDIR)/$(SGEMMINCOPY)

$(KDIR)$(SGEMMITCOPYOBJ) : $(KERNELDIR)/$(SGEMMITCOPY)
ifeq ($(OS), AIX)
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmitcopy.s
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmitcopy.s
m4 sgemmitcopy.s > sgemmitcopy_nomacros.s
$(CC) $(CFLAGS) -c -UDOUBLE -UCOMPLEX sgemmitcopy_nomacros.s -o $@
rm sgemmitcopy.s sgemmitcopy_nomacros.s
Expand Down
3 changes: 3 additions & 0 deletions utest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ endif
ifeq ($(C_COMPILER), PGI)
OBJS = utest_main2.o
endif
ifeq ($(OSNAME), AIX)
OBJS = utest_main2.o
endif

all : run_test

Expand Down

0 comments on commit 419b868

Please sign in to comment.