x86-64: Add sysdeps/x86_64/fpu/Makeconfig
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 12 Oct 2021 01:07:09 +0000 (18:07 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 20 Oct 2021 18:53:45 +0000 (11:53 -0700)
1. Add sysdeps/x86_64/fpu/Makeconfig to auto-generate libmvec.mk, which
contains libmvec ABI test dependencies and CFLAGS, in the build directory.
2. Include libmvec.mk for libmvec ABI test dependencies and CFLAGS.

Tested on SSE4, AVX, AVX2 and AVX512 machines.

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
sysdeps/x86_64/fpu/Makeconfig [new file with mode: 0644]
sysdeps/x86_64/fpu/Makefile
sysdeps/x86_64/fpu/multiarch/Makefile

diff --git a/sysdeps/x86_64/fpu/Makeconfig b/sysdeps/x86_64/fpu/Makeconfig
new file mode 100644 (file)
index 0000000..0a9341c
--- /dev/null
@@ -0,0 +1,92 @@
+# Generate libmvec.mk for libmvec ABI tests.
+
+# Copyright (C) 2021 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+-include $(common-objpfx)libmvec.mk
+postclean-generated += libmvec.mk
+
+# Define for both math and mathvec directories.
+libmvec-funcs = \
+  cos \
+  exp \
+  log \
+  pow \
+  sin \
+  sincos \
+
+# FIXME: Add ABI tests for all libmvec functions and replace
+# libmvec-abi-funcs with libmvec-funcs.
+libmvec-abi-funcs = \
+  sincos
+
+# The base libmvec ABI tests.
+libmvec-abi-func-tests = \
+  $(addprefix test-double-libmvec-,$(libmvec-abi-funcs)) \
+  $(addsuffix f,$(addprefix test-float-libmvec-,$(libmvec-abi-funcs)))
+
+# The AVX libmvec ABI tests.
+libmvec-abi-func-avx-tests = \
+  $(addsuffix -avx,$(libmvec-abi-func-tests))
+#
+# The AVX2 libmvec ABI tests.
+libmvec-abi-func-avx2-tests = \
+  $(addsuffix -avx2,$(libmvec-abi-func-tests))
+#
+# The AVX512F libmvec ABI tests.
+libmvec-abi-func-avx512f-tests = \
+  $(addsuffix -avx512f,$(libmvec-abi-func-tests))
+
+$(common-objpfx)libmvec.mk: $(common-objpfx)config.make
+       (echo "ifeq (\$$(subdir)\$$(build-mathvec),mathyes)"; \
+        echo; \
+        for i in "" "-avx" "-avx2" "-avx512f"; do \
+          for t in $(libmvec-abi-func-tests); do \
+            echo "\$$(objpfx)$$t$$i: \\"; \
+            echo "  \$$(objpfx)$$t$$i.o \\"; \
+            echo "  \$$(objpfx)test-libmvec$$i.o \$$(libmvec)"; \
+            echo; \
+          done; \
+        done; \
+        for t in $(libmvec-abi-funcs); do \
+          echo "CFLAGS-test-double-libmvec-$$t.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags)"; \
+          echo "CFLAGS-test-double-libmvec-$$t-avx.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags) \\"; \
+          echo "  \$$(double-vlen4-arch-ext-cflags)"; \
+          echo "CFLAGS-test-double-libmvec-$$t-avx2.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags) \\"; \
+          echo "  \$$(double-vlen4-arch-ext2-cflags)"; \
+          echo "CFLAGS-test-double-libmvec-$$t-avx512f.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags) \\"; \
+          echo "  \$$(double-vlen8-arch-ext-cflags)"; \
+          echo; \
+          echo "CFLAGS-test-float-libmvec-$${t}f.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags)"; \
+          echo "CFLAGS-test-float-libmvec-$${t}f-avx.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags) \\"; \
+          echo "  \$$(float-vlen8-arch-ext-cflags)"; \
+          echo "CFLAGS-test-float-libmvec-$${t}f-avx2.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags) \\"; \
+          echo "  \$$(float-vlen8-arch-ext2-cflags)"; \
+          echo "CFLAGS-test-float-libmvec-$${t}f-avx512f.c = \\"; \
+          echo "  \$$(libmvec-abi-test-cflags) \\"; \
+          echo "  \$$(float-vlen16-arch-ext-cflags)"; \
+          echo; \
+        done; \
+        echo "endif") > $@T
+       mv -f $@T $@
index e5a6575..d172ae8 100644 (file)
@@ -1,87 +1,48 @@
 ifeq ($(subdir),mathvec)
-libmvec-support += svml_d_cos2_core svml_d_cos4_core_avx \
-                  svml_d_cos4_core svml_d_cos8_core \
-                  svml_d_sin2_core svml_d_sin4_core_avx \
-                  svml_d_sin4_core svml_d_sin8_core svml_d_trig_data \
-                  svml_s_cosf4_core svml_s_cosf8_core_avx \
-                  svml_s_cosf8_core svml_s_cosf16_core svml_s_trig_data \
-                  svml_s_sinf4_core svml_s_sinf8_core_avx \
-                  svml_s_sinf8_core svml_s_sinf16_core \
-                  svml_d_sincos2_core svml_d_sincos4_core_avx \
-                  svml_d_sincos4_core svml_d_sincos8_core \
-                  svml_d_log2_core svml_d_log4_core_avx svml_d_log4_core \
-                  svml_d_log8_core svml_d_log_data svml_s_logf4_core \
-                  svml_s_logf8_core_avx svml_s_logf8_core svml_s_logf16_core \
-                  svml_s_logf_data svml_d_exp2_core svml_d_exp4_core_avx \
-                  svml_d_exp4_core svml_d_exp8_core svml_d_exp_data \
-                  svml_s_expf4_core svml_s_expf8_core_avx svml_s_expf8_core \
-                  svml_s_expf16_core svml_s_expf_data svml_d_pow2_core \
-                  svml_d_pow4_core_avx svml_d_pow4_core svml_d_pow8_core \
-                  svml_d_pow_data svml_s_powf4_core svml_s_powf8_core_avx \
-                  svml_s_powf8_core svml_s_powf16_core svml_s_powf_data \
-                  svml_s_sincosf4_core svml_s_sincosf8_core_avx \
-                  svml_s_sincosf8_core svml_s_sincosf16_core
+libmvec-double-func-list = \
+  2_core \
+  4_core \
+  4_core_avx \
+  8_core
+libmvec-float-func-list = \
+  f4_core \
+  f8_core \
+  f8_core_avx \
+  f16_core
+libmvec-support += \
+  svml_d_exp_data \
+  svml_d_log_data \
+  svml_d_pow_data \
+  svml_d_trig_data \
+  svml_s_expf_data \
+  svml_s_logf_data \
+  svml_s_powf_data \
+  svml_s_trig_data \
+  $(foreach l,$(libmvec-double-func-list), \
+    $(addprefix svml_d_,$(addsuffix $(l),$(libmvec-funcs)))) \
+  $(foreach l,$(libmvec-float-func-list), \
+    $(addprefix svml_s_,$(addsuffix $(l),$(libmvec-funcs))))
 endif
 
 # Variables for libmvec tests.
-ifeq ($(subdir),math)
-ifeq ($(build-mathvec),yes)
+ifeq ($(subdir)$(build-mathvec),mathyes)
 libmvec-tests += double-vlen2 double-vlen4 double-vlen4-avx2 \
-                float-vlen4 float-vlen8 float-vlen8-avx2
-tests += test-double-libmvec-sincos test-double-libmvec-sincos-avx \
-        test-double-libmvec-sincos-avx2 test-float-libmvec-sincosf \
-        test-float-libmvec-sincosf-avx test-float-libmvec-sincosf-avx2
-test-extras += test-libmvec test-libmvec-avx \
-              test-libmvec-avx2 test-libmvec-avx512f
-extra-test-objs += test-libmvec.o test-libmvec-avx.o \
-                  test-libmvec-avx2.o test-libmvec-avx512f.o
-
-$(objpfx)test-double-libmvec-sincos: \
-  $(objpfx)test-double-libmvec-sincos.o \
-  $(objpfx)test-libmvec.o $(libmvec)
-
-$(objpfx)test-double-libmvec-sincos-avx: \
-  $(objpfx)test-double-libmvec-sincos-avx.o \
-  $(objpfx)test-libmvec-avx.o $(libmvec)
-
-$(objpfx)test-double-libmvec-sincos-avx2: \
-  $(objpfx)test-double-libmvec-sincos-avx2.o \
-  $(objpfx)test-libmvec-avx2.o $(libmvec)
-
-$(objpfx)test-float-libmvec-sincosf: \
-  $(objpfx)test-float-libmvec-sincosf.o \
-  $(objpfx)test-libmvec.o $(libmvec)
-
-$(objpfx)test-float-libmvec-sincosf-avx: \
-  $(objpfx)test-float-libmvec-sincosf-avx.o \
-  $(objpfx)test-libmvec-avx.o $(libmvec)
-
-$(objpfx)test-float-libmvec-sincosf-avx2: \
-  $(objpfx)test-float-libmvec-sincosf-avx2.o \
-  $(objpfx)test-libmvec-avx2.o $(libmvec)
-
-libmvec-tests += double-vlen8 float-vlen16
-tests += test-double-libmvec-sincos-avx512f \
-        test-float-libmvec-sincosf-avx512f
-test-extras += test-libmvec-avx512f
-extra-test-objs += test-libmvec-avx512f.o
-
-$(objpfx)test-double-libmvec-sincos-avx512f: \
-  $(objpfx)test-double-libmvec-sincos-avx512f.o \
-  $(objpfx)test-libmvec-avx512f.o $(libmvec)
-
-$(objpfx)test-float-libmvec-sincosf-avx512f: \
-  $(objpfx)test-float-libmvec-sincosf-avx512f.o \
-  $(objpfx)test-libmvec-avx512f.o $(libmvec)
-
-double-vlen2-funcs = cos exp log pow sin sincos
-double-vlen4-funcs = cos exp log pow sin sincos
-double-vlen4-avx2-funcs = cos exp log pow sin sincos
-double-vlen8-funcs = cos exp log pow sin sincos
-float-vlen4-funcs = cos exp log pow sin sincos
-float-vlen8-funcs = cos exp log pow sin sincos
-float-vlen8-avx2-funcs = cos exp log pow sin sincos
-float-vlen16-funcs = cos exp log pow sin sincos
+                float-vlen4 float-vlen8 float-vlen8-avx2 \
+                double-vlen8 float-vlen16
+tests += \
+  $(libmvec-abi-func-tests) \
+  $(libmvec-abi-func-avx-tests) \
+  $(libmvec-abi-func-avx2-tests) \
+  $(libmvec-abi-func-avx512f-tests)
+
+double-vlen2-funcs = $(libmvec-funcs)
+double-vlen4-funcs = $(libmvec-funcs)
+double-vlen4-avx2-funcs = $(libmvec-funcs)
+double-vlen8-funcs = $(libmvec-funcs)
+float-vlen4-funcs = $(libmvec-funcs)
+float-vlen8-funcs = $(libmvec-funcs)
+float-vlen8-avx2-funcs = $(libmvec-funcs)
+float-vlen16-funcs = $(libmvec-funcs)
 
 double-vlen4-arch-ext-cflags = -mavx
 double-vlen4-arch-ext2-cflags = -mavx2
@@ -91,22 +52,13 @@ float-vlen8-arch-ext-cflags = -mavx
 float-vlen8-arch-ext2-cflags = -mavx2
 float-vlen16-arch-ext-cflags = -mavx512f
 
-libmvec-sincos-cflags = $(libm-test-fast-math-cflags) -fno-inline -fopenmp -Wno-unknown-pragmas
+libmvec-abi-test-cflags = \
+  $(libm-test-fast-math-cflags) \
+  -fno-inline -fopenmp -Wno-unknown-pragmas
 
 CFLAGS-test-double-vlen4-avx2-wrappers.c = $(double-vlen4-arch-ext2-cflags)
 
 CFLAGS-test-float-vlen8-avx2-wrappers.c = $(float-vlen8-arch-ext2-cflags)
-
-CFLAGS-test-double-libmvec-sincos.c = $(libmvec-sincos-cflags)
-CFLAGS-test-double-libmvec-sincos-avx.c = $(libmvec-sincos-cflags) $(double-vlen4-arch-ext-cflags)
-CFLAGS-test-double-libmvec-sincos-avx2.c = $(libmvec-sincos-cflags) $(double-vlen4-arch-ext2-cflags)
-CFLAGS-test-double-libmvec-sincos-avx512f.c = $(libmvec-sincos-cflags) $(double-vlen8-arch-ext-cflags)
-
-CFLAGS-test-float-libmvec-sincosf.c = $(libmvec-sincos-cflags)
-CFLAGS-test-float-libmvec-sincosf-avx.c = $(libmvec-sincos-cflags) $(float-vlen8-arch-ext-cflags)
-CFLAGS-test-float-libmvec-sincosf-avx2.c = $(libmvec-sincos-cflags) $(float-vlen8-arch-ext2-cflags)
-CFLAGS-test-float-libmvec-sincosf-avx512f.c = $(libmvec-sincos-cflags) $(float-vlen16-arch-ext-cflags)
-endif
 endif
 
 ifeq ($(subdir)$(config-cflags-mprefer-vector-width),mathyes)
index d425ffd..ec79627 100644 (file)
@@ -59,52 +59,24 @@ CFLAGS-s_tan-avx.c = -msse2avx -DSSE2AVX
 endif
 
 ifeq ($(subdir),mathvec)
-libmvec-sysdep_routines += svml_d_cos2_core_sse4 svml_d_cos4_core_avx2 \
-                          svml_d_cos8_core_avx512 svml_d_sin2_core_sse4 \
-                          svml_d_sin4_core_avx2 svml_d_sin8_core_avx512 \
-                          svml_d_log2_core_sse4 svml_d_log4_core_avx2 \
-                          svml_d_log8_core_avx512 svml_d_sincos2_core_sse4 \
-                          svml_d_sincos4_core_avx2 svml_d_sincos8_core_avx512 \
-                          svml_s_cosf4_core_sse4 svml_s_cosf8_core_avx2 \
-                          svml_s_cosf16_core_avx512 svml_s_sinf4_core_sse4 \
-                          svml_s_sinf8_core_avx2 svml_s_sinf16_core_avx512 \
-                          svml_s_logf4_core_sse4 svml_s_logf8_core_avx2 \
-                          svml_s_logf16_core_avx512 svml_d_exp2_core_sse4 \
-                          svml_d_exp4_core_avx2 svml_d_exp8_core_avx512 \
-                          svml_s_expf4_core_sse4 svml_s_expf8_core_avx2 \
-                          svml_s_expf16_core_avx512 svml_d_pow2_core_sse4 \
-                          svml_d_pow4_core_avx2 svml_d_pow8_core_avx512 \
-                          svml_s_powf4_core_sse4 svml_s_powf8_core_avx2 \
-                          svml_s_powf16_core_avx512 svml_s_sincosf4_core_sse4 \
-                          svml_s_sincosf8_core_avx2 \
-                          svml_s_sincosf16_core_avx512 \
-                          svml_d_cos2_core-sse2 svml_d_cos4_core-sse \
-                          svml_d_cos8_core-avx2 svml_d_exp2_core-sse2 \
-                          svml_d_exp4_core-sse svml_d_exp8_core-avx2 \
-                          svml_d_log2_core-sse2 svml_d_log4_core-sse \
-                          svml_d_log8_core-avx2 svml_d_pow2_core-sse2 \
-                          svml_d_pow4_core-sse svml_d_pow8_core-avx2 \
-                          svml_d_sin2_core-sse2 svml_d_sin4_core-sse \
-                          svml_d_sin8_core-avx2 \
-                          svml_d_sincos2_core-sse2 \
-                          svml_d_sincos4_core-sse \
-                          svml_d_sincos8_core-avx2 \
-                          svml_s_cosf16_core-avx2 \
-                          svml_s_cosf4_core-sse2 \
-                          svml_s_cosf8_core-sse \
-                          svml_s_expf16_core-avx2 \
-                          svml_s_expf4_core-sse2 \
-                          svml_s_expf8_core-sse \
-                          svml_s_logf16_core-avx2 \
-                          svml_s_logf4_core-sse2 \
-                          svml_s_logf8_core-sse \
-                          svml_s_powf16_core-avx2 \
-                          svml_s_powf4_core-sse2 \
-                          svml_s_powf8_core-sse \
-                          svml_s_sincosf16_core-avx2 \
-                          svml_s_sincosf4_core-sse2 \
-                          svml_s_sincosf8_core-sse \
-                          svml_s_sinf16_core-avx2 \
-                          svml_s_sinf4_core-sse2 \
-                          svml_s_sinf8_core-sse
+libmvec-multiarch-double-func-list = \
+  2_core-sse2 \
+  2_core_sse4 \
+  4_core-sse \
+  4_core_avx2 \
+  8_core-avx2 \
+  8_core_avx512
+libmvec-multiarch-float-func-list = \
+  f4_core-sse2 \
+  f4_core_sse4 \
+  f8_core-sse \
+  f8_core_avx2 \
+  f16_core-avx2 \
+  f16_core_avx512
+
+libmvec-sysdep_routines += \
+  $(foreach l,$(libmvec-multiarch-double-func-list), \
+    $(addprefix svml_d_,$(addsuffix $(l),$(libmvec-funcs)))) \
+  $(foreach l,$(libmvec-multiarch-float-func-list), \
+    $(addprefix svml_s_,$(addsuffix $(l),$(libmvec-funcs))))
 endif