Topic: Introducing vector types to C++
Author: cooky451@gmail.com
Date: Mon, 3 Dec 2012 08:07:43 -0800 (PST)
Raw View
------=_Part_798_14815144.1354550863762
Content-Type: text/plain; charset=ISO-8859-1
C++ has always been about getting most out of the hardware, at least when
it's needed. As most desktop CPUs nowadays have vector units (SSE etc.),
wouldn't it make sense to introduce vector types to C++? Compilers try to
auto-vectorize code, but I think that this has pretty strong limitations,
especially considering alignment of data. If C++ had vector types, this
wouldn't be a problem (I guess?) since the types could enforce every
alignment they want. I think this could be implemented either as a library
or a language feature - most compilers provide vector types anyway
nowadays. As for portability and machines that don't have vector units:
Since the vector types have stronger requirements than non-vector types,
this shouldn't be a problem at all, the behavior could easily be emulated.
One would not even pay a performance penalty, since all the vector types
are saying to the compiler is basically "look, this could be done in
parallel!".
I'm not really an expert on SSE (or ASM anyway), so I probably cannot write
an proposal for this. But it just seems like an awfully simple solution to
this problem, and I have to ask myself why the language doesn't have a
feature like that yet. Maybe I'm wrong, but I'm sure you'll at least make
me understand why. ;-)
--
------=_Part_798_14815144.1354550863762
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
C++ has always been about getting most out of the hardware, at least when i=
t's needed. As most desktop CPUs nowadays have vector units (SSE etc.), wou=
ldn't it make sense to introduce vector types to C++? Compilers try to auto=
-vectorize code, but I think that this has pretty strong limitations, espec=
ially considering alignment of data. If C++ had vector types, this wouldn't=
be a problem (I guess?) since the types could enforce every alignment they=
want. I think this could be implemented either as a library or a language =
feature - most compilers provide vector types anyway nowadays. As for porta=
bility and machines that don't have vector units: Since the vector types ha=
ve stronger requirements than non-vector types, this shouldn't be a problem=
at all, the behavior could easily be emulated. One would not even pay a pe=
rformance penalty, since all the vector types are saying to the compiler is=
basically "look, this could be done in parallel!".<br>I'm not really an ex=
pert on SSE (or ASM anyway), so I probably cannot write an proposal for thi=
s. But it just seems like an awfully simple solution to this problem, and I=
have to ask myself why the language doesn't have a feature like that yet. =
Maybe I'm wrong, but I'm sure you'll at least make me understand why. ;-)<b=
r>
<p></p>
-- <br />
<br />
<br />
<br />
------=_Part_798_14815144.1354550863762--
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Mon, 3 Dec 2012 08:19:19 -0800 (PST)
Raw View
------=_Part_216_30199620.1354551559255
Content-Type: text/plain; charset=ISO-8859-1
> C++ has always been about getting most out of the hardware, at least when
> it's needed. As most desktop CPUs nowadays have vector units (SSE etc.),
> wouldn't it make sense to introduce vector types to C++? Compilers try to
> auto-vectorize code, but I think that this has pretty strong limitations,
> especially considering alignment of data. If C++ had vector types, this
> wouldn't be a problem (I guess?) since the types could enforce every
> alignment they want. I think this could be implemented either as a library
> or a language feature - most compilers provide vector types anyway
> nowadays. As for portability and machines that don't have vector units:
> Since the vector types have stronger requirements than non-vector types,
> this shouldn't be a problem at all, the behavior could easily be emulated.
> One would not even pay a performance penalty, since all the vector types
> are saying to the compiler is basically "look, this could be done in
> parallel!".
> I'm not really an expert on SSE (or ASM anyway), so I probably cannot
> write an proposal for this. But it just seems like an awfully simple
> solution to this problem, and I have to ask myself why the language doesn't
> have a feature like that yet. Maybe I'm wrong, but I'm sure you'll at least
> make me understand why. ;-)
>
Is this not what std::valarray is for?
--
------=_Part_216_30199620.1354551559255
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;">C++ has always been about =
getting most out of the hardware, at least when it's needed. As most deskto=
p CPUs nowadays have vector units (SSE etc.), wouldn't it make sense to int=
roduce vector types to C++? Compilers try to auto-vectorize code, but I thi=
nk that this has pretty strong limitations, especially considering alignmen=
t of data. If C++ had vector types, this wouldn't be a problem (I guess?) s=
ince the types could enforce every alignment they want. I think this could =
be implemented either as a library or a language feature - most compilers p=
rovide vector types anyway nowadays. As for portability and machines that d=
on't have vector units: Since the vector types have stronger requirements t=
han non-vector types, this shouldn't be a problem at all, the behavior coul=
d easily be emulated. One would not even pay a performance penalty, since a=
ll the vector types are saying to the compiler is basically "look, this cou=
ld be done in parallel!".<br>I'm not really an expert on SSE (or ASM anyway=
), so I probably cannot write an proposal for this. But it just seems like =
an awfully simple solution to this problem, and I have to ask myself why th=
e language doesn't have a feature like that yet. Maybe I'm wrong, but I'm s=
ure you'll at least make me understand why. ;-)<br></blockquote><div><br>Is=
this not what <span style=3D"font-family: courier new,monospace;">std::val=
array</span> is for? <br></div>
<p></p>
-- <br />
<br />
<br />
<br />
------=_Part_216_30199620.1354551559255--
.
Author: "J. Daniel Garcia" <josedaniel.garcia@uc3m.es>
Date: Mon, 3 Dec 2012 13:32:09 -0600
Raw View
--f46d042dfe7ba3bb3d04cff7d00b
Content-Type: text/plain; charset=ISO-8859-1
Please note that there are current papers on discussion in this area.
N3419 is the latest one you want to look at.
--
J. Daniel
On Mon, Dec 3, 2012 at 10:07 AM, <cooky451@gmail.com> wrote:
> C++ has always been about getting most out of the hardware, at least when
> it's needed. As most desktop CPUs nowadays have vector units (SSE etc.),
> wouldn't it make sense to introduce vector types to C++? Compilers try to
> auto-vectorize code, but I think that this has pretty strong limitations,
> especially considering alignment of data. If C++ had vector types, this
> wouldn't be a problem (I guess?) since the types could enforce every
> alignment they want. I think this could be implemented either as a library
> or a language feature - most compilers provide vector types anyway
> nowadays. As for portability and machines that don't have vector units:
> Since the vector types have stronger requirements than non-vector types,
> this shouldn't be a problem at all, the behavior could easily be emulated.
> One would not even pay a performance penalty, since all the vector types
> are saying to the compiler is basically "look, this could be done in
> parallel!".
> I'm not really an expert on SSE (or ASM anyway), so I probably cannot
> write an proposal for this. But it just seems like an awfully simple
> solution to this problem, and I have to ask myself why the language doesn't
> have a feature like that yet. Maybe I'm wrong, but I'm sure you'll at least
> make me understand why. ;-)
>
> --
>
>
>
>
--
--f46d042dfe7ba3bb3d04cff7d00b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Please note that there are current papers on discussion in this area.<=
br></div><div><br></div><div>N3419 is the latest one you want to look at.</=
div><div><br></div><div>--</div><div>=A0 J. Daniel</div><div class=3D"gmail=
_extra">
<br><br><div class=3D"gmail_quote">On Mon, Dec 3, 2012 at 10:07 AM, <span =
dir=3D"ltr"><<a href=3D"mailto:cooky451@gmail.com" target=3D"_blank">coo=
ky451@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
C++ has always been about getting most out of the hardware, at least when i=
t's needed. As most desktop CPUs nowadays have vector units (SSE etc.),=
wouldn't it make sense to introduce vector types to C++? Compilers try=
to auto-vectorize code, but I think that this has pretty strong limitation=
s, especially considering alignment of data. If C++ had vector types, this =
wouldn't be a problem (I guess?) since the types could enforce every al=
ignment they want. I think this could be implemented either as a library or=
a language feature - most compilers provide vector types anyway nowadays. =
As for portability and machines that don't have vector units: Since the=
vector types have stronger requirements than non-vector types, this should=
n't be a problem at all, the behavior could easily be emulated. One wou=
ld not even pay a performance penalty, since all the vector types are sayin=
g to the compiler is basically "look, this could be done in parallel!&=
quot;.<br>
I'm not really an expert on SSE (or ASM anyway), so I probably cannot w=
rite an proposal for this. But it just seems like an awfully simple solutio=
n to this problem, and I have to ask myself why the language doesn't ha=
ve a feature like that yet. Maybe I'm wrong, but I'm sure you'l=
l at least make me understand why. ;-)<span class=3D"HOEnZb"><font color=3D=
"#888888"><br>
<p></p>
-- <br>
=A0<br>
=A0<br>
=A0<br>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div><br>
</div>
<p></p>
-- <br />
<br />
<br />
<br />
--f46d042dfe7ba3bb3d04cff7d00b--
.
Author: "Matt D." <matdzb@gmail.com>
Date: Fri, 07 Dec 2012 21:08:18 +0100
Raw View
On 12/3/2012 17:07, cooky451@gmail.com wrote:
> C++ has always been about getting most out of the hardware, at least
> when it's needed. As most desktop CPUs nowadays have vector units (SSE
> etc.), wouldn't it make sense to introduce vector types to C++?
> Compilers try to auto-vectorize code, but I think that this has pretty
> strong limitations, especially considering alignment of data. If C++
> had vector types, this wouldn't be a problem (I guess?) since the
> types could enforce every alignment they want. I think this could be
> implemented either as a library or a language feature - most compilers
> provide vector types anyway nowadays. As for portability and machines
> that don't have vector units: Since the vector types have stronger
> requirements than non-vector types, this shouldn't be a problem at
> all, the behavior could easily be emulated. One would not even pay a
> performance penalty, since all the vector types are saying to the
> compiler is basically "look, this could be done in parallel!".
> I'm not really an expert on SSE (or ASM anyway), so I probably cannot
> write an proposal for this. But it just seems like an awfully simple
> solution to this problem, and I have to ask myself why the language
> doesn't have a feature like that yet. Maybe I'm wrong, but I'm sure
> you'll at least make me understand why. ;-)
Hi!
I think Boost.SIMD (not yet a part of Boost, however) looks interesting
interesting in this context, so I'll pass some resources by reference ;-)
Meeting C++ 2012
"boost.SIMD: Generic Programming for portable SIMDimization"
http://meetingcpp.com/index.php/talkview/items/6.html
Slides [PDF] boost.SIMD: Generic Programming for portable SIMDimization
BoostCon 2011
"Practical SIMD acceleration with Boost.SIMD"
https://github.com/boostcon/2011_presentations/raw/master/thu/simd.pdf
"Boost.SIMD: generic programming for portable SIMDization"
http://dl.acm.org/citation.cfm?id=2370881
Docs:
http://nt2.metascale.fr/doc/html/the_boost_simd_library.html
Video:
http://blip.tv/boostcon/practical-simd-acceleration-with-boost-simd-5261117
Best,
Matt
--
.