Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Boost::MPL #1997

Open
ax3l opened this issue Apr 26, 2017 · 23 comments
Open

Replace Boost::MPL #1997

ax3l opened this issue Apr 26, 2017 · 23 comments
Labels
component: PMacc in PMacc refactoring code change to improve performance or to unify a concept but does not change public API

Comments

@ax3l
Copy link
Member

ax3l commented Apr 26, 2017

According to this reddit post the C++11 library Brigand is the hot new sh*t to replace the quite inactive and in C++11 times inefficient + C++98 verbose Boost MPL library.

We should take a look and evaluate it it's worth switching to a more modern and active dependency. This could also have a very positive impact on compile time.

An alternative for the future can also be Boost::HANA, but compiler support seems quite demanding as of today.

ccing @psychocoderHPC @theZiz

@ax3l ax3l added component: PMacc in PMacc refactoring code change to improve performance or to unify a concept but does not change public API labels Apr 26, 2017
@ax3l ax3l added this to the Future milestone Apr 26, 2017
@psychocoderHPC
Copy link
Member

Already stared, thanks for adding the issue.

@BenjaminW3
Copy link
Member

This is by far not the only option!
Currently there are multiple libraries proposed to be included into boost and even more coming.
There are:

(the links may not be correct)
See e.g. here for a comparison or many threads on the boost developer mailing list.

@ax3l
Copy link
Member Author

ax3l commented Apr 26, 2017

Wonderful, thanks! And anything in sight already? Looks all very recent. Please keep us posted!

@BenjaminW3
Copy link
Member

alpaka does also have some meta programming tools within "alpaka/meta/" which are similar to mp11. alpaka does not rely on MPL anymore. The design of the type computations allows any variadic template to be used as type list. However, most of the time, std::tuple is used. Furthermore alpaka specializes the MPL templates for std::tuple so that those type lists can be used within native MPL commands (e.g. type parametrized boost tests).

@theZiz
Copy link
Member

theZiz commented May 2, 2017

I would not switch to one solution, which looks promising at the moment but may be not maintained anymore later.
Instead I would abstract the functionality we need first using MPL as backend but with the easy option to change for faster solutions later. As far as I read at reddit, the MPL is not dead, but done. However as it highly depends on the preprocessor, it's slow, which can't be fixed without loosing C++03 compability.

@ax3l
Copy link
Member Author

ax3l commented May 2, 2017

I would not switch to one solution, which looks promising at the moment but may be not maintained anymore later.

Yes sure, no one is about to rush here until a well maintained third-party lib is found and evaluated.

Instead I would abstract the functionality we need first using MPL as backend [...]

No, I would not write yet an other wrapper around a simple list based meta-programming library. We can just wait what boost decides for and then evaluate their C++11 meta-programming lib if it fits our needs. Everything else is a waste of time that will end in building adapters for everything.

As far as I read at reddit, the MPL is not dead, but done.

yep. feature-complete but verbose (since C++03 compat.). C++03 style should be removed from our project wherever we can not only to be clean and less verbose but also to be faster in most cases (work-arounds and fallbacks do consume compile time and especially maintenance time, too).

@ax3l
Copy link
Member Author

ax3l commented Dec 5, 2017

@BenjaminW3 @psychocoderHPC digging out this thread, do you know which of the ones above will make it in boost? :)

@ax3l
Copy link
Member Author

ax3l commented Dec 5, 2017

From activity, popularity and compilation times, brigand and kvasir seem to be the most attractive to me from checking the projects again: http://metaben.ch/

@BenjaminW3
Copy link
Member

And the winner is - none of yours: mp11. It should be part of the next boost release. It is very similar to the alpaka metaprogramming tools. When we could raise the boost version that high, I will definitely use it.

@ax3l
Copy link
Member Author

ax3l commented Dec 6, 2017

Interesting, thanks! Does it work well with NVCC 7.5+?

I just started to love kvasir::mpl :'(, they really care about compile time :)

@ax3l ax3l mentioned this issue Dec 6, 2017
@BenjaminW3
Copy link
Member

It should work well even with nvcc 7.0 but I have not tried it yet.

@ax3l
Copy link
Member Author

ax3l commented Dec 6, 2017

All right, if you are eager to test mp11 in the current boost develop branch even before the release we would be very interested about the results. If it works for alpaka and all its backends we should definitely put it as the MPL replacement in PIConGPU as well!

