From 90d2444bf1799e89577efa00ab53407a96c384c9 Mon Sep 17 00:00:00 2001 From: Martin Reinecke Date: Fri, 18 Jan 2019 15:19:45 +0100 Subject: [PATCH] multiarch experiment --- Makefile.am | 25 +++++++++++++++++-------- libsharp/sharp_core.c | 4 ++-- libsharp/sharp_core_avx.c | 5 +---- libsharp/sharp_core_avx2.c | 5 +---- libsharp/sharp_core_avx512f.c | 5 +---- libsharp/sharp_core_fma.c | 5 +---- libsharp/sharp_core_fma4.c | 5 +---- 7 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Makefile.am b/Makefile.am index bcf53ff..a51f568 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4 lib_LTLIBRARIES = libsharp.la -src_sharp = \ +libsharp_la_SOURCES = \ c_utils/c_utils.c \ c_utils/c_utils.h \ pocketfft/pocketfft.c \ @@ -10,11 +10,6 @@ src_sharp = \ libsharp/sharp.c \ libsharp/sharp_almhelpers.c \ libsharp/sharp_core.c \ - libsharp/sharp_core_avx.c \ - libsharp/sharp_core_avx2.c \ - libsharp/sharp_core_fma.c \ - libsharp/sharp_core_fma4.c \ - libsharp/sharp_core_avx512f.c \ libsharp/sharp_geomhelpers.c \ libsharp/sharp_legendre_roots.c \ libsharp/sharp_ylmgen_c.c \ @@ -23,6 +18,16 @@ src_sharp = \ libsharp/sharp_vecsupport.h \ libsharp/sharp_ylmgen_c.h +libavx_la_SOURCES = libsharp/sharp_core_avx.c +libavx2_la_SOURCES = libsharp/sharp_core_avx2.c +libfma_la_SOURCES = libsharp/sharp_core_fma.c +libfma4_la_SOURCES = libsharp/sharp_core_fma4.c +libavx512f_la_SOURCES = libsharp/sharp_core_avx512f.c + +noinst_LTLIBRARIES = libavx.la libavx2.la libfma.la libfma4.la libavx512f.la + +libsharp_la_LIBADD = libavx.la libavx2.la libfma.la libfma4.la libavx512f.la + include_HEADERS = \ libsharp/sharp.h \ libsharp/sharp_geomhelpers.h \ @@ -33,8 +38,6 @@ EXTRA_DIST = \ libsharp/sharp_core_inc.c \ runtest.sh -libsharp_la_SOURCES = $(src_sharp) - check_PROGRAMS = sharp_testsuite sharp_testsuite_SOURCES = libsharp/sharp_testsuite.c c_utils/memusage.c c_utils/memusage.h c_utils/walltime_c.c c_utils/walltime_c.h sharp_testsuite_LDADD = libsharp.la @@ -43,6 +46,12 @@ TESTS = runtest.sh AM_CFLAGS = -I$(top_srcdir)/c_utils -I$(top_srcdir)/libsharp @AM_CFLAGS@ +libavx_la_CFLAGS = ${AM_CFLAGS} -mavx +libavx2_la_CFLAGS = ${AM_CFLAGS} -mavx2 +libfma_la_CFLAGS = ${AM_CFLAGS} -mfma +libfma4_la_CFLAGS = ${AM_CFLAGS} -mfma4 +libavx512f_la_CFLAGS = ${AM_CFLAGS} -mavx512f + pkgconfigdir = $(libdir)/pkgconfig nodist_pkgconfig_DATA = @PACKAGE_NAME@.pc diff --git a/libsharp/sharp_core.c b/libsharp/sharp_core.c index 036a8ed..e4c1059 100644 --- a/libsharp/sharp_core.c +++ b/libsharp/sharp_core.c @@ -18,7 +18,7 @@ static t_veclen veclen_ = NULL; static t_max_nvec max_nvec_ = NULL; static t_architecture architecture_ = NULL; -#if defined(__GNUC__) && defined (__x86_64__) && (__GNUC__>=6) +#ifdef MULTIARCH #define DECL(arch) \ static int XCONCATX2(have,arch)(void) \ @@ -59,7 +59,7 @@ DECL(avx) static void assign_funcs(void) { -#if defined(__GNUC__) && defined (__x86_64__) && (__GNUC__>=6) +#ifdef MULTIARCH #define DECL2(arch) \ if (XCONCATX2(have,arch)()) \ { \ diff --git a/libsharp/sharp_core_avx.c b/libsharp/sharp_core_avx.c index 724e629..053dfba 100644 --- a/libsharp/sharp_core_avx.c +++ b/libsharp/sharp_core_avx.c @@ -1,11 +1,8 @@ -#if (!defined(__AVX__)) && defined(__GNUC__) && defined (__x86_64__) && (__GNUC__>=6) - +#ifdef MULTIARCH #define XCONCATX(a,b) a##_##b #define XCONCATX2(a,b) XCONCATX(a,b) #define XARCH(a) XCONCATX2(a,ARCH) #define ARCH avx -#pragma GCC target("avx") #include "sharp_core_inc.c" - #endif diff --git a/libsharp/sharp_core_avx2.c b/libsharp/sharp_core_avx2.c index a7ab0a7..ca0a3b9 100644 --- a/libsharp/sharp_core_avx2.c +++ b/libsharp/sharp_core_avx2.c @@ -1,11 +1,8 @@ -#if (!defined(__AVX2__)) && defined(__GNUC__) && defined (__x86_64__) && (__GNUC__>=6) - +#ifdef MULTIARCH #define XCONCATX(a,b) a##_##b #define XCONCATX2(a,b) XCONCATX(a,b) #define XARCH(a) XCONCATX2(a,ARCH) #define ARCH avx2 -#pragma GCC target("avx2") #include "sharp_core_inc.c" - #endif diff --git a/libsharp/sharp_core_avx512f.c b/libsharp/sharp_core_avx512f.c index 7f17429..5781e3c 100644 --- a/libsharp/sharp_core_avx512f.c +++ b/libsharp/sharp_core_avx512f.c @@ -1,11 +1,8 @@ -#if (!defined(__AVX512F__)) && defined(__GNUC__) && defined (__x86_64__) && (__GNUC__>=6) - +#ifdef MULTIARCH #define XCONCATX(a,b) a##_##b #define XCONCATX2(a,b) XCONCATX(a,b) #define XARCH(a) XCONCATX2(a,ARCH) #define ARCH avx512f -#pragma GCC target("avx512f") #include "sharp_core_inc.c" - #endif diff --git a/libsharp/sharp_core_fma.c b/libsharp/sharp_core_fma.c index 793151f..bb0af2c 100644 --- a/libsharp/sharp_core_fma.c +++ b/libsharp/sharp_core_fma.c @@ -1,11 +1,8 @@ -#if (!defined(__FMA__)) && defined(__GNUC__) && defined (__x86_64__) && (__GNUC__>=6) - +#ifdef MULTIARCH #define XCONCATX(a,b) a##_##b #define XCONCATX2(a,b) XCONCATX(a,b) #define XARCH(a) XCONCATX2(a,ARCH) #define ARCH fma -#pragma GCC target("fma") #include "sharp_core_inc.c" - #endif diff --git a/libsharp/sharp_core_fma4.c b/libsharp/sharp_core_fma4.c index d71de74..9b7f67b 100644 --- a/libsharp/sharp_core_fma4.c +++ b/libsharp/sharp_core_fma4.c @@ -1,11 +1,8 @@ -#if (!defined(__FMA4__)) && defined(__GNUC__) && defined (__x86_64__) && (__GNUC__>=6) - +#ifdef MULTIARCH #define XCONCATX(a,b) a##_##b #define XCONCATX2(a,b) XCONCATX(a,b) #define XARCH(a) XCONCATX2(a,ARCH) #define ARCH fma4 -#pragma GCC target("fma4") #include "sharp_core_inc.c" - #endif