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]

Re: [RFC] How to add vector math functions to Glibc


Hi Joseph,

>> > 1. Should functions go in libm or a separate libmvec library?
>>
>> If integrate new functions with libm it will be easier for developers
>> to employ vectorization and should improve acceptance.
>> Libmvec case affects compiler options and it seems new header need to
>> be included instead of math.h, or is it OK include it in math.h?
>> But libmvec could be better from the side of optional build (mentioned
>> later in 2.) in case of addition most modern implementations.
>
> There is also the option of installing libm.so as a linker script that
> refers to libmvec inside AS_NEEDED - libc.so is already a linker script
> after all.  That way, libmvec would automatically be linked into programs
> that need it (preserving compatibility with the POSIX rules about what
> library names need specifying to get what functions), without restricting
> the tools that can build glibc if vector extensions are added for which
> tool support is recent, but building libmvec is optional.

is it OK to have following changes in GLIBC build:

diff --git a/Makeconfig b/Makeconfig
index cef0f06..5173414 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1060,11 +1060,11 @@ endif
 # These are the subdirectories containing the library source.  The order
 # is more or less arbitrary.  The sorting step will take care of the
 # dependencies.
-all-subdirs = csu assert ctype locale intl catgets math setjmp signal    \
-      stdlib stdio-common libio malloc string wcsmbs time dirent    \
-      grp pwd posix io termios resource misc socket sysvipc gmon    \
-      gnulib iconv iconvdata wctype manual shadow gshadow po argp   \
-      crypt localedata timezone rt conform debug    \
+all-subdirs = csu assert ctype locale intl catgets math mathvect setjmp    \
+      signal stdlib stdio-common libio malloc string wcsmbs time    \
+      dirent grp pwd posix io termios resource misc socket sysvipc  \
+      gmon gnulib iconv iconvdata wctype manual shadow gshadow po   \
+      argp crypt localedata timezone rt conform debug    \
       $(add-on-subdirs) dlfcn elf

 ifndef avoid-generated
diff --git a/Makerules b/Makerules
index 6b30e8c..058e748 100644
--- a/Makerules
+++ b/Makerules
@@ -965,7 +965,22 @@ $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
       ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \
  ) > $@.new
  mv -f $@.new $@
-
+else
+ifeq ($(subdir),mathvect)
+# We need to install libm.so as linker script
+# for more comfortable use of libmvect library.
+subdir_install: $(inst_libdir)/libm.so
+$(inst_libdir)/libm.so: $(common-objpfx)format.lds \
+ $(common-objpfx)math/libm.so$(libm.so-version) \
+ $(common-objpfx)mathvect/libmvect.so$(libmvect.so-version) \
+ $(+force)
+ (echo '/* GNU ld script */';\
+ cat $<; \
+ echo 'GROUP ( $(slibdir)/libm.so$(libm.so-version) ' \
+      'AS_NEEDED ( $(slibdir)/libmvect.so$(libmvect.so-version) ) )' \
+ ) > $@.new
+ mv -f $@.new $@
+endif
 endif

 else
diff --git a/shlib-versions b/shlib-versions
index 40469bd..8fddc04 100644
--- a/shlib-versions
+++ b/shlib-versions
@@ -35,6 +35,12 @@ sh.*-.*-linux.* libm=6 GLIBC_2.2
 .*-.*-linux.* libm=6
 .*-.*-gnu-gnu.* libm=6

+# We provide libmvect.so.1 starting from GLIBC_2.21 symbol set.
+sparc64.*-.*-linux.* libmvect=1 GLIBC_2.21
+sh.*-.*-linux.* libmvect=1 GLIBC_2.21
+.*-.*-linux.* libmvect=1 GLIBC_2.21
+.*-.*-gnu-gnu.* libmvect=1 GLIBC_2.21
+
 # We provide libc.so.6 for Linux kernel versions 2.0 and later.
 sh.*-.*-linux.* libc=6 GLIBC_2.2
 sparc64.*-.*-linux.* libc=6 GLIBC_2.2
diff --git a/sysdeps/x86_64/fpu/Makefile b/sysdeps/x86_64/fpu/Makefile
index 1cb3ec5..520ed09 100644
--- a/sysdeps/x86_64/fpu/Makefile
+++ b/sysdeps/x86_64/fpu/Makefile
@@ -1,3 +1,3 @@
-ifeq ($(subdir),math)
-libm-support += svml_d_cos4_core svml_d_cos_data
+ifeq ($(subdir),mathvect)
+libmvect-support += svml_d_cos4_core svml_d_cos_data
 endif
diff --git a/sysdeps/x86_64/fpu/Versions b/sysdeps/x86_64/fpu/Versions
index 1717a7a..1fd0921 100644
--- a/sysdeps/x86_64/fpu/Versions
+++ b/sysdeps/x86_64/fpu/Versions
@@ -1,4 +1,4 @@
-libm {
+libmvect {
diff --git a/sysdeps/x86_64/fpu/svml_d_cos4_core.S
b/sysdeps/x86_64/fpu/svml_d_cos4_core.S
index 8334875..d7fd42f 100644
--- a/sysdeps/x86_64/fpu/svml_d_cos4_core.S
+++ b/sysdeps/x86_64/fpu/svml_d_cos4_core.S
@@ -167,7 +168,7 @@ _LBL_1_10:
         vmovsd    328(%rsp,%r15), %xmm0
         vzeroupper

-        call      __cos@PLT
+        call      cos@PLT

         vmovsd    %xmm0, 392(%rsp,%r15)
         jmp       _LBL_1_8
@@ -178,8 +179,9 @@ _LBL_1_12:
         vmovsd    320(%rsp,%r15), %xmm0
         vzeroupper

-        call      __cos@PLT
+        call      cos@PLT

         vmovsd    %xmm0, 384(%rsp,%r15)
         jmp       _LBL_1_7


WBR,
Andrew


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