@ax3l ax3l modified the milestones: Future, 0.4.0 / 1.0.0: Next Stable Dec 6, 2017
@ax3l ax3l changed the title Replace Boost::MPL? Replace Boost::MPL Dec 6, 2017
@Flamefire
Copy link
Contributor

It is in the official boost repos now since 1.66.0. Any idea why there are now 3 TMP libs in boost? I mean they included Boost.Hana as the successor to Boost.MPL (I think) but now they also have Boost.mp11.

Seems like the same mess as with the lambdas in Boost.Bind, Boost.Lambda, Boost.Phoenix, Boost.Phoenix2, Boost.Proto, Boost.Phoenix3,...

@ax3l
Copy link
Member Author

ax3l commented Feb 7, 2018

It is in the official boost repos now since 1.66.0.

Good to know!

Boost hana is not a successor of MPL but does the connection from CT to RT as unified superset of MPL+Fusion: http://www.boost.org/doc/libs/1_63_0/libs/hana/doc/html/index.html
Out of the three (or more) proposed MPL successors only one was included, mp11.

yes, lambdas is a mess in boost (but a bit off-topic for this thread) :)

@bernhardmgruber
Copy link
Contributor

I think this work should be prioretized based on the timetrace I took in #3808.

@Flamefire
Copy link
Contributor

Based on my (now) experience with Boost and the author(s) I'd recommend MP11. Peter (the guy developing/maintaining it) is quite knowledgeable and MP11 seems to be a very decent lib. Especially if you use Boost anyway.
Over and out ;)

@bernhardmgruber
Copy link
Contributor

Based on my (now) experience with Boost and the author(s) I'd recommend MP11. Peter (the guy developing/maintaining it) is quite knowledgeable and MP11 seems to be a very decent lib. Especially if you use Boost anyway.

Same experience here. Peter Dimov is always helpful when you open issues and the lib is already available because we have Boost in many projects anyway. And if that ever becomes a problem, Boost.Mp11 can be used standalone outside Boost as well. This is also why LLAMA uses Boost.Mp11.

@psychocoderHPC
Copy link
Member

PIConGPU is heavily relying on compile-time lambda functions. Those are used in param files and internally.
As I know @sbastrakov sid in the past where he started to change from boost::mpl to boost::mp11 that lamda functions do not exist mp11.

boost mpl lambda functions: https://www.boost.org/doc/libs/1_65_1/libs/mpl/doc/refmanual/lambda.html

@bernhardmgruber
Copy link
Contributor

I wonder how much of this meta lambda functionality you need. boost::mp11 has higher order meta functions as well via template template parameters or so-called quoted metafunctions. Maybe such meta function lambdas could also be built on top of mp11 in a short amount of code. Could you point me at a typical use of such lambdas?

@sbastrakov
Copy link
Member

sbastrakov commented Sep 30, 2021

From what i remember, our most common pattern is as here. Have a struct taking particle species as a template parameter (in this example defined above in the same file, often it would be somewhere deep inside PIConGPU), and then applying it for the given species typelist. Meaning, instantiating an object for each relevant species and calling its operator(). The substitution of real species type instead of placeholder is here as far as i can see. To be honest, this appears not that difficult. So probably there was something more that posed an issue back then

@psychocoderHPC
Copy link
Member

psychocoderHPC commented Sep 30, 2021

In addition to what @sbastrakov wrote: The point of the lambda functions is that it is not defined which template parameter should be substituted with an explicit type. Additionally to substitute a template parameter apply can be defined within your struct even if this struct has no template parameter, this opens you the way to transform a type in case boost::mpl::apply is called.

The example functor is not depending on a species, if a species is applied it returns the identity of the functor type.

template<typename T_SpeciesType>
struct apply
{
using type = FreeRng;
};

@sbastrakov
Copy link
Member

This is the first real issue I tried to do with PIConGPU but it is still not implemented. Hopefully someone else will have more luck with it

@sbastrakov sbastrakov removed their assignment Sep 23, 2022
@bernhardmgruber
Copy link
Contributor

Well, it was almost completed by me in #3834 and #3983. It failed a few CI tests, but the rest was good. Let's see whether I can finish that up at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: PMacc in PMacc refactoring code change to improve performance or to unify a concept but does not change public API
Projects
None yet
Development

No branches or pull requests

7 participants