Skip to content

Commit 419b868

Browse files
authored
Merge pull request #2682 from martin-frbg/aix
[WIP] fix compilation on AIX
2 parents 3ab15ff + 5865c7d commit 419b868

File tree

7 files changed

+43
-20
lines changed

7 files changed

+43
-20
lines changed

Makefile.power

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ ifeq ($(USE_OPENMP), 1)
3434
COMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -malign-power -DUSE_OPENMP -fno-fast-math -fopenmp
3535
FCOMMON_OPT += -O2 -frecursive -mcpu=power8 -mtune=power8 -malign-power -DUSE_OPENMP -fno-fast-math -fopenmp
3636
else
37-
COMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -malign-power -fno-fast-math
38-
FCOMMON_OPT += -O2 -frecursive -mcpu=power8 -mtune=power8 -malign-power -fno-fast-math
37+
COMMON_OPT += -Ofast -mcpu=power8 -mtune=power8 -mvsx -malign-power -fno-fast-math
38+
FCOMMON_OPT += -O2 -frecursive -mcpu=power8 -mtune=power8 -malign-power -fno-fast-math
39+
ifeq ($(OSNAME), AIX)
40+
FCOMMON_OPT += -O1 -frecursive -mcpu=power8 -mtune=power8 -malign-power -fno-fast-math
41+
endif
3942
endif
4043
endif
4144

@@ -78,6 +81,9 @@ CCOMMON_OPT += -mpowerpc64 -maix64
7881
ifeq ($(COMPILER_F77), g77)
7982
FCOMMON_OPT += -mpowerpc64 -maix64
8083
endif
84+
ifeq ($(F_COMPILER), GFORTRAN)
85+
FCOMMON_OPT += -mpowerpc64 -maix64
86+
endif
8187
ifeq ($(COMPILER_F77), xlf)
8288
FCOMMON_OPT += -q64
8389
endif

Makefile.system

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ endif
109109
ifeq ($(TARGET), ARMV8)
110110
GETARCH_FLAGS := -DFORCE_ARMV7
111111
endif
112+
ifeq ($(TARGET), POWER8)
113+
GETARCH_FLAGS := -DFORCE_POWER6
114+
endif
112115
endif
113116

114117

c_check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Checking cross compile
77
$hostos = `uname -s | sed -e s/\-.*//`; chop($hostos);
88
$hostarch = `uname -m | sed -e s/i.86/x86/`;chop($hostarch);
9+
$hostarch = `uname -p` if ($hostos eq "AIX");
910
$hostarch = "x86_64" if ($hostarch eq "amd64");
1011
$hostarch = "arm" if ($hostarch =~ /^arm.*/);
1112
$hostarch = "arm64" if ($hostarch eq "aarch64");

cpuid_power.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#define CPUTYPE_PPCG4 7
5858
#define CPUTYPE_POWER8 8
5959
#define CPUTYPE_POWER9 9
60-
#define CPUTYPE_POWER10 10
60+
#define CPUTYPE_POWER10 10
6161

