Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace sed commands by upstreamed patches for BLIS built with intel-compilers toolchain #15958

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ toolchainopts = {'oneapi': True}

source_urls = ['https://github.com/flame/blis/archive/']
sources = ['%(version)s.tar.gz']
checksums = ['1135f664be7355427b91025075562805cdc6cc730d3173f83533b2c5dcc2f308']
patches = [
'%(name)s-%(version)s_blastest-enable-complex-return-intel.patch',
'%(name)s-%(version)s_ifx-complex-return-intel.patch',
]
checksums = [
'1135f664be7355427b91025075562805cdc6cc730d3173f83533b2c5dcc2f308', # 0.9.0.tar.gz
# BLIS-0.9.0_blastest-enable-complex-return-intel.patch
'0f1966b340d1f24cf02070f00f72f232b4cbfcd242ee9ce8c5f09f7220397cb4',
'097a2647b5c66386155cf6a33a2a617b876bd0f9096a2912359eb0897a29d2d5', # BLIS-0.9.0_ifx-complex-return-intel.patch
]

builddependencies = [
('Python', '3.10.4', '-bare'),
('Perl', '5.34.1'),
]

configopts = '--enable-cblas --enable-threading=openmp --enable-shared --complex-return=intel CC="$CC" auto'

# Intel expects classic f2c-style calling convention.
pretestopts = 'for cu in c u; do for cz in c z; do '
pretestopts += 'sed -i "s/\([^ ]*complex\) ${cz}dot${cu}_(/void ${cz}dot${cu}_(\\1 \*, /g;'
pretestopts += 's/\([qz]__1\) = ${cz}dot${cu}_(/${cz}dot${cu}_(\&\\1, /g" blastest/src/${cz}blat1.c; done; done && '
configopts = '--enable-cblas --enable-threading=openmp --enable-shared CC="$CC" auto'

