This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/N] [x86_64] Vectorized math functions


Hi,

this is addition of several macros: for condition in tests for vector
functions, for forming name of tested function, for runtime
architecture check.

ChangeLog

2014-11-20  Andrew Senkevich  <andrew.n.senkevich@gmail.com>

        * math/libm-test.inc (TEST_MATHVEC, VEC_PREFIX, INIT_ARCH_EXT,
        CHECK_ARCH_EXT, STR_CONCAT, STR_CON3): New macros. START refactored.
        * sysdeps/x86_64/fpu/math-tests.h: New file.

diff --git a/math/libm-test.inc b/math/libm-test.inc
index df11343..94931e2 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -678,13 +678,17 @@ test_exceptions (const char *test_name, int exception)
   feclearexcept (FE_ALL_EXCEPT);
 }

+#ifndef TEST_MATHVEC
+# define TEST_MATHVEC 0
+#endif
+
 /* Test whether errno for TEST_NAME, set to ERRNO_VALUE, has value
    EXPECTED_VALUE (description EXPECTED_NAME).  */
 static void
 test_single_errno (const char *test_name, int errno_value,
    int expected_value, const char *expected_name)
 {
-#ifndef TEST_INLINE
+#if !defined TEST_INLINE && !TEST_MATHVEC
   if (errno_value == expected_value)
     {
       if (print_screen (1))
@@ -1690,13 +1694,27 @@ struct test_fFF_11_data
        (ARRAY)[i].RM_##ROUNDING_MODE.extra2_expected); \
   ROUND_RESTORE_ ## ROUNDING_MODE

+#ifndef INIT_ARCH_EXT
+# define INIT_ARCH_EXT
+# define CHECK_ARCH_EXT
+#endif
+
+#ifndef VEC_PREFIX
+# define VEC_PREFIX
+#endif
+
 #ifndef FUNC_TEST
 # define FUNC_TEST FUNC
 #endif

+#define STR_CONCAT(a, b, c) __STRING (a##b##c)
+#define STR_CON3(a, b, c) STR_CONCAT (a, b, c)
+
 /* Start and end the tests for a given function.  */
-#define START(FUNC, EXACT) \
-  const char *this_func = #FUNC; \
+#define START(FUNC, SUFF, EXACT) \
+  CHECK_ARCH_EXT \
+  if (TEST_MATHVEC) return; \
+  const char *this_func = STR_CON3 (VEC_PREFIX, FUNC, SUFF); \
   init_max_error (this_func, EXACT)
 #define END \
   print_max_error (this_func)
@@ -1709,28 +1727,28 @@ struct test_fFF_11_data
     { \
       do \
  { \
-  START (FUNC, EXACT); \
+  START (FUNC,, EXACT); \
   LOOP_MACRO (FUNC, ARRAY, , ## __VA_ARGS__); \
   END_MACRO; \
  } \
       while (0); \
       do \
  { \
-  START (FUNC ## _downward, EXACT); \
+  START (FUNC, _downward, EXACT); \
   LOOP_MACRO (FUNC, ARRAY, FE_DOWNWARD, ## __VA_ARGS__); \
   END_MACRO; \
  } \
       while (0); \
       do \
  { \
-  START (FUNC ## _towardzero, EXACT); \
+  START (FUNC, _towardzero, EXACT); \
   LOOP_MACRO (FUNC, ARRAY, FE_TOWARDZERO, ## __VA_ARGS__); \
   END_MACRO; \
  } \
       while (0); \
       do \
  { \
-  START (FUNC ## _upward, EXACT); \
+  START (FUNC, _upward, EXACT); \
   LOOP_MACRO (FUNC, ARRAY, FE_UPWARD, ## __VA_ARGS__); \
   END_MACRO; \
  } \
@@ -6038,7 +6056,7 @@ static const struct test_c_c_data cexp_test_data[] =
 static void
 cexp_test (void)
 {
-  START (cexp, 0);
+  START (cexp,, 0);
   RUN_TEST_LOOP_c_c (cexp, cexp_test_data, );
   END_COMPLEX;
 }
@@ -7552,7 +7570,7 @@ static const struct test_if_f_data jn_test_data[] =
 static void
 jn_test (void)
 {
-  START (jn, 0);
+  START (jn,, 0);
   RUN_TEST_LOOP_if_f (jn, jn_test_data, );
   END;
 }
@@ -9378,7 +9396,7 @@ static const struct test_f_f_data tgamma_test_data[] =
 static void
 tgamma_test (void)
 {
-  START (tgamma, 0);
+  START (tgamma,, 0);
   RUN_TEST_LOOP_f_f (tgamma, tgamma_test_data, );
   END;
 }
@@ -9828,6 +9846,8 @@ main (int argc, char **argv)
   initialize ();
   printf (TEST_MSG);

+  INIT_ARCH_EXT
+
   check_ulp ();

   /* Keep the tests a wee bit ordered (according to ISO C99).  */
diff --git a/sysdeps/x86_64/fpu/math-tests.h b/sysdeps/x86_64/fpu/math-tests.h
new file mode 100644
index 0000000..466b97b
--- /dev/null
+++ b/sysdeps/x86_64/fpu/math-tests.h
@@ -0,0 +1,34 @@
+/* Configuration for math tests.  x86_64 version.
+   Copyright (C) 2013-2014 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef REQUIRE_AVX2
+# include <init-arch.h>
+
+  static int avx2_usable; /* Set to 1 if AVX2 supported */
+
+# define INIT_ARCH_EXT \
+    __init_cpu_features (); \
+    avx2_usable = __cpu_features.feature[index_AVX2_Usable] \
+ & bit_AVX2_Usable;
+
+# define CHECK_ARCH_EXT \
+  if (!avx2_usable) return;
+
+#endif
+
+#include_next <math-tests.h>


Attached the same.


--
WBR,
Andrew

Attachment: libmvec_2_of_N.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]