Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Zero-initialized memory with scalable_malloc

P_A__Jimenez
Beginner
715 Views

Hi,

I would like to know if scalable_malloc makes any guarantees about zero-initialized memory (for example: always zero-initialized up to requests for X bytes), whether or not this fact can be queried with the API (as in up to how many bytes this guarantee covers) and if it's going to stay like this in the future.

I need to guarantee zero-initialized memory for a project I'm working on, and it's a waste of precious CPU cycles to zero-initialize something if it's already zero-initialized.

Thanks in advance.

0 Kudos
2 Replies
Nikita_P_Intel
Employee
715 Views

Hi Jimenez,

TBB Allocator has no any guarantees regarding zero-initialized memory returned by scalable_malloc. However, you can use scalable_calloc instead that is always returns zero-initialized memory.

 

0 Kudos
P_A__Jimenez
Beginner
715 Views

Hi Nikita,

That's a very good point. I hadn't seen that function, and it does do what I need. Thanks :)

0 Kudos
Reply