[preprocessor] increase tuple size

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[preprocessor] increase tuple size

Boost - Users mailing list
Hi,

preprocessor/config/limits.hpp limits tuple size to 64 elements. Changing the BOOST_PP_LIMIT_TUPLE in this file seems not to have any effect. Is it possible to increase the maximal tuple size?
Are there scripts to update dependent macros like BOOST_PP_TUPLE_ELEM_* in preprocessor/tuple/elem.hpp?

Thanks in advance


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] increase tuple size

Boost - Users mailing list
On 23/10/2019 09:41, pavel b wrote:
> preprocessor/config/limits.hpp limits tuple size to 64 elements.
> Changing the BOOST_PP_LIMIT_TUPLE in this file seems not to have any
> effect. Is it possible to increase the maximal tuple size?

If you can use a modern compiler that supports variadic macros (thus
BOOST_PP_VARIADICS=1), then AFAIK it should support any size (up to
whatever your compiler's limit is).

This may require telling your compiler to compile in C++11 or later mode.

Alternatively you can try forcing it on by #define BOOST_PP_VARIADICS 1
before including any Boost headers (in all translation units), but this
is less preferable.

https://www.boost.org/doc/libs/1_68_0/libs/preprocessor/doc/topics/variadic_macros.html
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] increase tuple size

Boost - Users mailing list
On 10/23/2019 2:16 AM, Gavin Lambert via Boost-users wrote:

> On 23/10/2019 09:41, pavel b wrote:
>> preprocessor/config/limits.hpp limits tuple size to 64 elements.
>> Changing the BOOST_PP_LIMIT_TUPLE in this file seems not to have any
>> effect. Is it possible to increase the maximal tuple size?
>
> If you can use a modern compiler that supports variadic macros (thus
> BOOST_PP_VARIADICS=1), then AFAIK it should support any size (up to
> whatever your compiler's limit is).
>
> This may require telling your compiler to compile in C++11 or later mode.
>
> Alternatively you can try forcing it on by #define BOOST_PP_VARIADICS 1
> before including any Boost headers (in all translation units), but this
> is less preferable.
>
> https://www.boost.org/doc/libs/1_68_0/libs/preprocessor/doc/topics/variadic_macros.html 

No, this is not true. The current design in the Boost preprocessor
library does not allow the user to change the limits and therefore get
more elements supported of any of the Boost PP data types. Whether a
compiler supports variadic macros or not makes no difference with the
current code. Please remember that all the design of the Boost PP data
types, by Paul Mensonides, was done before variadic macros even existed.
Anyone who believes they can change the current design to something
better, which would allow arbitrary numbers of elements for any of the
Boost PP data types, such as the tuple, is free to submit a PR to do so.



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] increase tuple size

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On 10/22/2019 4:41 PM, pavel b via Boost-users wrote:
> Hi,
>
> preprocessor/config/limits.hpp limits tuple size to 64 elements.
> Changing the BOOST_PP_LIMIT_TUPLE in this file seems not to have any
> effect. Is it possible to increase the maximal tuple size?
> Are there scripts to update dependent macros like BOOST_PP_TUPLE_ELEM_*
> in preprocessor/tuple/elem.hpp?
>
> Thanks in advance

No, you should not be changing the limits and doing so will not actually
change anything. If you want more than 64 tuple elements you could have
a tuple whose elements themselves are tuples. For instance if you wanted
256 tuple elements you could program this as a tuple with 64 elements
and each of those elements is a tuple with 4 elements. Or if you like a
tuple with 16 elements and each of those elements a tuple of 16
elements. You get the idea.

My problem of changing this in Boost PP to some other greater hardcoded
limit is that preprocessing speed will slow down overall if I do so,
even for those people who do not need to use greater limits. If you feel
there is some way of providing dynamic limits, where changing some limit
value somehow changes the limit for all tuple functionality, please
provide a PR for doing so, realizing that allowing dynamic changing of
limits affects quite bit of tuple functionality in the Boost PP library
which would have to have new implementations in your PR.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] increase tuple size

Boost - Users mailing list

Hi,

No, you should not be changing the limits and doing so will not actually
change anything. If you want more than 64 tuple elements you could have
a tuple whose elements themselves are tuples. For instance if you wanted
256 tuple elements you could program this as a tuple with 64 elements
and each of those elements is a tuple with 4 elements. Or if you like a
tuple with 16 elements and each of those elements a tuple of 16
elements. You get the idea.

Thank you, good Idea! But in my case it was about the support of an old project, therefore a redesign was not my first choice.

Unfortunately, there is only little room for improvement. Microsoft C++ compiler, for example, supports only 127 macro arguments.

After extending BOOST_PP_VARIADIC_SIZE and BOOST_PP_VARIADIC_SIZE_I in boost/preprocessor/variadic/size.hpp and defining additional BOOST_PP_VARIADIC_ELEM_[64..125] as in preprocessor/tuple/elem.hpp BOOST_PP_TUPLE_SIZE() and BOOST_PP_TUPLE_ELEM() work with up to 126 elemnets.

BOOST_PP_TUPLE_TO_SEQ() uses internal some additional macro parameters, it supports tuples with up to 124 elemrnts after adding BOOST_PP_TUPLE_TO_SEQ_[65..124] similar to preprocessor/tuple/to_seq.hpp

No other boost preprocessor macros were changed/tested.

So after a few simple changes, I have succeeded to extend tuple size from 64 to 124 elements. It seems to work under current MSVC, clang and gcc versions.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] increase tuple size

Boost - Users mailing list
On 10/28/2019 8:35 PM, pavel b via Boost-users wrote:

>
> Hi,
>
>     No, you should not be changing the limits and doing so will not
>     actually
>     change anything. If you want more than 64 tuple elements you could have
>     a tuple whose elements themselves are tuples. For instance if you
>     wanted
>     256 tuple elements you could program this as a tuple with 64 elements
>     and each of those elements is a tuple with 4 elements. Or if you like a
>     tuple with 16 elements and each of those elements a tuple of 16
>     elements. You get the idea.
>
>
> Thank you, good Idea! But in my case it was about the support of an old
> project, therefore a redesign was not my first choice.
>
> Unfortunately, there is only little room for improvement. Microsoft C++
> compiler, for example, supports only 127 macro arguments. >
> After extending BOOST_PP_VARIADIC_SIZE and BOOST_PP_VARIADIC_SIZE_I in
> boost/preprocessor/variadic/size.hpp and defining additional
> BOOST_PP_VARIADIC_ELEM_[64..125] as in preprocessor/tuple/elem.hpp
> BOOST_PP_TUPLE_SIZE() and BOOST_PP_TUPLE_ELEM() work with up to 126
> elemnets.

I am not sure what you are saying above. Did you extend the number of
maximum variadic elements, the number of maximum tuple elements, or both ?

>
> BOOST_PP_TUPLE_TO_SEQ() uses internal some additional macro parameters,
> it supports tuples with up to 124 elemrnts after adding
> BOOST_PP_TUPLE_TO_SEQ_[65..124] similar to preprocessor/tuple/to_seq.hpp

OK.

>
> No other boost preprocessor macros were changed/tested.
>
> So after a few simple changes, I have succeeded to extend tuple size
> from 64 to 124 elements. It seems to work under current MSVC, clang and
> gcc versions.

You really need to enhance the current tests dealing with variadic data
and tuples so that you can show that variadic data and tuples with 126
elements will work properly, in order to verify that your changes work
in all cases.

Also if you would like to create a PR for your changes I will be glad to
look at it.

As far as Microsoft C++ only supporting a maximum of 127 macro
arguments, do you have something which shows that ? It should only
affect variadic data and not tuples.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] increase tuple size

Boost - Users mailing list
> I am not sure what you are saying above. Did you extend the number of
> maximum variadic elements, the number of maximum tuple elements, or both ?  

Here I changed only the number of maximum variadic elements

> As far as Microsoft C++ only supporting a maximum of 127 macro
> arguments, do you have something which shows that ?  

https://docs.microsoft.com/en-us/cpp/cpp/compiler-limits?view=vs-2019

> It should only affect variadic data and not tuples

I am afraid that some tuples-specific files like  tuple/to_list.hpp or tuple/lo_seq.hpp need to be changed as well

On Tue, Oct 29, 2019 at 3:44 AM Edward Diener via Boost-users <[hidden email]> wrote:
On 10/28/2019 8:35 PM, pavel b via Boost-users wrote:
>
> Hi,
>
>     No, you should not be changing the limits and doing so will not
>     actually
>     change anything. If you want more than 64 tuple elements you could have
>     a tuple whose elements themselves are tuples. For instance if you
>     wanted
>     256 tuple elements you could program this as a tuple with 64 elements
>     and each of those elements is a tuple with 4 elements. Or if you like a
>     tuple with 16 elements and each of those elements a tuple of 16
>     elements. You get the idea.
>
>
> Thank you, good Idea! But in my case it was about the support of an old
> project, therefore a redesign was not my first choice.
>
> Unfortunately, there is only little room for improvement. Microsoft C++
> compiler, for example, supports only 127 macro arguments. >
> After extending BOOST_PP_VARIADIC_SIZE and BOOST_PP_VARIADIC_SIZE_I in
> boost/preprocessor/variadic/size.hpp and defining additional
> BOOST_PP_VARIADIC_ELEM_[64..125] as in preprocessor/tuple/elem.hpp
> BOOST_PP_TUPLE_SIZE() and BOOST_PP_TUPLE_ELEM() work with up to 126
> elemnets.

I am not sure what you are saying above. Did you extend the number of
maximum variadic elements, the number of maximum tuple elements, or both ?

