Re: [GSOC2020][Boost.uBLAS] C++20-ification of uBLAS

Cem Bassoy via ublas <[email protected]> Mon, 16 Mar 2020 11:49:53 +0100
Newsgroups gmane.comp.lib.boost.ublas
Message-ID <CADrR+Fv57sOV2fT4J-BU+rwXaPKKRDRMSp_7MEUfPJd55a_edw@mail.gmail.com>
--===============3459999340660606498==
Content-Type: multipart/alternative; boundary="000000000000edae1b05a0f694e0"

--000000000000edae1b05a0f694e0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Ashar,

happy to have you back.

While 20++-ification is a necessary step for uBLAS, we have to be cautious
as many features of the 20++ standard are not even implemented yet, see
https://en.cppreference.com/w/cpp/compiler_support.



Am Fr., 13. M=C3=A4rz 2020 um 19:10 Uhr schrieb Ashar via ublas <
[email protected]>:

> Hi
> My name is Ashar, a pre-final year undergraduate student. Last year I
> worked with Boost.uBLAS and added Boost.YAP Expression template and anoth=
er
> student Amit added some new interfaces like subtensor view and other real=
ly
> cool things.
>

They are! Indeed.


>
> During the development and addition of new YAP based ET, I did faced many
> issues with the legacy C++ code in matrix and vectors, this was more
> pronounced as Boost.uBLAS.tensor was targetting C++17 and rest of the uBL=
AS
> had C++11 or earlier code. The new project about C++20-ification of
> Boost.uBLAS seems a really nice step towards creating a more unified and
> standardized experience across all 3 types (vector, matrix, tensor) also =
we
> can experiment if C++20 does makes things faster or not.
>
> I have been following C++20 since its first draft (July 2017, Toronto) an=
d
> now that it has been finalized, I have tested and experimented with most =
of
> its features with clang/gcc/trunks. So, I believe this makes me a potenti=
al
> candidate for this project.
>
> I am interested in working in this project and Here are some of the ideas
> in general that I have toward C++20-ification of uBLAS.
>

Very happy about that. Let me go through your list.


>
> 1. concepts : We have so many type_traits.hpp and all those legacy traits
> which can be really replaced by new concepts. It will make template type
> errors really short and nice to debug.
>

Agree. I would like to slowly approach this topic and start with it when
the tensor data type with subtensors are finalized.


>
> 2. The one ranges : Eric Neibler's one ranges will be very nice to have i=
n
> uBLAS, we currently have iterator based abstraction but since ranges are
> the new way to interact with containers in C++20, addition of this will
> really make uBLAS one of its kind in Linear algebra. Further more, Amit's
> work can be used here and we can have views and adapter (only for tensor
> upto now).
>

This topic might be too early for an investigation right now. Once
subtensors are included in boost we should try to


>
> 3. std::span : Span are used widely in linear algebra and with C++20,
> Standard has added it. Albeit uBLAS has its own span and extents it will =
be
> very good to make them compatible or interoperable with standard spans.
>

std::span and boost::numeric::ublas::span have different meanings. The
latter is used for tensor selections with three member variables while the
other is refering to a static or dynamic memory region with a pointer to
the memory region and its length. Still std::span could be a good use for
ublas.



> 4. Constexpr-ification : C++20 made so much things constexpr, try/catch t=
o
> even dynamic containers like vector and strings. We can really leverage t=
he
> new constexpr abilities like memory allocation and freeing to build a
> really awesome constexpr vector/matrix/tensor interfaces.
>

This is a good point. I think that C++17 gave us already the right
opportunities.


>
> 5. Modules : Finally we got rid of leaky include directives, making uBLAS
> modules based will be I think the first library in Boost to have it.
>

We should see how and when the boost community switches to modules.


>
> 6. New Tool-chains : Travis CI is used for CI and its at best cannot give
> over 18.04LTS for jobs, Setting up CI with modern tool-chain to build and
> run C++20 will also be a job of its own.
>

Oh. I am totally for stabilizing our current development branch. This is
something ublas needs to do.


>
> 7. Misc: spaceship operator and other minor changes like
> feature/test-macros and other minor topping that comes with C++20 can be
> used really nicely.
>
>
> I am also very aware of that all these can take much more time than what
> we get in GSOC, but I will choose and prioritise the task, I have just
> proposed some new things that I would like to add if given a chance to wo=
rk
> on it. I have intensionally left coroutines and other features because I
> can't find any practical use of those features for uBLAS. If you have som=
e
> ideas, how we can use it to improve then please its welcomed.
>
> Cem and David are the mentors that I am seeking and I will be submitting
> my C++20 competency test to one of you very soon. Please consider this as
> official application email and we can always further discuss and finalize
> the direction of the work directly.
>
>
All in all I find the inclusion of most C++20 features very important - yet
too early. We already made a huge step with C++17.