6262
char *cpuname[] = {
6363
"UNKNOWN",
@@ -83,8 +83,8 @@ char *lowercpuname[] = {
8383
"cell",
8484
"ppcg4",
8585
"power8",
86-
"power9",
87-
"power10"
86+
"power9",
87+
"power10"
8888
};
8989

9090
char *corename[] = {
@@ -97,8 +97,8 @@ char *corename[] = {
9797
"CELL",
9898
"PPCG4",
9999
"POWER8",
100-
"POWER9",
101-
"POWER10"
100+
"POWER9",
101+
"POWER10"
102102
};
103103

104104
int detect(void){
@@ -154,17 +154,17 @@ int detect(void){
154154

155155
pclose(infile);
156156

157-
if (!strncasecmp(p, "POWER3", 6)) return CPUTYPE_POWER3;
158-
if (!strncasecmp(p, "POWER4", 6)) return CPUTYPE_POWER4;
159-
if (!strncasecmp(p, "PPC970", 6)) return CPUTYPE_PPC970;
160-
if (!strncasecmp(p, "POWER5", 6)) return CPUTYPE_POWER5;
161-
if (!strncasecmp(p, "POWER6", 6)) return CPUTYPE_POWER6;
162-
if (!strncasecmp(p, "POWER7", 6)) return CPUTYPE_POWER6;
163-
if (!strncasecmp(p, "POWER8", 6)) return CPUTYPE_POWER8;
164-
if (!strncasecmp(p, "POWER9", 6)) return CPUTYPE_POWER9;
165-
if (!strncasecmp(p, "POWER10", 7)) return CPUTYPE_POWER10;
166-
if (!strncasecmp(p, "Cell", 4)) return CPUTYPE_CELL;
167-
if (!strncasecmp(p, "7447", 4)) return CPUTYPE_PPCG4;
157+
if (strstr(p, "POWER3")) return CPUTYPE_POWER3;
158+
if (strstr(p, "POWER4")) return CPUTYPE_POWER4;
159+
if (strstr(p, "PPC970")) return CPUTYPE_PPC970;
160+
if (strstr(p, "POWER5")) return CPUTYPE_POWER5;
161+
if (strstr(p, "POWER6")) return CPUTYPE_POWER6;
162+
if (strstr(p, "POWER7")) return CPUTYPE_POWER6;
163+
if (strstr(p, "POWER8")) return CPUTYPE_POWER8;
164+
if (strstr(p, "POWER9")) return CPUTYPE_POWER9;
165+
if (strstr(p, "POWER10")) return CPUTYPE_POWER10;
166+
if (strstr(p, "Cell")) return CPUTYPE_CELL;
167+
if (strstr(p, "7447")) return CPUTYPE_PPCG4;
168168
return CPUTYPE_POWER5;
169169
#endif
170170

getarch.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,16 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9090
#include <sys/sysinfo.h>
9191
#include <unistd.h>
9292
#endif
93+
#if defined(AIX)
94+
#include <sys/sysinfo.h>
95+
#endif
9396

97+
#if defined(__x86_64__) || defined(_M_X64)
9498
#if (( defined(__GNUC__) && __GNUC__ > 6 && defined(__AVX2__)) || (defined(__clang__) && __clang_major__ >= 6))
9599
#else
96100
#define NO_AVX512
97101
#endif
102+
#endif
98103
/* #define FORCE_P2 */
99104
/* #define FORCE_KATMAI */
100105
/* #define FORCE_COPPERMINE */
@@ -1297,6 +1302,11 @@ static int get_num_cores(void) {
12971302
sysctl(m, 2, &count, &len, NULL, 0);
12981303

12991304
return count;
1305+
1306+
#elif defined(AIX)
1307+
//returns the number of processors which are currently online
1308+
return sysconf(_SC_NPROCESSORS_ONLN);
1309+
13001310
#else
13011311
return 2;
13021312
#endif

kernel/Makefile.L3

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ $(KDIR)$(SGEMMONCOPYOBJ) : $(KERNELDIR)/$(SGEMMONCOPY)
514514

515515
$(KDIR)$(SGEMMOTCOPYOBJ) : $(KERNELDIR)/$(SGEMMOTCOPY)
516516
ifeq ($(OS), AIX)
517-
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmotcopy.s
517+
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmotcopy.s
518518
m4 sgemmotcopy.s > sgemmotcopy_nomacros.s
519519
$(CC) $(CFLAGS) -c -UDOUBLE -UCOMPLEX sgemmotcopy_nomacros.s -o $@
520520
rm sgemmotcopy.s sgemmotcopy_nomacros.s
@@ -530,7 +530,7 @@ $(KDIR)$(SGEMMINCOPYOBJ) : $(KERNELDIR)/$(SGEMMINCOPY)
530530

531531
$(KDIR)$(SGEMMITCOPYOBJ) : $(KERNELDIR)/$(SGEMMITCOPY)
532532
ifeq ($(OS), AIX)
533-
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmitcopy.s
533+
$(CC) $(CFLAGS) -S -UDOUBLE -UCOMPLEX $< -o - > sgemmitcopy.s
534534
m4 sgemmitcopy.s > sgemmitcopy_nomacros.s
535535
$(CC) $(CFLAGS) -c -UDOUBLE -UCOMPLEX sgemmitcopy_nomacros.s -o $@
536536
rm sgemmitcopy.s sgemmitcopy_nomacros.s

utest/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ endif
3434
ifeq ($(C_COMPILER), PGI)
3535
OBJS = utest_main2.o
3636
endif
37+
ifeq ($(OSNAME), AIX)
38+
OBJS = utest_main2.o
39+
endif
3740

3841
all : run_test
3942

0 commit comments

Comments
 (0)