<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Feb 14, 2021, at 10:09 AM, Pierre Jolivet <<a href="mailto:pierre@joliv.et" class="">pierre@joliv.et</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class=""><br class="Apple-interchange-newline">
<br class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<blockquote type="cite" class="" style="font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div class="">On 14 Feb 2021, at 4:52 PM, Zhang, Hong via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class=""><br class="Apple-interchange-newline">
<br class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div class="">On Feb 14, 2021, at 5:05 AM, Patrick Sanan <<a href="mailto:patrick.sanan@gmail.com" class="">patrick.sanan@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br class="Apple-interchange-newline">
<br class="">
<blockquote type="cite" class="">
<div class="">Am 14.02.2021 um 07:22 schrieb Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>>:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class=""><br class="">
<br class="">
<blockquote type="cite" class="">On Feb 13, 2021, at 11:58 PM, Jed Brown <<a href="mailto:jed@jedbrown.org" class="">jed@jedbrown.org</a>> wrote:<br class="">
<br class="">
I usually configure --with-debugging=0 COPTFLAGS='-O2 -march=native' or similar. There's a tension here between optimizing aggressively for the current machine and making binaries that work on other machines. Most configure systems default to making somewhat
portable binaries, so that's a principal of least surprise. (Though you're no novice and seem to have been surprised anyway.)<br class="">
<br class="">
I'd kinda prefer if we recommended making portable binaries that run-time detected when to use newer instructions where it matters.<br class="">
</blockquote>
<br class="">
How do we do this? What can we put in configure to do this.<br class="">
<br class="">
Yes, I never paid attention to the AVX nonsense over the years and never realized that Intel and Gnu (and hence PETSc) both compile by default for machines I used in my twenties.<br class="">
<br class="">
Expecting PETSc users to automatically add -march= is not realistic. I will try to rig something up in configure where if the user does not provide march something reasonable is selected.<span class="Apple-converted-space"> </span><br class="">
</div>
</div>
</blockquote>
A softer (yet trivial to implement) option might also be to just alert the user that these flags exist in the usual message about using default optimization flags. Something like this would encourage users to do what Jed is doing:</div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
***** WARNING: Using default optimization C flags -g -O3</div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
You might consider manually setting optimal optimization flags for your system with</div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
COPTFLAGS="optimization flags" see config/examples/arch-*-opt.py for examples. </div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<b class="">In particular, you may want to supply specific flags (e.g. -march=native) </b></div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<b class="">to take advantage of higher-performance instructions.</b></div>
</div>
</blockquote>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
I think this is a reasonable thing to do.</div>
</div>
</blockquote>
<div style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br class="">
</div>
<div style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
This is a reasonable message to print on the screen, but I don’t think this is a reasonable flag to impose by default.</div>
<div style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
You are basically asking all package managers to add a new flag (-march=generic) which was previously not needed.</div>
<div style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<br class="">
</div>
<div style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
I’m crossing my fingers Jed has a clever way of "making portable binaries that run-time detected when to use newer instructions where it matters”, because -march=native by default is just not practical when deploying software.</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>This is doable using Intel compilers with -ax options at the cost of generating fat binaries. For example,</div>
<div><br class="">
</div>
<span class="">-axCORE-AVX512,MIC-AVX512</span></div>
<span class="">-axAVX,CORE-AVX2</span><span class="">-axarch<br class="">
<br class="">
Hong</span>
<div class=""><span class=""><br class="">
<blockquote type="cite" class=""><br class="">
Thanks,<br class="">
Pierre<br class="">
<br class="">
<blockquote type="cite" class="" style="font-family: Verdana; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">
We should also inform users that tuning -march options may enable vectorization instructions such as SSE(3 and above) and AVX but generate nonportable binaries.<br class="">
<br class="">
If we add -march=native to the configure test, we will need to run executables to make sure the specified instruction sets are supported by the CPU where the code is running. For PETSc, the executables should cover all the intrinsics we use in the code ideally;
otherwise, users will get run-time errors when there is a mismatch in vectorization instructions between compiler support and CPU support.<br class="">
<br class="">
Hong<br class="">
<br class="">
<blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br class="">
None of the examples in config/examples actually use -march=native, and this is a very common thing to do that, as you point out, isn't obvious until you know you have to do it, so it seems to be worth the screen space.<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<blockquote type="cite" class=""><br class="">
Barry<br class="">
<br class="">
<br class="">
<blockquote type="cite" class=""><br class="">
Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> writes:<br class="">
<br class="">
<blockquote type="cite" class="">Shouldn't configure be setting something appropriate for this automatically? This is nuts, it means when users do a ./configure make unless they pass weird arguments they sure as heck don't know about to the compiler they won't
get any of the glory that they expect and that has been in almost all Intel systems forever.<br class="">
<br class="">
Barry<br class="">
<br class="">
I run ./configure --with-debugging=0 and I get none of the stuff added by Intel for 15+ years?<br class="">
<br class="">
<br class="">
<blockquote type="cite" class="">On Feb 13, 2021, at 11:26 PM, Jed Brown <jed@jedbrown.org> wrote:<br class="">
<br class="">
Use -march=native or similar. The default target is basic x86_64, which has only SSE2.<br class="">
<br class="">
Barry Smith <bsmith@petsc.dev> writes:<br class="">
<br class="">
<blockquote type="cite" class="">PETSc source has code like defined(__AVX2__) in the source but it does not seem to be able to find any of these macros (icc or gcc) on the petsc-02 system<br class="">
<br class="">
Are these macros supposed to be defined? How does on get them to be defined? Why are they not define? What am I doing wrong?<br class="">
<br class="">
Keep reading<br class="">
<br class="">
$ lscpu <br class="">
Architecture: x86_64<br class="">
CPU op-mode(s): 32-bit, 64-bit<br class="">
Byte Order: Little Endian<br class="">
CPU(s): 64<br class="">
On-line CPU(s) list: 0-63<br class="">
Thread(s) per core: 2<br class="">
Core(s) per socket: 16<br class="">
Socket(s): 2<br class="">
NUMA node(s): 2<br class="">
Vendor ID: GenuineIntel<br class="">
CPU family: 6<br class="">
Model: 85<br class="">
Model name: Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz<br class="">
Stepping: 7<br class="">
CPU MHz: 1000.603<br class="">
CPU max MHz: 2301.0000<br class="">
CPU min MHz: 1000.0000<br class="">
BogoMIPS: 4600.00<br class="">
Virtualization: VT-x<br class="">
L1d cache: 32K<br class="">
L1i cache: 32K<br class="">
L2 cache: 1024K<br class="">
L3 cache: 22528K<br class="">
NUMA node0 CPU(s): 0-15,32-47<br class="">
NUMA node1 CPU(s): 16-31,48-63<br class="">
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 art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf
pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba
ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc
cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities<br class="">
<br class="">
Test program <br class="">
<br class="">
#if defined(__FMA__)<br class="">
#error FMA<br class="">
#endif<br class="">
<br class="">
#if defined(__AVX512F__)<br class="">
#error AVX512F<br class="">
#endif<br class="">
<br class="">
#if defined(__AVX2__)<br class="">
#error AVX2<br class="">
#endif<br class="">
<br class="">
<br class="">
icc mytest.c<br class="">
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':<br class="">
(.text+0x20): undefined reference to `main'<br class="">
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<br class="">
</span></div>
</body>
</html>