Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

tbb concurrent_vector max_size

904knight
Beginner
770 Views

Hi all, 

 

I'm in a bit of a tough spot and figured maybe the community would have some advice here. I am running a ray tracing code that uses concurrent_vectors to store data. The code works fine on my company's HPC, however when I am attempting to run on a customer's HPC I am getting the error below

 

"Exception caught:reservation size exceeds permitted max size”

 

We have determined that it is throwing this error when one of the array objects is attempting to resize. 

 

The hardware on the two systems is very comparible, and I have tried to swap out libtbb.so.2 libraries with no luck. 

 

My question is: where is tbb coming up with the max_size value? Is there an environment or setting that could be limiting that value? 

0 Kudos
5 Replies
NoorjahanSk_Intel
Moderator
745 Views

Hi,

Thanks for reaching out to us.

 

Could you please provide us a sample reproducer(steps to be followed to reproduce the issue) so that we can try it from our end.

>>The hardware on the two systems is very comparible

Could you provide the hardware details of both systems. Also provide OS details & version of Compilers being used.

 

Thanks & Regards

Noorjahan

 

NoorjahanSk_Intel
Moderator
722 Views

Hi,

Could you please provide the above-requested details? so that it will help us to investigate more on your issue.

 

Thanks & Regards

Noorjahan

 

NoorjahanSk_Intel
Moderator
690 Views

Hi,

I have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question

 

Thanks & Regards

Noorjahan.

 

Mark_L_Intel
Employee
519 Views

Hello,


It looks like you are trying to reserve the size of concurrent_vector greater than can be allocated (available) on one of the systems (you use). In TBB, tbb_misc.cpp contains the exception (definition) of what you see,


https://github.com/wjakob/tbb/blob/9e219e24fe223b299783200f217e9d27790a87b0/src/tbb/tbb_misc.cpp#L14...


case eid_reservation_length_error: DO_THROW(std::length_error, ("reservation size exceeds permitted max size") );


which is called from concurrent_vector.cpp


void concurrent_vector_base_v3::internal_reserve( size_type n, size_type element_size, size_type max_size ) {

if( n>max_size )

throw_exception(eid_reservation_length_error);



And internal_reserve() method is called in reserve() method which is defined in concurrent_vector.h:


//! Allocate enough space to grow to size n without having to allocate more memory later.

/** Like most of the methods provided for STL compatibility, this method is *not* thread safe.

The capacity afterwards may be bigger than the requested reservation. */

void reserve( size_type n ) {

if( n )

internal_reserve(n, sizeof(T), max_size());

}


and so finally max_size() is defined in the same file concurrent_vector.h


//! Upper bound on argument to reserve.

942 size_type max_size() const {return (~size_type(0))/sizeof(T);}

~(size_t)0 is guaranteed to be the maximum size_t value. For example, see discussion at


https://stackoverflow.com/questions/7302602/why-is-size-t0-0xffffffff-in-most-32-bit-systems-not-a-v...


"

Why is ~(size_t)0 guaranteed to be the maximum? Because the standard explicitly says so: from §6.5.3.3: "If the promoted type is an unsigned type, the expression ~E is equivalent to the maximum value representable in that type minus E." 

"

You can try to print ~size_type(0))/sizeof(T) on both systems in question.






Mark_L_Intel
Employee
492 Views

Hello,


I talked to engineering team and they pointed to me that it seems that you use the "old" TBB version: TBB 2020 or earlier.


Starting from oneTBB 2021, the implementation of concurrent_vector was redesigned and one of the significant changes is improved support for user-provided allocators. The implementation of concurrent_vector::max_size was also affected: now it returns the maximum number of elements which can be allocated with the allocator, provided by the user (specifically ``std::allocator_traits<Allocator>::max_size(alloc_obj).


It seems that the question you are asking is not applicable to oneTBB 2021 and currently we are not planning to backport the changes described above into the older TBB versions. Just one more reason to switch to new oneTBB version if you can.


Also, please indicate if you are still interested in this issue. With no response from you, the support will be limited to community support.


Reply