Re: 答复: Build and test memory functions in glibc-2.25(Internet mail)

H.J. Lu hjl.tools@gmail.com
Tue Mar 28 14:43:00 GMT 2017


On Mon, Mar 27, 2017 at 8:31 PM, wentingli(李文亭) <wentingli@tencent.com> wrote:
> Hongjiu,
>
>
>
> Really thanks for your reply.
>
>
>
> I wrote a test program(memcpy and memset a chunk of memory) and ran under
> glibc-2.25. According to the debugging output in gdb below, it seems that it
> always calls the vec-unaligned-erms versions of memcpy(memmove) and
> __memset_sse2_unaligned_erms no matter how much memory being processed.
>

Since your CPU is based on Ivy Bridge, it uses __memset_sse2_unaligned_erms.

>
> This seems odd to me in that I have a relatively new CPU for my dev machine.
> Is it expected? Is it possible to trigger the avx
> version(avx512-no-vzeroupper/avx512-unaligned-erms) of memory functions with
> a particular size of chunk of memory?

You need Skylake server CPU to use AVX512.

H.J.
>
>
> -----------------------------------------------------------------------------
>
> Gdb output:
> Breakpoint 2, test () at thirdparty/glibc/test/main.cc:12
>
> 12          memcpy(p, s.c_str(), s.length());
>
> (gdb) s
>
> memcpy@GLIBC_2.2.5 () at
> ../sysdeps/x86_64/multiarch/../multiarch/memmove-vec-unaligned-erms.S:131
>
> 131             movq    %rdi, %rax
>
> (gdb) bt
>
> #0  memcpy@GLIBC_2.2.5 () at
> ../sysdeps/x86_64/multiarch/../multiarch/memmove-vec-unaligned-erms.S:131
>
> #1  0x000000000040b496 in test () at thirdparty/glibc/test/main.cc:12
>
> #2  0x000000000040b639 in main () at thirdparty/glibc/test/main.cc:25
>
> (gdb) n
>
> 133             cmpq    $VEC_SIZE, %rdx
>
> (gdb) fin
>
> Run till exit from #0  memcpy@GLIBC_2.2.5 () at
> ../sysdeps/x86_64/multiarch/../multiarch/memmove-vec-unaligned-erms.S:133
>
> test () at thirdparty/glibc/test/main.cc:13
>
> 13          memset(p, 0, count);
>
> (gdb) s
>
> __memset_sse2_unaligned_erms () at
> ../sysdeps/x86_64/multiarch/../multiarch/memset-vec-unaligned-erms.S:135
>
> 135             VDUP_TO_VEC0_AND_SET_RETURN (%esi, %rdi)
>
> (gdb) bt
>
> #0  __memset_sse2_unaligned_erms () at
> ../sysdeps/x86_64/multiarch/../multiarch/memset-vec-unaligned-erms.S:135
>
> #1  0x000000000040b4a5 in test () at thirdparty/glibc/test/main.cc:13
>
> #2  0x000000000040b639 in main () at thirdparty/glibc/test/main.cc:25
>
>
>
> /proc/cpuinfo(24 cores):
> processor       : 23
>
> vendor_id       : GenuineIntel
>
> cpu family      : 6
>
> model           : 62
>
> model name      : Intel(R) Xeon(R) CPU E5-2420 v2 @ 2.20GHz
>
> stepping        : 4
>
> cpu MHz         : 2201.000
>
> cache size      : 15360 KB
>
> physical id     : 1
>
> siblings        : 12
>
> core id         : 5
>
> cpu cores       : 6
>
> apicid          : 43
>
> initial apicid  : 43
>
> fpu             : yes
>
> fpu_exception   : yes
>
> cpuid level     : 13
>
> wp              : yes
>
> flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
> cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx
> pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology
> nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2
> ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 x2apic popcnt aes xsave avx lahf_lm
> ida arat tpr_shadow vnmi flexpriority ept vpid
>
> bogomips        : 4389.36
>
> clflush size    : 64
>
> cache_alignment : 64
>
> address sizes   : 46 bits physical, 48 bits virtual
>
>
>
> wentingli(李文亭)
>
>
>
>
>
> -----邮件原件-----
> 发件人: Lu, Hongjiu [mailto:hongjiu.lu@intel.com]
> 发送时间: 2017年3月28日 0:01
> 收件人: wentingli(李文亭); libc-help@sourceware.org
> 抄送: hjl.tools@gmail.com
> 主题: RE: Build and test memory functions in glibc-2.25(Internet mail)
>
>
>
> Hi hongjiu and glibc developers,
>
>
>
> I was investigating whether a few memory functions(memcpy, memset, memmove)
> with various versions(sse4, ssse3, avx2, avx512) in glibc-2.25 could have
> performance gain for our server programs in Linux(glibc 2.12). I put the
> detailed question on
> stackoverflow(http://stackoverflow.com/questions/42999511/port-glibc-2-25-and-test-memory-functions).
> In short, my questions are as follows:
>
>
>
> 1. I built glibc-2.25 on my dev machine and run my application under newly
> built glibc. Then did the glibc select the most suitable version of memory
> functions automatically for me according to the cpu/os/memory?
>
>
>
> That is correct.
>
>
>
> H.J.
>
> ----
>
> 2. If #1’s answer is no, do I need to tweak a few options for
> ./configuration and make to achieve that?
>
>
>
> 3. If #2 is impossible, I was wondering if I need to dispatch the
> memcpy/memset/memmove calls to the appropriate version of functions with
> __attribute__((ifunc))( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40528 )
> manually according to the corresponding boolean test of the cpu(Built-in
> Function: int __builtin_cpu_supports (const char *feature))?
>
>
>
> I reviewed changelog and the related links above and put hongjiu on the list
> explicitly. Please help take a look and I’m looking forward to your replies.
>
>
>
> Thanks in advance.
>
>
>
> ________________________________________
>
> wentingli(李文亭)
>
>
>
>



-- 
H.J.



More information about the Libc-help mailing list