Patchwork x86_64: Utilize vector math functions w/o -fopenmp

login
register
mail settings
Submitter Andrew Senkevich
Date Dec. 4, 2015, 2:59 p.m.
Message ID <CAMXFM3tOcznwyGywfCLf1baLW6rLyUdnX1SZe6-AGh41Wb0mqA@mail.gmail.com>
Download mbox | patch
Permalink /patch/9888/
State New
Headers show

Comments

Andrew Senkevich - Dec. 4, 2015, 2:59 p.m.
Hi,

this patch adds GCC 6.* __attribute__((__simd__)) to declaration of
vector math functions to utilize them w/o -fopenmp.

Libmvec wike page will be updated appropriately with example of usage
(w/o -fopenmp will be needed -ftree-loop-vectorize).

2015-12-04  Andrew Senkevich  <andrew.senkevich@intel.com>

        * sysdeps/x86/fpu/bits/math-vector.h: Add __attribute__((__simd__)) to
        vector functions declaration.


Is it Ok for trunk?


--
WBR,
Andrew
Joseph Myers - Dec. 4, 2015, 3:46 p.m.
On Fri, 4 Dec 2015, Andrew Senkevich wrote:

> +# elif __GNUC_PREREQ (6,0)
> +/* W/o OpenMP use GCC 6.*  __attribute__((__simd__)).  */
> +#  define __ATTR_SIMD_x86_64 __attribute__((__simd__("notinbranch")))
> +#  undef __DECL_SIMD_cos
> +#  define __DECL_SIMD_cos __ATTR_SIMD_x86_64

Why do you need to duplicate the list of functions?  It would seem better 
to define __DECL_SIMD_x86_64 with two different definitions depending on 
the macros predefined by the compiler, then define all the 
__DECL_SIMD_<func> macros if __DECL_SIMD_x86_64 has been defined.

# if defined _OPENMP && _OPENMP >= 201307
#  define __DECL_SIMD_x86_64 ...
# elif __GNUC_PREREQ (6,0)
#  define __DECL_SIMD_x86_64 ...
# endif
# ifdef __DECL_SIMD_x86_64
#  undef __DECL_SIMD_cos
#  define __DECL_SIMD_cos __DECL_SIMD_x86_64
etc.

Patch

diff --git a/sysdeps/x86/fpu/bits/math-vector.h
b/sysdeps/x86/fpu/bits/math-vector.h
index f3bfb86..155d326 100644
--- a/sysdeps/x86/fpu/bits/math-vector.h
+++ b/sysdeps/x86/fpu/bits/math-vector.h
@@ -53,5 +53,32 @@ 
 #  undef __DECL_SIMD_powf
 #  define __DECL_SIMD_powf __DECL_SIMD_x86_64

+# elif __GNUC_PREREQ (6,0)
+/* W/o OpenMP use GCC 6.*  __attribute__((__simd__)).  */
+#  define __ATTR_SIMD_x86_64 __attribute__((__simd__("notinbranch")))
+#  undef __DECL_SIMD_cos
+#  define __DECL_SIMD_cos __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_cosf
+#  define __DECL_SIMD_cosf __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_sin
+#  define __DECL_SIMD_sin __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_sinf
+#  define __DECL_SIMD_sinf __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_sincos
+#  define __DECL_SIMD_sincos __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_sincosf
+#  define __DECL_SIMD_sincosf __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_log
+#  define __DECL_SIMD_log __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_logf
+#  define __DECL_SIMD_logf __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_exp
+#  define __DECL_SIMD_exp __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_expf
+#  define __DECL_SIMD_expf __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_pow
+#  define __DECL_SIMD_pow __ATTR_SIMD_x86_64
+#  undef __DECL_SIMD_powf
+#  define __DECL_SIMD_powf __ATTR_SIMD_x86_64
 # endif
 #endif