Topic: cpu dispatch mechanisms
Author: aambitny@gmail.com
Date: Tue, 6 Jan 2015 11:02:38 -0800 (PST)
Raw View
------=_Part_8_1773725872.1420570958344
Content-Type: multipart/alternative;
boundary="----=_Part_9_1790226697.1420570958344"
------=_Part_9_1790226697.1420570958344
Content-Type: text/plain; charset=UTF-8
Motivation:
One of the biggest performance problem with most of C++ programs is that
they do not make use of the newest CPU features, because they are compiled
for very old processors. Because of that, C++ programs may even perform
worse than theoretically heavier languages like Java or .NET ones, because
they use *just-in-time* compilation method.
However, GNU (since 4.8) [2] and Intel [3] compilers overcame that problem
by implementing extensions to support the same function to be defined more
than once (each time for CPU with other features). For example, it is
possible to implement the same function 3 times: one implementation using
AVX extensions, one using SSE2 extensions, and the generic one. Thanks to
such approach, it is possible to compile library/application once, and
easily make use of newer CPU features without breaking the compatibility
with older ones.
Proposal:
This would be beneficial to have such feature in each compiler with
standardized way of implementing few versions of function. Currently, GCC
and Intel are the only implementations known to me.
GCC example:
__attribute__ ((target ("default")))
int foo ()
{
// The default version of foo.
return 0;
}
__attribute__ ((target ("sse4.2")))
int foo ()
{
// foo version for SSE4.2
return 1;
}
__attribute__ ((target ("arch=atom")))
int foo ()
{
// foo version for the Intel ATOM processor
return 2;
}
Intel example:
// need to create specific function versions for the following processors:
__declspec(cpu_dispatch(generic, core_2_duo_ssse3, core_i7_sse4_2, core_2nd_gen_avx))
// stub that will call the appropriate specific function version
void dispatch_func() {};
__declspec(cpu_specific(generic))
void dispatch_func() {
printf("/nCode for non-Intel processors and generic Intel processors goes here/n");
}
__declspec(cpu_specific(core_2_duo_ssse3))
void dispatch_func() {
printf("/nCode for Intel Core 2 Duo processors with support for SSSE3 goes here/n");
}
__declspec(cpu_specific(core_i7_sse4_2))
void dispatch_func() {
printf("/nCode for Intel Core processors with support for SSE4.2 goes here/n");
}
__declspec(cpu_specific(core_2nd_gen_avx))
void dispatch_func() {
printf("/nCode for 2nd generation Intel Core processors goes here/n");
}
int main() {
dispatch_func();
printf("Return from dispatch_func/n");
return 0;
}
What is interesting, is that both techniques looks similar, and C++11
already defined standard way of defining attributes.
[1] http://www.agner.org/optimize/optimizing_cpp.pdf
[2]
https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Function-Multiversioning.html
[3]
https://software.intel.com/en-us/articles/how-to-manually-target-2nd-generation-intel-core-processors-with-support-for-intel-avx
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_9_1790226697.1420570958344
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Motivation:<br><br>One of the biggest performance problem =
with most of C++ programs is that they do not make use of the newest CPU fe=
atures, because they are compiled for very old processors. Because of that,=
C++ programs may even perform worse than theoretically heavier languages l=
ike Java or .NET ones, because they use <span class=3D"st"><em>just-in-time=
</em> compilation method</span>.<br><br>However, GNU (since 4.8) [2] and In=
tel [3] compilers overcame that problem by implementing extensions to suppo=
rt the same function to be defined more than once (each time for CPU with o=
ther features). For example, it is possible to implement the same function =
3 times: one implementation using AVX extensions, one using SSE2 extensions=
, and the generic one. Thanks to such approach, it is possible to compile l=
ibrary/application once, and easily make use of newer CPU features without =
breaking the compatibility with older ones.<br><br>Proposal:<br><br>This wo=
uld be beneficial to have such feature in each compiler with standardized w=
ay of implementing few versions of function. Currently, GCC and Intel are t=
he only implementations known to me.<br><br>GCC example:<br><pre class=3D"s=
mallexample"><div class=3D"prettyprint" style=3D"background-color: rgb(250,=
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-w=
idth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><pre class=3D"smallexample"><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> __attribute__ </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">((</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">target </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
080;" class=3D"styled-by-prettify">"default"</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">)))</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> foo </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">// The default version of fo=
o.</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; <br> __attribute__ </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">((</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">target </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #080;" class=3D"s=
tyled-by-prettify">"sse4.2"</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)))</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> foo </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br> </span><span style=3D"color: #800;"=
class=3D"styled-by-prettify">// foo version for SSE4.2</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> &nb=
sp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">return<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br> <br>&nbs=
p; __attribute__ </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">((</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">target </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
"arch=3Datom"</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)))</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> foo </span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; </span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">// foo version for the Intel ATOM processor</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br> </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">}</span></pre></div></=
code></div><br>Intel example:<br><div class=3D"prettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><pre><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">// need to create specific function versions for =
the following processors: </span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>__declspec</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">cpu_dispatch</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">generic</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
core_2_duo_ssse3</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> c=
ore_i7_sse4_2</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> core_=
2nd_gen_avx</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>))</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">// stub that =
will call the appropriate specific function version </span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> dispatch_func</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{};</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> <br> <br>__declspec</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">cpu_specific</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">generic</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">))</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> <br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> dispatch_func</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> <br>printf</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #080;" class=3D"styled-by-prettify">"/nCode for non-Intel p=
rocessors and generic Intel processors goes here/n"</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> <br></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> <br> <br>__declspec</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">cpu_specific</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">core_2_duo_ssse3</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">))</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> <br></span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> dispatch_func</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> <br>printf</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
"/nCode for Intel Core 2 Duo processors with support for SSSE3 goes here/n"=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> <br> <br>__de=
clspec</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">cpu_specific<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">core_i7_sse4_2</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">))</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> dispatch_func</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> <br>printf</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">"/nCode for Intel Core processors with support for =
SSE4.2 goes here/n"</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> <br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
<br> <br>__declspec</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">cpu_specific</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
ore_2nd_gen_avx</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">))</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &n=
bsp;<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">vo=
id</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> dispatc=
h_func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> <br>printf</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">"/nCode for 2nd generation I=
ntel Core processors goes here/n"</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> <br></span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> <br> <br></span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> <br>dispatc=
h_func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=
printf</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #080;" class=3D"styled-by-prettify">"Return from =
dispatch_func/n"</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &=
nbsp;<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">r=
eturn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> <br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">}</span></pre></div></code></di=
v><br>What is interesting, is that both techniques looks similar, and C++11=
already defined standard way of defining attributes.<br><br>[1] http://www=
..agner.org/optimize/optimizing_cpp.pdf<br>[2] https://gcc.gnu.org/onlinedoc=
s/gcc-4.9.0/gcc/Function-Multiversioning.html<br>[3] https://software.intel=
..com/en-us/articles/how-to-manually-target-2nd-generation-intel-core-proces=
sors-with-support-for-intel-avx<br></pre></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_9_1790226697.1420570958344--
------=_Part_8_1773725872.1420570958344--
.
Author: David Krauss <potswa@gmail.com>
Date: Wed, 7 Jan 2015 07:01:19 +0800
Raw View
--Apple-Mail=_EC724C12-C048-443A-B746-E48092B76A82
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9301=E2=80=9307, at 3:02 AM, aambitny@gmail.com wrote:
>=20
> What is interesting, is that both techniques looks similar, and C++11 alr=
eady defined standard way of defining attributes.
Unfortunately, standard attributes are restricted from being essential to t=
he program=E2=80=99s meaning. A bracket-delimited attribute must allow the =
implementation to ignore it or the user to delete it. Deleting the attribut=
es from your example leads to multiple definition errors.
However, Concepts would allow this to be done nicely, as long as the condit=
ion is not required to be template dependent. I=E2=80=99m not sure whether =
that=E2=80=99s the case or not.
void dispatch_func() requires( ! __ssse3 ) { =20
printf("/nCode for non-Intel processors and generic Intel processors goes h=
ere/n"); =20
}
void dispatch_func() requires( __ssse3 && ! __sse4_2 ) { =20
printf("/nCode for Intel Core 2 Duo processors with support for SSSE3 goes =
here/n"); =20
} =20
=20
void dispatch_func() requires( __sse4_2 && ! __avx ) { =20
printf("/nCode for Intel Core processors with support for SSE4.2 goes here/=
n"); =20
} =20
=20
void dispatch_func() requires( __avx ) { =20
printf("/nCode for 2nd generation Intel Core processors goes here/n"); =20
} =20
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_EC724C12-C048-443A-B746-E48092B76A82
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9301=
=E2=80=9307, at 3:02 AM, <a href=3D"mailto:aambitny@gmail.com" class=3D"">a=
ambitny@gmail.com</a> wrote:</div><br class=3D"Apple-interchange-newline"><=
div class=3D""><pre class=3D"smallexample" style=3D"font-size: 12px; font-s=
tyle: normal; font-variant: normal; font-weight: normal; letter-spacing: no=
rmal; line-height: normal; orphans: auto; text-align: start; text-indent: 0=
px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-str=
oke-width: 0px;">What is interesting, is that both techniques looks similar=
, and C++11 already defined standard way of defining attributes.<br class=
=3D""></pre></div></blockquote></div>Unfortunately, standard attributes are=
restricted from being essential to the program=E2=80=99s meaning. A bracke=
t-delimited attribute must allow the implementation to ignore it or the use=
r to delete it. Deleting the attributes from your example leads to multiple=
definition errors.<div class=3D""><br class=3D""></div><div class=3D"">How=
ever, Concepts would allow this to be done nicely, as long as the condition=
is not required to be template dependent. I=E2=80=99m not sure whether tha=
t=E2=80=99s the case or not.</div><div class=3D""><br class=3D""></div><div=
class=3D""><pre class=3D""><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 136);">void</span><span class=3D"styled-by-prettify"> dispatc=
h_func</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 10=
2, 0);">()</span><span class=3D"styled-by-prettify"> requires( ! __ssse3 ) =
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">{</span><span class=3D"styled-by-prettify"> <br class=3D"">printf</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=
(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 136, 0);"=
>"/nCode for non-Intel processors and generic Intel processors goes here/n"=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">);</span><span class=3D"styled-by-prettify"> <br class=3D""></span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</sp=
an><span class=3D"styled-by-prettify"><br class=3D""></span></pre><pre clas=
s=3D""><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">=
void</span><span class=3D"styled-by-prettify"> dispatch_func</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</span><spa=
n class=3D"styled-by-prettify"> requires( __ssse3 && ! __sse4_2 ) <=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>{</span><span class=3D"styled-by-prettify"> <br class=3D"">printf</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 136, 0);">=
"/nCode for Intel Core 2 Duo processors with support for SSSE3 goes here/n"=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">);</span><span class=3D"styled-by-prettify"> <br class=3D""></span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</sp=
an><span class=3D"styled-by-prettify"> <br class=3D""> <br clas=
s=3D""></span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
136);">void</span><span class=3D"styled-by-prettify"> dispatch_func</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</sp=
an><span class=3D"styled-by-prettify"> requires( __sse4_2 && ! __av=
x ) </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102,=
0);">{</span><span class=3D"styled-by-prettify"> <br class=3D"">prin=
tf</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0=
);">(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 136, =
0);">"/nCode for Intel Core processors with support for SSE4.2 goes here/n"=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">);</span><span class=3D"styled-by-prettify"> <br class=3D""></span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</sp=
an><span class=3D"styled-by-prettify"> <br class=3D""> <br clas=
s=3D""></span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
136);">void</span><span class=3D"styled-by-prettify"> dispatch_func</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</sp=
an><span class=3D"styled-by-prettify"> requires( __avx ) </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span cl=
ass=3D"styled-by-prettify"> <br class=3D"">printf</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 136, 0);">"/nCode for 2nd=
generation Intel Core processors goes here/n"</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(102, 102, 0);">);</span><span class=3D"sty=
led-by-prettify"> <br class=3D""></span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(102, 102, 0);">}</span><span class=3D"styled-by-p=
rettify"> <br class=3D""><br class=3D""></span></pre></div></body></h=
tml>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_EC724C12-C048-443A-B746-E48092B76A82--
.
Author: gmisocpp@gmail.com
Date: Tue, 6 Jan 2015 15:37:30 -0800 (PST)
Raw View
------=_Part_1878_536570803.1420587450365
Content-Type: multipart/alternative;
boundary="----=_Part_1879_861652268.1420587450365"
------=_Part_1879_861652268.1420587450365
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, January 7, 2015 12:01:28 PM UTC+13, David Krauss wrote:
>
>
> On 2015=E2=80=9301=E2=80=9307, at 3:02 AM, aamb...@gmail.com <javascript:=
> wrote:
>
> What is interesting, is that both techniques looks similar, and C++11 alr=
eady defined standard way of defining attributes.
>
> Unfortunately, standard attributes are restricted from being essential to=
=20
> the program=E2=80=99s meaning. A bracket-delimited attribute must allow t=
he=20
> implementation to ignore it or the user to delete it. Deleting the=20
> attributes from your example leads to multiple definition errors.
>
> However, Concepts would allow this to be done nicely, as long as the=20
> condition is not required to be template dependent. I=E2=80=99m not sure =
whether=20
> that=E2=80=99s the case or not.
>
> void dispatch_func() requires( ! __ssse3 ) { =20
> printf("/nCode for non-Intel processors and generic Intel processors goes=
here/n"); =20
> }
>
> void dispatch_func() requires( __ssse3 && ! __sse4_2 ) { =20
> printf("/nCode for Intel Core 2 Duo processors with support for SSSE3 goe=
s here/n"); =20
> } =20
> =20
> void dispatch_func() requires( __sse4_2 && ! __avx ) { =20
> printf("/nCode for Intel Core processors with support for SSE4.2 goes her=
e/n"); =20
> } =20
> =20
> void dispatch_func() requires( __avx ) { =20
> printf("/nCode for 2nd generation Intel Core processors goes here/n"); =
=20
> } =20
>
>
How would anyone keep up with Standardizing the identifiers in any=20
meaningful way for this code to be Standard?
New hardware comes out daily and if you want to support that you need an=20
identifier that won't be in the current Standard.
By the time it is Standard, maybe the compiler itself already understands=
=20
the cpu anyway and can just automatically use the appropriate instructions=
=20
anyway.
I suspect this isn't something the Committee can facilitate realistically=
=20
or do you think I'm likely wrong in that assumption?
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_1879_861652268.1420587450365
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, January 7, 2015 12:01:28 PM UTC+13, =
David Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0=
px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bor=
der-left-width: 1px; border-left-style: solid;"><div style=3D"-ms-word-wrap=
: break-word;"><br><div><blockquote type=3D"cite"><div>On 2015=E2=80=9301=
=E2=80=9307, at 3:02 AM, <a onmousedown=3D"this.href=3D'javascript:';return=
true;" onclick=3D"this.href=3D'javascript:';return true;" href=3D"javascri=
pt:" target=3D"_blank" gdf-obfuscated-mailto=3D"HpPGnP2Q0k4J">aamb...@gmail=
..com</a> wrote:</div><br><div><pre style=3D"text-transform: none; line-heig=
ht: normal; text-indent: 0px; letter-spacing: normal; font-size: 12px; font=
-style: normal; font-variant: normal; font-weight: normal; word-spacing: 0p=
x;">What is interesting, is that both techniques looks similar, and C++11 a=
lready defined standard way of defining attributes.<br></pre></div></blockq=
uote></div>Unfortunately, standard attributes are restricted from being ess=
ential to the program=E2=80=99s meaning. A bracket-delimited attribute must=
allow the implementation to ignore it or the user to delete it. Deleting t=
he attributes from your example leads to multiple definition errors.<div><b=
r></div><div>However, Concepts would allow this to be done nicely, as long =
as the condition is not required to be template dependent. I=E2=80=99m not =
sure whether that=E2=80=99s the case or not.</div><div><br></div><div><pre>=
<span style=3D"color: rgb(0, 0, 136);">void</span><span> dispatch_func</spa=
n><span style=3D"color: rgb(102, 102, 0);">()</span><span> requires( ! __ss=
se3 ) </span><span style=3D"color: rgb(102, 102, 0);">{</span><span> =
<br>printf</span><span style=3D"color: rgb(102, 102, 0);">(</span><span sty=
le=3D"color: rgb(0, 136, 0);">"/nCode for non-Intel processors and generic =
Intel processors goes here/n"</span><span style=3D"color: rgb(102, 102, 0);=
">);</span><span> <br></span><span style=3D"color: rgb(102, 102, 0);"=
>}</span><span><br></span></pre><pre><span style=3D"color: rgb(0, 0, 136);"=
>void</span><span> dispatch_func</span><span style=3D"color: rgb(102, 102, =
0);">()</span><span> requires( __ssse3 && ! __sse4_2 ) </span><span=
style=3D"color: rgb(102, 102, 0);">{</span><span> <br>printf</span><=
span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0=
, 136, 0);">"/nCode for Intel Core 2 Duo processors with support for SSSE3 =
goes here/n"</span><span style=3D"color: rgb(102, 102, 0);">);</span><span>=
<br></span><span style=3D"color: rgb(102, 102, 0);">}</span><span> &=
nbsp;<br> <br></span><span style=3D"color: rgb(0, 0, 136);">void</spa=
n><span> dispatch_func</span><span style=3D"color: rgb(102, 102, 0);">()</s=
pan><span> requires( __sse4_2 && ! __avx ) </span><span style=3D"co=
lor: rgb(102, 102, 0);">{</span><span> <br>printf</span><span style=
=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 136, 0);=
">"/nCode for Intel Core processors with support for SSE4.2 goes here/n"</s=
pan><span style=3D"color: rgb(102, 102, 0);">);</span><span> <br></sp=
an><span style=3D"color: rgb(102, 102, 0);">}</span><span> <br> =
<br></span><span style=3D"color: rgb(0, 0, 136);">void</span><span> dispat=
ch_func</span><span style=3D"color: rgb(102, 102, 0);">()</span><span> requ=
ires( __avx ) </span><span style=3D"color: rgb(102, 102, 0);">{</span><span=
> <br>printf</span><span style=3D"color: rgb(102, 102, 0);">(</span><=
span style=3D"color: rgb(0, 136, 0);">"/nCode for 2nd generation Intel Core=
processors goes here/n"</span><span style=3D"color: rgb(102, 102, 0);">);<=
/span><span> <br></span><span style=3D"color: rgb(102, 102, 0);">}</s=
pan><span> <br><br></span></pre></div></div></blockquote><div><br></d=
iv><div>How would anyone keep up with Standardizing the identifiers in any =
meaningful way for this code to be Standard?</div><div>New hardware comes o=
ut daily and if you want to support that you need an identifier that won't =
be in the current Standard.</div><div>By the time it is Standard, maybe the=
compiler itself already understands the cpu anyway and can just automatica=
lly use the appropriate instructions anyway.</div><div><br></div><div>I sus=
pect this isn't something the Committee can facilitate realistica=
lly or do you think I'm likely wrong in that assumption?</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1879_861652268.1420587450365--
------=_Part_1878_536570803.1420587450365--
.
Author: David Krauss <potswa@gmail.com>
Date: Wed, 7 Jan 2015 07:58:11 +0800
Raw View
--Apple-Mail=_EA248E7C-C5E2-4A26-B3A5-FEE23F0D438E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9301=E2=80=9307, at 7:37 AM, gmisocpp@gmail.com wrote:
>=20
> How would anyone keep up with Standardizing the identifiers in any meanin=
gful way for this code to be Standard?
The leading double underscores imply that the identifiers wouldn=E2=80=99t =
be standardized. They might be defined by the vendor, like conditional macr=
os and intrinsics already are.
> I suspect this isn't something the Committee can facilitate realistically=
or do you think I'm likely wrong in that assumption?
The committee won=E2=80=99t be interested in specific editions of x86 but t=
he basic idea of =E2=80=9Cfat binaries=E2=80=9D is certainly interesting.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_EA248E7C-C5E2-4A26-B3A5-FEE23F0D438E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9301=
=E2=80=9307, at 7:37 AM, <a href=3D"mailto:gmisocpp@gmail.com" class=3D"">g=
misocpp@gmail.com</a> wrote:</div><br class=3D"Apple-interchange-newline"><=
div class=3D""><div dir=3D"ltr" style=3D"font-family: Helvetica; font-size:=
12px; font-style: normal; font-variant: normal; font-weight: normal; lette=
r-spacing: normal; line-height: normal; orphans: auto; text-align: start; t=
ext-indent: 0px; text-transform: none; white-space: normal; widows: auto; w=
ord-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D"">How would any=
one keep up with Standardizing the identifiers in any meaningful way for th=
is code to be Standard?</div></div></blockquote><div><br class=3D""></div><=
div>The leading double underscores imply that the identifiers wouldn=E2=80=
=99t be standardized. They might be defined by the vendor, like conditional=
macros and intrinsics already are.</div><br class=3D""><blockquote type=3D=
"cite" class=3D""><div dir=3D"ltr" style=3D"font-family: Helvetica; font-si=
ze: 12px; font-style: normal; font-variant: normal; font-weight: normal; le=
tter-spacing: normal; line-height: normal; orphans: auto; text-align: start=
; text-indent: 0px; text-transform: none; white-space: normal; widows: auto=
; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><div class=
=3D"">I suspect this isn't something the Committee can facilitate =
;realistically or do you think I'm likely wrong in that assumption?</div></=
div></blockquote><div><br class=3D""></div></div>The committee won=E2=80=99=
t be interested in specific editions of x86 but the basic idea of =E2=80=9C=
fat binaries=E2=80=9D is certainly interesting.</body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_EA248E7C-C5E2-4A26-B3A5-FEE23F0D438E--
.
Author: "Daniel Gutson" <danielgutson@gmail.com>
Date: Wed, 7 Jan 2015 01:03:40 +0000
Raw View
--part707-boundary-1082802553-1895886585
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
I also think that this is the joint job of the build system and the install=
er. Please do not pollute the language by adding features that should not b=
e related to the language itself.
There's plenty of multi-platform projects already with a good source code o=
rganization (e.g. architectures in subfolders).
This would affect cross compilers.
Get a better build system and a scriptable installer capable of querying th=
e destination architecture and installing the most suitable binary. See the=
gcc's multilibs concept for more ideas (I acknowledge they solve a differe=
nt problem, but the idea is still useful).
Daniel.
-----Original Message-----
From: David Krauss <potswa@gmail.com>
Date: Wed, 7 Jan 2015 07:58:11=20
To: <std-proposals@isocpp.org>
Reply-To: std-proposals@isocpp.org
Subject: Re: [std-proposals] cpu dispatch mechanisms
> On 2015=E2=80=9301=E2=80=9307, at 7:37 AM, gmisocpp@gmail.com wrote:
>=20
> How would anyone keep up with Standardizing the identifiers in any meanin=
gful way for this code to be Standard?
The leading double underscores imply that the identifiers wouldn=E2=80=99t =
be standardized. They might be defined by the vendor, like conditional macr=
os and intrinsics already are.
> I suspect this isn't something the Committee can facilitate realistically=
or do you think I'm likely wrong in that assumption?
The committee won=E2=80=99t be interested in specific editions of x86 but t=
he basic idea of =E2=80=9Cfat binaries=E2=80=9D is certainly interesting.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--part707-boundary-1082802553-1895886585
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D"">I also think that =
this is the joint job of the build system and the installer. Please do not =
pollute the language by adding features that should not be related to the l=
anguage itself.<br/>There's plenty of multi-platform projects already with =
a good source code organization (e.g. architectures in subfolders).<br/>Thi=
s would affect cross compilers.<br/><br/>Get a better build system and a sc=
riptable installer capable of querying the destination architecture and ins=
talling the most suitable binary. See the gcc's multilibs concept for more =
ideas (I acknowledge they solve a different problem, but the idea is still =
useful).<br/><br/> Daniel.<hr/><div><b>From: </b> David Krauss <potswa@=
gmail.com>
</div><div><b>Date: </b>Wed, 7 Jan 2015 07:58:11 +0800</div><div><b>To: </b=
><std-proposals@isocpp.org></div><div><b>ReplyTo: </b> std-proposals@=
isocpp.org
</div><div><b>Subject: </b>Re: [std-proposals] cpu dispatch mechanisms</div=
><div><br/></div><br class=3D""><div><blockquote type=3D"cite" class=3D""><=
div class=3D"">On 2015=E2=80=9301=E2=80=9307, at 7:37 AM, <a href=3D"mailto=
:gmisocpp@gmail.com" class=3D"">gmisocpp@gmail.com</a> wrote:</div><br clas=
s=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" style=3D"f=
ont-family: Helvetica; font-size: 12px; font-style: normal; font-variant: n=
ormal; font-weight: normal; letter-spacing: normal; line-height: normal; or=
phans: auto; text-align: start; text-indent: 0px; text-transform: none; whi=
te-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-widt=
h: 0px;" class=3D"">How would anyone keep up with Standardizing the identif=
iers in any meaningful way for this code to be Standard?</div></div></block=
quote><div><br class=3D""></div><div>The leading double underscores imply t=
hat the identifiers wouldn=E2=80=99t be standardized. They might be defined=
by the vendor, like conditional macros and intrinsics already are.</div><b=
r class=3D""><blockquote type=3D"cite" class=3D""><div dir=3D"ltr" style=3D=
"font-family: Helvetica; font-size: 12px; font-style: normal; font-variant:=
normal; font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: none; w=
hite-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-wi=
dth: 0px;" class=3D""><div class=3D"">I suspect this isn't something the&nb=
sp;Committee can facilitate realistically or do you think I'm likely w=
rong in that assumption?</div></div></blockquote><div><br class=3D""></div>=
</div>The committee won=E2=80=99t be interested in specific editions of x86=
but the basic idea of =E2=80=9Cfat binaries=E2=80=9D is certainly interest=
ing.</body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--part707-boundary-1082802553-1895886585--
.
Author: David Krauss <potswa@gmail.com>
Date: Wed, 7 Jan 2015 09:42:15 +0800
Raw View
--Apple-Mail=_6F841318-EF8B-4820-B5B3-AAD26349ED22
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9301=E2=80=9307, at 9:03 AM, Daniel Gutson <danielgutson@gm=
ail.com> wrote:
>=20
> I also think that this is the joint job of the build system and the insta=
ller.
A fat binary is by definition one where the final, installed product is sui=
table for different machines. Many OS vendors have decided to offer such an=
alternative, and it tends to be a popular style of application distributio=
n even when sophisticated installers are readily available.
> Please do not pollute the language by adding features that should not be =
related to the language itself.
My suggestion may or may not be considered to be an extension to the langua=
ge. Use of a double-underscore means anything goes, so pedantically, there=
=E2=80=99s nothing to standardize here. The only tricky semantic is that th=
e requires clause doesn=E2=80=99t actually evaluate to true or false, but a=
ll the functions get compiled and the switch happens at program load time.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_6F841318-EF8B-4820-B5B3-AAD26349ED22
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9301=
=E2=80=9307, at 9:03 AM, Daniel Gutson <<a href=3D"mailto:danielgutson@g=
mail.com" class=3D"">danielgutson@gmail.com</a>> wrote:</div><br class=
=3D"Apple-interchange-newline"><div class=3D""><meta http-equiv=3D"Content-=
Type" content=3D"text/html charset=3Dutf-8" class=3D""><div style=3D"word-w=
rap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-=
space;" class=3D"">I also think that this is the joint job of the build sys=
tem and the installer. </div></div></blockquote><div><br class=3D""></div><=
div>A fat binary is by definition one where the final, installed product is=
suitable for different machines. Many OS vendors have decided to offer suc=
h an alternative, and it tends to be a popular style of application distrib=
ution even when sophisticated installers are readily available.</div><br cl=
ass=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div style=3D=
"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after=
-white-space;" class=3D"">Please do not pollute the language by adding feat=
ures that should not be related to the language itself.<br class=3D""></div=
></div></blockquote><div><br class=3D""></div><div>My suggestion may or may=
not be considered to be an extension to the language. Use of a double-unde=
rscore means anything goes, so pedantically, there=E2=80=99s nothing to sta=
ndardize here. The only tricky semantic is that the <font face=3D"Courier" =
class=3D"">requires</font> clause doesn=E2=80=99t actually evaluate to true=
or false, but all the functions get compiled and the switch happens at pro=
gram load time.</div></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_6F841318-EF8B-4820-B5B3-AAD26349ED22--
.
Author: "Daniel Gutson" <danielgutson@gmail.com>
Date: Wed, 7 Jan 2015 01:59:56 +0000
Raw View
--part795-boundary-1172538134-585867666
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
(Sorry I can't comment inline).
I agree with you David, the request to not pollute the language was meant t=
o the OP and other suggestions like this one that I'm seeing lately.
-----Original Message-----
From: David Krauss <potswa@gmail.com>
Date: Wed, 7 Jan 2015 09:42:15=20
To: <std-proposals@isocpp.org>
Reply-To: std-proposals@isocpp.org
Subject: Re: [std-proposals] cpu dispatch mechanisms
> On 2015=E2=80=9301=E2=80=9307, at 9:03 AM, Daniel Gutson <danielgutson@gm=
ail.com> wrote:
>=20
> I also think that this is the joint job of the build system and the insta=
ller.
A fat binary is by definition one where the final, installed product is sui=
table for different machines. Many OS vendors have decided to offer such an=
alternative, and it tends to be a popular style of application distributio=
n even when sophisticated installers are readily available.
> Please do not pollute the language by adding features that should not be =
related to the language itself.
My suggestion may or may not be considered to be an extension to the langua=
ge. Use of a double-underscore means anything goes, so pedantically, there=
=E2=80=99s nothing to standardize here. The only tricky semantic is that th=
e requires clause doesn=E2=80=99t actually evaluate to true or false, but a=
ll the functions get compiled and the switch happens at program load time.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--part795-boundary-1172538134-585867666
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D"">(Sorry I can't com=
ment inline).<br/><br/>I agree with you David, the request to not pollute t=
he language was meant to the OP and other suggestions like this one that I'=
m seeing lately.<hr/><div><b>From: </b> David Krauss <potswa@gmail.com&g=
t;
</div><div><b>Date: </b>Wed, 7 Jan 2015 09:42:15 +0800</div><div><b>To: </b=
><std-proposals@isocpp.org></div><div><b>ReplyTo: </b> std-proposals@=
isocpp.org
</div><div><b>Subject: </b>Re: [std-proposals] cpu dispatch mechanisms</div=
><div><br/></div><br class=3D""><div><blockquote type=3D"cite" class=3D""><=
div class=3D"">On 2015=E2=80=9301=E2=80=9307, at 9:03 AM, Daniel Gutson <=
;<a href=3D"mailto:danielgutson@gmail.com" class=3D"">danielgutson@gmail.co=
m</a>> wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D=
""><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8" =
class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; -=
webkit-line-break: after-white-space;" class=3D"">I also think that this is=
the joint job of the build system and the installer. </div></div></blockqu=
ote><div><br class=3D""></div><div>A fat binary is by definition one where =
the final, installed product is suitable for different machines. Many OS ve=
ndors have decided to offer such an alternative, and it tends to be a popul=
ar style of application distribution even when sophisticated installers are=
readily available.</div><br class=3D""><blockquote type=3D"cite" class=3D"=
"><div class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D"">Please do not poll=
ute the language by adding features that should not be related to the langu=
age itself.<br class=3D""></div></div></blockquote><div><br class=3D""></di=
v><div>My suggestion may or may not be considered to be an extension to the=
language. Use of a double-underscore means anything goes, so pedantically,=
there=E2=80=99s nothing to standardize here. The only tricky semantic is t=
hat the <font face=3D"Courier" class=3D"">requires</font> clause doesn=E2=
=80=99t actually evaluate to true or false, but all the functions get compi=
led and the switch happens at program load time.</div></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--part795-boundary-1172538134-585867666--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 06 Jan 2015 23:17:45 -0800
Raw View
On Wednesday 07 January 2015 07:01:19 David Krauss wrote:
> > On 2015=E2=80=9301=E2=80=9307, at 3:02 AM, aambitny@gmail.com wrote:
> >=20
> > What is interesting, is that both techniques looks similar, and C++11
> > already defined standard way of defining attributes.
> Unfortunately, standard attributes are restricted from being essential to
> the program=E2=80=99s meaning. A bracket-delimited attribute must allow t=
he
> implementation to ignore it or the user to delete it. Deleting the
> attributes from your example leads to multiple definition errors.
>=20
> However, Concepts would allow this to be done nicely, as long as the
> condition is not required to be template dependent. I=E2=80=99m not sure =
whether
> that=E2=80=99s the case or not.
>=20
> void dispatch_func() requires( ! __ssse3 ) {
> printf("/nCode for non-Intel processors and generic Intel processors goes
> here/n"); }
> void dispatch_func() requires( __ssse3 && ! __sse4_2 ) {
> printf("/nCode for Intel Core 2 Duo processors with support for SSSE3 goe=
s
> here/n"); }
>=20
> void dispatch_func() requires( __sse4_2 && ! __avx ) {
> printf("/nCode for Intel Core processors with support for SSE4.2 goes
> here/n"); }
>=20
> void dispatch_func() requires( __avx ) {
> printf("/nCode for 2nd generation Intel Core processors goes here/n");
> }
Might as well use overload-dispatching (which is what GCC uses):
struct Generic {};
struct SSE : Generic {};
struct SSE2 : SSE {}
struct SSE3 : SSE2 {};
struct SSSE3 : SSE3 {};
struct SSE4_1 : SSSE3 {};
struct SSE4_2 : SSE4_1 {};
struct AVX : SSE4_2 {};
struct AVX2 : AVX {};
struct AVX512F : AVX2 {};
typedef implementation-specific CurrentCPU;
void dispatch_func(T1 arg1, T2 arg2, Generic)
{
// generic
}
void dispatch_func(T1 arg1, T2 arg2, SSSE3)
{
// SSSE3 version
}
void dispatch_func(T1 arg1, T2 arg2, SSE4_2)
{
// SSE4.2 version
}
void dispatch_func(T1 arg1, T2 arg2, AVX)
{
// AVX version
}
There are two issues left here:
1) the dispatch magic itself. Up to GCC 4.9, you had to write the dispatch=
er=20
yourself, which isn't hard, but it's a lot of boiler plate.
2) code generation and use of intrinsics -- which is entirely outside of t=
he=20
scope of the Standard.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Joel FALCOU <joel.falcou@gmail.com>
Date: Wed, 07 Jan 2015 08:28:09 +0100
Raw View
>
> Might as well use overload-dispatching (which is what GCC uses):
>
> struct Generic {};
> struct SSE : Generic {};
> struct SSE2 : SSE {}
> struct SSE3 : SSE2 {};
> struct SSSE3 : SSE3 {};
> struct SSE4_1 : SSSE3 {};
> struct SSE4_2 : SSE4_1 {};
> struct AVX : SSE4_2 {};
> struct AVX2 : AVX {};
> struct AVX512F : AVX2 {};
>
> typedef implementation-specific CurrentCPU;
>
> void dispatch_func(T1 arg1, T2 arg2, Generic)
> {
> // generic
> }
>
> void dispatch_func(T1 arg1, T2 arg2, SSSE3)
> {
> // SSSE3 version
> }
>
> void dispatch_func(T1 arg1, T2 arg2, SSE4_2)
> {
> // SSE4.2 version
> }
>
> void dispatch_func(T1 arg1, T2 arg2, AVX)
> {
> // AVX version
> }
>
AS a matter of fact and code being actually used right now, that's the
soltion Boost.SIMD is using.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: David Krauss <potswa@gmail.com>
Date: Wed, 7 Jan 2015 15:29:40 +0800
Raw View
> On 2015=E2=80=9301=E2=80=9307, at 3:17 PM, Thiago Macieira <thiago@maciei=
ra.org> wrote:
>=20
> Might as well use overload-dispatching (which is what GCC uses):
>=20
> typedef implementation-specific CurrentCPU;
How is this specific to GCC?
This cannot produce a fat binary. It will generate one executable per platf=
orm.
> There are two issues left here:
> 1) the dispatch magic itself. Up to GCC 4.9, you had to write the dispatc=
her=20
> yourself, which isn't hard, but it's a lot of boiler plate.
>=20
> 2) code generation and use of intrinsics -- which is entirely outside of =
the=20
> scope of the Standard.
Ideally, there should be no dispatcher at all, the program can only see one=
function by the time it=E2=80=99s resident in memory.
And, the compiler should be free to optimize per platform, no intrinsics, w=
ith different platforms in the same TU, as in the OP.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 06 Jan 2015 23:50:46 -0800
Raw View
On Wednesday 07 January 2015 15:29:40 David Krauss wrote:
> > On 2015=E2=80=9301=E2=80=9307, at 3:17 PM, Thiago Macieira <thiago@maci=
eira.org> wrote:
> >=20
> > Might as well use overload-dispatching (which is what GCC uses):
> >=20
> > typedef implementation-specific CurrentCPU;
>=20
> How is this specific to GCC?
I didn't mean the code I wrote. I meant that the automatic dispatching that=
=20
GCC 4.9 uses is based on function overloading. That's the reason why it wor=
ks=20
only on C++, not with C.
> This cannot produce a fat binary. It will generate one executable per
> platform.
> > There are two issues left here:
> > 1) the dispatch magic itself. Up to GCC 4.9, you had to write the
> > dispatcher yourself, which isn't hard, but it's a lot of boiler plate.
> >=20
> > 2) code generation and use of intrinsics -- which is entirely outside o=
f
> > the scope of the Standard.
>=20
> Ideally, there should be no dispatcher at all, the program can only see o=
ne
> function by the time it=E2=80=99s resident in memory.
Possible, but unlikely. This would require different sections in the binary=
and=20
at least ELF always loads everything. It's cheaper.
The Linux kernel "alternatives" solution uses hot-patching of the code, but=
=20
impure code is frowned upon in userland.
> And, the compiler should be free to optimize per platform, no intrinsics,
> with different platforms in the same TU, as in the OP.
Agreed, that's what I meant by "code generation". But if you know that ther=
e's=20
a given code that is better for a given CPU sub-architecture, it's probably=
=20
because you have the optimised version and that either requires writing=20
assembly or using intrinsics.
See my slides at:
https://www.qtdeveloperdays.com/presentation/writing-better-code-help-qt-an=
d-compiler
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: David Krauss <potswa@gmail.com>
Date: Wed, 7 Jan 2015 16:33:40 +0800
Raw View
--Apple-Mail=_EB6DF859-6816-46BD-9259-153A3529A3BE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9301=E2=80=9307, at 3:50 PM, Thiago Macieira <thiago@maciei=
ra.org> wrote:
>=20
> Possible, but unlikely. This would require different sections in the bina=
ry and=20
> at least ELF always loads everything. It's cheaper.
>=20
> The Linux kernel "alternatives" solution uses hot-patching of the code, b=
ut=20
> impure code is frowned upon in user land.
There are various ways to achieve it. You can load dead code but adjust bra=
nch instructions, piggybacking on PIC machinery. Depending on what the ABI =
doesn=E2=80=99t allow, there might be a runtime dispatcher which is just ke=
pt hidden.
> See my slides at:
> https://www.qtdeveloperdays.com/presentation/writing-better-code-help-qt-=
and-compiler
Yeah=E2=80=A6 lots of techniques and overlapping support among the platform=
s for things that can ultimately be made semi-portable.
Perhaps Intel would be interested in advocating common, if not formally sta=
ndardized, syntax for the example in the original post? I suppose anything =
would need to be based on C, not C++, much less Concepts. However, that cou=
ld just mean replacing requires with __requires when in C.
In any case, as you demonstrate, the preprocessor is often strong enough to=
translate among roughly equivalent features. And, that=E2=80=99s one of th=
e main reasons for its existence in the first place.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_EB6DF859-6816-46BD-9259-153A3529A3BE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9301=
=E2=80=9307, at 3:50 PM, Thiago Macieira <<a href=3D"mailto:thiago@macie=
ira.org" class=3D"">thiago@macieira.org</a>> wrote:</div><br class=3D"Ap=
ple-interchange-newline"><div class=3D"">Possible, but unlikely. This would=
require different sections in the binary and <br class=3D"">at least ELF a=
lways loads everything. It's cheaper.<br class=3D""><br class=3D"">The Linu=
x kernel "alternatives" solution uses hot-patching of the code, but <br cla=
ss=3D"">impure code is frowned upon in user land.<br class=3D""></div></blo=
ckquote><div><br class=3D""></div><div>There are various ways to achieve it=
.. You can load dead code but adjust branch instructions, piggybacking on PI=
C machinery. Depending on what the ABI doesn=E2=80=99t allow, there might b=
e a runtime dispatcher which is just kept hidden.</div><div><br class=3D"">=
</div><blockquote type=3D"cite" class=3D""><div class=3D"">See my slides at=
:<br class=3D""><a href=3D"https://www.qtdeveloperdays.com/presentation/wri=
ting-better-code-help-qt-and-compiler" class=3D"">https://www.qtdeveloperda=
ys.com/presentation/writing-better-code-help-qt-and-compiler</a><br class=
=3D""></div></blockquote></div><br class=3D""><div class=3D"">Yeah=E2=80=A6=
lots of techniques and overlapping support among the platforms for things =
that can ultimately be made semi-portable.</div><div class=3D""><br class=
=3D""></div><div class=3D"">Perhaps Intel would be interested in advocating=
common, if not formally standardized, syntax for the example in the origin=
al post? I suppose anything would need to be based on C, not C++, much less=
Concepts. However, that could just mean replacing <font face=3D"Courier" c=
lass=3D"">requires</font> with <font face=3D"Courier" class=3D"">__requires=
</font> when in C.</div><div class=3D""><br class=3D""></div><div clas=
s=3D"">In any case, as you demonstrate, the preprocessor is often strong en=
ough to translate among roughly equivalent features. And, that=E2=80=99s on=
e of the main reasons for its existence in the first place.</div></body></h=
tml>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_EB6DF859-6816-46BD-9259-153A3529A3BE--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 07 Jan 2015 08:44:48 -0800
Raw View
On Wednesday 07 January 2015 16:33:40 David Krauss wrote:
> > On 2015=E2=80=9301=E2=80=9307, at 3:50 PM, Thiago Macieira <thiago@maci=
eira.org> wrote:
> >=20
> > Possible, but unlikely. This would require different sections in the
> > binary and at least ELF always loads everything. It's cheaper.
> >=20
> > The Linux kernel "alternatives" solution uses hot-patching of the code,
> > but
> > impure code is frowned upon in user land.
>=20
> There are various ways to achieve it. You can load dead code but adjust
> branch instructions, piggybacking on PIC machinery. Depending on what the
> ABI doesn=E2=80=99t allow, there might be a runtime dispatcher which is j=
ust kept
> hidden.
> > See my slides at:
> > https://www.qtdeveloperdays.com/presentation/writing-better-code-help-q=
t-a
> > nd-compiler
> Yeah=E2=80=A6 lots of techniques and overlapping support among the platfo=
rms for
> things that can ultimately be made semi-portable.
>=20
> Perhaps Intel would be interested in advocating common, if not formally
> standardized, syntax for the example in the original post? I suppose
> anything would need to be based on C, not C++, much less Concepts. Howeve=
r,
> that could just mean replacing requires with __requires when in C.
>=20
> In any case, as you demonstrate, the preprocessor is often strong enough =
to
> translate among roughly equivalent features. And, that=E2=80=99s one of t=
he main
> reasons for its existence in the first place.
I think that if we go this way, we should make it a little more general.
That is, given two functions, how can I make the code dispatch to one or th=
e=20
other according to a global variable?
int global;
void dispatch_func() requires(...);
void dispatch_func() requires(global > 2);
Because that allows us to implement:
enum CPUSubArchictecture {
Generic =3D 0,
SSE =3D 1,
SSE2 =3D 2,
SSE3 =3D 3
} subArchitecture;
void dispatch_func() requires(...);
void dispatch_func() requires(subArchitecture >=3D SSE2);
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: =?UTF-8?B?UGF3ZcWCIFN0YW5rb3dza2k=?= <aambitny@gmail.com>
Date: Thu, 08 Jan 2015 00:14:34 +0100
Raw View
Thank you all very much for supporting the idea.
@dgutson: I think that my idea won't pollute the language, but it will
increase performance instead. Managing few library versions has some
drawbacks:
- When changing CPU, your installed application may stop working at some
point, because library version installed may not be compatible with new CPU=
..
- If your shared library is big (like Qt5Core for example), you have to
create new library for functions that you optimize or your installer
will become very heavy. When you do that, all developers using that
function will have to link to this new library when linking to the
original one. Worse, you have to move functions from one library to
another when you want to optimize them.
- Most of libraries have only few optimized functions, but you still
have to compile whole library for each possible target. And each time
you optimize function with use of some new feature, you have to compile
library once more time.
On 07.01.2015 09:33, David Krauss wrote:
>=20
>> On 2015=E2=80=9301=E2=80=9307, at 3:50 PM, Thiago Macieira <thiago@macie=
ira.org
>> <mailto:thiago@macieira.org>> wrote:
>>
>> Possible, but unlikely. This would require different sections in the
>> binary and
>> at least ELF always loads everything. It's cheaper.
>>
>> The Linux kernel "alternatives" solution uses hot-patching of the
>> code, but
>> impure code is frowned upon in user land.
>=20
> There are various ways to achieve it. You can load dead code but adjust
> branch instructions, piggybacking on PIC machinery. Depending on what
> the ABI doesn=E2=80=99t allow, there might be a runtime dispatcher which =
is just
> kept hidden.
>=20
>> See my slides at:
>> https://www.qtdeveloperdays.com/presentation/writing-better-code-help-qt=
-and-compiler
>=20
> Yeah=E2=80=A6 lots of techniques and overlapping support among the platfo=
rms for
> things that can ultimately be made semi-portable.
>=20
> Perhaps Intel would be interested in advocating common, if not formally
> standardized, syntax for the example in the original post?
> I suppose
> anything would need to be based on C, not C++, much less Concepts.
> However, that could just mean replacing requires with __requires when in =
C.
That's a good point. However, isn't that a problem that 'requires'
should be followed by constexpr, and we don't know anything about
runtime CPU during compilation?
I think that when it comes to C compatibility, giving developer a way to
write a resolver manually would be a good start (and we would not to
specify CPU features names in the standard).
C-compatible program compilable by GCC:
> #include <stdio.h>
>=20
> void foo_optimized(void) {
> printf("Optimized\n");
> }
>=20
> void foo_generic(void) {
> printf("Generic\n");
> }
>=20
> static void (*resolve_foo(void)) (void) {
> __builtin_cpu_init();
> if (__builtin_cpu_supports("sse")) {
> return &foo_optimized;
> }
> else {
> return &foo_generic;
> }
> }
>=20
> void foo(void) __attribute__((ifunc("resolve_foo")));
>=20
> int main()
> {
> foo();
> return 0;
> }
As David pointed out, standard attributes cannot be used in such
context. So maybe the simplest way would be to introduce new keyword
similar to noexcept specifier? For example:
foo.h:
extern void foo(void);
foo.c:
void foo(void) ifunc(resolve_foo);
[...] /* rest of code similar to previous example */
Regards,
Pawe=C5=82 Stankowski
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: gmisocpp@gmail.com
Date: Wed, 7 Jan 2015 19:25:07 -0800 (PST)
Raw View
------=_Part_9930_838582003.1420687507346
Content-Type: multipart/alternative;
boundary="----=_Part_9931_654081312.1420687507346"
------=_Part_9931_654081312.1420687507346
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, January 8, 2015 5:45:31 AM UTC+13, Thiago Macieira wrote:
>
> On Wednesday 07 January 2015 16:33:40 David Krauss wrote:=20
> > > On 2015=E2=80=9301=E2=80=9307, at 3:50 PM, Thiago Macieira <thi...@ma=
cieira.org=20
> <javascript:>> wrote:=20
> > >=20
> > > Possible, but unlikely. This would require different sections in the=
=20
> > > binary and at least ELF always loads everything. It's cheaper.=20
> > >=20
> > > The Linux kernel "alternatives" solution uses hot-patching of the=20
> code,=20
> > > but=20
> > > impure code is frowned upon in user land.=20
> >=20
> > There are various ways to achieve it. You can load dead code but adjust=
=20
> > branch instructions, piggybacking on PIC machinery. Depending on what=
=20
> the=20
> > ABI doesn=E2=80=99t allow, there might be a runtime dispatcher which is=
just=20
> kept=20
> > hidden.=20
> > > See my slides at:=20
> > >=20
> https://www.qtdeveloperdays.com/presentation/writing-better-code-help-qt-=
a=20
> > > nd-compiler=20
> > Yeah=E2=80=A6 lots of techniques and overlapping support among the plat=
forms for=20
> > things that can ultimately be made semi-portable.=20
> >=20
> > Perhaps Intel would be interested in advocating common, if not formally=
=20
> > standardized, syntax for the example in the original post? I suppose=20
> > anything would need to be based on C, not C++, much less Concepts.=20
> However,=20
> > that could just mean replacing requires with __requires when in C.=20
> >=20
> > In any case, as you demonstrate, the preprocessor is often strong enoug=
h=20
> to=20
> > translate among roughly equivalent features. And, that=E2=80=99s one of=
the main=20
> > reasons for its existence in the first place.=20
>
> I think that if we go this way, we should make it a little more general.=
=20
>
> That is, given two functions, how can I make the code dispatch to one or=
=20
> the=20
> other according to a global variable?=20
>
> int global;=20
> void dispatch_func() requires(...);=20
> void dispatch_func() requires(global > 2);=20
>
> Because that allows us to implement:=20
>
> enum CPUSubArchictecture {=20
> Generic =3D 0,=20
> SSE =3D 1,=20
> SSE2 =3D 2,=20
> SSE3 =3D 3=20
> } subArchitecture;=20
> void dispatch_func() requires(...);=20
> void dispatch_func() requires(subArchitecture >=3D SSE2);=20
>
> =20
This reminds me of Concepts which is compile time / constexpr based right?
But you need a runtime based thing, right?
Or both. I can imagine needing to pick a CPU path at runtime but also=20
wanting to override or force one at compile time.
I wonder if a fusion of this technology would help:
http://www.stroustrup.com/OpenPatternMatching.pdf=20
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_9931_654081312.1420687507346
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, January 8, 2015 5:45:31 AM UTC+13, Th=
iago Macieira wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px =
0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bo=
rder-left-width: 1px; border-left-style: solid;">On Wednesday 07 January 20=
15 16:33:40 David Krauss wrote:
<br>> > On 2015=E2=80=9301=E2=80=9307, at 3:50 PM, Thiago Macieira &l=
t;<a onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this=
..href=3D'javascript:';return true;" href=3D"javascript:" target=3D"_blank" =
gdf-obfuscated-mailto=3D"mivs1tqlOKMJ">thi...@macieira.org</a>> wrote:
<br>> >=20
<br>> > Possible, but unlikely. This would require different sections=
in the
<br>> > binary and at least ELF always loads everything. It's cheaper=
..
<br>> >=20
<br>> > The Linux kernel "alternatives" solution uses hot-patching of=
the code,
<br>> > but
<br>> > impure code is frowned upon in user land.
<br>>=20
<br>> There are various ways to achieve it. You can load dead code but a=
djust
<br>> branch instructions, piggybacking on PIC machinery. Depending on w=
hat the
<br>> ABI doesn=E2=80=99t allow, there might be a runtime dispatcher whi=
ch is just kept
<br>> hidden.
<br>> > See my slides at:
<br>> > <a onmousedown=3D"this.href=3D'https://www.google.com/url?q\7=
5https%3A%2F%2Fwww.qtdeveloperdays.com%2Fpresentation%2Fwriting-better-code=
-help-qt-a\46sa\75D\46sntz\0751\46usg\75AFQjCNEYm9IHViLPhGf8ILyhdfj_MPI-Yg'=
;return true;" onclick=3D"this.href=3D'https://www.google.com/url?q\75https=
%3A%2F%2Fwww.qtdeveloperdays.com%2Fpresentation%2Fwriting-better-code-help-=
qt-a\46sa\75D\46sntz\0751\46usg\75AFQjCNEYm9IHViLPhGf8ILyhdfj_MPI-Yg';retur=
n true;" href=3D"https://www.qtdeveloperdays.com/presentation/writing-bette=
r-code-help-qt-a" target=3D"_blank">https://www.qtdeveloperdays.<wbr>com/pr=
esentation/writing-<wbr>better-code-help-qt-a</a>
<br>> > nd-compiler
<br>> Yeah=E2=80=A6 lots of techniques and overlapping support among the=
platforms for
<br>> things that can ultimately be made semi-portable.
<br>>=20
<br>> Perhaps Intel would be interested in advocating common, if not for=
mally
<br>> standardized, syntax for the example in the original post? I suppo=
se
<br>> anything would need to be based on C, not C++, much less Concepts.=
However,
<br>> that could just mean replacing requires with __requires when in C.
<br>>=20
<br>> In any case, as you demonstrate, the preprocessor is often strong =
enough to
<br>> translate among roughly equivalent features. And, that=E2=80=99s o=
ne of the main
<br>> reasons for its existence in the first place.
<br>
<br>I think that if we go this way, we should make it a little more general=
..
<br>
<br>That is, given two functions, how can I make the code dispatch to one o=
r the=20
<br>other according to a global variable?
<br>
<br>int global;
<br>void dispatch_func() requires(...);
<br>void dispatch_func() requires(global > 2);
<br>
<br>Because that allows us to implement:
<br>
<br>enum CPUSubArchictecture {
<br> Generic =3D 0,
<br> SSE =3D 1,
<br> SSE2 =3D 2,
<br> SSE3 =3D 3
<br>} subArchitecture;
<br>void dispatch_func() requires(...);
<br>void dispatch_func() requires(subArchitecture >=3D SSE2);
<br>
<br>
</blockquote><div> </div><div>This reminds me of Concepts which is com=
pile time / constexpr based right?</div><div>But you need a runtime ba=
sed thing, right?</div><div>Or both. I can imagine needing to pick&nbs=
p;a CPU path at runtime but also wanting to override or forc=
e one at compile time.</div><div><br></div><div>I wonder if&=
nbsp;a fusion of this technology would help:<br></div><div><a hre=
f=3D"http://www.stroustrup.com/OpenPatternMatching.pdf">http://www.stroustr=
up.com/OpenPatternMatching.pdf</a> </div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_9931_654081312.1420687507346--
------=_Part_9930_838582003.1420687507346--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 07 Jan 2015 21:24:19 -0800
Raw View
On Wednesday 07 January 2015 19:25:07 gmisocpp@gmail.com wrote:
> > enum CPUSubArchictecture {
> >
> > Generic = 0,
> > SSE = 1,
> > SSE2 = 2,
> > SSE3 = 3
> >
> > } subArchitecture;
> > void dispatch_func() requires(...);
> > void dispatch_func() requires(subArchitecture >= SSE2);
>
> This reminds me of Concepts which is compile time / constexpr based right?
> But you need a runtime based thing, right?
> Or both. I can imagine needing to pick a CPU path at runtime but also
> wanting to override or force one at compile time.
>
> I wonder if a fusion of this technology would help:
> http://www.stroustrup.com/OpenPatternMatching.pdf
Compile-time detection is easy and a solved problem. See my slides and the
previous post with overloading with an extra argument.
The question is how to do runtime dispatching.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.