From 2443ed0a7018eab84e7abf96b0e5c494006c594d Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Sat, 4 Jun 2016 10:13:22 +0100
Subject: [PATCH] wmake/rules/linux64GccKNL: Optimized compilation options for
 the Knights Landing MIC processor

---
 wmake/rules/linux64GccKNL/c                   | 16 +++++++++++++
 wmake/rules/linux64GccKNL/c++                 | 24 +++++++++++++++++++
 wmake/rules/linux64GccKNL/c++Debug            |  2 ++
 wmake/rules/linux64GccKNL/c++Opt              |  4 ++++
 .../{linux64KNLIcc => linux64GccKNL}/c++Prof  |  0
 wmake/rules/linux64GccKNL/cDebug              |  2 ++
 wmake/rules/linux64GccKNL/cOpt                |  2 ++
 .../{linux64KNLIcc => linux64GccKNL}/cProf    |  0
 wmake/rules/linux64GccKNL/general             |  8 +++++++
 .../mplibHPMPI                                |  0
 .../mplibINTELMPI                             |  0
 .../rules/{linux64KNLIcc => linux64IccKNL}/c  |  0
 .../{linux64KNLIcc => linux64IccKNL}/c++      |  0
 .../{linux64KNLIcc => linux64IccKNL}/c++Debug |  0
 .../{linux64KNLIcc => linux64IccKNL}/c++Opt   |  0
 wmake/rules/linux64IccKNL/c++Prof             |  2 ++
 .../{linux64KNLIcc => linux64IccKNL}/cDebug   |  0
 .../{linux64KNLIcc => linux64IccKNL}/cOpt     |  0
 wmake/rules/linux64IccKNL/cProf               |  2 ++
 .../{linux64KNLIcc => linux64IccKNL}/general  |  0
 wmake/rules/linux64IccKNL/mplibHPMPI          |  3 +++
 wmake/rules/linux64IccKNL/mplibINTELMPI       |  3 +++
 22 files changed, 68 insertions(+)
 create mode 100644 wmake/rules/linux64GccKNL/c
 create mode 100644 wmake/rules/linux64GccKNL/c++
 create mode 100644 wmake/rules/linux64GccKNL/c++Debug
 create mode 100644 wmake/rules/linux64GccKNL/c++Opt
 rename wmake/rules/{linux64KNLIcc => linux64GccKNL}/c++Prof (100%)
 create mode 100644 wmake/rules/linux64GccKNL/cDebug
 create mode 100644 wmake/rules/linux64GccKNL/cOpt
 rename wmake/rules/{linux64KNLIcc => linux64GccKNL}/cProf (100%)
 create mode 100644 wmake/rules/linux64GccKNL/general
 rename wmake/rules/{linux64KNLIcc => linux64GccKNL}/mplibHPMPI (100%)
 rename wmake/rules/{linux64KNLIcc => linux64GccKNL}/mplibINTELMPI (100%)
 rename wmake/rules/{linux64KNLIcc => linux64IccKNL}/c (100%)
 rename wmake/rules/{linux64KNLIcc => linux64IccKNL}/c++ (100%)
 rename wmake/rules/{linux64KNLIcc => linux64IccKNL}/c++Debug (100%)
 rename wmake/rules/{linux64KNLIcc => linux64IccKNL}/c++Opt (100%)
 create mode 100644 wmake/rules/linux64IccKNL/c++Prof
 rename wmake/rules/{linux64KNLIcc => linux64IccKNL}/cDebug (100%)
 rename wmake/rules/{linux64KNLIcc => linux64IccKNL}/cOpt (100%)
 create mode 100644 wmake/rules/linux64IccKNL/cProf
 rename wmake/rules/{linux64KNLIcc => linux64IccKNL}/general (100%)
 create mode 100644 wmake/rules/linux64IccKNL/mplibHPMPI
 create mode 100644 wmake/rules/linux64IccKNL/mplibINTELMPI

diff --git a/wmake/rules/linux64GccKNL/c b/wmake/rules/linux64GccKNL/c
new file mode 100644
index 00000000000..a1cd9d6613e
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/c
@@ -0,0 +1,16 @@
+SUFFIXES += .c
+
+cWARN        = -Wall
+
+cc          = gcc -m64 -march=knl -DvectorMachine -DKNL
+
+include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION)
+
+cFLAGS      = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC
+
+ctoo        = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@
+
+LINK_LIBS   = $(cDBUG)
+
+LINKLIBSO   = $(cc) -shared
+LINKEXE     = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs
diff --git a/wmake/rules/linux64GccKNL/c++ b/wmake/rules/linux64GccKNL/c++
new file mode 100644
index 00000000000..ed1ad0de521
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/c++
@@ -0,0 +1,24 @@
+SUFFIXES += .C
+
+c++WARN     = -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof
+
+# Suppress some warnings for flex++ and CGAL
+c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
+
+CC          = g++ -std=c++0x -m64 -march=knl -DvectorMachine -DKNL
+
+include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)
+
+ptFLAGS     = -DNoRepository -ftemplate-depth-100
+
+c++FLAGS    = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
+
+Ctoo        = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@
+cxxtoo      = $(Ctoo)
+cctoo       = $(Ctoo)
+cpptoo      = $(Ctoo)
+
+LINK_LIBS   = $(c++DBUG)
+
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
+LINKEXE     = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed
diff --git a/wmake/rules/linux64GccKNL/c++Debug b/wmake/rules/linux64GccKNL/c++Debug
new file mode 100644
index 00000000000..19bdb9c3346
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/c++Debug
@@ -0,0 +1,2 @@
+c++DBUG    = -ggdb3 -DFULLDEBUG
+c++OPT      = -O0 -fdefault-inline
diff --git a/wmake/rules/linux64GccKNL/c++Opt b/wmake/rules/linux64GccKNL/c++Opt
new file mode 100644
index 00000000000..599e6aba611
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/c++Opt
@@ -0,0 +1,4 @@
+c++DBUG     =
+c++OPT      = -O3
+
+ROUNDING_MATH = -frounding-math
diff --git a/wmake/rules/linux64KNLIcc/c++Prof b/wmake/rules/linux64GccKNL/c++Prof
similarity index 100%
rename from wmake/rules/linux64KNLIcc/c++Prof
rename to wmake/rules/linux64GccKNL/c++Prof
diff --git a/wmake/rules/linux64GccKNL/cDebug b/wmake/rules/linux64GccKNL/cDebug
new file mode 100644
index 00000000000..72b638f4582
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/cDebug
@@ -0,0 +1,2 @@
+cDBUG       = -ggdb -DFULLDEBUG
+cOPT        = -O1 -fdefault-inline -finline-functions
diff --git a/wmake/rules/linux64GccKNL/cOpt b/wmake/rules/linux64GccKNL/cOpt
new file mode 100644
index 00000000000..17318709f1f
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/cOpt
@@ -0,0 +1,2 @@
+cDBUG       =
+cOPT        = -O3
diff --git a/wmake/rules/linux64KNLIcc/cProf b/wmake/rules/linux64GccKNL/cProf
similarity index 100%
rename from wmake/rules/linux64KNLIcc/cProf
rename to wmake/rules/linux64GccKNL/cProf
diff --git a/wmake/rules/linux64GccKNL/general b/wmake/rules/linux64GccKNL/general
new file mode 100644
index 00000000000..1002cb169b5
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/general
@@ -0,0 +1,8 @@
+CPP        = cpp -traditional-cpp $(GFLAGS)
+
+PROJECT_LIBS = -l$(WM_PROJECT) -ldl
+
+include $(GENERAL_RULES)/standard
+
+include $(DEFAULT_RULES)/c
+include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linux64KNLIcc/mplibHPMPI b/wmake/rules/linux64GccKNL/mplibHPMPI
similarity index 100%
rename from wmake/rules/linux64KNLIcc/mplibHPMPI
rename to wmake/rules/linux64GccKNL/mplibHPMPI
diff --git a/wmake/rules/linux64KNLIcc/mplibINTELMPI b/wmake/rules/linux64GccKNL/mplibINTELMPI
similarity index 100%
rename from wmake/rules/linux64KNLIcc/mplibINTELMPI
rename to wmake/rules/linux64GccKNL/mplibINTELMPI
diff --git a/wmake/rules/linux64KNLIcc/c b/wmake/rules/linux64IccKNL/c
similarity index 100%
rename from wmake/rules/linux64KNLIcc/c
rename to wmake/rules/linux64IccKNL/c
diff --git a/wmake/rules/linux64KNLIcc/c++ b/wmake/rules/linux64IccKNL/c++
similarity index 100%
rename from wmake/rules/linux64KNLIcc/c++
rename to wmake/rules/linux64IccKNL/c++
diff --git a/wmake/rules/linux64KNLIcc/c++Debug b/wmake/rules/linux64IccKNL/c++Debug
similarity index 100%
rename from wmake/rules/linux64KNLIcc/c++Debug
rename to wmake/rules/linux64IccKNL/c++Debug
diff --git a/wmake/rules/linux64KNLIcc/c++Opt b/wmake/rules/linux64IccKNL/c++Opt
similarity index 100%
rename from wmake/rules/linux64KNLIcc/c++Opt
rename to wmake/rules/linux64IccKNL/c++Opt
diff --git a/wmake/rules/linux64IccKNL/c++Prof b/wmake/rules/linux64IccKNL/c++Prof
new file mode 100644
index 00000000000..3bda4dad55e
--- /dev/null
+++ b/wmake/rules/linux64IccKNL/c++Prof
@@ -0,0 +1,2 @@
+c++DBUG    = -pg
+c++OPT     = -O2
diff --git a/wmake/rules/linux64KNLIcc/cDebug b/wmake/rules/linux64IccKNL/cDebug
similarity index 100%
rename from wmake/rules/linux64KNLIcc/cDebug
rename to wmake/rules/linux64IccKNL/cDebug
diff --git a/wmake/rules/linux64KNLIcc/cOpt b/wmake/rules/linux64IccKNL/cOpt
similarity index 100%
rename from wmake/rules/linux64KNLIcc/cOpt
rename to wmake/rules/linux64IccKNL/cOpt
diff --git a/wmake/rules/linux64IccKNL/cProf b/wmake/rules/linux64IccKNL/cProf
new file mode 100644
index 00000000000..ca3ac9bf5f0
--- /dev/null
+++ b/wmake/rules/linux64IccKNL/cProf
@@ -0,0 +1,2 @@
+cDBUG       = -pg
+cOPT        = -O2
diff --git a/wmake/rules/linux64KNLIcc/general b/wmake/rules/linux64IccKNL/general
similarity index 100%
rename from wmake/rules/linux64KNLIcc/general
rename to wmake/rules/linux64IccKNL/general
diff --git a/wmake/rules/linux64IccKNL/mplibHPMPI b/wmake/rules/linux64IccKNL/mplibHPMPI
new file mode 100644
index 00000000000..d7c4b0cf30f
--- /dev/null
+++ b/wmake/rules/linux64IccKNL/mplibHPMPI
@@ -0,0 +1,3 @@
+PFLAGS     =
+PINC       = -isystem $(MPI_ARCH_PATH)/include -D_MPICC_H
+PLIBS      = -L$(MPI_ARCH_PATH)/lib/linux_amd64 -lmpi
diff --git a/wmake/rules/linux64IccKNL/mplibINTELMPI b/wmake/rules/linux64IccKNL/mplibINTELMPI
new file mode 100644
index 00000000000..278e0b0f22c
--- /dev/null
+++ b/wmake/rules/linux64IccKNL/mplibINTELMPI
@@ -0,0 +1,3 @@
+PFLAGS     = -DMPICH_SKIP_MPICXX
+PINC       = -isystem $(MPI_ARCH_PATH)/include64
+PLIBS      = -L$(MPI_ARCH_PATH)/lib64 -lmpi
-- 
GitLab