>
> BOOST_PP_TUPLE_TO_SEQ() uses internal some additional macro parameters,
> it supports tuples with up to 124 elemrnts after adding
> BOOST_PP_TUPLE_TO_SEQ_[65..124] similar to preprocessor/tuple/to_seq.hpp

OK.

>
> No other boost preprocessor macros were changed/tested.
>
> So after a few simple changes, I have succeeded to extend tuple size
> from 64 to 124 elements. It seems to work under current MSVC, clang and
> gcc versions.

You really need to enhance the current tests dealing with variadic data
and tuples so that you can show that variadic data and tuples with 126
elements will work properly, in order to verify that your changes work
in all cases.

Also if you would like to create a PR for your changes I will be glad to
look at it.

As far as Microsoft C++ only supporting a maximum of 127 macro
arguments, do you have something which shows that ? It should only
affect variadic data and not tuples.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] increase tuple size

Boost - Users mailing list
On 11/6/2019 6:03 PM, pavel b via Boost-users wrote:

>  > I am not sure what you are saying above. Did you extend the number of
>  > maximum variadic elements, the number of maximum tuple elements, or
> both ?
>
> Here I changed only the number of maximum variadic elements
>
>  > As far as Microsoft C++ only supporting a maximum of 127 macro
>  > arguments, do you have something which shows that ?
>
> https://docs.microsoft.com/en-us/cpp/cpp/compiler-limits?view=vs-2019
>
>  > It should only affect variadic data and not tuples
>
> I am afraid that some tuples-specific files like  tuple/to_list.hpp or
> tuple/lo_seq.hpp need to be changed as well

As I said if you would like to create a PR with your work to increase
the number of elements for tuples and variadic data I will look at it.
Ideally if I decided to increase the maximum number number of tuple
elements and variadic data I would probably go for 256 so as to match
the maximum number of seq elements. The main reason for not doing so in
the past, aside from the fact that it has almost never been requested,
is that I did not want to slow down the preprocessor for all those
programmers using Boost PP tuples and variadic data functionality who do
not need to consider more than 64 elements. So a large part of any
decision to increase the number of tuple and variadic data elements for
all Boost PP end-users is to measure if there really is a significant
slowdown by the preprocessor in doing so.

>
> On Tue, Oct 29, 2019 at 3:44 AM Edward Diener via Boost-users
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     On 10/28/2019 8:35 PM, pavel b via Boost-users wrote:
>      >
>      > Hi,
>      >
>      >     No, you should not be changing the limits and doing so will not
>      >     actually
>      >     change anything. If you want more than 64 tuple elements you
>     could have
>      >     a tuple whose elements themselves are tuples. For instance if you
>      >     wanted
>      >     256 tuple elements you could program this as a tuple with 64
>     elements
>      >     and each of those elements is a tuple with 4 elements. Or if
>     you like a
>      >     tuple with 16 elements and each of those elements a tuple of 16
>      >     elements. You get the idea.
>      >
>      >
>      > Thank you, good Idea! But in my case it was about the support of
>     an old
>      > project, therefore a redesign was not my first choice.
>      >
>      > Unfortunately, there is only little room for improvement.
>     Microsoft C++
>      > compiler, for example, supports only 127 macro arguments. >
>      > After extending BOOST_PP_VARIADIC_SIZE and
>     BOOST_PP_VARIADIC_SIZE_I in
>      > boost/preprocessor/variadic/size.hpp and defining additional
>      > BOOST_PP_VARIADIC_ELEM_[64..125] as in preprocessor/tuple/elem.hpp
>      > BOOST_PP_TUPLE_SIZE() and BOOST_PP_TUPLE_ELEM() work with up to 126
>      > elemnets.
>
>     I am not sure what you are saying above. Did you extend the number of
>     maximum variadic elements, the number of maximum tuple elements, or
>     both ?
>
>      >
>      > BOOST_PP_TUPLE_TO_SEQ() uses internal some additional macro
>     parameters,
>      > it supports tuples with up to 124 elemrnts after adding
>      > BOOST_PP_TUPLE_TO_SEQ_[65..124] similar to
>     preprocessor/tuple/to_seq.hpp
>
>     OK.
>
>      >
>      > No other boost preprocessor macros were changed/tested.
>      >
>      > So after a few simple changes, I have succeeded to extend tuple size
>      > from 64 to 124 elements. It seems to work under current MSVC,
>     clang and
>      > gcc versions.
>
>     You really need to enhance the current tests dealing with variadic data
>     and tuples so that you can show that variadic data and tuples with 126
>     elements will work properly, in order to verify that your changes work
>     in all cases.
>
>     Also if you would like to create a PR for your changes I will be
>     glad to
>     look at it.
>
>     As far as Microsoft C++ only supporting a maximum of 127 macro
>     arguments, do you have something which shows that ? It should only
>     affect variadic data and not tuples.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users