From patchwork Wed Sep 24 19:45:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Senkevich X-Patchwork-Id: 2964 Received: (qmail 19217 invoked by alias); 24 Sep 2014 19:46:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 19207 invoked by uid 89); 24 Sep 2014 19:46:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f173.google.com X-Received: by 10.140.19.36 with SMTP id 33mr13088565qgg.32.1411587982087; Wed, 24 Sep 2014 12:46:22 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Andrew Senkevich Date: Wed, 24 Sep 2014 23:45:52 +0400 Message-ID: Subject: Re: [RFC] How to add vector math functions to Glibc To: "Joseph S. Myers" Cc: libc-alpha 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: WBR, Andrew 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