Therefore, my suggestion for ublas is to name this gosc project (stablizing
and improving code quality ublas) :

   1. (not part as gsoc) make a final decision about yapp

   2. stablilize and improve the code from the previous gsoc implementation
   (static rank and extents, subtensor)
   3. improve code quality using advanced and modern toolchains like cmake,
   clang-static-analyzer, clang-tidy, etc.
   4. improve code quality by enhancing the code-covarge percentage for
   tensor only
   5. improve the constexpr-ness of tensor and subtensor (finalization with
   C++17)
   6. prepare a matrix and vector data structures as an instance of
   tensor<T,rank=3D2> and tensor<T,rank=3D1>

   7. using a different branch, improve code quality using c++20 contracts
   and attributes for tensor, using (expects,ensure,assert) contract
   <https://www.modernescpp.com/index.php/c-core-guidelines-a-detour-to-con=
tracts>
   8. prepare concepts


Best,
Cem



> Regards
> _______________________________________________
> ublas mailing list
> [email protected]
> https://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: [email protected]
>

--000000000000edae1b05a0f694e0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi Ashar,</div><div><br></div><div>happy to have you =
back.</div><div><br></div><div>While 20++-ification is a necessary step for=
 uBLAS, we have to be cautious as many features of the 20++ standard are no=
t even implemented yet, see <a href=3D"https://en.cppreference.com/w/cpp/co=
mpiler_support">https://en.cppreference.com/w/cpp/compiler_support</a>. <br=
></div><div><br></div><div><br></div><div><br></div><div class=3D"gmail_quo=
te"><div dir=3D"ltr" class=3D"gmail_attr">Am Fr., 13. M=C3=A4rz 2020 um 19:=
10=C2=A0Uhr schrieb Ashar via ublas &lt;<a href=3D"mailto:[email protected]=
.org">[email protected]</a>&gt;:<br></div><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,20=
4);padding-left:1ex"><div dir=3D"auto"><div dir=3D"auto">Hi<br></div><div d=
ir=3D"auto">My name is Ashar, a pre-final year undergraduate student. Last =
year I worked with Boost.uBLAS and added Boost.YAP Expression template and =
another student Amit added some new interfaces like subtensor view and othe=
r really cool things.</div></div></blockquote><div><br></div><div>They are!=
 Indeed.<br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div dir=3D"auto"><div dir=3D"auto"><br></div><div dir=3D"auto">=
During the development and addition of new YAP based ET, I did faced many i=
ssues with the legacy C++ code in matrix and vectors, this was more pronoun=
ced as Boost.uBLAS.tensor was targetting C++17 and rest of the uBLAS had C+=
+11 or earlier code. The new project about C++20-ification of Boost.uBLAS s=
eems a really nice step towards creating a more unified and standardized ex=
perience across all 3 types (vector, matrix, tensor) also we can experiment=
 if C++20 does makes things faster or not.</div><div dir=3D"auto"><br></div=
><div dir=3D"auto">I have been following C++20 since its first draft (July =
2017, Toronto) and now that it has been finalized, I have tested and experi=
mented with most of its features with clang/gcc/trunks. So, I believe this =
makes me a potential candidate for this project.</div><div dir=3D"auto"><br=
></div><div dir=3D"auto">I am interested in working in this project and Her=
e are some of the ideas in general that I have toward C++20-ification of uB=
LAS.=C2=A0</div></div></blockquote><div><br></div><div>Very happy about tha=
t. Let me go through your list.<br></div><div>=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"auto"><div dir=3D"auto"><br></=
div><div dir=3D"auto">1. concepts : We have so many type_traits.hpp and all=
 those legacy traits which can be really replaced by new concepts. It will =
make template type errors really short and nice to debug.=C2=A0</div></div>=
</blockquote><div><br></div><div>Agree. I would like to slowly approach thi=
s topic and start with it when the tensor data type with subtensors are fin=
alized.<br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div dir=3D"auto"><div dir=3D"auto"><br></div><div dir=3D"auto">=
2. The one ranges : Eric Neibler&#39;s one ranges will be very nice to have=
 in uBLAS, we currently have iterator based abstraction but since ranges ar=
e the new way to interact with containers in C++20, addition of this will r=
eally make uBLAS one of its kind in Linear algebra. Further more, Amit&#39;=
s work can be used here and we can have views and adapter (only for tensor =
upto now).</div></div></blockquote><div><br></div><div>This topic might be =
too early for an investigation right now. Once subtensors are included in b=
oost we should try to <br></div><div>=C2=A0</div><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204=
,204);padding-left:1ex"><div dir=3D"auto"><div dir=3D"auto"><br></div><div =
dir=3D"auto">3. std::span : Span are used widely in linear algebra and with=
 C++20, Standard has added it. Albeit uBLAS has its own span and extents it=
 will be very good to make them compatible or interoperable with standard s=
