Community
cancel
Showing results for 
Search instead for 
Did you mean: 
zoolii
Beginner
58 Views

TBB allocator question

Hi Experts,

I am doing some experiments with TBB. I read that TBB allocator will use thread specific heaps. I suppose this is a pool of freememory allocated from global heap andkeptspecifically foreach threads.My program allocates memory using scalable_malloc indifferent threads (TBB threads) butmemory is released in one of the threads. It is basically a pipeline processing .So the parallel filters allocate memory and a serial filter deallocates. Now I got following doubts.

1. Will the scalable_free return it to correct thread specific heap ?. If so how it does that ?. By looking some address range ?

2. WillThreads created by TBBbe alive till the end of the program so that thread never dies and the corresponding heap is alwaysaccessable?.

Thanks

Zooli







Thanks
0 Kudos
1 Reply
Dmitry_Vyukov
Valued Contributor I
58 Views

> 2. WillThreads created by TBBbe alive till the end of the program so that thread never dies and the corresponding heap is alwaysaccessable?

You don't need it to be alive till the end of the program, you need it to be alive so long to not cause any faults. And of course it's alive so long to not cause any faults. Otherwise it would be completely unusable.


> 1. Will the scalable_free return it to correct thread specific heap ?. If so how it does that ?. By looking some address range ?

Yes, it will. For blocks allocated via slab allocator it should look like:
super_block_t* sb = (super_block_t*)((uintptr_t)p & ~(super_block_alignment - 1));
thread_t* owner = sb->owner;

Reply