From 9fbeb88fb87dcc418c9ef01c5f24c85029dfbbef Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 23 Mar 2022 15:19:55 +0100 Subject: [PATCH 1/3] Utilize compiler AVX512 capability info from c_check when building getarch --- Makefile.prebuild | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.prebuild b/Makefile.prebuild index 399db956f..4dad74d63 100644 --- a/Makefile.prebuild +++ b/Makefile.prebuild @@ -71,7 +71,8 @@ endif getarch : getarch.c cpuid.S dummy $(CPUIDEMU) - $(HOSTCC) $(HOST_CFLAGS) $(EXFLAGS) -o $(@F) getarch.c cpuid.S $(CPUIDEMU) + avx512=$$(perl c_check - - gcc | grep NO_AVX512); \ + $(HOSTCC) $(HOST_CFLAGS) $(EXFLAGS) $${avx512:+-D$${avx512}} -o $(@F) getarch.c cpuid.S $(CPUIDEMU) getarch_2nd : getarch_2nd.c config.h dummy ifndef TARGET_CORE From 93a81856ae6a34c4329054744237d46ed347ccec Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 23 Mar 2022 15:22:13 +0100 Subject: [PATCH 2/3] Revert AVX512 capability check from PR #1980 (moved to build) --- getarch.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/getarch.c b/getarch.c index 00e544bc7..e49eac1a3 100644 --- a/getarch.c +++ b/getarch.c @@ -94,14 +94,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif -#if defined(__x86_64__) || defined(_M_X64) -#if (( defined(__GNUC__) && __GNUC__ > 6 && defined(__AVX2__)) || (defined(__clang__) && __clang_major__ >= 6)) -#else -#ifndef NO_AVX512 -#define NO_AVX512 -#endif -#endif -#endif /* #define FORCE_P2 */ /* #define FORCE_KATMAI */ /* #define FORCE_COPPERMINE */ From c87a4dbf35c809ebe6bc88c7d8dce8f2e7b135ea Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 23 Mar 2022 15:48:58 +0100 Subject: [PATCH 3/3] Fix checks for AVX512 and atomics --- c_check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c_check b/c_check index 999f5a7a7..e10ddfebc 100644 --- a/c_check +++ b/c_check @@ -254,7 +254,7 @@ if (($architecture eq "x86") || ($architecture eq "x86_64")) { # $tmpf = new File::Temp( UNLINK => 1 ); ($fh,$tmpf) = tempfile( SUFFIX => '.c' , UNLINK => 1 ); $code = '"vbroadcastss -4 * 4(%rsi), %zmm2"'; - print $tmpf "#include \n\nint main(void){ __asm__ volatile($code); }\n"; + print $fh "#include \n\nint main(void){ __asm__ volatile($code); }\n"; $args = " -march=skylake-avx512 -c -o $tmpf.o $tmpf"; if ($compiler eq "PGI") { $args = " -tp skylake -c -o $tmpf.o $tmpf"; @@ -278,7 +278,7 @@ if ($data =~ /HAVE_C11/) { $c11_atomics = 0; } else { ($fh,$tmpf) = tempfile( SUFFIX => '.c' , UNLINK => 1 ); - print $tmpf "#include \nint main(void){}\n"; + print $fh "#include \nint main(void){}\n"; $args = " -c -o $tmpf.o $tmpf"; my @cmd = ("$compiler_name $flags $args >/dev/null 2>/dev/null"); system(@cmd) == 0;