pans.</div></div></blockquote><div><br></div>std::span and boost::numeric::=
ublas::span have different meanings. The latter is used for tensor selectio=
ns with three member variables while the other is refering to a static or d=
ynamic memory region with a pointer to the memory region and its length. St=
ill std::span could be a good use for ublas.<br><div><br></div><div>=C2=A0<=
/div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"auto"><d=
iv dir=3D"auto">4. Constexpr-ification : C++20 made so much things constexp=
r, try/catch to even dynamic containers like vector and strings. We can rea=
lly leverage the new constexpr abilities like memory allocation and freeing=
 to build a really awesome constexpr vector/matrix/tensor interfaces.</div>=
</div></blockquote><div><br></div><div>This is a good point. I think that C=
++17 gave us already the right opportunities.<br></div><div>=C2=A0</div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"auto"><div dir=
=3D"auto"><br></div><div dir=3D"auto">5. Modules : Finally we got rid of le=
aky include directives, making uBLAS modules based will be I think the firs=
t library in Boost to have it.=C2=A0</div></div></blockquote><div><br></div=
><div>We should see how and when the boost community switches to modules. <=
br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"=
><div dir=3D"auto"><div dir=3D"auto"><br></div><div dir=3D"auto">6. New Too=
l-chains : Travis CI is used for CI and its at best cannot give over 18.04L=
TS for jobs, Setting up CI with modern tool-chain to build and run C++20 wi=
ll also be a job of its own.</div></div></blockquote><div><br></div><div>Oh=
. I am totally for stabilizing our current development branch. This is some=
thing ublas needs to do.<br></div><div>=C2=A0</div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,2=
04,204);padding-left:1ex"><div dir=3D"auto"><div dir=3D"auto"><br></div><di=
v dir=3D"auto">7. Misc: spaceship operator and other minor changes like fea=
ture/test-macros and other minor topping that comes with C++20 can be used =
really nicely.</div><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div=
><div dir=3D"auto">I am also very aware of that all these can take much mor=
e time than what we get in GSOC, but I will choose and prioritise the task,=
 I have just proposed some new things that I would like to add if given a c=
hance to work on it. I have intensionally left coroutines and other feature=
s because I can&#39;t find any practical use of those features for uBLAS. I=
f you have some ideas, how we can use it to improve then please its welcome=
d.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Cem and David are the=
 mentors that I am seeking and I will be submitting my C++20 competency tes=
t to one of you very soon. Please consider this as official application ema=
il and we can always further discuss and finalize the direction of the work=
 directly.</div><div dir=3D"auto"><br></div></div></blockquote><div><br></d=
iv><div>All in all I find the inclusion of most C++20 features very importa=
nt - yet too early. We already made a huge step with C++17. <br></div></div=
><div class=3D"gmail_quote"><br></div><div class=3D"gmail_quote">Therefore,=
 my suggestion for ublas is to name this gosc project (stablizing and impro=
ving code quality ublas) : <br></div><div class=3D"gmail_quote"><ol><li>(no=
t part as gsoc) make a final decision about yapp<br><br></li><li>stablilize=
 and improve the code from the previous gsoc implementation (static rank an=
d extents, subtensor)<br></li><li>improve code quality using advanced and m=
odern toolchains like cmake, clang-static-analyzer, clang-tidy, etc.<br></l=
i><li>improve code quality by enhancing the code-covarge percentage for ten=
sor only<br></li><li>improve the constexpr-ness of tensor and subtensor (fi=
nalization with C++17)</li><li>prepare a matrix and vector data structures =
as an instance of tensor&lt;T,rank=3D2&gt; and tensor&lt;T,rank=3D1&gt;<br>=
<br></li><li>using a different branch, improve code quality using c++20 con=
tracts and attributes for tensor, using (expects,ensure,assert) <a href=3D"=
https://www.modernescpp.com/index.php/c-core-guidelines-a-detour-to-contrac=
ts">contract</a></li><li>prepare concepts <br></li></ol></div><div class=3D=
"gmail_quote"><div><br></div><div>Best,</div><div>Cem<br></div><div><br></d=
iv><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div =
dir=3D"auto"><div dir=3D"auto"></div><div dir=3D"auto">Regards</div></div>
_______________________________________________<br>
ublas mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
t.org</a><br>
<a href=3D"https://lists.boost.org/mailman/listinfo.cgi/ublas" rel=3D"noref=
errer" target=3D"_blank">https://lists.boost.org/mailman/listinfo.cgi/ublas=
</a><br>
Sent to: <a href=3D"mailto:[email protected]" target=3D"_blank">cem.bass=
[email protected]</a><br>
</blockquote></div></div>

--000000000000edae1b05a0f694e0--

--===============3459999340660606498==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline