-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patch to fix openblas build system for cooperlake CPUs
(based on upstream PR #4192)
- Loading branch information
Showing
1 changed file
with
144 additions
and
0 deletions.
There are no files selected for viewing
144 changes: 144 additions & 0 deletions
144
O/OpenBLAS/[email protected]/bundled/patches/openblas-march.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
From b4a9e5684facdb1ce998de73821040857a0ed5c1 Mon Sep 17 00:00:00 2001 | ||
From: Ian McInerney <[email protected]> | ||
Date: Mon, 14 Aug 2023 16:38:27 +0100 | ||
Subject: [PATCH] Fix cooperlake/saphire rapids build | ||
|
||
--- | ||
Makefile.system | 5 ++++ | ||
Makefile.x86_64 | 74 +++++++++++++++++++++++++++++++++---------------- | ||
kernel/Makefile | 4 +-- | ||
3 files changed, 57 insertions(+), 26 deletions(-) | ||
|
||
diff --git a/Makefile.system b/Makefile.system | ||
index 343b94bb3..46c9cb607 100644 | ||
--- a/Makefile.system | ||
+++ b/Makefile.system | ||
@@ -384,6 +384,11 @@ GCCMINORVERSIONGTEQ4 := $(shell expr `$(CC) $(GCCDUMPVERSION_PARAM) | cut -f2 -d | ||
GCCMINORVERSIONGTEQ7 := $(shell expr `$(CC) $(GCCDUMPVERSION_PARAM) | cut -f2 -d.` \>= 7) | ||
endif | ||
|
||
+ifeq ($(C_COMPILER), CLANG) | ||
+CLANGVERSIONGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9) | ||
+CLANGVERSIONGTEQ12 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 12) | ||
+endif | ||
+ | ||
# | ||
# OS dependent settings | ||
# | ||
diff --git a/Makefile.x86_64 b/Makefile.x86_64 | ||
index 7ab331b1f..702447ace 100644 | ||
--- a/Makefile.x86_64 | ||
+++ b/Makefile.x86_64 | ||
@@ -75,18 +75,31 @@ endif | ||
ifeq ($(CORE), COOPERLAKE) | ||
ifndef NO_AVX512 | ||
ifeq ($(C_COMPILER), GCC) | ||
-# cooperlake support was added in 10.1 | ||
-ifeq ($(GCCVERSIONGTEQ10)$(GCCMINORVERSIONGTEQ1), 11) | ||
-CCOMMON_OPT += -march=cooperlake | ||
-ifneq ($(F_COMPILER), NAG) | ||
-FCOMMON_OPT += -march=cooperlake | ||
-endif | ||
-else # gcc not support, fallback to avx512 | ||
-CCOMMON_OPT += -march=skylake-avx512 | ||
-ifneq ($(F_COMPILER), NAG) | ||
-FCOMMON_OPT += -march=skylake-avx512 | ||
-endif | ||
-endif | ||
+ # cooperlake support was added in 10.1 | ||
+ ifeq ($(GCCVERSIONGTEQ10)$(GCCMINORVERSIONGTEQ1), 11) | ||
+ CCOMMON_OPT += -march=cooperlake | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=cooperlake | ||
+ endif | ||
+ else # gcc not support, fallback to avx512 | ||
+ CCOMMON_OPT += -march=skylake-avx512 | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=skylake-avx512 | ||
+ endif | ||
+ endif | ||
+else ifeq ($(C_COMPILER), CLANG) | ||
+ # cooperlake support was added in clang 9 | ||
+ ifeq ($(CLANGVERSIONGTEQ9), 1) | ||
+ CCOMMON_OPT += -march=cooperlake | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=cooperlake | ||
+ endif | ||
+ else # not supported in clang, fallback to avx512 | ||
+ CCOMMON_OPT += -march=skylake-avx512 | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=skylake-avx512 | ||
+ endif | ||
+ endif | ||
endif | ||
ifeq ($(OSNAME), CYGWIN_NT) | ||
CCOMMON_OPT += -fno-asynchronous-unwind-tables | ||
@@ -104,18 +117,31 @@ endif | ||
ifeq ($(CORE), SAPPHIRERAPIDS) | ||
ifndef NO_AVX512 | ||
ifeq ($(C_COMPILER), GCC) | ||
-# sapphire rapids support was added in 11 | ||
-ifeq ($(GCCVERSIONGTEQ11), 1) | ||
-CCOMMON_OPT += -march=sapphirerapids | ||
-ifneq ($(F_COMPILER), NAG) | ||
-FCOMMON_OPT += -march=sapphirerapids | ||
-endif | ||
-else # gcc not support, fallback to avx512 | ||
-CCOMMON_OPT += -march=skylake-avx512 | ||
-ifneq ($(F_COMPILER), NAG) | ||
-FCOMMON_OPT += -march=skylake-avx512 | ||
-endif | ||
-endif | ||
+ # sapphire rapids support was added in 11 | ||
+ ifeq ($(GCCVERSIONGTEQ11), 1) | ||
+ CCOMMON_OPT += -march=sapphirerapids | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=sapphirerapids | ||
+ endif | ||
+ else # gcc not support, fallback to avx512 | ||
+ CCOMMON_OPT += -march=skylake-avx512 | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=skylake-avx512 | ||
+ endif | ||
+ endif | ||
+else ifeq ($(C_COMPILER), CLANG) | ||
+ # cooperlake support was added in clang 12 | ||
+ ifeq ($(CLANGVERSIONGTEQ12), 1) | ||
+ CCOMMON_OPT += -march=cooperlake | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=cooperlake | ||
+ endif | ||
+ else # not supported in clang, fallback to avx512 | ||
+ CCOMMON_OPT += -march=skylake-avx512 | ||
+ ifneq ($(F_COMPILER), NAG) | ||
+ FCOMMON_OPT += -march=skylake-avx512 | ||
+ endif | ||
+ endif | ||
endif | ||
ifeq ($(OSNAME), CYGWIN_NT) | ||
CCOMMON_OPT += -fno-asynchronous-unwind-tables | ||
diff --git a/kernel/Makefile b/kernel/Makefile | ||
index 977886044..795f25eec 100644 | ||
--- a/kernel/Makefile | ||
+++ b/kernel/Makefile | ||
@@ -33,7 +33,7 @@ endif | ||
ifdef TARGET_CORE | ||
ifeq ($(TARGET_CORE), SAPPHIRERAPIDS) | ||
override CFLAGS += -DBUILD_KERNEL -DTABLE_NAME=gotoblas_$(TARGET_CORE) | ||
- ifeq ($(GCCVERSIONGTEQ10), 1) | ||
+ ifeq (1, $(filter 1,$(GCCVERSIONGTEQ11) $(CLANGVERSIONGTEQ12))) | ||
override CFLAGS += -march=sapphirerapids | ||
else | ||
override CFLAGS += -march=skylake-avx512 -mavx512f | ||
@@ -48,7 +48,7 @@ ifeq ($(TARGET_CORE), SAPPHIRERAPIDS) | ||
endif | ||
else ifeq ($(TARGET_CORE), COOPERLAKE) | ||
override CFLAGS += -DBUILD_KERNEL -DTABLE_NAME=gotoblas_$(TARGET_CORE) | ||
- ifeq ($(GCCVERSIONGTEQ10), 1) | ||
+ ifeq (1, $(filter 1,$(GCCVERSIONGTEQ10) $(CLANGVERSIONGTEQ9))) | ||
override CFLAGS += -march=cooperlake | ||
else | ||
override CFLAGS += -march=skylake-avx512 -mavx512f | ||
-- | ||
2.41.0 | ||
|