runtest = 'check'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
From 9b1beec60be31c6ea20b85806d61551497b699e4 Mon Sep 17 00:00:00 2001
From: bartoldeman <bartoldeman@users.noreply.github.com>
Date: Mon, 11 Jul 2022 20:15:12 -0400
Subject: [PATCH] Use BLIS_ENABLE_COMPLEX_RETURN_INTEL in blastest files (#636)

Details:
- Fixed a crash that occurs when either cblat1 or zblat1 are linked
with a build of BLIS that was compiled with '--complex-return=intel'.
This fix involved inserting preprocessor macro guards based on
BLIS_ENABLE_COMPLEX_RETURN_INTEL into blastest/src/cblat1.c and
blastest/src/zblat1.c to correctly handle situations where BLIS is
compiled with Intel/f2c-style calling conventions for complex numbers.
- Updated blastest/src/fortran/run-f2c.sh so that future executions
will insert the aforementioned cpp macro conditional where
appropriate.
---
blastest/src/cblat1.c | 32 ++++++++++++++++++++++++++++----
blastest/src/fortran/run-f2c.sh | 20 +++++++++++---------
blastest/src/zblat1.c | 32 ++++++++++++++++++++++++++++----
3 files changed, 67 insertions(+), 17 deletions(-)

diff --git a/blastest/src/cblat1.c b/blastest/src/cblat1.c
index daccb2f6c..606511662 100644
--- a/blastest/src/cblat1.c
+++ b/blastest/src/cblat1.c
@@ -475,11 +475,23 @@ static real c_b52 = 0.f;
integer mx, my;
complex cdot[1];
integer lenx, leny;
- extern /* Complex */ complex cdotc_(integer *, complex *, integer
+ extern /* Complex */
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ void cdotc_(complex *,
+#else
+complex cdotc_(
+#endif
+ integer *, complex *, integer
*, complex *, integer *);
extern /* Subroutine */ int ccopy_(integer *, complex *, integer *,
complex *, integer *);
- extern /* Complex */ complex cdotu_(integer *, complex *, integer
+ extern /* Complex */
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ void cdotu_(complex *,
+#else
+complex cdotu_(
+#endif
+ integer *, complex *, integer
*, complex *, integer *);
extern /* Subroutine */ int cswap_(integer *, complex *, integer *,
complex *, integer *), ctest_(integer *, complex *, complex *,
@@ -526,14 +538,26 @@ static real c_b52 = 0.f;
}
if (combla_1.icase == 1) {
/* .. CDOTC .. */
- q__1 = cdotc_(&combla_1.n, cx, &combla_1.incx, cy, &
+
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ cdotc_(&q__1,
+#else
+ q__1 = cdotc_(
+#endif
+ &combla_1.n, cx, &combla_1.incx, cy, &
combla_1.incy);
cdot[0].r = q__1.r, cdot[0].i = q__1.i;
ctest_(&c__1, cdot, &ct6[kn + (ki << 2) - 5], &csize1[kn - 1],
sfac);
} else if (combla_1.icase == 2) {
/* .. CDOTU .. */
- q__1 = cdotu_(&combla_1.n, cx, &combla_1.incx, cy, &
+
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ cdotu_(&q__1,
+#else
+ q__1 = cdotu_(
+#endif
+ &combla_1.n, cx, &combla_1.incx, cy, &
combla_1.incy);
cdot[0].r = q__1.r, cdot[0].i = q__1.i;
ctest_(&c__1, cdot, &ct7[kn + (ki << 2) - 5], &csize1[kn - 1],
diff --git a/blastest/src/fortran/run-f2c.sh b/blastest/src/fortran/run-f2c.sh
index fdad4fd34..f0df2f5b8 100755
--- a/blastest/src/fortran/run-f2c.sh
+++ b/blastest/src/fortran/run-f2c.sh
@@ -50,13 +50,15 @@ recursive-sed.sh -c "s/-4.f };/-4.f }};/g" -p "s*1.c"

# Convert from brain-dead f2c complex calling conventions to normal
# return-based conventions.
-recursive-sed.sh -c "s/void cdotc_(complex \*, /complex cdotc_(/g" -p "c*1.c"
-recursive-sed.sh -c "s/void cdotu_(complex \*, /complex cdotu_(/g" -p "c*1.c"
-recursive-sed.sh -c "s/cdotc_(&q__1, /q__1 = cdotc_(/g" -p "c*1.c"
-recursive-sed.sh -c "s/cdotu_(&q__1, /q__1 = cdotu_(/g" -p "c*1.c"
-
-recursive-sed.sh -c "s/void zdotc_(doublecomplex \*, /doublecomplex zdotc_(/g" -p "z*1.c"
-recursive-sed.sh -c "s/void zdotu_(doublecomplex \*, /doublecomplex zdotu_(/g" -p "z*1.c"
-recursive-sed.sh -c "s/zdotc_(\&z__1, /z__1 = zdotc_(/g" -p "z*1.c"
-recursive-sed.sh -c "s/zdotu_(\&z__1, /z__1 = zdotu_(/g" -p "z*1.c"
+subst1='\n#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL\n&\n#else\n'
+subst2='\n#endif\n'
+recursive-sed.sh -c "s/ void cdotc_(complex \*,/${subst1}complex cdotc_(${subst2}/g" -p "c*1.c"
+recursive-sed.sh -c "s/ void cdotu_(complex \*,/${subst1}complex cdotu_(${subst2}/g" -p "c*1.c"
+recursive-sed.sh -c "s/\(.*\)cdotc_(&q__1,/${subst1}\1q__1 = cdotc_(${subst2}\1/g" -p "c*1.c"
+recursive-sed.sh -c "s/\(.*\)cdotu_(&q__1,/${subst1}\1q__1 = cdotu_(${subst2}\1/g" -p "c*1.c"
+
+recursive-sed.sh -c "s/ void zdotc_(doublecomplex \*,/${subst1}doublecomplex zdotc_(${subst2}/g" -p "z*1.c"
+recursive-sed.sh -c "s/ void zdotu_(doublecomplex \*,/${subst1}doublecomplex zdotu_(${subst2}/g" -p "z*1.c"
+recursive-sed.sh -c "s/\(.*\)zdotc_(\&z__1,/${subst1}\1z__1 = zdotc_(${subst2}\1/g" -p "z*1.c"
+recursive-sed.sh -c "s/\(.*\)zdotu_(\&z__1,/${subst1}\1z__1 = zdotu_(${subst2}\1/g" -p "z*1.c"

diff --git a/blastest/src/zblat1.c b/blastest/src/zblat1.c
index c34a57262..b620910be 100644
--- a/blastest/src/zblat1.c
+++ b/blastest/src/zblat1.c
@@ -459,12 +459,24 @@ static doublereal c_b52 = 0.;
integer lenx, leny;
extern /* Subroutine */ int ctest_(integer *, doublecomplex *,
doublecomplex *, doublecomplex *, doublereal *);
- extern /* Double Complex */ doublecomplex zdotc_(integer *,
+ extern /* Double Complex */
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ void zdotc_(doublecomplex *,
+#else
+doublecomplex zdotc_(
+#endif
+ integer *,
doublecomplex *, integer *, doublecomplex *, integer *);
integer ksize;
extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *,
doublecomplex *, integer *);
- extern /* Double Complex */ doublecomplex zdotu_(integer *,
+ extern /* Double Complex */
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ void zdotu_(doublecomplex *,
+#else
+doublecomplex zdotu_(
+#endif
+ integer *,
doublecomplex *, integer *, doublecomplex *, integer *);
extern /* Subroutine */ int zswap_(integer *, doublecomplex *, integer *,
doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *,
@@ -508,14 +520,26 @@ static doublereal c_b52 = 0.;
}
if (combla_1.icase == 1) {
/* .. ZDOTC .. */
- z__1 = zdotc_(&combla_1.n, cx, &combla_1.incx, cy, &
+
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ zdotc_(&z__1,
+#else
+ z__1 = zdotc_(
+#endif
+ &combla_1.n, cx, &combla_1.incx, cy, &
combla_1.incy);
cdot[0].r = z__1.r, cdot[0].i = z__1.i;
ctest_(&c__1, cdot, &ct6[kn + (ki << 2) - 5], &csize1[kn - 1],
sfac);
} else if (combla_1.icase == 2) {
/* .. ZDOTU .. */
- z__1 = zdotu_(&combla_1.n, cx, &combla_1.incx, cy, &
+
+#ifdef BLIS_ENABLE_COMPLEX_RETURN_INTEL
+ zdotu_(&z__1,
+#else
+ z__1 = zdotu_(
+#endif
+ &combla_1.n, cx, &combla_1.incx, cy, &
combla_1.incy);
cdot[0].r = z__1.r, cdot[0].i = z__1.i;
ctest_(&c__1, cdot, &ct7[kn + (ki << 2) - 5], &csize1[kn - 1],
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 98d467891b74021ace7f248cb0856bec734e39b6 Mon Sep 17 00:00:00 2001
From: bartoldeman <bartoldeman@users.noreply.github.com>
Date: Mon, 11 Jul 2022 19:40:53 -0400
Subject: [PATCH] Change complex_return='intel' for ifx. (#637)

Details:
- When checking the version string of the Fortran compiler for the
purposes of determining a default return convention for complex
domain values, grep for "IFORT" instead of "ifort" since that string
is common to both the 'ifx' and 'ifort' binaries provided by Intel:

$ ifx --version
ifx (IFORT) 2022.1.0 20220316
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

$ ifort --version
ifort (IFORT) 2021.6.0 20220226
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.
---
configure | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 5ff877317..a6018edab 100755
--- a/configure
+++ b/configure
@@ -3688,9 +3688,9 @@ main()
# Query the compiler "vendor" (ie: the compiler's simple name).
# The last part ({ read first rest ; echo $first ; }) is a workaround
# to OS X's egrep only returning the first match.
- fc_vendor=$(echo "${vendor_string}" | egrep -o 'ifort|GNU' | { read first rest ; echo $first ; })
+ fc_vendor=$(echo "${vendor_string}" | egrep -o 'IFORT|GNU' | { read first rest ; echo $first ; })

- if [ "x${fc_vendor}" = "xifort" ]; then
+ if [ "x${fc_vendor}" = "xIFORT" ]; then
complex_return='intel'
elif [ "x${fc_vendor}" = "xGNU" ]; then
complex_return='gnu'