Boost logo

Boost :

Subject: Re: [boost] [cpo-proposal] presentation of the idea
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-08-18 22:24:49


On 08/18/13 18:49, Santiago Tapia wrote:
[snip]

>> Date: Fri, 16 Aug 2013 19:20:36 -0500
>> From: Larry Evans <cppljevans_at_[hidden]>
>
>>> Yes, that is the idea. Actually, whether the implementation uses a collection
>>> of vectors or other mechanism is an implementation detail. I use a map
>>> of vectors in the classifier container, but I will try other implementations.
>> Is the map key something like the type_info:
>>
>> http://www.cplusplus.com/reference/typeinfo/
>
> Yes, actually a wrapper of typeinfo because of a problem with typeinfo
> I could not workaround. But that is an implementation detail, I mean,
> that will be an inner detail of the library and I might find a better solution
> without changing the interface of the classifier container.
>
>>
>> If there is a separate vector for each type, then the storage for a
>> container containing more than one type can't be contiguous,
>> since the vectors for the containers for the types cannot be
>> contiguous, or am I missing something? I think what Thorsten
>> was aiming at in this post:
>>
>> http://article.gmane.org/gmane.comp.lib.boost.devel/243504
>
> I could not follow the link... ?

Sorry. It should have been:

http://lists.boost.org/Archives/boost/2013/08/205811.php

[snip]

>> Date: Sat, 17 Aug 2013 09:20:14 -0500
>> From: Larry Evans <cppljevans_at_[hidden]>
>>
>> The attached demonstrates, I believe, what Thorsten was aiming at
>> an shows the storage of *different* types in contiguous storage.
>>
>> HTH.
>>
>>
>> -regards,
>> Larry
>>
>> -------------- next part --------------
>> A non-text attachment was scrubbed...
>> Name: align_in_buffer.cpp
>> Type: text/x-c++src
>> Size: 4402 bytes
>> Desc: not available
>> URL: <http://lists.boost.org/boost/attachments/20130817/7b23e93f/attachment.bin>
>>
>
> I can not find the attachment.
Strange. Pointing my Firefox browser here:

http://lists.boost.org/Archives/boost/2013/08/205827.php

and then clinking on the:

text/x-c++src attachment: align_in_buffer.cpp

link opens the align_in_buffer.cpp in my browser.
>
> Anyway, I am not sure about the memory model. As I said in the first
> version I will
> choose contigous allocation for each type, that is, objects of same type will be
> contigous and objects of different objects will not.
> There are some reasons for that decision:
> 1) It is easier to implement.
> 2) I think it will more effective. Of course, that has to be proved.
> 3) Contigous storage for same type enables random access by index directly.

I'm not sure how 3) could be done because to find the i-th Base element
in the container, you'd have to first figure out what type the i-th
element is, and then go to the "subcontainer" for that type and figure
where the i-th Base element is in that subcontainer. OTOH, if
everything was in a contiguous container, you'd just need
a vector of offsets for all the elements. Now if all the Base
elements are stored in some:

  char buffer[SumSizes];

then just

  Base*base_ptr=static_cast<Base*>(buffer[offset[i]]);

I've not seen how you would do this with separate containers
for each type; hence, I can't really guess if that would be
more or less complicated. Could you give a brief outline
how you're doing it for comparison?

>
> But if contigous storage of different types is better, I will switch
> to it or provide
> different containers using each memory model.
>

Good question. Maybe the brief outline of how mentioned above
would help answer that question.

-regards,
Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk