Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
2401 Discussions

Zero-initialized memory with scalable_malloc

P_A__Jimenez
Beginner
107 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
107 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.

 

P_A__Jimenez
Beginner
107 Views

Hi Nikita,

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

Reply